无关风月
2025-04-01 562ccac1d78a2dc3e5936ef2c6dd77d22ebbfb0e
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TShopController.java
@@ -1,7 +1,7 @@
package com.dsh.guns.modular.system.controller.code;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -9,33 +9,54 @@
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.communityWorldCup.Model.WorldCupStore;
import com.dsh.course.feignClient.communityWorldCup.Model.WorldCupStoreVO;
import com.dsh.course.feignClient.communityWorldCup.WorldCupStoreClient;
import com.dsh.course.feignClient.competition.CompetitionClient;
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;
import com.dsh.guns.core.base.tips.SuccessTip;
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.*;
import com.dsh.guns.modular.system.util.GaoDeMapUtil;
import com.dsh.guns.modular.system.model.StoreConfig;
import com.dsh.guns.modular.system.model.TCity;
import com.dsh.guns.modular.system.model.TOperator;
import com.dsh.guns.modular.system.model.TOperatorCity;
import com.dsh.guns.modular.system.model.TStore;
import com.dsh.guns.modular.system.model.TStoreListVo;
import com.dsh.guns.modular.system.model.TStoreOther;
import com.dsh.guns.modular.system.model.TStoreOtherConfig;
import com.dsh.guns.modular.system.model.TStoreOtherConfigTrue;
import com.dsh.guns.modular.system.model.TTurn;
import com.dsh.guns.modular.system.model.User;
import com.dsh.guns.modular.system.service.ICityService;
import com.dsh.guns.modular.system.service.IStoreService;
import com.dsh.guns.modular.system.service.ITSiteService;
import com.dsh.guns.modular.system.service.IUserService;
import com.dsh.guns.modular.system.service.StoreConfigService;
import com.dsh.guns.modular.system.service.TOperatorCityService;
import com.dsh.guns.modular.system.service.TOperatorService;
import com.dsh.guns.modular.system.service.TStoreOtherConfigService;
import com.dsh.guns.modular.system.service.TStoreOtherConfigTrueService;
import com.dsh.guns.modular.system.service.TStoreOtherService;
import com.dsh.guns.modular.system.service.TTurnService;
import com.dsh.guns.modular.system.util.HttpRequestUtil;
import io.swagger.models.auth.In;
import org.apache.poi.ss.formula.functions.T;
import org.bouncycastle.math.raw.Mod;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 车辆管理控制器
@@ -85,6 +106,8 @@
    private ITSiteService siteService;
    @Autowired
    private IUserService userService;
    @Autowired
    private WorldCupStoreClient worldCupStoreClient;
    // 添加SUTU
@@ -110,25 +133,25 @@
        return SUCCESS_TIP;
    }
    public static void main(String[] args) {
//    public static void main(String[] args) {
////        HashMap<String, String> map = new HashMap<>();
////        map.put("page","1");
////        map.put("space_id","2010");
////        // 获取门禁列表
////        String s1 = HttpRequestUtil.getRequest
////                ("https://port.daowepark.com/v7/user_api/general/getDevice", map);
////        System.err.println(s1);
//
//        HashMap<String, String> map = new HashMap<>();
//        map.put("page","1");
//        map.put("space_id","2010");
//        map.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
//        map.put("space_id","1");
//        map.put("device_id","1");
//        map.put("region_id","2010");
//        // 获取门禁列表
//        String s1 = HttpRequestUtil.getRequest
//                ("https://try.daowepark.com/v7/user_api/general/getDevice", map);
//                ("https://port.daowepark.com/v7/user_api/general/getDevice", map);
//        System.err.println(s1);
        HashMap<String, String> map = new HashMap<>();
        map.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
        map.put("space_id","1");
        map.put("device_id","1");
        map.put("region_id","2010");
        // 获取门禁列表
        String s1 = HttpRequestUtil.getRequest
                ("https://try.daowepark.com/v7/user_api/general/getDevice", map);
        System.err.println(s1);
    };
//    };
    /**
     * 跳转到车辆管理首页
     */
@@ -168,12 +191,12 @@
        }
//        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);
            }
        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);
@@ -216,7 +239,7 @@
        }else{
            List<TOperatorCity> list = operatorCityService.list(new QueryWrapper<TOperatorCity>()
                    .eq("operatorId", operatorId)
            .eq("pid",byId.getId()));
                    .eq("pid",byId.getId()));
            if (list.size() == 0){
                // 说明管理整个省
                TCity code = cityService.getOne(new QueryWrapper<TCity>().eq("code", byId.getCode()));
@@ -306,7 +329,7 @@
        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);
