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