From 8dc960dd9fda130ff19faaafed6b1234e622610b Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期五, 19 十二月 2025 15:23:05 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/controller/BasMapController.java |  136 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 111 insertions(+), 25 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/BasMapController.java b/src/main/java/com/zy/asrs/controller/BasMapController.java
index 16ca989..7a45904 100644
--- a/src/main/java/com/zy/asrs/controller/BasMapController.java
+++ b/src/main/java/com/zy/asrs/controller/BasMapController.java
@@ -2,24 +2,25 @@
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.core.common.DateUtils;
+import com.zy.asrs.entity.BasDevp;
 import com.zy.asrs.entity.BasMap;
-import com.zy.asrs.entity.BasShuttleCharge;
+import com.zy.asrs.entity.DeviceConfig;
+import com.zy.asrs.service.BasDevpService;
 import com.zy.asrs.service.BasMapService;
 import com.core.annotations.ManagerAuth;
 import com.core.common.BaseRes;
 import com.core.common.Cools;
 import com.core.common.R;
-import com.zy.asrs.service.BasShuttleChargeService;
+import com.zy.asrs.service.DeviceConfigService;
 import com.zy.asrs.utils.MapExcelUtils;
-import com.zy.common.model.MapNode;
 import com.zy.common.utils.RedisUtil;
 import com.zy.common.web.BaseController;
-import com.zy.core.enums.RedisKeyType;
+import com.zy.core.enums.SlaveType;
+import com.zy.core.model.StationObjModel;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -34,7 +35,9 @@
     @Autowired
     private BasMapService basMapService;
     @Autowired
-    private BasShuttleChargeService basShuttleChargeService;
+    private BasDevpService basDevpService;
+    @Autowired
+    private DeviceConfigService deviceConfigService;
     @Autowired
     private RedisUtil redisUtil;
 
@@ -137,38 +140,121 @@
         return R.ok();
     }
 
+    @GetMapping("/basMap/lev/{lev}/auth")
+    @ManagerAuth
+    public R getByLev(@PathVariable("lev") Integer lev) {
+        BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev));
+        if (basMap == null){
+            return R.error("鍦板浘涓嶅瓨鍦�");
+        }
+        return R.ok().add(basMap.getData());
+    }
+
+    @GetMapping("/basMap/getLevList")
+    @ManagerAuth
+    public R getLevList() {
+        List<Integer> levList = basMapService.getLevList();
+        return R.ok().add(levList);
+    }
+
     @Autowired
     private MapExcelUtils mapExcelUtils;
 
