From 9f05696822f8feee385a34a92dd9aa16009e84a0 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 18 六月 2023 12:38:00 +0800
Subject: [PATCH] 寻路算法,地图节点优化,剔除原入出库模式获取地图节点方案,改为根据库位状态实时获取节点信息或直接获取无过滤的完整节点信息

---
 src/main/java/com/zy/common/utils/NavigateMapData.java |   91 +++++++++++++++++++++++++++++++++------------
 1 files changed, 66 insertions(+), 25 deletions(-)

diff --git a/src/main/java/com/zy/common/utils/NavigateMapData.java b/src/main/java/com/zy/common/utils/NavigateMapData.java
index 2fa688e..6012be6 100644
--- a/src/main/java/com/zy/common/utils/NavigateMapData.java
+++ b/src/main/java/com/zy/common/utils/NavigateMapData.java
@@ -1,10 +1,14 @@
 package com.zy.common.utils;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.core.common.SpringUtils;
 import com.zy.asrs.entity.BasMap;
+import com.zy.asrs.entity.LocMast;
+import com.zy.asrs.service.LocMastService;
 import com.zy.common.model.MapNode;
 import com.zy.common.model.NavigateNode;
+import com.zy.common.model.enums.NavigationMapType;
 import com.zy.core.enums.ShuttleTaskModeType;
 import org.springframework.stereotype.Component;
 
@@ -30,10 +34,10 @@
     }
 
     public int[][] getData() {
-        return getData(ShuttleTaskModeType.PAK_IN.id);
+        return getData(NavigationMapType.NONE.id, null);//榛樿璇诲彇鏃犺繃婊ょ殑鍏ㄩ儴鍦板浘鏁版嵁
     }
 