@@ -421,8 +444,15 @@
        StoreConfig c8 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,8));
        model.addAttribute("c8",c8);
        model.addAttribute("id",id);
        StoreConfig c9 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,9));
        model.addAttribute("c9",c9);
        List<WorldCupStoreVO> worldCupStores = worldCupStoreClient.getWorldCupStoreListByStoreId(id);
        if (CollectionUtils.isEmpty(worldCupStores)){
            model.addAttribute("worldCupStores",new ArrayList<>());
        }else{
            model.addAttribute("worldCupStores",worldCupStores);
        }
        //惠民卡
        StoreConfig c10 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,10));
        model.addAttribute("c10",c10);
        return PREFIX + "TShop_imgAll.html";
    }
@@ -480,7 +510,7 @@
                if(list1.size()>0){
                    if (ToolUtil.isNotEmpty(tStore.getProvinceCode())) {
                        TOperatorCity byId = operatorCityService.getOne(new QueryWrapper<TOperatorCity>().eq("code",tStore.getProvinceCode())
                        .eq("operatorId",yyId));
                                .eq("operatorId",yyId));
                        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getCode()));
                        tStore.setProvince(one.getName());
                        tStore.setProvinceCode(one.getCode());
@@ -545,19 +575,17 @@
            user.setStatus(1);
            userMapper.insert(user);
            tStore.setStoreStaffId(user.getId());
                tStore.setLon(lon);
                tStore.setLat(lat);
                if (yyId == null || yyId == 0){
                    tStore.setOperatorId(0);
                }else{
                    tStore.setOperatorId(yyId);
                }
            tStore.setLon(lon);
            tStore.setLat(lat);
            if (yyId == null || yyId == 0){
                tStore.setOperatorId(0);
            }else{
                tStore.setOperatorId(yyId);
            }
            if (UserExt.getUser().getObjectType()==2){
                tStore.setOperatorId(UserExt.getUser().getObjectId());
            }
            user.setObjectId(tStore.getId());
            userService.updateById(user);
            // 添加门店
            HashMap<String, String> map1 = new HashMap<>();
            map1.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
@@ -572,7 +600,7 @@
            map1.put("remark",tStore.getIntroduce());
            map1.put("lat",tStore.getLat());
            map1.put("lng",tStore.getLon());
            String result = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpace", map1);
            String result = HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/addSpace", map1);
            System.out.println(result);
            JSONObject jsonObject = JSONObject.parseObject(result);
            JSONObject data = jsonObject.getJSONObject("data");
