From e030255c23c7ba3e2cbad1036a810d6d72fa864f Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期四, 26 十月 2023 18:04:58 +0800
Subject: [PATCH] 修改bug

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TShopController.java |  644 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 598 insertions(+), 46 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TShopController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TShopController.java
index 59b1de2..36654a5 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TShopController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TShopController.java
@@ -1,16 +1,16 @@
 package com.dsh.guns.modular.system.controller.code;
 
 import cn.hutool.crypto.SecureUtil;
+import cn.hutool.http.HttpRequest;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dsh.course.feignClient.account.CityClient;
 import com.dsh.course.feignClient.account.model.CityListQuery;
 import com.dsh.course.feignClient.account.model.TCityManager;
 import com.dsh.course.feignClient.competition.CompetitionClient;
-import com.dsh.course.feignClient.competition.model.Competition;
-import com.dsh.course.feignClient.competition.model.GetPeopleQuery;
-import com.dsh.course.feignClient.competition.model.Participant;
-import com.dsh.course.mapper.StoreConfigMapper;
+import com.dsh.course.feignClient.other.model.Site;
 import com.dsh.course.mapper.UserMapper;
 import com.dsh.guns.config.UserExt;
 import com.dsh.guns.core.base.controller.BaseController;
@@ -18,9 +18,12 @@
 import com.dsh.guns.core.common.constant.factory.PageFactory;
 import com.dsh.guns.core.util.ToolUtil;
 import com.dsh.guns.modular.system.model.*;
-import com.dsh.guns.modular.system.service.ICityService;
-import com.dsh.guns.modular.system.service.IStoreService;
-import com.dsh.guns.modular.system.service.StoreConfigService;
+import com.dsh.guns.modular.system.service.*;
+import com.dsh.guns.modular.system.util.GaoDeMapUtil;
+import com.dsh.guns.modular.system.util.HttpRequestUtil;
+import io.swagger.models.auth.In;
+import org.apache.poi.ss.formula.functions.T;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -29,8 +32,8 @@
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 车辆管理控制器
@@ -61,6 +64,24 @@
     @Resource
     private StoreConfigService storeConfigService;
 
