From dad4b7fd3a7fcaed73d28f0ebd9e90d86ca21225 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 22 七月 2025 12:34:51 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/utils/NavigateSolution.java |   71 ++++++++++++++++++-----------------
 1 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/src/main/java/com/zy/common/utils/NavigateSolution.java b/src/main/java/com/zy/common/utils/NavigateSolution.java
index 0c632b9..6910520 100644
--- a/src/main/java/com/zy/common/utils/NavigateSolution.java
+++ b/src/main/java/com/zy/common/utils/NavigateSolution.java
@@ -5,6 +5,7 @@
 import com.core.common.SpringUtils;
 import com.core.exception.CoolException;
 import com.zy.common.model.NavigateNode;
+import com.zy.common.model.enums.NavigationMapType;
 import com.zy.core.enums.MapNodeType;
 import com.zy.core.model.PythonResult;
 import com.zy.system.entity.Config;
@@ -25,10 +26,10 @@
 
     int[][] map = {{}};
 
-    public NavigateSolution(Integer mapType, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) {
+    public NavigateSolution(List<NavigationMapType> mapTypes, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) {
         //杞藉叆鍦板浘鎸囧畾灞傞珮鍦板浘
         NavigateMapData mapData = SpringUtils.getBean(NavigateMapData.class);
-        int[][] data = mapData.getDataFromRedis(lev, mapType, whitePoints, shuttlePoints);
+        int[][] data = mapData.getDataFromRedis(lev, mapTypes, whitePoints, shuttlePoints);
         if (data == null) {
             throw new CoolException("鍦板浘鏈浇鍏ワ紒");
         }
@@ -103,6 +104,18 @@
     }
 
     public NavigateNode astarSearchJava(NavigateNode start, NavigateNode end) {
+        //榛樿鍦板浘姣嶈建鏂瑰悜x
+        String mapDirection = "x";
+        ConfigService configService = SpringUtils.getBean(ConfigService.class);
+        if (configService != null) {
+            Config config = configService.selectOne(new EntityWrapper<Config>()
+                    .eq("code", "direction_map")
+                    .eq("status", 1));
+            if (config != null) {
+                mapDirection = config.getValue();
+            }
+        }
+
         //鎶婄涓�涓紑濮嬬殑缁撶偣鍔犲叆鍒癘pen琛ㄤ腑
         this.Open.add(start);
         //涓诲惊鐜�
@@ -117,7 +130,7 @@
             //灏嗚繖涓粨鐐瑰姞鍏ュ埌Close琛ㄤ腑
             Close.add(current_node);
             //瀵瑰綋鍓嶇粨鐐硅繘琛屾墿灞曪紝寰楀埌涓�涓洓鍛ㄧ粨鐐圭殑鏁扮粍
-            ArrayList<NavigateNode> neighbour_node = extend_current_node(current_node);
+            ArrayList<NavigateNode> neighbour_node = extend_current_node(current_node, mapDirection);
             //瀵硅繖涓粨鐐归亶鍘嗭紝鐪嬫槸鍚︽湁鐩爣缁撶偣鍑虹幇
             for (NavigateNode node : neighbour_node) {
                 // G + H + E (瀵瑰惎鍙戝嚱鏁板鍔犲幓鎷愮偣鏂规calcNodeExtraCost)
@@ -143,19 +156,7 @@
     }
 
 
-    public ArrayList<NavigateNode> extend_current_node(NavigateNode current_node) {
-        //榛樿鍦板浘姣嶈建鏂瑰悜x
-        String mapDirection = "x";
-        ConfigService configService = SpringUtils.getBean(ConfigService.class);
-        if (configService != null) {
-            Config config = configService.selectOne(new EntityWrapper<Config>()
-                    .eq("config", "direction_map")
-                    .eq("status", 1));
-            if (config != null) {
-                mapDirection = config.getValue();
-            }
-        }
-
+    public ArrayList<NavigateNode> extend_current_node(NavigateNode current_node, String mapDirection) {
         //鑾峰彇褰撳墠缁撶偣鐨剎, y
         int x = current_node.getX();
         int y = current_node.getY();
@@ -192,56 +193,56 @@
         if (mapDirection.equals("x")) {//姣嶈建x鏂瑰悜
             if (map[x][y] == MapNodeType.MAIN_PATH.id) {
                 //姣嶈建鎵嶈兘杩涜涓婁笅绉诲姩
-                if (is_valid(x + 1, y))
-                {
+                if (is_valid(x + 1, y)) {
                     NavigateNode node = new NavigateNode(x + 1, y);
+                    node.setNodeValue(map[x + 1][y]);
                     neighbour_node.add(node);
                 }
-                if (is_valid(x - 1, y))
-                {
-                    NavigateNode node = new NavigateNode(x -1, y);
+                if (is_valid(x - 1, y)) {
+                    NavigateNode node = new NavigateNode(x - 1, y);
+                    node.setNodeValue(map[x - 1][y]);
                     neighbour_node.add(node);
                 }
             }
 
             if (map[x][y] == MapNodeType.NORMAL_PATH.id || map[x][y] == MapNodeType.MAIN_PATH.id || map[x][y] == MapNodeType.CONVEYOR_CAR_GO.id || map[x][y] == MapNodeType.CHARGE.id || map[x][y] == MapNodeType.LIFT.id) {
                 //瀛愯建鍜屾瘝杞ㄣ�佸皬杞﹀彲璧拌緭閫佺嚎銆佸厖鐢垫々銆佹彁鍗囨満鎵嶈兘杩涜宸﹀彸绉诲姩
-                if (is_valid(x, y + 1))
-                {
+                if (is_valid(x, y + 1)) {
                     NavigateNode node = new NavigateNode(x, y + 1);
+                    node.setNodeValue(map[x][y + 1]);
                     neighbour_node.add(node);
                 }
-                if (is_valid(x, y - 1))
-                {
+                if (is_valid(x, y - 1)) {
                     NavigateNode node = new NavigateNode(x, y - 1);
+                    node.setNodeValue(map[x][y - 1]);
                     neighbour_node.add(node);
                 }
             }
-        }else if (mapDirection.equals("y")) {//姣嶈建y鏂瑰悜
+        } else if (mapDirection.equals("y")) {//姣嶈建y鏂瑰悜
             if (map[x][y] == MapNodeType.MAIN_PATH.id) {
                 //姣嶈建鎵嶈兘杩涜宸﹀彸绉诲姩
-                if (is_valid(x, y + 1))
-                {
+                if (is_valid(x, y + 1)) {
                     NavigateNode node = new NavigateNode(x, y + 1);
+                    node.setNodeValue(map[x][y + 1]);
                     neighbour_node.add(node);
                 }
-                if (is_valid(x, y - 1))
-                {
+                if (is_valid(x, y - 1)) {
                     NavigateNode node = new NavigateNode(x, y - 1);
+                    node.setNodeValue(map[x][y - 1]);
                     neighbour_node.add(node);
                 }
             }
 
             if (map[x][y] == MapNodeType.NORMAL_PATH.id || map[x][y] == MapNodeType.MAIN_PATH.id || map[x][y] == MapNodeType.CONVEYOR_CAR_GO.id || map[x][y] == MapNodeType.CHARGE.id || map[x][y] == MapNodeType.LIFT.id) {
                 //瀛愯建鍜屾瘝杞ㄣ�佸皬杞﹀彲璧拌緭閫佺嚎銆佸厖鐢垫々銆佹彁鍗囨満鎵嶈兘杩涜涓婁笅绉诲姩
-                if (is_valid(x + 1, y))
-                {
+                if (is_valid(x + 1, y)) {
                     NavigateNode node = new NavigateNode(x + 1, y);
+                    node.setNodeValue(map[x + 1][y]);
                     neighbour_node.add(node);
                 }
-                if (is_valid(x - 1, y))
-                {
-                    NavigateNode node = new NavigateNode(x -1, y);
+                if (is_valid(x - 1, y)) {
+                    NavigateNode node = new NavigateNode(x - 1, y);
+                    node.setNodeValue(map[x - 1][y]);
                     neighbour_node.add(node);
                 }
             }

--
Gitblit v1.9.1