@@ -580,7 +608,8 @@
            Integer integer = Integer.valueOf(space_id);
            tStore.setId(integer);
            storeService.save(tStore);
            System.err.println(tStore);
            user.setObjectId(tStore.getId());
            userService.updateById(user);
            ArrayList<StoreConfig> storeConfigs = new ArrayList<>();
            for (int i = 1; i < 9; i++) {
                StoreConfig storeConfig = new StoreConfig();
@@ -597,7 +626,7 @@
//            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);
//            HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/addSpaceArea", mapSite);
//            for (String s : tStore.getIds().split(",")) {
//                HashMap<String, String> map = new HashMap<>();
//                map.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
@@ -605,7 +634,7 @@
//                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);
//                String s1 = HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/addDevice", map);
//                System.out.println(s1);
//            }
            return new SuccessTip<>();
@@ -712,9 +741,9 @@
    }
    @RequestMapping(value = "/saveImgAll")
    @ResponseBody
    public Object saveImgAll(Integer id,Integer px1,Integer px2,Integer px3,Integer px4,Integer px5,Integer px6,Integer px7,Integer px8,Integer px9,
                             String c1,String c2,String c3,String c4,String c5,String c6,String c7,String c8,String c9,
                             Integer r1,Integer r2,Integer r3,Integer r4,Integer r5,Integer r6,Integer r7,Integer r8,Integer r9) {
    public Object saveImgAll(Integer id,Integer px1,Integer px2,Integer px3,Integer px4,Integer px5,Integer px6,Integer px7,Integer px8,Integer px10,
                             String c1,String c2,String c3,String c4,String c5,String c6,String c7,String c8,String c10,
                             Integer r1,Integer r2,Integer r3,Integer r4,Integer r5,Integer r6,Integer r7,Integer r8,Integer r10,String str) {
        try {
            ArrayList<StoreConfig> storeConfigs = new ArrayList<>();
            StoreConfig collect1 = collect(id, px1, r1, c1, 1);
@@ -725,6 +754,7 @@
            StoreConfig collect6 = collect(id, px6, r6, c6, 6);
            StoreConfig collect7 = collect(id, px7, r7, c7, 7);
            StoreConfig collect8 = collect(id, px8, r8, c8, 8);
            StoreConfig collect10 = collect(id, px10, r10, c10, 10);
            storeConfigs.add(collect1);
            storeConfigs.add(collect2);
            storeConfigs.add(collect3);
@@ -733,9 +763,28 @@
            storeConfigs.add(collect6);
            storeConfigs.add(collect7);
            storeConfigs.add(collect8);
            StoreConfig collect9 = collect(id, px9, r9, c9, 9);
            storeConfigs.add(collect9);
            storeConfigService.updateBatchById(storeConfigs);
            storeConfigs.add(collect10);
            storeConfigService.saveOrUpdateBatch(storeConfigs);
            // 修改世界杯
            JSONArray jsonArray = JSONObject.parseArray(str);
            List<WorldCupStore> worldCupStores = new ArrayList<>();
            for (Object o : jsonArray) {
                String s = JSONObject.toJSONString(o);
                JSONObject jsonObject = JSONObject.parseObject(s);
                Integer id1 = jsonObject.getInteger("id");
                String backgroundImage = jsonObject.getString("backgroundImage");
                Integer isOpen = jsonObject.getInteger("isOpen");
                Integer sort = jsonObject.getInteger("sort");
                WorldCupStore worldCupStore = new WorldCupStore();
                worldCupStore.setSort(sort);
                worldCupStore.setId(id1);
                worldCupStore.setBackgroundImage(backgroundImage);
                worldCupStore.setIsOpen(isOpen);
                worldCupStores.add(worldCupStore);
            }
            worldCupStoreClient.updateWorldCupStoreListById(worldCupStores);
            return new SuccessTip<>();
        }catch (Exception e){
            e.printStackTrace();
@@ -744,12 +793,27 @@
    }
    private StoreConfig collect(Integer id,Integer sort,Integer isOpen,String img,int type){
        StoreConfig one = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType, type));
        one.setSort(sort);
        one.setIsOpen(isOpen);
        if(ToolUtil.isNotEmpty(img)){
            one.setBackgroundImage(img);
        StoreConfig one = storeConfigService.getOne(new QueryWrapper<StoreConfig>()
                .eq("storeId", id)
                .eq("type", type));
        if (one!=null){
            one.setSort(sort);
            one.setIsOpen(isOpen);
            if(ToolUtil.isNotEmpty(img)){
                one.setBackgroundImage(img);
            }
        }
        if (one == null){
            StoreConfig storeConfig = new StoreConfig();
            storeConfig.setStoreId(id);
            storeConfig.setType(type);
            storeConfig.setIsOpen(isOpen);
            storeConfig.setSort(sort);
            storeConfig.setBackgroundImage(img);
            storeConfigService.save(storeConfig);
            return storeConfig;
        }
        return one;
    }
    @RequestMapping(value = "/oneChangeNext")
@@ -848,8 +912,7 @@
    @RequestMapping(value = "/deleteTwo")
    public Object delete2(Integer id) {
        try {
            storeOtherConfigService.removeById(id);
            tStoreOtherConfigTrueService.removeById(id);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
@@ -987,7 +1050,7 @@
    @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);
            storeService.addConfigOne(url,name,page,type,turnId,sort);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
@@ -1020,7 +1083,7 @@
            }
        return SUCCESS_TIP;
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
@@ -1036,7 +1099,7 @@
            storeOtherService.updateById(byId);
        return SUCCESS_TIP;
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
@@ -1098,9 +1161,9 @@
    @RequestMapping(value = "/addConfigOne9")
    @ResponseBody
    public Object addConfigOne9(String url,String name,Integer page,Integer type,String  turnId,Integer sort,Integer id) {
            try {
        try {
            TStoreOtherConfigTrue byId = new TStoreOtherConfigTrue();
                byId.setPid(id);
            byId.setPid(id);
            if(ToolUtil.isNotEmpty(url)){
                byId.setUrl(url);
            }