From ee9cb0da4a43bcf523ebb157678f64a2895fba1a Mon Sep 17 00:00:00 2001
From: nickchange <126672920+nickchange@users.noreply.github.com>
Date: 星期二, 10 十月 2023 15:30:38 +0800
Subject: [PATCH] 10.10

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCompetitionController.java |  374 +++++++++++++++++++++++++++-------------------------
 1 files changed, 193 insertions(+), 181 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCompetitionController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCompetitionController.java
index 10b8110..5e49720 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCompetitionController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCompetitionController.java
@@ -1,25 +1,28 @@
 package com.dsh.guns.modular.system.controller.code;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.dsh.course.feignClient.course.CourseClient;
-import com.dsh.guns.config.UserExt;
+import com.dsh.course.feignClient.competition.CompetitionClient;
+import com.dsh.course.feignClient.competition.model.*;
 import com.dsh.guns.core.base.controller.BaseController;
+import com.dsh.guns.core.base.tips.SuccessTip;
 import com.dsh.guns.core.common.constant.factory.PageFactory;
-import com.dsh.guns.core.util.SinataUtil;
-import com.dsh.guns.modular.system.util.DateUtil;
-import com.dsh.guns.modular.system.util.ExcelExportUtil;
-import com.dsh.guns.modular.system.util.ResultUtil;
-import org.apache.commons.lang.time.DateUtils;
+import com.dsh.guns.core.util.ToolUtil;
+import com.dsh.guns.modular.system.model.TCity;
+import com.dsh.guns.modular.system.model.TStore;
+import com.dsh.guns.modular.system.service.ICityService;
+import com.dsh.guns.modular.system.service.IStoreService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 车辆管理控制器
@@ -28,13 +31,21 @@
  * @Date 2020-06-05 17:25:12
  */
 @Controller
-@RequestMapping("/TCompetition")
+@RequestMapping("/tCompetition")
 public class TCompetitionController extends BaseController {
 
-    private String PREFIX = "/system/TCompetition/";
+    private String PREFIX = "/system/tCompetition/";
 
     @Autowired
-    private CourseClient courseClient;
+    private CompetitionClient competitionClient;
+
+    @Autowired
+    private IStoreService storeService;
+
+    @Autowired
+    private ICityService cityService;
+
+
 
 
     /**
@@ -42,6 +53,8 @@
      */
     @RequestMapping("")
     public String index(Model model) {
+        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        model.addAttribute("list",list);
         return PREFIX + "TCompetition.html";
     }
 
@@ -50,7 +63,9 @@
      */
     @RequestMapping("/tCompetition_add")
     public String tCompetitionAdd(Model model) {
-        return PREFIX + "tCompetition_add.html";
+        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        model.addAttribute("list",list);
+        return PREFIX + "TCompetition_add.html";
     }
 
 
@@ -59,191 +74,188 @@
      */
     @RequestMapping("/tCompetition_update/{id}")
     public String tCarUpdate(@PathVariable Integer id, Model model) {
-        return PREFIX + "tCompetition_edit.html";
+        Competition competition = competitionClient.queryById(id);
+        model.addAttribute("item",competition);
+        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getProvinceCode()));
+        List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId()));
+
+        List<TStore> list2 = storeService.list(new LambdaQueryWrapper<TStore>().eq(TStore::getCityCode,competition.getCityCode()));
+        model.addAttribute("list",list);
+        model.addAttribute("list1",list1);
+        model.addAttribute("list2",list2);
+        model.addAttribute("type",1);
+        return PREFIX + "TCompetition_edit.html";
+    }
+    @RequestMapping("/tCompetition_info/{id}")
+    public String tCarInfo(@PathVariable Integer id, Model model) {
+        Competition competition = competitionClient.queryById(id);
+        model.addAttribute("item",competition);
+        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getProvinceCode()));
+        List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId()));
+
+        List<TStore> list2 = storeService.list(new LambdaQueryWrapper<TStore>().eq(TStore::getCityCode,competition.getCityCode()));
+        model.addAttribute("list",list);
+        model.addAttribute("list1",list1);
+        model.addAttribute("list2",list2);
+        model.addAttribute("type",2);
+
+        return PREFIX + "TCompetition_edit.html";
+    }
+    @RequestMapping("/tCompetition_user/{id}")
+    public String tCarUser(@PathVariable Integer id, Model model) {
+        model.addAttribute("id",id);
+        return PREFIX + "TCompetitionUser.html";
     }
 
 
