From fd658508f4470f0c479b2a36738b0f50481cbbe9 Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期六, 16 九月 2023 10:59:09 +0800
Subject: [PATCH] 后台代码

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TBodySideAppointmentsController.java |   91 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 88 insertions(+), 3 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TBodySideAppointmentsController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TBodySideAppointmentsController.java
index 42238b3..15abeb8 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TBodySideAppointmentsController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TBodySideAppointmentsController.java
@@ -2,8 +2,10 @@
 
 
 import com.dsh.course.feignClient.account.CityManagerClient;
+import com.dsh.course.feignClient.account.StoreStaffClient;
 import com.dsh.course.feignClient.account.model.CityManager;
 import com.dsh.course.feignClient.account.model.Coach;
+import com.dsh.course.feignClient.account.model.TStoreStaff;
 import com.dsh.course.feignClient.activity.BodySideAppointmentClient;
 import com.dsh.course.feignClient.activity.model.BodySideAppointment;
 import com.dsh.course.feignClient.activity.model.QueryBodySideAppointment;
@@ -11,6 +13,7 @@
 import com.dsh.course.feignClient.other.StoreClient;
 import com.dsh.guns.config.UserExt;
 import com.dsh.guns.modular.system.model.CoachQuery;
+import com.dsh.guns.modular.system.model.Store;
 import com.dsh.guns.modular.system.util.ResultUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -19,6 +22,7 @@
 
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 体测预约管理控制器
@@ -34,6 +38,8 @@
     private BodySideAppointmentClient bodySideAppointmentClient;
     @Autowired
     private CityManagerClient cityManagerClient;
+    @Autowired
+    private StoreStaffClient storeStaffClient;
     /**
      * 跳转体测预约管理首页
      */
@@ -46,6 +52,7 @@
      */
     @RequestMapping("/add")
     public String add(Model model) {
+        Integer roleType = UserExt.getUser().getObjectType();
         List<CityManager> province = cityManagerClient.listAll();
         Set<String> seenNames = new HashSet<>();
         List<CityManager> result = new ArrayList<>();
@@ -55,14 +62,60 @@
                 seenNames.add(cityManager.getProvince());
             }
         }
+        if (roleType == 2){
+            Integer cityManagerId = UserExt.getUser().getObjectId();
+            CityManager cityManager = cityManagerClient.queryCityManagerById(cityManagerId);
+            List<Store> stores = storeClient.getStoreByCityManagerId(cityManagerId);
+            model.addAttribute("stores",stores);
+        }
         model.addAttribute("list",result);
+
+        model.addAttribute("roleType",roleType);
         return PREFIX + "TBodySideAppointment_add.html";
     }
     /**
      * 跳转体测预约管理编辑页面
      */
