From 04345d4eaec301c21331c4253b4da0f29b285349 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期六, 10 一月 2026 13:17:41 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/controller/BasMapController.java |  327 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 174 insertions(+), 153 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/BasMapController.java b/src/main/java/com/zy/asrs/controller/BasMapController.java
index b261f07..8a199cc 100644
--- a/src/main/java/com/zy/asrs/controller/BasMapController.java
+++ b/src/main/java/com/zy/asrs/controller/BasMapController.java
@@ -165,175 +165,196 @@
     }
 
     @PostMapping("/basMap/crn/upload")
-    public R uploadExcel(@RequestParam("file") MultipartFile file) throws IOException {
-        // 淇濆瓨涓婁紶鐨勬枃浠跺埌涓存椂浣嶇疆
-        String filePath = System.getProperty("java.io.tmpdir") + file.getOriginalFilename();
-        file.transferTo(new File(filePath));
+    public R uploadExcel(@RequestParam("file") MultipartFile file) {
+        try {
+            // 淇濆瓨涓婁紶鐨勬枃浠跺埌涓存椂浣嶇疆
+            String filePath = System.getProperty("java.io.tmpdir") + file.getOriginalFilename();
+            file.transferTo(new File(filePath));
 
-        HashMap<Integer, List<List<HashMap<String, Object>>>> dataMap = mapExcelUtils.readExcel(filePath);
-        HashMap<Integer, List<StationObjModel>> deviceStationMap = new HashMap<>();
-        HashMap<Integer, List<StationObjModel>> barcodeStationMap = new HashMap<>();
-        HashMap<Integer, List<StationObjModel>> inStationMap = new HashMap<>();
-        HashMap<Integer, List<StationObjModel>> outStationMap = new HashMap<>();
-        HashMap<Integer, List<StationObjModel>> runBlockReassignStationMap = new HashMap<>();
+            HashMap<Integer, List<List<HashMap<String, Object>>>> dataMap = mapExcelUtils.readExcel(filePath);
+            HashMap<Integer, List<StationObjModel>> deviceStationMap = new HashMap<>();
+            HashMap<Integer, List<StationObjModel>> barcodeStationMap = new HashMap<>();
+            HashMap<Integer, List<StationObjModel>> inStationMap = new HashMap<>();
+            HashMap<Integer, List<StationObjModel>> outStationMap = new HashMap<>();
+            HashMap<Integer, List<StationObjModel>> runBlockReassignStationMap = new HashMap<>();
 
-        for (Map.Entry<Integer, List<List<HashMap<String, Object>>>> entry : dataMap.entrySet()) {
-            Integer lev = entry.getKey();
-            List<List<HashMap<String, Object>>> dataList = new ArrayList<>();
-            List<List<HashMap<String, Object>>> list = entry.getValue();
+            for (Map.Entry<Integer, List<List<HashMap<String, Object>>>> entry : dataMap.entrySet()) {
+                Integer lev = entry.getKey();
+                List<List<HashMap<String, Object>>> dataList = new ArrayList<>();
+                List<List<HashMap<String, Object>>> list = entry.getValue();
 
-            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);
+                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"));
+                        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");
+                        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(255,255,0)")) {
+                            //鍙屽伐浣嶅爢鍨涙満
+                            nodeData.put("type", "dualCrn");
+                        } 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"));
-                        stationObjModel.setStationLev(lev);
+                            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"));
+                            stationObjModel.setStationLev(lev);
 
-                        List<StationObjModel> stationList = deviceStationMap.getOrDefault(deviceNo, new ArrayList<>());
-                        stationList.add(stationObjModel);
-                        deviceStationMap.put(deviceNo, stationList);
+                            List<StationObjModel> stationList = deviceStationMap.getOrDefault(deviceNo, new ArrayList<>());
+                            stationList.add(stationObjModel);
+                            deviceStationMap.put(deviceNo, stationList);
 
-                        Integer isBarcodeStation = value.getInteger("isBarcodeStation");
-                        if (isBarcodeStation != null && isBarcodeStation == 1) {
-                            List<StationObjModel> barcodeStationList = barcodeStationMap.getOrDefault(deviceNo, new ArrayList<>());
-                            barcodeStationList.add(stationObjModel);
-                            barcodeStationMap.put(deviceNo, barcodeStationList);
+                            Integer isBarcodeStation = value.getInteger("isBarcodeStation");
+                            if (isBarcodeStation != null && isBarcodeStation == 1) {
+                                StationObjModel barcodeStationModel = new StationObjModel();
+                                barcodeStationModel.setDeviceNo(deviceNo);
+                                barcodeStationModel.setStationId(value.getInteger("stationId"));
+                                barcodeStationModel.setBarcodeIdx(value.getInteger("barcodeIdx"));
+
+                                if (value.getInteger("backStation") != null) {
+                                    StationObjModel backStation = new StationObjModel();
+                                    barcodeStationModel.setBackStation(backStation);
+
+                                    backStation.setDeviceNo(value.getInteger("backStationDeviceNo"));
+                                    backStation.setStationId(value.getInteger("backStation"));
+                                }
+
+                                List<StationObjModel> barcodeStationList = barcodeStationMap.getOrDefault(deviceNo, new ArrayList<>());
+                                barcodeStationList.add(barcodeStationModel);
+                                barcodeStationMap.put(deviceNo, barcodeStationList);
+                            }
+
+                            Integer isInStation = value.getInteger("isInStation");
+                            if (isInStation != null && isInStation == 1) {
+                                StationObjModel inStationModel = new StationObjModel();
+                                StationObjModel barcodeStation = new StationObjModel();
+                                inStationModel.setDeviceNo(deviceNo);
+                                inStationModel.setStationId(value.getInteger("stationId"));
+                                inStationModel.setBarcodeStation(barcodeStation);
+
+                                barcodeStation.setDeviceNo(value.getInteger("barcodeStationDeviceNo"));
+                                barcodeStation.setStationId(value.getInteger("barcodeStation"));
+
+                                List<StationObjModel> inStationList = inStationMap.getOrDefault(deviceNo, new ArrayList<>());
+                                inStationList.add(inStationModel);
+                                inStationMap.put(deviceNo, inStationList);
+                            }
+
+                            Integer isOutStation = value.getInteger("isOutStation");
+                            if (isOutStation != null && isOutStation == 1) {
+                                List<StationObjModel> outStationList = outStationMap.getOrDefault(deviceNo, new ArrayList<>());
+                                outStationList.add(stationObjModel);
+                                outStationMap.put(deviceNo, outStationList);
+                            }
+
+                            Integer runBlockReassign = value.getInteger("runBlockReassign");
+                            if (runBlockReassign != null && runBlockReassign == 1) {
+                                List<StationObjModel> runBlockReassignStationList = runBlockReassignStationMap.getOrDefault(deviceNo, new ArrayList<>());
+                                runBlockReassignStationList.add(stationObjModel);
+                                runBlockReassignStationMap.put(deviceNo, runBlockReassignStationList);
+                            }
+                        } 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");
                         }
 
-                        Integer isInStation = value.getInteger("isInStation");
-                        if (isInStation != null && isInStation == 1) {
-                            StationObjModel inStationModel = new StationObjModel();
-                            StationObjModel barcodeStation = new StationObjModel();
-                            inStationModel.setDeviceNo(deviceNo);
-                            inStationModel.setStationId(value.getInteger("stationId"));
-                            inStationModel.setBarcodeStation(barcodeStation);
+                        nodeData.put("cellWidth", map.get("cellWidth"));
+                        nodeData.put("cellHeight", map.get("cellHeight"));
+                        nodeData.put("rowSpan", map.get("rowSpan"));
+                        nodeData.put("colSpan", map.get("colSpan"));
 
-                            barcodeStation.setDeviceNo(value.getInteger("barcodeStationDeviceNo"));
-                            barcodeStation.setStationId(value.getInteger("barcodeStation"));
-
-                            List<StationObjModel> inStationList = inStationMap.getOrDefault(deviceNo, new ArrayList<>());
-                            inStationList.add(inStationModel);
-                            inStationMap.put(deviceNo, inStationList);
-                        }
-
-                        Integer isOutStation = value.getInteger("isOutStation");
-                        if (isOutStation != null && isOutStation == 1) {
-                            List<StationObjModel> outStationList = outStationMap.getOrDefault(deviceNo, new ArrayList<>());
-                            outStationList.add(stationObjModel);
-                            outStationMap.put(deviceNo, outStationList);
-                        }
-
-                        Integer runBlockReassign = value.getInteger("runBlockReassign");
-                        if (runBlockReassign != null && runBlockReassign == 1) {
-                            List<StationObjModel> runBlockReassignStationList = runBlockReassignStationMap.getOrDefault(deviceNo, new ArrayList<>());
-                            runBlockReassignStationList.add(stationObjModel);
-                            runBlockReassignStationMap.put(deviceNo, runBlockReassignStationList);
-                        }
-                    }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");
+                        arrayList.add(nodeData);
                     }