-    @PostMapping("/basMap/upload")
+    @PostMapping("/basMap/crn/upload")
     public R uploadExcel(@RequestParam("file") MultipartFile file) throws IOException {
         // 淇濆瓨涓婁紶鐨勬枃浠跺埌涓存椂浣嶇疆
-        String tempFilePath = System.getProperty("java.io.tmpdir") + file.getOriginalFilename();
-        file.transferTo(new File(tempFilePath));
+        String filePath = System.getProperty("java.io.tmpdir") + file.getOriginalFilename();
+        file.transferTo(new File(filePath));
 
-        HashMap<Integer, List<List<HashMap<String, Object>>>> dataMap = mapExcelUtils.readExcel(tempFilePath);
-        HashMap<Integer, List<List<MapNode>>> levMap = mapExcelUtils.processExcelData(dataMap);
+        HashMap<Integer, List<List<HashMap<String, Object>>>> dataMap = mapExcelUtils.readExcel(filePath);
+        HashMap<Integer, List<StationObjModel>> deviceStationMap = new HashMap<>();
 
-        // 鍒犻櫎涓存椂鏂囦欢
-        new File(tempFilePath).delete();
-
-        basMapService.delete(new EntityWrapper<>());
-
-        for (Map.Entry<Integer, List<List<MapNode>>> entry : levMap.entrySet()) {
+        for (Map.Entry<Integer, List<List<HashMap<String, Object>>>> entry : dataMap.entrySet()) {
             Integer lev = entry.getKey();
-            List<List<MapNode>> map = entry.getValue();
+            List<List<HashMap<String, Object>>> dataList = new ArrayList<>();
+            List<List<HashMap<String, Object>>> list = entry.getValue();
 
-            Date now = new Date();
-            BasMap basMap = new BasMap();
+            for (int i = 0; i < list.size(); i++) {
+                List<HashMap<String, Object>> bayList = list.get(i);
+                List<HashMap<String, Object>> arrayList = new ArrayList<>();
+                for (int j = 0; j < bayList.size(); j++) {
+                    HashMap<String, Object> map = bayList.get(j);
+
+                    HashMap<String, Object> nodeData = new HashMap<>();
+                    nodeData.put("value", map.get("value"));
+
+                    String nodeType = map.get("bgColor").toString();
+                    if (nodeType.equals("RGB(0,176,80)")) {
+                        //璐ф灦
+                        nodeData.put("type", "shelf");
+                    }else if (nodeType.equals("RGB(255,192,0)")) {
+                        //鍫嗗灈鏈�
+                        nodeData.put("type", "crn");
+                    }else if (nodeType.equals("RGB(0,112,192)")) {
+                        //杈撻�佺嚎
+                        nodeData.put("type", "devp");
+
+                        JSONObject value = JSON.parseObject(String.valueOf(map.get("value")));
+                        Integer deviceNo = value.getInteger("deviceNo");
+                        StationObjModel stationObjModel = new StationObjModel();
+                        stationObjModel.setDeviceNo(deviceNo);
+                        stationObjModel.setStationId(value.getInteger("stationId"));
+
+                        List<StationObjModel> stationList = deviceStationMap.getOrDefault(deviceNo, new ArrayList<>());
+                        stationList.add(stationObjModel);
+                        deviceStationMap.put(deviceNo, stationList);
+                    }else if (nodeType.equals("RGB(0,176,240)")) {
+                        //RGV
+                        nodeData.put("type", "rgv");
+                    } else if (nodeType.equals("none")) {
+                        //绌虹櫧鍖哄煙
+                        nodeData.put("type", "none");
+                    } else if (nodeType.equals("merge")) {
+                        //鍚堝苟鍖哄煙
+                        nodeData.put("type", "merge");
+                    }
+
+                    nodeData.put("cellWidth", map.get("cellWidth"));
+                    nodeData.put("cellHeight", map.get("cellHeight"));
+                    nodeData.put("rowSpan", map.get("rowSpan"));
+                    nodeData.put("colSpan", map.get("colSpan"));
+
+                    arrayList.add(nodeData);
+                }
+                dataList.add(arrayList);
+            }
+
+            BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev));
+            if (basMap == null){
+                basMap = new BasMap();
+            }
+            basMap.setData(JSON.toJSONString(dataList));
+            basMap.setOriginData(JSON.toJSONString(dataList));
+            basMap.setCreateTime(new Date());
+            basMap.setUpdateTime(new Date());
             basMap.setLev(lev);
-            basMap.setOriginData(JSON.toJSONString(map, SerializerFeature.DisableCircularReferenceDetect));
-            basMap.setCreateTime(now);
-            basMap.setUpdateTime(now);
-            basMapService.insert(basMap);
+            basMapService.insertOrUpdate(basMap);
 
-            redisUtil.del(RedisKeyType.MAP.key + lev);
         }
 
+        deviceStationMap.forEach((deviceNo, stationList) -> {
+            BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("devp_no", deviceNo));
+            if (basDevp == null){
+                basDevp = new BasDevp();
+                basDevp.setDevpNo(deviceNo);
+                basDevp.setCreateTime(new Date());
+                basDevp.setStatus(1);
+            }
+            basDevp.setStationList(JSON.toJSONString(stationList));
+            basDevp.setUpdateTime(new Date());
+            basDevpService.insertOrUpdate(basDevp);
+
+            DeviceConfig deviceConfig = deviceConfigService.selectOne(new EntityWrapper<DeviceConfig>().eq("device_no", deviceNo).eq("device_type", String.valueOf(SlaveType.Devp)));
+            if (deviceConfig != null){
+                deviceConfig.setFakeInitStatus(JSON.toJSONString(stationList));
+                deviceConfigService.updateById(deviceConfig);
+            }
+        });
         return R.ok();
     }
 

--
Gitblit v1.9.1