From 61eeab28ca6b4c16508953efd7e613ee9dea823b Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期一, 15 九月 2025 16:27:08 +0800
Subject: [PATCH] 1
---
src/main/java/com/zy/common/utils/NavigateUtils.java | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/NavigateUtils.java b/src/main/java/com/zy/common/utils/NavigateUtils.java
index 6528cc3..f2ec05d 100644
--- a/src/main/java/com/zy/common/utils/NavigateUtils.java
+++ b/src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -10,12 +10,16 @@
import com.zy.core.News;
import com.zy.core.enums.MapNodeType;
import com.zy.core.model.PythonSimilarityResult;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.BufferedReader;
import java.io.InputStreamReader;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
/**
* A*绠楁硶浣跨敤宸ュ叿
@@ -25,9 +29,10 @@
@Value("${pythonCalcPath}")
private String pythonCalcPath;
-
@Value("${pythonCalcSimilarity}")
private String pythonCalcSimilarity;
+ @Autowired
+ private NavigateMapData navigateMapData;
public List<NavigateNode> calc(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites) {
return calcJava(startPoint, endPoint, mapType, shuttlePoints, whites);
@@ -46,14 +51,17 @@
//鑾峰彇褰撳墠鑺傜偣璁$畻鐨勫眰楂橈紝骞惰祴鍊煎埌姣忎竴涓妭鐐逛腑
int lev = Utils.getLev(startPoint);
+ NavigateSolution solution = new NavigateSolution(mapType, lev, whiteList, shuttlePoints);
+ int[][] map = solution.map;
//鍒濆鍖栧紑濮嬭妭鐐�
NavigateNode start = new NavigateNode(startArr[0], startArr[1]);
//寮�濮嬭妭鐐规棤鐖惰妭鐐�
start.setFather(null);
+ start.setNodeValue(map[startArr[0]][startArr[1]]);
NavigateNode end = new NavigateNode(endArr[0], endArr[1]);
- NavigateSolution solution = new NavigateSolution(mapType, lev, whiteList, shuttlePoints);
+ end.setNodeValue(map[endArr[0]][endArr[1]]);
//寮�濮嬭妭鐐癸紝涓嶇撼鍏ョ鐢ㄨ妭鐐瑰唴璁$畻
NavigateNode res_node = solution.astarSearchJava(start, end);
@@ -116,14 +124,17 @@
//鑾峰彇褰撳墠鑺傜偣璁$畻鐨勫眰楂橈紝骞惰祴鍊煎埌姣忎竴涓妭鐐逛腑
int lev = Utils.getLev(startPoint);
+ NavigateSolution solution = new NavigateSolution(mapType, lev, whiteList, shuttlePoints);
+ int[][] map = solution.map;
//鍒濆鍖栧紑濮嬭妭鐐�
NavigateNode start = new NavigateNode(startArr[0], startArr[1]);
+ start.setNodeValue(map[startArr[0]][startArr[1]]);
//寮�濮嬭妭鐐规棤鐖惰妭鐐�
start.setFather(null);
NavigateNode end = new NavigateNode(endArr[0], endArr[1]);
- NavigateSolution solution = new NavigateSolution(mapType, lev, whiteList, shuttlePoints);
+ end.setNodeValue(map[endArr[0]][endArr[1]]);
//寮�濮嬭妭鐐癸紝涓嶇撼鍏ョ鐢ㄨ妭鐐瑰唴璁$畻
String pathStr = solution.astarSearchPython(start, end, pythonCalcPath);
@@ -180,7 +191,7 @@
}
//鍒ゆ柇褰撳墠鑺傜偣鍒颁笅涓�涓妭鐐规槸鍚︿负鎷愮偣
- public HashMap<String,Object> searchInflectionPoint(NavigateNode currentNode, NavigateNode fatherNode, NavigateNode nextNode) {
+ public HashMap<String, Object> searchInflectionPoint(NavigateNode currentNode, NavigateNode fatherNode, NavigateNode nextNode) {
HashMap<String, Object> map = new HashMap<>();
map.put("result", false);//鏄惁涓烘嫄鐐癸紝true锛氭嫄鐐癸紝false锛氱洿绾�
// 绗竴涓偣鎴栫洿绾跨偣
@@ -210,7 +221,7 @@
if (currentNode.getX() - fatherNode.getX() > 0) {
//澶т簬0锛屾柟鍚憈op
direction = "top";
- }else {
+ } else {
//灏忎簬0锛屾柟鍚慴ottom
direction = "bottom";
}
@@ -222,7 +233,7 @@
if (currentNode.getY() - fatherNode.getY() > 0) {
//澶т簬0锛屾柟鍚憀eft
direction = "left";
- }else {
+ } else {
//灏忎簬0锛屾柟鍚憆ight
direction = "right";
}
@@ -346,8 +357,7 @@
* 妫�娴嬭矾寰勬槸鍚﹀彲鐢�(鍙蛋)
*/
public boolean checkPathIsAvailable(List<NavigateNode> path, Integer shuttleNo, Integer lev) {
- NavigateSolution solution = new NavigateSolution(NavigationMapType.DFX.id, lev, null, Utils.getShuttlePoints(shuttleNo, lev));//鑾峰彇鏃犵櫧鍚嶅崟鍦板浘(璇ュ湴鍥惧寘鍚皬杞﹀潗鏍�)
- int[][] map = solution.map;
+ int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.DFX.id, null, Utils.getShuttlePoints(shuttleNo, lev));
for (NavigateNode node : path) {
int value = map[node.getX()][node.getY()];
if (value != MapNodeType.NORMAL_PATH.id && value != MapNodeType.MAIN_PATH.id && value != MapNodeType.CHARGE.id && value != MapNodeType.CONVEYOR_CAR_GO.id) {//姣嶈建閬�3銆佸瓙杞ㄩ亾0銆佸厖鐢垫々5銆佸皬杞﹀彲璧拌緭閫佺珯
--
Gitblit v1.9.1