-
-                    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);
                 }
-                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);
+                basMapService.insertOrUpdate(basMap);
             }
 
-            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);
-            basMapService.insertOrUpdate(basMap);
+            basStationService.delete(new EntityWrapper<>());
+
+            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);
+                }
+
+                List<StationObjModel> barcodeStationList = barcodeStationMap.get(deviceNo);
+                List<StationObjModel> inStationList = inStationMap.get(deviceNo);
+                List<StationObjModel> outStationList = outStationMap.get(deviceNo);
+                List<StationObjModel> runBlockReassignStationList = runBlockReassignStationMap.get(deviceNo);
+
+                if (barcodeStationList != null) {
+                    basDevp.setBarcodeStationList(JSON.toJSONString(barcodeStationList, SerializerFeature.DisableCircularReferenceDetect));
+                }
+
+                if (inStationList != null) {
+                    basDevp.setInStationList(JSON.toJSONString(inStationList, SerializerFeature.DisableCircularReferenceDetect));
+                }
+
+                if (outStationList != null) {
+                    basDevp.setOutStationList(JSON.toJSONString(outStationList, SerializerFeature.DisableCircularReferenceDetect));
+                }
+
+                if (runBlockReassignStationList != null) {
+                    basDevp.setRunBlockReassignLocStationList(JSON.toJSONString(runBlockReassignStationList, SerializerFeature.DisableCircularReferenceDetect));
+                }
+
+                basDevp.setStationList(JSON.toJSONString(stationList, SerializerFeature.DisableCircularReferenceDetect));
+                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);
+                }
+
+                for (StationObjModel stationObjModel : stationList) {
+                    BasStation basStation = new BasStation();
+                    basStation.setStationId(stationObjModel.getStationId());
+                    basStation.setDeviceNo(stationObjModel.getDeviceNo());
+                    basStation.setStationLev(stationObjModel.getStationLev());
+                    basStation.setCreateTime(new Date());
+                    basStation.setStatus(1);
+                    basStationService.insert(basStation);
+                }
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.error(e.getMessage());
         }
