nickchange
2023-10-16 ea2e322e4564a177b49ad38fda2d42780632ea0d
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TShopController.java
@@ -3,6 +3,7 @@
import cn.hutool.crypto.SecureUtil;
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;
@@ -17,6 +18,7 @@
import com.dsh.guns.modular.system.model.*;
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;
@@ -28,9 +30,8 @@
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
 * 车辆管理控制器
@@ -99,6 +100,17 @@
        String roleid = UserExt.getUser().getRoleid();
        model.addAttribute("role",roleid);
        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";
    }
@@ -119,6 +131,14 @@
        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";
    }
    /**
@@ -132,15 +152,19 @@
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
//        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getProvinceCode()));
        TOperatorCity one = operatorCityService.getOne(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, byId.getOperatorId()).eq(TOperatorCity::getType, 1));
        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));
        model.addAttribute("list",ones);
        List<TOperatorCity> list3 = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getPid, one.getId()).eq(TOperatorCity::getType, 2));
        if(list3.size()>0){
        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);
@@ -293,25 +317,51 @@
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object list(TStore tStore,String time,String userName,String userPhone,String ids,Integer type,Integer yyId,String lat,String lon) {
    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,String provinceCode,String cityCode) {
        try {
            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());
            if(yyId==null){
                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 byId1 = cityService.getById(tStore.getCityCode());
                    TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId1.getCode()));
                    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));
                tStore.setProvince(one.getName());
                tStore.setProvinceCode(one.getCode());
                TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, cCode1));
                tStore.setCity(one1.getName());
                tStore.setCityCode(one1.getCode());
            }
            tStore.setStartTime(time.split(" - ")[0]);
            tStore.setEndTime(time.split(" - ")[1]);
@@ -319,6 +369,7 @@
            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){
@@ -335,6 +386,15 @@
                tStore.setLat(lat);
            storeService.save(tStore);
            HashMap<String, String> map = new HashMap<>();
            map.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
            map.put("space_id","");
            map.put("device_id",tStore.getIds()+"");
            map.put("region_id",tStore.getId()+"");
            // 添加门禁
            String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map);
            ArrayList<StoreConfig> storeConfigs = new ArrayList<>();
            for (int i = 1; i < 9; i++) {
@@ -355,27 +415,53 @@
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TStore tStore,String time,String userName,String userPhone,String ids,Integer type,Integer yyId,String lat,String lon) {
    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())) {
                TOperatorCity tOperatorCity = operatorCityService.getById(tStore.getProvinceCode());
                TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, tOperatorCity.getCode()));
                tStore.setProvince(one.getName());
                tStore.setProvinceCode(one.getCode());
                List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getPid, tOperatorCity.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());
            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 byId1 = cityService.getById(tStore.getCityCode());
                    TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId1.getCode()));
                    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());
                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]);
@@ -383,9 +469,9 @@
            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";
@@ -397,6 +483,16 @@
            tStore.setLon(lon);
            tStore.setLat(lat);
            storeService.updateById(tStore);
            HashMap<String, String> map = new HashMap<>();
            map.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
            map.put("space_id","");
            map.put("device_id",tStore.getIds());
            map.put("region_id",tStore.getId()+"");
            // 编辑门禁
            String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/editDevice/ids/82", map);
            JSONObject jsonObject = JSONObject.parseObject(s);
            JSONObject data = jsonObject.getJSONObject("data");
            String spaceId = data.getString("space_id");
            return new SuccessTip<>();
        }catch (Exception e){
            e.printStackTrace();
@@ -483,7 +579,13 @@
    public Object onChange1(Integer oneId) {
        try {
            List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, oneId).eq(TOperatorCity::getType, 1));
            return list;
            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;
@@ -494,8 +596,15 @@
    @ResponseBody
    public Object onChange2(Integer oneId) {
        try {
            List<TOperatorCity> list1 = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, oneId).eq(TOperatorCity::getType, 1));
            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();