From fa82f80cc61e149224f12cae5fde31d45e1319f7 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 03 三月 2026 16:50:06 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/utils/NavigateSolution.java | 66 +++++++++++++++++++++++++++++---
1 files changed, 59 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/NavigateSolution.java b/src/main/java/com/zy/common/utils/NavigateSolution.java
index e2d429f..e2112fc 100644
--- a/src/main/java/com/zy/common/utils/NavigateSolution.java
+++ b/src/main/java/com/zy/common/utils/NavigateSolution.java
@@ -41,21 +41,38 @@
JSONObject map = row.get(j);
NavigateNode navigateNode = new NavigateNode(i, j);
+ String mergeType = map.getString("mergeType");
String nodeType = map.getString("type");
+ String nodeValue = map.getString("value");
if(nodeType == null) {
navigateNode.setValue(MapNodeType.DISABLE.id);
- }else if(nodeType.equals("devp") || nodeType.equals("merge")){
+ }else if(nodeType.equals("devp") || (nodeType.equals("merge") && mergeType.equals("devp"))) {
navigateNode.setValue(MapNodeType.NORMAL_PATH.id);
JSONObject valueObj = JSON.parseObject(map.getString("value"));
List<String> directionList = valueObj.getJSONArray("direction").toJavaList(String.class);
navigateNode.setDirectionList(directionList);
- }else {
+ } else if (nodeType.equals("rgv")) {
+ navigateNode.setValue(MapNodeType.NORMAL_PATH.id);
+ JSONObject valueObj = JSON.parseObject(map.getString("value"));
+
+ JSONObject newNodeValue = new JSONObject();
+ newNodeValue.put("rgvCalcFlag", 1);
+ nodeValue = JSON.toJSONString(newNodeValue);
+
+ //RGV鏆備笉鎺у埗琛岃蛋鏂瑰悜锛岄粯璁や笂涓嬪乏鍙抽兘鍙蛋
+ List<String> directionList = new ArrayList<>();
+ directionList.add("top");
+ directionList.add("bottom");
+ directionList.add("left");
+ directionList.add("right");
+ navigateNode.setDirectionList(directionList);
+ } else {
navigateNode.setValue(MapNodeType.DISABLE.id);
}
navigateNode.setNodeType(nodeType);
- navigateNode.setNodeValue(map.getString("value"));
+ navigateNode.setNodeValue(nodeValue);
navigateNodeRow.add(navigateNode);
}
navigateNodeList.add(navigateNodeRow);
@@ -285,22 +302,22 @@
for(String direction : directionList) {
if(direction.equals("top")) {
- NavigateNode node = getValidNavigateNode(map, x - 1, y);
+ NavigateNode node = getValidNavigateNode(map, current_node, x - 1, y, direction);
if(node != null) {
neighbour_node.add(node);
}
}else if(direction.equals("bottom")) {
- NavigateNode node = getValidNavigateNode(map, x + 1, y);
+ NavigateNode node = getValidNavigateNode(map, current_node, x + 1, y, direction);
if(node != null) {
neighbour_node.add(node);
}
}else if(direction.equals("left")) {
- NavigateNode node = getValidNavigateNode(map, x, y - 1);
+ NavigateNode node = getValidNavigateNode(map, current_node, x, y - 1, direction);
if(node != null) {
neighbour_node.add(node);
}
}else if(direction.equals("right")) {
- NavigateNode node = getValidNavigateNode(map, x, y + 1);
+ NavigateNode node = getValidNavigateNode(map, current_node, x, y + 1, direction);
if(node != null) {
neighbour_node.add(node);
}
@@ -308,6 +325,22 @@
}
return neighbour_node;
+ }
+
+ /**
+ * 閭绘帴鐐规牎楠岋細鍙揪 + 鏂瑰悜涓�鑷达紙褰撳墠鑺傜偣涓庝笅涓�鑺傜偣瀵规湰娆¤璧版柟鍚戜竴鑷达級
+ */
+ public NavigateNode getValidNavigateNode(List<List<NavigateNode>> map, NavigateNode currentNode, int x, int y, String moveDirection) {
+ NavigateNode node = getValidNavigateNode(map, x, y);
+ if (node == null) {
+ return null;
+ }
+
+ if (!isDirectionConsistent(currentNode, node, moveDirection)) {
+ return null;
+ }
+
+ return node;
}
public NavigateNode getValidNavigateNode(List<List<NavigateNode>> map, int x, int y) {
@@ -324,6 +357,25 @@
return node;
}
+ private boolean isDirectionConsistent(NavigateNode currentNode, NavigateNode nextNode, String moveDirection) {
+ if (currentNode == null || nextNode == null) {
+ return false;
+ }
+
+ if (moveDirection == null) {
+ return false;
+ }
+
+ List<String> currentDirectionList = currentNode.getDirectionList();
+ List<String> nextDirectionList = nextNode.getDirectionList();
+ if (currentDirectionList == null || nextDirectionList == null) {
+ return false;
+ }
+
+ // 褰撳墠鑺傜偣鍏佽鍚� moveDirection 鍑哄彂锛屼笖涓嬩竴鑺傜偣鍦ㄨ鏂瑰悜涓婁繚鎸佷竴鑷达紝鎵嶅厑璁搁�氳
+ return currentDirectionList.contains(moveDirection) && nextDirectionList.contains(moveDirection);
+ }
+
public NavigateNode findStationNavigateNode(List<List<NavigateNode>> map, int stationId) {
for(int x = 0; x < map.size(); x++) {
for(int y = 0; y < map.get(0).size(); y++) {
--
Gitblit v1.9.1