-
-        basStationService.delete(new EntityWrapper<>());
-
-        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);
-            }
-
-            List<StationObjModel> barcodeStationList = barcodeStationMap.get(deviceNo);
-            List<StationObjModel> inStationList = inStationMap.get(deviceNo);
-            List<StationObjModel> outStationList = outStationMap.get(deviceNo);
-            List<StationObjModel> runBlockReassignStationList = runBlockReassignStationMap.get(deviceNo);
-
-            if (barcodeStationList != null) {
-                basDevp.setBarcodeStationList(JSON.toJSONString(barcodeStationList, SerializerFeature.DisableCircularReferenceDetect));
-            }
-
-            if (inStationList != null) {
-                basDevp.setInStationList(JSON.toJSONString(inStationList, SerializerFeature.DisableCircularReferenceDetect));
-            }
-
-            if (outStationList != null) {
-                basDevp.setOutStationList(JSON.toJSONString(outStationList, SerializerFeature.DisableCircularReferenceDetect));
-            }
-
-            if (runBlockReassignStationList != null) {
-                basDevp.setRunBlockReassignLocStationList(JSON.toJSONString(runBlockReassignStationList, SerializerFeature.DisableCircularReferenceDetect));
-            }
-
-            basDevp.setStationList(JSON.toJSONString(stationList, SerializerFeature.DisableCircularReferenceDetect));
-            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);
-            }
-
-            for (StationObjModel stationObjModel : stationList) {
-                BasStation basStation = new BasStation();
-                basStation.setStationId(stationObjModel.getStationId());
-                basStation.setDeviceNo(stationObjModel.getDeviceNo());
-                basStation.setStationLev(stationObjModel.getStationLev());
-                basStation.setCreateTime(new Date());
-                basStation.setStatus(1);
-                basStationService.insert(basStation);
-            }
-        });
         return R.ok();
     }
 

--
Gitblit v1.9.1