From 05f8bdf7e09849c1db885b6c996ad18280d130b3 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期一, 18 十二月 2023 16:18:25 +0800
Subject: [PATCH] #map latest test
---
src/main/java/com/zy/common/utils/NyShuttleOperaUtils.java | 33 +++++++++++++++++++++++++++------
1 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/NyShuttleOperaUtils.java b/src/main/java/com/zy/common/utils/NyShuttleOperaUtils.java
index d7f5d6a..fe9d716 100644
--- a/src/main/java/com/zy/common/utils/NyShuttleOperaUtils.java
+++ b/src/main/java/com/zy/common/utils/NyShuttleOperaUtils.java
@@ -22,7 +22,7 @@
* @param startPoint 璧风偣锛堝皬杞﹀綋鍓嶄綅缃級
* @param targetPoint 鐩爣鐐癸紙璐х墿鐩爣浣嶇疆锛�
*/
- public static NyShuttleOperaResult getShuttleTransportCommands(Integer shuttleNo, Integer wrkNo, String startPoint, String targetPoint) {
+ public static synchronized NyShuttleOperaResult getShuttleTransportCommands(Integer shuttleNo, Integer wrkNo, String startPoint, String targetPoint) {
//琛岃蛋璺緞
ArrayList<NavigateNode> nodes = new ArrayList<>();
//鍛戒护闆嗗悎
@@ -51,7 +51,7 @@
* @param middlePoint 涓棿鐐癸紙璐х墿浣嶇疆锛�
* @param targetPoint 鐩爣鐐癸紙璐х墿鐩爣浣嶇疆锛�
*/
- public static NyShuttleOperaResult getShuttleTransportCommands(Integer shuttleNo, Integer wrkNo, String startPoint, String middlePoint, String targetPoint) {
+ public static synchronized NyShuttleOperaResult getShuttleTransportCommands(Integer shuttleNo, Integer wrkNo, String startPoint, String middlePoint, String targetPoint) {
//琛岃蛋璺緞
ArrayList<NavigateNode> nodes = new ArrayList<>();
//鍛戒护闆嗗悎
@@ -86,7 +86,7 @@
/**
* 鑾峰彇璧风偣鍒扮洰鏍囩偣琛岃蛋鍛戒护
*/
- public static NyShuttleOperaResult getStartToTargetCommands(Integer shuttleNo, Integer wrkNo, String startPoint, String targetPoint, Integer mapType) {
+ public static synchronized NyShuttleOperaResult getStartToTargetCommands(Integer shuttleNo, Integer wrkNo, String startPoint, String targetPoint, Integer mapType) {
NavigateMapUtils navigateMapUtils = SpringUtils.getBean(NavigateMapUtils.class);
//璁$畻璧风偣鍒扮洰鏍囩偣琛岃蛋鑺傜偣
List<NavigateNode> calc = NavigateUtils.calc(startPoint, targetPoint, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startPoint)), null);
@@ -114,14 +114,17 @@
allNode.addAll(nodes);
}
- navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(startPoint), allNode, true);//閿佸畾璺緞
+ boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(startPoint), allNode, true);//閿佸畾璺緞
+ if (!result) {
+ return null;//璺緞閿佸畾澶辫触
+ }
return result(commands, calc);
}
/**
* 鑾峰彇璧风偣鍒扮洰鏍囩偣琛岃蛋鍛戒护(鍙紶鐧藉悕鍗�)
*/
- public static NyShuttleOperaResult getStartToTargetCommandsByWhites(Integer shuttleNo, Integer wrkNo, String startPoint, String targetPoint, Integer mapType, List<int[]> whites) {
+ public static synchronized NyShuttleOperaResult getStartToTargetCommandsByWhites(Integer shuttleNo, Integer wrkNo, String startPoint, String targetPoint, Integer mapType, List<int[]> whites) {
NavigateMapUtils navigateMapUtils = SpringUtils.getBean(NavigateMapUtils.class);
//璁$畻璧风偣鍒扮洰鏍囩偣琛岃蛋鑺傜偣
List<NavigateNode> calc = NavigateUtils.calc(startPoint, targetPoint, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startPoint)), whites);
@@ -149,7 +152,25 @@
allNode.addAll(nodes);
}
- navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(startPoint), allNode, true);//閿佸畾璺緞
+ //閿佸畾璺緞鏃跺墧闄ょ櫧鍚嶅崟鑺傜偣
+ ArrayList<NavigateNode> nodes = new ArrayList<>();
+ for (NavigateNode node : allNode) {
+ boolean flag = false;
+ for (int[] white : whites) {
+ if (node.getX() == white[0] && node.getY() == white[1]) {
+ flag = true;//瀛樺湪鐧藉悕鍗曡妭鐐�
+ break;//璺宠繃鐧藉悕鍗曡妭鐐�
+ }
+ }
+
+ if (!flag) {
+ nodes.add(node);
+ }
+ }
+ boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(startPoint), nodes, true);//閿佸畾璺緞
+ if (!result) {
+ return null;//璺緞閿佸畾澶辫触
+ }
return result(commands, calc);
}
--
Gitblit v1.9.1