+    @Autowired
+    private TStoreOtherConfigTrueService tStoreOtherConfigTrueService;
+
+    @Autowired
+    private TStoreOtherConfigService storeOtherConfigService;
+
+    @Autowired
+    private TTurnService tTurnService;
+
+    @Autowired
+    private TStoreOtherService storeOtherService;
+
+    @Autowired
+    private TOperatorService tOperatorService;
+
+    @Autowired
+    private ITSiteService siteService;
+
 
     /**
      * 跳转到车辆管理首页
@@ -83,7 +104,45 @@
         model.addAttribute("list",list);
         String roleid = UserExt.getUser().getRoleid();
         model.addAttribute("role",roleid);
-        return PREFIX + "tShop_add.html";
+        List<TOperator> list1 = tOperatorService.list();
+
+
+//        if (!roleid.equals("1")){
+            TOperator operator1 = tOperatorService.getOne(new QueryWrapper<TOperator>().eq("userId", UserExt.getUser().getId()));
+            if(operator1!=null){
+                model.addAttribute("operator",operator1.getId());
+            }else {
+                model.addAttribute("operator",0);
+            }
+//        }
+
+        model.addAttribute("yysList",list1);
+        return PREFIX + "TShop_add.html";
+    }
+    @RequestMapping("/tShop_add_one")
+    public String tCompetitionAddOne(Integer id,Model model) {
+        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        model.addAttribute("list",list);
+        String roleid = UserExt.getUser().getRoleid();
+        model.addAttribute("id",id);
+
+        return PREFIX + "TShop_add_one.html";
+    }
+    @RequestMapping("/tShop_add_two")
+    public String tCompetitionAddTwo(Integer id,Model model) {
+        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        model.addAttribute("list",list);
+        model.addAttribute("id",id);
+        String roleid = UserExt.getUser().getRoleid();
+        return PREFIX + "TShop_edit_three.html";
+    }
+    @RequestMapping("/tShop_add_two1")
+    public String tCompetitionAddTwo1(Integer id,Model model) {
+        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        model.addAttribute("list",list);
+        model.addAttribute("id",id);
+        String roleid = UserExt.getUser().getRoleid();
+        return PREFIX + "TShop_add_two.html";
     }
 
 
@@ -93,26 +152,90 @@
     @RequestMapping("/tShop_update/{id}")
     public String tCityUpdate(@PathVariable Integer id, Model model) {
         TStore byId = storeService.getById(id);
+        System.out.println("======byId========="+byId);
         model.addAttribute("item",byId);
         List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
-        model.addAttribute("list",list);
-        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getProvinceCode()));
-        List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId()));
+
+//        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getProvinceCode()));
+        List<TOperatorCity> one = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, byId.getOperatorId()).eq(TOperatorCity::getType, 1));
+        List<TOperatorCity> ones = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, byId.getOperatorId()).eq(TOperatorCity::getType, 1));
+
+        if(ones.size()>0){
+            model.addAttribute("list",ones);
+            TOperatorCity one1 = operatorCityService.getOne(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, byId.getOperatorId()).eq(TOperatorCity::getType, 1).eq(TOperatorCity::getCode,byId.getProvinceCode()));
+            List<TOperatorCity> list3 = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().in(TOperatorCity::getPid, one1.getId()).eq(TOperatorCity::getType, 2));
+            model.addAttribute("list1",list3);
+            System.out.println("===list3======="+list3);
+
+        }else {
+            List<TCity> list2 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+            model.addAttribute("list",list2);
+            TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getProvinceCode()));
+            List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one1.getId()));
+            model.addAttribute("list1",list1);
+            System.out.println("===list1======="+list1);
+        }
         CityListQuery cityListQuery = new CityListQuery();
         cityListQuery.setOffset(1);
         cityListQuery.setLimit(10000);
         cityListQuery.setCityCode(byId.getCityCode());
         Page<TCityManager> list2 = cityClient.list(cityListQuery);
-        model.addAttribute("list1",list1);
+
+        List<TOperator> list1 = tOperatorService.list();
+        model.addAttribute("yysList",list1);
+
         model.addAttribute("list2",list2.getRecords());
         String roleid = UserExt.getUser().getRoleid();
-        model.addAttribute("role",roleid);
+            model.addAttribute("role",roleid);
         model.addAttribute("time",byId.getStartTime()+" - "+byId.getEndTime());
         User byId1 = userMapper.selectById(byId.getStoreStaffId());
         model.addAttribute("city",byId1);
         model.addAttribute("type",1);
-        return PREFIX + "tShop_edit.html";
+        return PREFIX + "TShop_edit.html";
     }
+    @RequestMapping("/tShop_update1/{id}")
+    public String tCityUpdate1(@PathVariable Integer id, Model model) {
+        TStoreOther byId = storeOtherService.getById(id);
+        model.addAttribute("item",byId);
+        return PREFIX + "TShop_edit_one.html";
+    }
+
+
+
+
+    @RequestMapping("/tShop_update_one/{id}")
+    public String tCityUpdateOne(@PathVariable Integer id, Model model) {
+        TStoreOtherConfig byId = storeOtherConfigService.getById(id);
+        TTurn one = tTurnService.getOne(new LambdaQueryWrapper<TTurn>().eq(TTurn::getName, byId.getName()));
+        // page list
+        if (one!=null) {
+            List<TTurn> list = tTurnService.list(new LambdaQueryWrapper<TTurn>().eq(TTurn::getPid, one.getId()));
+            model.addAttribute("list", list);
+        }
+        // type list
+        List<TTurn> list1 = tTurnService.list(new LambdaQueryWrapper<TTurn>().eq(TTurn::getPid, byId.getPageId()));
+        model.addAttribute("item",byId);
+        model.addAttribute("list1",list1);
+
+        return PREFIX + "TShop_edit_two.html";
+    }
+    @RequestMapping("/tShop_update_one1/{id}")
+    public String tCityUpdateOne1(@PathVariable Integer id, Model model) {
+        TStoreOtherConfigTrue byId = tStoreOtherConfigTrueService.getById(id);
+        TTurn one = tTurnService.getOne(new LambdaQueryWrapper<TTurn>().eq(TTurn::getName, byId.getName()));
+        // page list
+        List<TTurn> list = tTurnService.list(new LambdaQueryWrapper<TTurn>().eq(TTurn::getPid, one.getId()));
+        // type list
+        List<TTurn> list1 = tTurnService.list(new LambdaQueryWrapper<TTurn>().eq(TTurn::getPid, byId.getPageId()));
+        model.addAttribute("item",byId);
+        model.addAttribute("list",list);
+        model.addAttribute("list1",list1);
+
+        return PREFIX + "TShop_add_three.html";
+    }
+
+
+
     @RequestMapping("/tShop_info/{id}")
     public String tCityInfo(@PathVariable Integer id, Model model) {
         TStore byId = storeService.getById(id);
@@ -125,6 +248,7 @@
         cityListQuery.setOffset(1);
         cityListQuery.setLimit(10000);
         cityListQuery.setCityCode(byId.getCityCode());
+        model.addAttribute("yysList", tOperatorService.list());
         Page<TCityManager> list2 = cityClient.list(cityListQuery);
         model.addAttribute("list1",list1);
         model.addAttribute("list2",list2.getRecords());
@@ -134,14 +258,14 @@
         User byId1 = userMapper.selectById(byId.getStoreStaffId());
         model.addAttribute("city",byId1);
         model.addAttribute("type",0);
-        return PREFIX + "tShop_edit.html";
+        return PREFIX + "TShop_edit.html";
     }
     @RequestMapping("/tShop_gift/{id}")
     public String tCityGift(@PathVariable Integer id, Model model) {
         TStore byId = storeService.getById(id);
         model.addAttribute("welfarePicture",byId.getWelfarePicture());
         model.addAttribute("id",id);
-        return PREFIX + "tShop_img.html";
+        return PREFIX + "TShop_img.html";
     }
     @RequestMapping("/tShop_indexSet/{id}")
     public String tCityIndexSet(@PathVariable Integer id, Model model) {
@@ -162,7 +286,7 @@
         StoreConfig c8 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,8));
         model.addAttribute("c8",c8);
         model.addAttribute("id",id);
-        return PREFIX + "tShop_imgAll.html";
+        return PREFIX + "TShop_imgAll.html";
     }
 
 
@@ -170,30 +294,106 @@
     @ResponseBody
     public Object list(String provinceCode, String cityCode , String name, String phone,String shopName) {
         Page<TStoreListVo> page = new PageFactory<TStoreListVo>().defaultPage();
-        List<TStoreListVo> list =  storeService.listAll(page,provinceCode,cityCode,name,phone,shopName);
-        for (TStoreListVo tStoreListVo : list) {
-            TCityManager byId = cityClient.getById(tStoreListVo.getCityManagerId());
-            tStoreListVo.setAccount(byId.getName()+"-"+byId.getPhone());
-
+        String roleid = UserExt.getUser().getRoleid();
+        List<TStoreListVo> list =new ArrayList<>();
+        if("3".equals(roleid)){
+            Integer objectId = UserExt.getUser().getObjectId();
+            list = storeService.listAllStore(page,provinceCode,cityCode,name,phone,shopName,objectId);
+        }else {
+            Integer objectId = UserExt.getUser().getObjectId();
+            list = storeService.listAll(page,provinceCode,cityCode,name,phone,shopName,objectId);
         }
         page.setRecords(list);
         return  super.packForBT(page);
     }
-
+    @RequestMapping(value = "/listOne")
+    @ResponseBody
+    public Object listOne(Integer id) {
+        Page<Map<String,Object>> page = new PageFactory<Map<String,Object>>().defaultPage();
+        List<Map<String,Object>> list =  storeService.listOne(page,id);
+        page.setRecords(list);
+        return  super.packForBT(page);
+    }
+    @RequestMapping(value = "/listTwo")
+    @ResponseBody
+    public Object listTwo() {
+        Page<Map<String,Object>> page = new PageFactory<Map<String,Object>>().defaultPage();
+        List<Map<String,Object>> list =  storeService.listTwo(page);
+        page.setRecords(list);
+        return  super.packForBT(page);
+    }
+    @RequestMapping(value = "/listTwo1")
+    @ResponseBody
+    public Object listTwo1(Integer id) {
+        Page<TStoreOtherConfigTrue> page = new PageFactory<TStoreOtherConfigTrue>().defaultPage();
+        List<TStoreOtherConfigTrue> list = tStoreOtherConfigTrueService.page(page,new LambdaQueryWrapper<TStoreOtherConfigTrue>().eq(TStoreOtherConfigTrue::getPid, id).eq(TStoreOtherConfigTrue::getState,1)).getRecords();
+        page.setRecords(list);
+        return  super.packForBT(page);
+    }
 
     @RequestMapping(value = "/add")
     @ResponseBody
-    public Object list(TStore tStore,String time,String userName,String userPhone) {
+    public Object list(TStore tStore,String time,String userName,String userPhone,String ids,Integer type,Integer yyId,String lat,String lon,String pCode1,String cCode1) {
         try {
-            if(ToolUtil.isNotEmpty(tStore.getProvinceCode())) {
-                TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, tStore.getProvinceCode()));
-                tStore.setProvince(one.getName());
-                TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, tStore.getCityCode()));
-                tStore.setCity(one1.getName());
+
+
+            if(yyId==null || type==1){
+                yyId=0;
+            }
+            if(yyId!=0) {
+                List<TOperatorCity> list1 = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, yyId));
+                if(list1.size()>0){
+                    if (ToolUtil.isNotEmpty(tStore.getProvinceCode())) {
+                        TOperatorCity byId = operatorCityService.getById(tStore.getProvinceCode());
+                        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getCode()));
+                        tStore.setProvince(one.getName());
+                        tStore.setProvinceCode(one.getCode());
+                        List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getPid, byId.getId()).eq(TOperatorCity::getType, 2));
+                        if (list.size() > 0) {
+                            TOperatorCity byId1 = operatorCityService.getById(tStore.getCityCode());
+                            TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId1.getCode()));
+                            tStore.setCity(one1.getName());
+                            tStore.setCityCode(one1.getCode());
+                        } else {
+                            TCity byId1 = cityService.getById(tStore.getCityCode());
+                            TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId1.getCode()));
+                            tStore.setCity(one1.getName());
+                            tStore.setCityCode(one1.getCode());
+                        }
+                    }
+                }else {
+                    TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getId, tStore.getProvinceCode()));
+                    tStore.setProvince(one.getName());
+                    tStore.setProvinceCode(one.getCode());
+                    TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getId, tStore.getCityCode()));
+                    tStore.setCity(one1.getName());
+                    tStore.setCityCode(one1.getCode());
+                }
+
+            }else {
+                TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, pCode1));
+                if (one !=null){
+                    tStore.setProvince(one.getName());
+                    tStore.setProvinceCode(one.getCode());
+                }
+                TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, cCode1));
+                if (one1 !=null){
+                    tStore.setCity(one1.getName());
+                    tStore.setCityCode(one1.getCode());
+                }
             }
             tStore.setStartTime(time.split(" - ")[0]);
             tStore.setEndTime(time.split(" - ")[1]);
+            tStore.setIds(ids);
+            if (UserExt.getUser().getObjectType()==2){
+                tStore.setType(2);
+            }else{
+                tStore.setType(type);
+            }
+
+            tStore.setOperatorId(yyId);
             tStore.setState(1);
+            tStore.setCreateTime(new Date());
             User user = new User();
             List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getAccount, userPhone));
             if(users.size()>0){
@@ -201,12 +401,35 @@
             }
             user.setAccount(userPhone);
             user.setName(userName);
-            user.setRoleid("2");
+            user.setRoleid("3");
             user.setPhone(userPhone);
             user.setPassword(SecureUtil.md5("a123456"));
-            userMapper.insert(user);
+            user.setObjectType(3);
+            user.setStatus(1);
             tStore.setStoreStaffId(user.getId());
+                tStore.setLon(lon);
+                tStore.setLat(lat);
+            tStore.setOperatorId(UserExt.getUser().getObjectId());
             storeService.save(tStore);
+
+            user.setObjectId(tStore.getId());
+            userMapper.insert(user);
+
+
+
+            // 添加场地
+            TSite tSite = new TSite();
+            tSite.setName(tStore.getName());
+            tSite.setStoreId(tStore.getId());
+            tSite.setSign(1);
+            siteService.save(tSite);
+
+            HashMap<String, String> mapSite = new HashMap<>();
+            mapSite.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
+            mapSite.put("name",tStore.getName());
+            mapSite.put("space_id",tStore.getId().toString());
+            mapSite.put("area_id",tSite.getId().toString());
+            HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpaceArea", mapSite);
 
             ArrayList<StoreConfig> storeConfigs = new ArrayList<>();
             for (int i = 1; i < 9; i++) {
@@ -218,6 +441,41 @@
                 storeConfigs.add(storeConfig);
             }
             storeConfigService.saveBatch(storeConfigs);
+
+
+            // 添加门店
+            HashMap<String, String> map1 = new HashMap<>();
+            map1.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
+            map1.put("name",tStore.getName());
+            map1.put("short_name",tStore.getName());
+            map1.put("location",tStore.getCity());
+            map1.put("address",tStore.getAddress());
+            map1.put("telephone",tStore.getPhone());
+            map1.put("linkman",userName);
+            map1.put("business_time","[{\"start_time\":\""+tStore.getStartTime()+"\",\"close_time\":\""+tStore.getEndTime()+"\"}]");
+            map1.put("logo",tStore.getCoverDrawing());
+            map1.put("remark",tStore.getIntroduce());
+            map1.put("lat",tStore.getLat());
+            map1.put("lng",tStore.getLon());
+            map1.put("space_id",tStore.getId().toString());
+            String result = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpace", map1);
+            System.out.println(result);
+
+
+
+            for (String s : tStore.getIds().split(",")) {
+                HashMap<String, String> map = new HashMap<>();
+                map.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
+                map.put("space_id",tStore.getId()+"");
+                map.put("device_id",s);
+                map.put("region_id",tSite.getId().toString());
+                // 添加门禁
+                String s1 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map);
+                System.out.println(s1);
+            }
+
+
+
             return new SuccessTip<>();
         }catch (Exception e){
             e.printStackTrace();
@@ -227,22 +485,63 @@
 
     @RequestMapping(value = "/update")
     @ResponseBody
-    public Object update(TStore tStore,String time,String userName,String userPhone) {
+    public Object update(TStore tStore,String time,String userName,String userPhone,String ids,Integer type,Integer yyId,String lat,String lon,String pCode1,String cCode1) {
         try {
-            TStore byId = storeService.getById(tStore.getId());
+            TStore byIdc = storeService.getById(tStore.getId());
 
-            if(ToolUtil.isNotEmpty(tStore.getProvinceCode())) {
-                TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, tStore.getProvinceCode()));
+            if(yyId==null){
+                yyId=0;
+            }
+            if(tStore.getType()==1){
+                yyId=0;
+            }
+            if(yyId!=0) {
+                List<TOperatorCity> list1 = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, yyId));
+                if(list1.size()>0){
+                    if (ToolUtil.isNotEmpty(tStore.getProvinceCode())) {
+                        TOperatorCity byId = operatorCityService.getById(tStore.getProvinceCode());
+                        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getCode()));
+                        tStore.setProvince(one.getName());
+                        tStore.setProvinceCode(one.getCode());
+                        List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getPid, byId.getId()).eq(TOperatorCity::getType, 2));
+                        if (list.size() > 0) {
+                            TOperatorCity byId1 = operatorCityService.getById(tStore.getCityCode());
+                            TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId1.getCode()));
+                            tStore.setCity(one1.getName());
+                            tStore.setCityCode(one1.getCode());
+                        } else {
+                            TCity byId1 = cityService.getById(tStore.getCityCode());
+                            TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId1.getCode()));
+                            tStore.setCity(one1.getName());
+                            tStore.setCityCode(one1.getCode());
+                        }
+                    }
+                }else {
+                    TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getId, tStore.getProvinceCode()));
+                    tStore.setProvince(one.getName());
+                    tStore.setProvinceCode(one.getCode());
+                    TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getId, tStore.getCityCode()));
+                    tStore.setCity(one1.getName());
+                    tStore.setCityCode(one1.getCode());
+                }
+
+            }else {
+                        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getId, tStore.getProvinceCode()));
                 tStore.setProvince(one.getName());
-                TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, tStore.getCityCode()));
+                tStore.setProvinceCode(one.getCode());
+                TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getId, tStore.getCityCode()));
                 tStore.setCity(one1.getName());
+                tStore.setCityCode(one1.getCode());
             }
             tStore.setStartTime(time.split(" - ")[0]);
             tStore.setEndTime(time.split(" - ")[1]);
+            tStore.setIds(ids);
+            tStore.setType(type);
+            tStore.setOperatorId(yyId);
             if(ToolUtil.isEmpty(tStore.getCoverDrawing())){
-                tStore.setCoverDrawing(byId.getCoverDrawing());
+                tStore.setCoverDrawing(byIdc.getCoverDrawing());
             }
-            User user = userMapper.selectById(byId.getStoreStaffId());
+            User user = userMapper.selectById(byIdc.getStoreStaffId());
             List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getAccount, userPhone).ne(User::getId,tStore.getStoreStaffId()));
             if(users.size()>0){
                 return "5001";
@@ -251,7 +550,33 @@
             user.setName(userName);
             user.setPhone(userPhone);
             userMapper.updateById(user);
+            tStore.setLon(lon);
+            tStore.setLat(lat);
             storeService.updateById(tStore);
+            String ids1 = byIdc.getIds();
+
+
+
+            HashMap<String, String> mapx = new HashMap<>();
+            mapx.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
+            for (String s : ids1.split(",")) {
+              String post = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/deleteDevice/ids/" + s,mapx);
+                System.out.println(post);
+            }
+
+            for (String s : ids.split(",")) {
+                HashMap<String, String> map1 = new HashMap<>();
+                map1.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
+                map1.put("space_id",tStore.getId()+"");
+                map1.put("device_id",s);
+                map1.put("region_id","");
+                // 添加门禁
+                String s1 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map1);
+                System.out.println(s1);
+            }
+
+
+
             return new SuccessTip<>();
         }catch (Exception e){
             e.printStackTrace();
@@ -330,11 +655,96 @@
         }
     }
 
+    @Autowired
+    private TOperatorCityService operatorCityService;
+
+    @RequestMapping(value = "/onChange1")
+    @ResponseBody
+    public Object onChange1(Integer oneId) {
+        try {
+            List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, oneId).eq(TOperatorCity::getType, 1));
+            if(list.size()==0){
+                List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+                return list1;
+            }else {
+
+                return list;
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+
+    @RequestMapping(value = "/onChange2")
+    @ResponseBody
+    public Object onChange2(Integer oneId) {
+        try {
+            List<TOperatorCity> list1 = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getId, oneId).eq(TOperatorCity::getType, 1));
+            List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getPid, oneId).eq(TOperatorCity::getType, 2));
+
+            // 若是全国 为空 去找这个省下面的市
+            if(list1.size()==0){
+                TCity byId = cityService.getById(oneId);
+                List<TCity> list2 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, byId.getId()));
+                return list2;
+            }
+            if(list.size()==0){
+                TOperatorCity tOperatorCity = list1.get(0);
+                Integer code = tOperatorCity.getCode();
+                TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, code));
+                List<TCity> list2 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, one.getId()));
+                return list2;
+            }else {
+                return list;
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+
 
     @RequestMapping(value = "/cancel")
     public Object cancel(Integer id) {
         try {
             competitionClient.cancel(id);
+            return SUCCESS_TIP;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+    @ResponseBody
+    @RequestMapping(value = "/deleteOne")
+    public Object delete1(Integer id) {
+        try {
+            storeService.delete1(id);
+            return SUCCESS_TIP;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+    @ResponseBody
+    @RequestMapping(value = "/deleteTwo")
+    public Object delete2(Integer id) {
+        try {
+            storeOtherConfigService.removeById(id);
+
+            return SUCCESS_TIP;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+    @ResponseBody
+    @RequestMapping(value = "/del")
+    public Object del(Integer id) {
+        try {
+            storeOtherService.removeById(id);
+            tStoreOtherConfigTrueService.remove(new LambdaQueryWrapper<TStoreOtherConfigTrue>().eq(TStoreOtherConfigTrue::getPid,id));
+
             return SUCCESS_TIP;
         }catch (Exception e){
             e.printStackTrace();
@@ -383,6 +793,20 @@
         }
     }
 
+    @RequestMapping(value = "/unfreeze1")
+    @ResponseBody
+    public Object unfreeze1(Integer id,Integer type) {
+        try {
+            TStoreOther byId = storeOtherService.getById(id);
+            byId.setState(type);
+            storeOtherService.updateById(byId);
+            return SUCCESS_TIP;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+
     @RequestMapping(value = "/pwd")
     @ResponseBody
     public Object pwd(Integer id) {
@@ -397,18 +821,146 @@
             return ERROR;
         }
     }
-
-    @RequestMapping(value = "/getPeopleFromId")
-    public Object getPeopleFromId(Integer id,Integer state) {
+    @RequestMapping(value = "/typeChange")
+    @ResponseBody
+    public Object typeChange(String name) {
         try {
-            Page<Object> page = new PageFactory<>().defaultPage();
-            Page<Participant> data =   competitionClient.getPeopleFromId(new GetPeopleQuery(page.getSize(),page.getCurrent(),id,state));
-            return  super.packForBT(data);
+            List<Map<String,Object>> list = storeService.typeChange(name);
+            return list;
         }catch (Exception e){
             e.printStackTrace();
             return ERROR;
         }
     }
+    @RequestMapping(value = "/typeChangeOne")
+    @ResponseBody
+    public Object typeChangeOne(Integer id) {
+        try {
+            List<Map<String,Object>> list = storeService.typeChangeOne(id);
+            return list;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+
+    /**
+     * ajax.set("url",url);
+     *     ajax.set("name",name);
+     *     ajax.set("page",page);
+     *     ajax.set("type",type);
+     *     ajax.set("turnId",turnId);
+     *     ajax.set("sort",sort);
+     * @return
+     */
+    @RequestMapping(value = "/addConfigOne")
+    @ResponseBody
+    public Object addConfigOne(String url,String name,Integer page,Integer type,String  turnId,Integer sort) {
+        try {
+             storeService.addConfigOne(url,name,page,type,turnId,sort);
+            return SUCCESS_TIP;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+    @RequestMapping(value = "/addConfig")
+    @ResponseBody
+    public Object addConfig(String name,Integer id) {
+        try {
+            List<TStoreOtherConfig> list = storeOtherConfigService.list();
+            if(list.size()>0){
+                TStoreOther tStoreOther = new TStoreOther();
+                tStoreOther.setName(name);
+                tStoreOther.setStoreId(id);
+                storeOtherService.save(tStoreOther);
+
+                // 找出temp表数据
+
+                ArrayList<TStoreOtherConfigTrue> tStoreOtherConfigTrues = new ArrayList<>();
+                for (TStoreOtherConfig tStoreOtherConfig : list) {
+                    TStoreOtherConfigTrue tStoreOtherConfigTrue = new TStoreOtherConfigTrue();
+                    BeanUtils.copyProperties(tStoreOtherConfig,tStoreOtherConfigTrue);
+                    tStoreOtherConfigTrue.setPid(tStoreOther.getId());
+                    tStoreOtherConfigTrues.add(tStoreOtherConfigTrue);
+                }
+                tStoreOtherConfigTrueService.saveBatch(tStoreOtherConfigTrues);
+                storeOtherConfigService.remove(new LambdaQueryWrapper<TStoreOtherConfig>().gt(TStoreOtherConfig::getId,0));
+            }
+
+
+        return SUCCESS_TIP;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+    @RequestMapping(value = "/addConfig1")
+    @ResponseBody
+    public Object addConfig1(String name,Integer id) {
+        try {
+            TStoreOther byId = storeOtherService.getById(id);
+            byId.setName(
+                    name
+            );
+            storeOtherService.updateById(byId);
+
+
+        return SUCCESS_TIP;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+    @RequestMapping(value = "/updateConfigOne")
+    @ResponseBody
+    public Object addConfigOne(String url,String name,Integer page,Integer type,String  turnId,Integer sort,Integer id) {
+        try {
+            TStoreOtherConfig byId = storeOtherConfigService.getById(id);
+            if(ToolUtil.isNotEmpty(url)){
+                byId.setUrl(url);
+            }
+            byId.setName(name);
+            TTurn byId1 = tTurnService.getById(page);
+            TTurn byId2 = tTurnService.getById(type);
+            byId.setPage(byId1.getName());
+            byId.setType(byId2.getName());
+            byId.setTurnId(turnId);
+            byId.setSort(sort);
+            byId.setPageId(page);
+            byId.setTypeId(type);
+            storeOtherConfigService.updateById(byId);
+            return SUCCESS_TIP;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+    @RequestMapping(value = "/updateConfigOne3")
+    @ResponseBody
+    public Object addConfigOne3(String url,String name,Integer page,Integer type,String  turnId,Integer sort,Integer id) {
+        try {
+            TStoreOtherConfigTrue byId = tStoreOtherConfigTrueService.getById(id);
+            if(ToolUtil.isNotEmpty(url)){
+                byId.setUrl(url);
+            }
+            byId.setName(name);
+            TTurn byId1 = tTurnService.getById(page);
+            TTurn byId2 = tTurnService.getById(type);
+            byId.setPage(byId1.getName());
+            byId.setType(byId2.getName());
+            byId.setTurnId(turnId);
+            byId.setSort(sort);
+            byId.setPageId(page);
+            byId.setTypeId(type);
+            tStoreOtherConfigTrueService.updateById(byId);
+            return SUCCESS_TIP;
+        }catch (Exception e){
+            e.printStackTrace();
+            return ERROR;
+        }
+    }
+
 
 
 

--
Gitblit v1.7.1