From 19bf1b4e5c7b650e84a042f6cbb70717faf21add Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期二, 26 三月 2024 13:24:49 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java |  186 +++++++++++++++++++++++-----------------------
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/Utils.java            |   41 ++++++++++
 2 files changed, 134 insertions(+), 93 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java
index 396260b..00a447e 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java
@@ -1,93 +1,93 @@
-//package com.zy.asrs.wcs.core.utils;
-//
-//import com.alibaba.fastjson.JSON;
-//import com.zy.asrs.common.wms.entity.BasMap;
-//import com.zy.asrs.framework.common.SpringUtils;
-//import com.zy.asrs.wcs.core.model.MapNode;
-//import com.zy.asrs.wcs.core.model.NavigateNode;
-//import com.zy.asrs.wcs.core.model.enums.NavigationMapType;
-//import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
-//import org.springframework.stereotype.Component;
-//
-//import java.util.ArrayList;
-//import java.util.Date;
-//import java.util.List;
-//
-//@Component
-//public class NavigateMapUtils {
-//
-//    /**
-//     * 鍐欏叆璺緞鑺傜偣鏁版嵁鍒皉edis鍦板浘涓�
-//     * lock涓簍rue 绂佺敤搴撲綅锛宭ock涓篺alse鎭㈠搴撲綅
-//     */
-//    public synchronized boolean writeNavigateNodeToRedisMap(Integer lev, Integer shuttleNo, List<NavigateNode> nodes, boolean lock) {
-//        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
-//        try {
-//            if (nodes.isEmpty()) {
-//                return true;
-//            }
-//
-//            NavigateMapData navigateMapData = new NavigateMapData(lev);
-//
-//            Object o = redisUtil.get(DeviceRedisConstant.MAP + lev);
-//            if (o == null) {
-//                return false;
-//            }
-//
-//            //鑾峰彇灏忚溅鑺傜偣
-//            List<int[]> shuttlePoints = Utils.getShuttlePoints(shuttleNo, lev);
-//
-//            BasMap basMap = JSON.parseObject(o.toString(), BasMap.class);
-//            ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class);
-//            //甯﹀皬杞﹀湴鍥�
-//            List<List<MapNode>> listsHasShuttle = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, shuttlePoints);//鑾峰彇甯﹀皬杞﹀湴鍥炬暟鎹�
-//            List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, null);//鑾峰彇鍏ㄩ儴鍦板浘鏁版嵁
-//
-//            //妫�娴嬭矾寰勬槸鍚﹁閿佸畾
-//            if (lock) {
-//                for (NavigateNode node : nodes) {
-//                    List<MapNode> listX = listsHasShuttle.get(node.getX());
-//                    MapNode mapNode = listX.get(node.getY());
-//                    if (mapNode.getValue() == -999) {
-//                        return false;//璺緞琚攣瀹氳繃锛岀姝㈠啀娆¢攣瀹�
-//                    }
-//                    if (mapNode.getValue() == 66) {
-//                        return false;//璺緞瀛樺湪灏忚溅锛岀姝㈤攣瀹�
-//                    }
-//                }
-//            }
-//
-//            //灏濊瘯閿佸畾/瑙i攣璺緞
-//            NavigateMapData mapData = new NavigateMapData(nodes.get(0).getZ());
-//            List<List<MapNode>> realMap = mapData.getJsonData(-1, null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱)
-//            for (NavigateNode node : nodes) {
-//                if (node.getZ() != lev) {
-//                    continue;
-//                }
-//
-//                List<MapNode> listX = lists.get(node.getX());
-//                MapNode mapNode = listX.get(node.getY());
-//                if (lock) {
-//                    mapNode.setValue(-999);//绂佺敤搴撲綅
-//                } else {
-//                    //鑾峰彇鍘熷鑺傜偣鏁版嵁
-//                    List<MapNode> rows = realMap.get(node.getX());
-//                    MapNode col = rows.get(node.getY());
-//                    mapNode.setValue(col.getValue());//鎭㈠搴撲綅
-//                }
-//
-//                listX.set(node.getY(), mapNode);
-//                lists.set(node.getX(), listX);
-//            }
-//            basMap.setData(JSON.toJSONString(lists));
-//            basMap.setUpdateTime(new Date());
-//            //灏嗘暟鎹簱鍦板浘鏁版嵁瀛樺叆redis
-//            redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(basMap));
-//            return true;
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        return false;
-//    }
-//
-//}
+package com.zy.asrs.wcs.core.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.zy.asrs.common.wms.entity.BasMap;
+import com.zy.asrs.framework.common.SpringUtils;
+import com.zy.asrs.wcs.core.model.MapNode;
+import com.zy.asrs.wcs.core.model.NavigateNode;
+import com.zy.asrs.wcs.core.model.enums.NavigationMapType;
+import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Component
+public class NavigateMapUtils {
+
+    /**
+     * 鍐欏叆璺緞鑺傜偣鏁版嵁鍒皉edis鍦板浘涓�
+     * lock涓簍rue 绂佺敤搴撲綅锛宭ock涓篺alse鎭㈠搴撲綅
+     */
+    public synchronized boolean writeNavigateNodeToRedisMap(Integer lev, Integer shuttleNo, List<NavigateNode> nodes, boolean lock) {
+        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
+        try {
+            if (nodes.isEmpty()) {
+                return true;
+            }
+
+            NavigateMapData navigateMapData = new NavigateMapData(lev);
+
+            Object o = redisUtil.get(DeviceRedisConstant.MAP + lev);
+            if (o == null) {
+                return false;
+            }
+
+            //鑾峰彇灏忚溅鑺傜偣
+            List<int[]> shuttlePoints = Utils.getShuttlePoints(shuttleNo, lev);
+
+            BasMap basMap = JSON.parseObject(o.toString(), BasMap.class);
+            ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class);
+            //甯﹀皬杞﹀湴鍥�
+            List<List<MapNode>> listsHasShuttle = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, shuttlePoints);//鑾峰彇甯﹀皬杞﹀湴鍥炬暟鎹�
+            List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, null);//鑾峰彇鍏ㄩ儴鍦板浘鏁版嵁
+
+            //妫�娴嬭矾寰勬槸鍚﹁閿佸畾
+            if (lock) {
+                for (NavigateNode node : nodes) {
+                    List<MapNode> listX = listsHasShuttle.get(node.getX());
+                    MapNode mapNode = listX.get(node.getY());
+                    if (mapNode.getValue() == -999) {
+                        return false;//璺緞琚攣瀹氳繃锛岀姝㈠啀娆¢攣瀹�
+                    }
+                    if (mapNode.getValue() == 66) {
+                        return false;//璺緞瀛樺湪灏忚溅锛岀姝㈤攣瀹�
+                    }
+                }
+            }
+
+            //灏濊瘯閿佸畾/瑙i攣璺緞
+            NavigateMapData mapData = new NavigateMapData(nodes.get(0).getZ());
+            List<List<MapNode>> realMap = mapData.getJsonData(-1, null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱)
+            for (NavigateNode node : nodes) {
+                if (node.getZ() != lev) {
+                    continue;
+                }
+
+                List<MapNode> listX = lists.get(node.getX());
+                MapNode mapNode = listX.get(node.getY());
+                if (lock) {
+                    mapNode.setValue(-999);//绂佺敤搴撲綅
+                } else {
+                    //鑾峰彇鍘熷鑺傜偣鏁版嵁
+                    List<MapNode> rows = realMap.get(node.getX());
+                    MapNode col = rows.get(node.getY());
+                    mapNode.setValue(col.getValue());//鎭㈠搴撲綅
+                }
+
+                listX.set(node.getY(), mapNode);
+                lists.set(node.getX(), listX);
+            }
+            basMap.setData(JSON.toJSONString(lists));
+            basMap.setUpdateTime(new Date());
+            //灏嗘暟鎹簱鍦板浘鏁版嵁瀛樺叆redis
+            redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(basMap));
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/Utils.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/Utils.java
new file mode 100644
index 0000000..81dae25
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/Utils.java
@@ -0,0 +1,41 @@
+package com.zy.asrs.wcs.core.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Utils {
+
+    //鑾峰彇闄ょ櫧鍚嶅崟澶栫殑鎸囧畾妤煎眰鍏ㄩ儴绌挎杞y鍧愭爣鐐�
+    public static List<int[]> getShuttlePoints(Integer whiteShuttle, Integer lev) {
+//        SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class);
+        ArrayList<int[]> list = new ArrayList<>();
+//        for (ShuttleSlave slave : slaveProperties.getShuttle()) {
+//            if (slave.getId().intValue() == whiteShuttle) {
+//                continue;//璺宠繃鐧藉悕鍗�
+//            }
+//
+//            //鑾峰彇绌挎杞︽墍鍦ㄨ妭鐐逛綅缃�
+//            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
+//            if (shuttleThread == null) {
+//                continue;
+//            }
+//            ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+//            if (shuttleProtocol == null) {
+//                continue;
+//            }
+//
+//            if (shuttleProtocol.getCurrentLocNo() == null) {
+//                continue;
+//            }
+//
+//            if (lev != Utils.getLev(shuttleProtocol.getCurrentLocNo())) {
+//                continue;//妤煎眰涓嶅悓
+//            }
+//
+//            int[] xyPosition = NavigatePositionConvert.positionToXY(shuttleProtocol.getCurrentLocNo());//閫氳繃搴撲綅鍙疯幏鍙杧y鍧愭爣
+//            list.add(xyPosition);
+//        }
+        return list;
+    }
+
+}

--
Gitblit v1.9.1