-
-
-    /**
-     * 获取车辆管理列表
-     */
     @RequestMapping(value = "/list")
     @ResponseBody
-    public Object list(String createTime,
-                       String id,
-                       String brandName,
-                       String modelName,
-                       String carColor,
-                       String serverStr,
-                       String carLicensePlate,
-                       String driverName,
-                       String companyName,
-                       String franchiseeName) {
-        String beginTime = null;
-        String endTime = null;
-        if (SinataUtil.isNotEmpty(createTime)){
-            String[] timeArray = createTime.split(" - ");
-            beginTime = timeArray[0];
-            endTime = timeArray[1];
+    public Object list(String provinceCode, String cityCode, String shopName, String eventName, String time, Integer state, Integer registerCondition) {
+        List<Integer> ids = new ArrayList<>();
+        List<TStore> list = null;
+        // 获取门店id
+        if(ToolUtil.isNotEmpty(shopName)){
+             list = storeService.list(new LambdaQueryWrapper<TStore>().like(TStore::getName, shopName));
+            ids = list.stream().map(TStore::getId).collect(Collectors.toList());
+        }else {
+            list = storeService.list();
+            ids = storeService.list().stream().map(TStore::getId).collect(Collectors.toList());
         }
-        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
-        return super.packForBT(page);
+        if(ids.size()==0){
+            ids.add(-1);
+        }
+        Page<Competition> page = new PageFactory<Competition>().defaultPage();
+        ListQuery listQuery = new ListQuery(page.getSize(),page.getCurrent(),provinceCode,cityCode,eventName,time,state,registerCondition,ids);
+        Page<Competition> competitions = competitionClient.list(listQuery);
+        for (Competition competition : competitions.getRecords()) {
+            for (TStore tStore : list) {
+                String[] split = competition.getStoreId().split(",");
+
+                for (String s : split) {
+                    if(s.equals(String.valueOf(tStore.getId()))){
+                        if (competition.getStoreName()==null){
+                            competition.setStoreName(tStore.getName());
+                        }else {
+                            competition.setStoreName(competition.getStoreName()+","+tStore.getName());
+                        }
+                    }
+                }
+            }
+        }
+        return  super.packForBT(competitions);
     }
 
-    /**
-     * 新增车辆管理
-     */
+
+    @RequestMapping(value = "/listUser/{id}")
+    @ResponseBody
+    public Object listUser(@PathVariable Integer id,Integer state) {
+        try {
+            Page<Object> page = new PageFactory<>().defaultPage();
+            Page<CompetitionUser> data =   competitionClient.getPeopleFromId(new GetPeopleQuery(page.getSize(),page.getCurrent(),id,state));
+            return  super.packForBT(data);
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+
+
     @RequestMapping(value = "/add")
     @ResponseBody
-    public Object add( ) {
-        return ResultUtil.success();
+    public Object list(Competition competition) {
+        try {
+            if(ToolUtil.isNotEmpty(competition.getProvinceCode())) {
+                TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getProvinceCode()));
+                competition.setProvince(one.getName());
+                TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getCityCode()));
+                competition.setCity(one1.getName());
+            }
+            competition.setAuditStatus(1);
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
+            competition.setStartTime(format1.parse(competition.getSTime()));
+            competition.setEndTime(format1.parse(competition.getETime()));
+            competition.setRegisterEndTime(format.parse(competition.getREndTime()));
+            competitionClient.add(competition);
+            return new SuccessTip<>();
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
     }
 
-    /**
-     * 删除车辆管理
-     */
-    @RequestMapping(value = "/delete")
-    @ResponseBody
-    public Object delete(@RequestParam Integer tCarId) {
-        return SUCCESS_TIP;
-    }
-
-    /**
-     * 修改车辆管理
-     */
     @RequestMapping(value = "/update")
     @ResponseBody
-    public Object update() {
-        return ResultUtil.success();
-    }
-
-    /**
-     * 车辆管理详情
-     */
-    @RequestMapping(value = "/detail/{tCarId}")
-    @ResponseBody
-    public Object detail(@PathVariable("tCarId") Integer tCarId) {
-        return null;
-    }
-
-    /**
-     * 下载模板
-     * @param request
-     * @param response
-     */
-    @RequestMapping(value = "/uploadCarModel")
-    public void uploadCarModel(HttpServletRequest request, HttpServletResponse response) {
-        // 表格数据【封装】 Table datas
-        List<List<String>> dataList = new ArrayList<List<String>>();
-        Integer language = UserExt.getLanguage();
-        if(language==1){
-            // 首行【封装】 first line 
-            List<String> shellList = new ArrayList<String>();
-            shellList.add("所属机构[平台车辆/加盟车辆]");
-            shellList.add("所属分公司[提示:加盟车辆选填]");
-            shellList.add("所属加盟商[提示:加盟车辆选填]");
-            shellList.add("服务模式:摩托车车[是/否]");
-            shellList.add("服务模式:同城快送[是/否]");
-            shellList.add("车辆品牌");
-            shellList.add("车辆类型");
-            shellList.add("车辆颜色[1(黑色)/2(银色)/3(白色)/4(红色)/5(黄色)/6(橙色)/7(蓝色)]");
-            shellList.add("车牌号");
-            shellList.add("行驶证编号");
-            shellList.add("年检到期时间[例如 2020-02-02]");
-            shellList.add("商业保险到期时间[例如 2020-02-02]");
-            dataList.add(shellList);
-
-            try {
-                // 调用工具类进行导出 Invoke the utility class to carry out data export.
-                ExcelExportUtil.easySheet("平台导入车辆模板"+DateUtil.format(new Date(), "YYYYMMddHHmmss"), "平台导入车辆模板", dataList, request, response);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }else if(language==2){
-            // 首行【封装】 first line 
-            List<String> shellList = new ArrayList<String>();
-            shellList.add("Affiliated Organization [Platform Vehicle/Franchised Vehicle]");
-            shellList.add("Affiliated branch [Tip: Select for franchised vehicle]");
-            shellList.add("Franchisee [Tip: Select Franchised vehicle]");
-            shellList.add("Service mode: Motorcycle [Yes/No]");
-            shellList.add("Service mode: intra-city express [Yes/No]");
-            shellList.add("Vehicle brand");
-            shellList.add("Vehicle type");
-            shellList.add("Vehicle color [1(Black)/2(Silver)/3(white)/4(red)/5(yellow)/6(orange)/7(Blue)]");
-            shellList.add("License plate number");
-            shellList.add("License number");
-            shellList.add("Annual inspection expiration time [e.g. 2020-02-02]");
-            shellList.add("Commercial Insurance Expiration Time [e.g. 2020-02-02]");
-            dataList.add(shellList);
-
-            try {
-                // 调用工具类进行导出 Invoke the utility class to carry out data export.
-                ExcelExportUtil.easySheet("Platform import vehicle template"+DateUtil.format(new Date(), "YYYYMMddHHmmss"), "Platform import vehicle template", dataList, request, response);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }else {
-            // 首行【封装】 first line
-            List<String> shellList = new ArrayList<String>();
-            shellList.add("Organisasi Berkait [Platform Vehicle/Franchised Vehicle]");
-            shellList.add("Branch terkait [Tip: Pilih untuk kendaraan terkait]");
-            shellList.add("Franchisee [Tip: Pilih kendaraan Franchised]");
-            shellList.add("Mod layanan: Motosikal [Ya/Tidak]");
-            shellList.add("Modus layanan: ekspres intra-kota [Ya/Tidak]");
-            shellList.add("Tanda kendaraan");
-            shellList.add("Jenis kendaraan");
-            shellList.add("Warna kendaraan [1(Hitam)/2(Perak)/3(putih)/4(merah)/5(kuning)/6(oranye)/7(Biru)]");
-            shellList.add("Nomor plat lisensi");
-            shellList.add("Nomor lisensi");
-            shellList.add("Waktu penggantian inspeksi tahunan [contohnya 2020-02-02]");
-            shellList.add("Waktu Expiration Insurance Commercial [contohnya 2020-02-02]");
-            dataList.add(shellList);
-
-            try {
-                // 调用工具类进行导出 Invoke the utility class to carry out data export.
-                ExcelExportUtil.easySheet("templat kendaraan import platform"+DateUtil.format(new Date(), "YYYYMMddHHmmss"), "templat kendaraan import platform", dataList, request, response);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-
-
-    }
-
-
-    /**
-     * 判断日期是否满足yyyy-MM-dd格式
-     * @param str
-     * @return
-     */
-    public static boolean isValidDate(String str) {
-        boolean convertSuccess=true;
-        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+    public Object update(Competition competition) {
         try {
-            format.setLenient(false);
-            format.parse(str);
-        } catch (Exception e) {
-            convertSuccess=false;
+            Competition competition1 = competitionClient.queryById(competition.getId());
+            if(ToolUtil.isNotEmpty(competition.getProvinceCode())) {
+                TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getProvinceCode()));
+                competition.setProvince(one.getName());
+                TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getCityCode()));
+                competition.setCity(one1.getName());
+            }
+            if(ToolUtil.isEmpty(competition.getCoverDrawing())){
+                competition.setCoverDrawing(competition1.getCoverDrawing());
+            }
+            if(ToolUtil.isEmpty(competition.getRegistrationNotes())){
+                competition.setRegistrationNotes(competition1.getRegistrationNotes());
+            }
+            competitionClient.update(competition);
+            return new SuccessTip<>();
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
         }
-        return convertSuccess;
     }
 
 
-    /**
-     * 转换日期
-     * @return
-     */
-    public static String importByExcelForDate(String value) {//value就是它的天数
-        String currentCellValue = "";
-        if(value != null && !value.equals("")){
-            Calendar calendar = new GregorianCalendar(1900,0,-1);
-            Date d = calendar.getTime();
-            Date dd = DateUtils.addDays(d,Integer.valueOf(value));
-            DateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
-            currentCellValue = formater.format(dd);
+    @RequestMapping(value = "/cancel")
+    public Object cancel(Integer id) {
+        try {
+            competitionClient.cancel(id);
+            return SUCCESS_TIP;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
         }
-        return currentCellValue;
     }
 
+    @RequestMapping(value = "/getPeopleFromId")
+    public Object getPeopleFromId(Integer id,Integer state) {
+        try {
+            Page<Object> page = new PageFactory<>().defaultPage();
+            Page<CompetitionUser> data =   competitionClient.getPeopleFromId(new GetPeopleQuery(page.getSize(),page.getCurrent(),id,state));
+            return  super.packForBT(data);
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+
+    @RequestMapping(value = "/onChange")
+    @ResponseBody
+    public Object onChange(Integer oneId) {
+        try {
+            TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, oneId));
+            return cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId()));
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+    @RequestMapping(value = "/oneChangeNext")
+    @ResponseBody
+    public Object oneChangeNext(Integer oneId) {
+        try {
+            return storeService.list(new LambdaQueryWrapper<TStore>().eq(TStore::getCityCode, oneId));
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+
+
 }

--
Gitblit v1.7.1