-    public int[][] getData(Integer mapType) {
+    public int[][] getData(Integer mapType, List<int[]> whitePoints) {
         try {
             String mapFilename = "map_" + lev + ".json";
 
@@ -51,7 +55,7 @@
 
                 //瑙f瀽json鍦板浘鏁版嵁
                 ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class);
-                List<List<MapNode>> lists = filterMap(mapType, arrayList);//杩囨护鍦板浘鏁版嵁
+                List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints);//杩囨护鍦板浘鏁版嵁
                 int[][] map = new int[lists.size()][];
                 int j = 0;
                 for (List<MapNode> list : lists) {
@@ -78,7 +82,7 @@
     /**
      * 灏濊瘯浠巖edis鑾峰彇鏁版嵁
      */
-    public int[][] getDataFromRedis(Integer mapType) {
+    public int[][] getDataFromRedis(Integer mapType, List<int[]> whitePoints) {
         RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
         Object o = redisUtil.get("realtimeBasMap_" + lev);
         if (o == null) {
@@ -86,15 +90,15 @@
         }
 
         BasMap basMap = JSON.parseObject(o.toString(), BasMap.class);
-        return this.getDataFormString(basMap.getData(), mapType);
+        return this.getDataFormString(basMap.getData(), mapType, whitePoints);
     }
 
     /**
      * 浠嶭ist鏁版嵁涓幏鍙栧湴鍥�
      */
-    public int[][] getDataFormString(String data, Integer mapType) {
+    public int[][] getDataFormString(String data, Integer mapType, List<int[]> whitePoints) {
         ArrayList arrayList = JSON.parseObject(data, ArrayList.class);
-        List<List<MapNode>> lists = filterMap(mapType, arrayList);//杩囨护鍦板浘鏁版嵁
+        List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints);//杩囨护鍦板浘鏁版嵁
         int[][] map = new int[lists.size()][];
         int j = 0;
         for (List<MapNode> list : lists) {
@@ -112,7 +116,7 @@
     }
 
     //鑾峰彇JSON鏍煎紡鏁版嵁
-    public List<List<MapNode>> getJsonData(Integer mapType) {
+    public List<List<MapNode>> getJsonData(Integer mapType, List<int[]> whitePoints) {
         try {
             String mapFilename = "map_" + lev + ".json";
 
@@ -130,7 +134,7 @@
 
                 //瑙f瀽json鍦板浘鏁版嵁
                 ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class);
-                List<List<MapNode>> lists = filterMap(mapType, arrayList);//杩囨护鍦板浘鏁版嵁
+                List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints);//杩囨护鍦板浘鏁版嵁
 
                 return lists;
             } else {
@@ -143,31 +147,68 @@
     }
 
     /**
-     * 杩囨护鍦板浘鏁版嵁锛屽叆搴撴搷浣滃垯杩囨护鍑哄簱鐨勭鐢ㄥ簱浣嶏紝鍑哄簱鎿嶄綔鍒欒繃婊ゅ叆搴撶殑绂佺敤搴撲綅
+     * 杩囨护鍦板浘鏁版嵁
+     * mapType -1=>鏃犺繃婊わ紝1=銆嬭繃婊ゅ簱浣嶇姸鎬丏FX锛�2=銆嬭繃婊ゅ簱浣嶇姸鎬乆
+     * @param whitePoints 鐧藉悕鍗曡妭鐐癸紝涓嶉渶瑕佽杩囨护
      */
-    public List<List<MapNode>> filterMap(Integer mapType,List arrayList) {
+    public List<List<MapNode>> filterMap(Integer mapType, List arrayList, Integer lev, List<int[]> whitePoints) {
         List<List<MapNode>> lists = new ArrayList<>();
+
+        //閲嶅缓鏁版嵁鏍煎紡
         for (int i = 0; i < arrayList.size(); i++) {
             Object obj = arrayList.get(i);
             List<MapNode> list = JSON.parseArray(obj.toString(), MapNode.class);
             for (int j = 0; j < list.size(); j++) {
                 MapNode mapNode = list.get(j);
-                if (mapType == ShuttleTaskModeType.PAK_IN.id) {
-                    //鍏ュ簱鍦板浘
-                    if (mapNode.getData().equals("IN_X")) {
-                        //绂佹浣跨敤鐨勫簱浣嶏紝璁剧疆涓�-1
-                        mapNode.setValue(-1);
-                    }
-                }else if(mapType == ShuttleTaskModeType.PAK_OUT.id){
-                    //鍑哄簱鍦板浘
-                    if (mapNode.getData().equals("OUT_X")) {
-                        //绂佹浣跨敤鐨勫簱浣嶏紝璁剧疆涓�-1
-                        mapNode.setValue(-1);
-                    }
-                }
                 list.set(j, mapNode);
             }
             lists.add(list);
+        }
+
+        //杩囨护鏁版嵁
+        LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
+        //鑾峰彇褰撳墠妤煎眰搴撲綅鏁版嵁
+        List<LocMast> locMasts = locMastService.selectLocByLev(lev);
+        for (LocMast locMast : locMasts) {
+            Integer row = locMast.getRow1();
+            Integer bay = locMast.getBay1();
+
+            boolean whiteFlag = false;//榛樿涓嶅瓨鍦ㄧ櫧鍚嶅崟
+            if (whitePoints != null) {
+                for (int[] whitePoint : whitePoints) {
+                    if (whitePoint[0] == row && whitePoint[1] == bay) {
+                        //瀛樺湪鐧藉悕鍗�
+                        whiteFlag = true;
+                        break;
+                    }
+                }
+            }
+            if (whiteFlag) {
+                continue;//瀛樺湪鐧藉悕鍗曪紝涓嶆墽琛屼笅鍒楄繃婊ゆ柟妗�
+            }
+
+
+            List<MapNode> list = lists.get(row);
+            MapNode mapNode = list.get(bay);
+
+            if (mapType == NavigationMapType.NONE.id) {
+                //涓嶈繃婊や换浣曟暟鎹�
+            } else if (mapType == NavigationMapType.DFX.id) {
+                //杞﹁締鏈夎揣
+                //璇诲彇瀵瑰簲搴撲綅鏁版嵁锛屽皢DFX搴撲綅鐘舵�佺殑鑺傜偣缃负-1(闅滅鐗�)
+                if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") || locMast.getLocSts().equals("X")) {
+                    mapNode.setValue(-1);//绂佺敤鑺傜偣
+                }
+            } else if (mapType == NavigationMapType.NORMAL.id) {
+                //杩囨护搴撲綅鐘舵�乆
+                if (locMast.getLocSts().equals("X")) {
+                    mapNode.setValue(-1);//绂佺敤鑺傜偣
+                }
+            }
+
+            //鏇存柊list
+            list.set(bay, mapNode);
+            lists.set(row, list);
         }
 
         return lists;
@@ -186,7 +227,7 @@
 
         BasMap basMap = JSON.parseObject(o.toString(), BasMap.class);
         ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class);
-        List<List<MapNode>> lists = filterMap(-1, arrayList);//鑾峰彇鍏ㄩ儴鍦板浘鏁版嵁
+        List<List<MapNode>> lists = filterMap(NavigationMapType.NONE.id, arrayList, lev, null);//鑾峰彇鍏ㄩ儴鍦板浘鏁版嵁
 
         for (NavigateNode node : nodes) {
             if (node.getZ() != lev) {

--
Gitblit v1.9.1