-    @RequestMapping("/update")
-    public String update(Model model) {
+    @RequestMapping("/update/{id}")
+    public String update(Model model,@PathVariable("id") Integer id) {
+        Integer roleType = UserExt.getUser().getObjectType();
+        Integer objectId = UserExt.getUser().getObjectId();
+        BodySideAppointment data = bodySideAppointmentClient.getInfoById(id);
+        if (roleType == 1){
+            List<CityManager> cityManagers = cityManagerClient.listAll();
+            List<CityManager> province = new ArrayList<>();
+            List<CityManager> city = new ArrayList<>();
+            Set<String> seenNames = new HashSet<>();
+            Set<String> c    = new HashSet<>();
+            // 省列表
+            List<CityManager> result = new ArrayList<>();
+            // 市列表
+            List<CityManager> cities = new ArrayList<>();
+            // 对省/市去重
+            for (CityManager cityManager : cityManagers) {
+                if(!seenNames.contains(cityManager.getProvince())){
+                    result.add(cityManager);
+                    seenNames.add(cityManager.getProvince());
+                }
+                if(!c.contains(cityManager.getProvince())){
+                    cities.add(cityManager);
+                    c.add(cityManager.getProvince());
+                }
+            }
+            List<Store> stores = storeClient.getStore(data.getCity());
+            model.addAttribute("stores",stores);
+            model.addAttribute("list",result);
+            model.addAttribute("cities",cities);
+        }else if (roleType == 2){
+            List<Store> stores = storeClient.getStoreByCityManagerId(objectId);
+            model.addAttribute("stores",stores);
+        }
+        String birthday = new SimpleDateFormat("yyyy-MM-dd").format(data.getBirthday());
+        String appointmentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(data.getAppointmentTime());
+        model.addAttribute("birthday",birthday);
+        model.addAttribute("appointmentTime",appointmentTime);
+        model.addAttribute("data",data);
+        model.addAttribute("roleType",roleType);
         return PREFIX + "TBodySideAppointment_edit.html";
     }
 
@@ -72,15 +125,30 @@
      */
     @RequestMapping("/listAll")
     @ResponseBody
-    public List<QueryBodySideAppointmentVO> listAll(String phone,String parentName,Integer state){
+    public List<QueryBodySideAppointmentVO> listAll(String phone,String parentName,Integer state,Integer day){
         QueryBodySideAppointment vo = new QueryBodySideAppointment();
         vo.setParentName(parentName);
         vo.setPhone(phone);
         vo.setState(state);
+        vo.setDay(day);
+        Integer roleType = UserExt.getUser().getObjectType();
+        Integer objectId = UserExt.getUser().getObjectId();
+        if (roleType == 2){
+            // 获取门店集合
+            List<Integer> collect = storeClient.getStoreByCityManagerId(objectId)
+                    .stream().map(Store::getId).collect(Collectors.toList());
+            vo.setIds(collect);
+        }else if(roleType == 3){
+            List<Integer> list = new ArrayList<>();
+            TStoreStaff storeByStoreStaffId = storeStaffClient.getStoreByStoreStaffId(objectId);
+            list.add(storeByStoreStaffId.getStoreId());
+            vo.setIds(list);
+        }
         List<QueryBodySideAppointmentVO> queryBodySideAppointmentVOS = bodySideAppointmentClient.listAll(vo);
         for (QueryBodySideAppointmentVO queryBodySideAppointmentVO : queryBodySideAppointmentVOS) {
             queryBodySideAppointmentVO.setProvinceAndCity(queryBodySideAppointmentVO.getProvince()+queryBodySideAppointmentVO.getCity());
         }
+
         return queryBodySideAppointmentVOS;
     }
 
@@ -90,6 +158,23 @@
     @ResponseBody
     @RequestMapping(value = "/addBodySideAppointments")
     public ResultUtil addBodySideAppointments(@RequestBody QueryBodySideAppointmentVO vo) {
+        Integer roleType = UserExt.getUser().getObjectType();
+        // 获取当前登录人id
+        Integer cityManagerId = UserExt.getUser().getObjectId();
+        if (roleType == 2){
+            CityManager cityManager = cityManagerClient.queryCityManagerById(cityManagerId);
+            vo.setProvince(cityManager.getProvince());
+            vo.setProvinceCode(cityManager.getProvinceCode());
+            vo.setCity(cityManager.getCity());
+            vo.setCityCode(cityManager.getCityCode());
+        }else if (roleType == 3){
+            TStoreStaff storeByStoreStaffId = storeStaffClient.getStoreByStoreStaffId(cityManagerId);
+            Store storeById = storeClient.getStoreById(storeByStoreStaffId.getStoreId());
+            vo.setProvince(storeById.getProvince());
+            vo.setProvinceCode(storeById.getProvinceCode());
+            vo.setCity(storeById.getCity());
+            vo.setCityCode(storeById.getCityCode());
+        }
         bodySideAppointmentClient.addBodySideAppointments(vo);
         return ResultUtil.success("添加成功");
     }

--
Gitblit v1.7.1