From 517966d4dbed6ef6e5d591720b971af427e6b63a Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 04 十二月 2025 15:25:47 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/utils/NavigateUtils.java |   90 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 88 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/zy/common/utils/NavigateUtils.java b/src/main/java/com/zy/common/utils/NavigateUtils.java
index b0ff36d..2e210a5 100644
--- a/src/main/java/com/zy/common/utils/NavigateUtils.java
+++ b/src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -4,6 +4,8 @@
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+
+import com.zy.core.News;
 import org.springframework.stereotype.Component;
 
 import com.alibaba.fastjson.JSON;
@@ -14,9 +16,9 @@
 @Component
 public class NavigateUtils {
 
-    public synchronized List<NavigateNode> calcByStationId(Integer startStationId, Integer endStationId) {
+    public synchronized List<NavigateNode> calcByStationId(int lev, Integer startStationId, Integer endStationId) {
         NavigateSolution navigateSolution = new NavigateSolution();
-        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap();
+        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(lev);
 
         NavigateNode startNode = navigateSolution.findStationNavigateNode(stationMap, startStationId);
         if (startNode == null){
@@ -28,10 +30,13 @@
             throw new CoolException("鏈壘鍒拌 缁堢偣 瀵瑰簲鐨勮妭鐐�");
         }
 
+        long startTime = System.currentTimeMillis();
+        News.info("[WCS Debug] 绔欑偣璺緞寮�濮嬭绠�,startStationId={},endStationId={}", startStationId, endStationId);
         NavigateNode res_node = navigateSolution.astarSearchJava(stationMap, startNode, endNode);
         if (res_node == null) {
             throw new CoolException("鏈壘鍒拌璺緞");
         }
+        News.info("[WCS Debug] 绔欑偣璺緞璁$畻瀹屾垚锛岃�楁椂锛歿}ms", System.currentTimeMillis() - startTime);
 
         ArrayList<NavigateNode> list = new ArrayList<>();
         // 浣跨敤 visited 闆嗗悎闃叉鐖堕摼鍑虹幇鐜鑷存寰幆锛屽悓鏃惰缃畨鍏ㄦ鏁颁笂闄�
@@ -66,4 +71,85 @@
         return fitlerList;
     }
 
+    public synchronized List<NavigateNode> calcByTrackSiteNo(int lev, Integer startTrackSiteNo, Integer endTrackSiteNo) {
+        NavigateSolution navigateSolution = new NavigateSolution();
+        List<List<NavigateNode>> rgvTrackMap = navigateSolution.getRgvTrackMap(lev);
+
+        NavigateNode startNode = navigateSolution.findTrackSiteNoNavigateNode(rgvTrackMap, startTrackSiteNo);
+        if (startNode == null){
+            throw new CoolException("鏈壘鍒拌 璧风偣 瀵瑰簲鐨勮妭鐐�");
+        }
+
+        NavigateNode endNode = navigateSolution.findTrackSiteNoNavigateNode(rgvTrackMap, endTrackSiteNo);
+        if (endNode == null){
+            throw new CoolException("鏈壘鍒拌 缁堢偣 瀵瑰簲鐨勮妭鐐�");
+        }
+
+        long startTime = System.currentTimeMillis();
+        News.info("[WCS Debug] RGV璺緞寮�濮嬭绠�,startTrackSiteNo:{},endTrackSiteNo={}", startTrackSiteNo, endTrackSiteNo);
+        NavigateNode res_node = navigateSolution.astarSearchJava(rgvTrackMap, startNode, endNode);
+        if (res_node == null) {
+            throw new CoolException("鏈壘鍒拌璺緞");
+        }
+        News.info("[WCS Debug] RGV璺緞璁$畻瀹屾垚锛岃�楁椂锛歿}ms", System.currentTimeMillis() - startTime);
+
+        ArrayList<NavigateNode> list = new ArrayList<>();
+        // 浣跨敤 visited 闆嗗悎闃叉鐖堕摼鍑虹幇鐜鑷存寰幆锛屽悓鏃惰缃畨鍏ㄦ鏁颁笂闄�
+        HashSet<NavigateNode> visited = new HashSet<>();
+        int maxSteps = rgvTrackMap.size() * rgvTrackMap.get(0).size() + 5; // 瀹夊叏涓婇檺
+        int steps = 0;
+        while (res_node != null && visited.add(res_node) && steps++ < maxSteps) {
+            list.add(res_node);
+            res_node = res_node.getFather();//杩唬鎿嶄綔
+        }
+        if (steps >= maxSteps) {
+            throw new CoolException("璺緞鍥炴函瓒呭嚭瀹夊叏涓婇檺锛岀枒浼煎瓨鍦ㄧ埗閾惧惊鐜�");
+        }
+        Collections.reverse(list);
+        //灏嗘瘡涓妭鐐归噷闈㈢殑fatherNode鑷充负null(鏂逛究鍚庣画璁$畻鏃剁埗鑺傜偣杩囧瀵艰嚧鏄剧ず鐨勮妭鐐瑰お澶�)
+        for (NavigateNode navigateNode : list) {
+            //鐖惰妭鐐硅缃负null锛屼笉褰卞搷璁$畻缁撴灉锛屼笉褰卞搷鍚庣画鎿嶄綔銆�
+            //姝ゆ搷浣滀粎涓哄悗缁帓鏌ュ鐞嗘彁渚涜瑙夋柟渚裤��
+            navigateNode.setFather(null);
+        }
+
+        //鍘婚噸
+        HashSet<Integer> set = new HashSet<>();
+        List<NavigateNode> fitlerList = new ArrayList<>();
+        for(NavigateNode navigateNode : list){
+            JSONObject valuObject = JSON.parseObject(navigateNode.getNodeValue());
+            if(set.add(valuObject.getInteger("trackSiteNo"))){
+                fitlerList.add(navigateNode);
+            }
+        }
+
+        return fitlerList;
+    }
+
+    public synchronized List<NavigateNode> findLiftStationList(int lev) {
+        NavigateSolution navigateSolution = new NavigateSolution();
+        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(lev);
+
+        List<NavigateNode> liftStationList = new ArrayList<>();
+        for (List<NavigateNode> navigateNodes : stationMap) {
+            for (NavigateNode navigateNode : navigateNodes) {
+                String nodeType = navigateNode.getNodeType();
+                if(nodeType == null){
+                    continue;
+                }
+                if(!nodeType.equals("devp")){
+                    continue;
+                }
+                JSONObject valuObject = JSON.parseObject(navigateNode.getNodeValue());
+                if(valuObject == null){
+                    continue;
+                }
+                if (valuObject.containsKey("liftNo")) {
+                    liftStationList.add(navigateNode);
+                }
+            }
+        }
+
+        return liftStationList;
+    }
 }

--
Gitblit v1.9.1