From c029b6ac3f04ea38e5df52a0ad6ddfa1f5b614b4 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 10 四月 2025 18:29:22 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/utils/ShuttleOperaUtils.java | 153 +++++++++++++++++++++++++++++++++-----------------
1 files changed, 101 insertions(+), 52 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java b/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
index d7a6adc..9451d91 100644
--- a/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
+++ b/src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
@@ -44,9 +44,93 @@
Integer shuttleNo = shuttleProtocol.getShuttleNo();
//鑾峰彇灏忚溅绉诲姩閫熷害
Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000);
+ List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), whites);
+ if (nodeList == null) {
+ News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo);
+ shuttleThread.offerSystemMsg("{} dash {} can't find navigate path!", startLocNo, endLocNo);
+ return null;
+ }
+
+ List<NavigateNode> allNode = new ArrayList<>();
+ List<NavigateNode> lockNode = new ArrayList<>();
+ for (NavigateNode node : nodeList) {
+ allNode.add(node.clone());
+
+ if (whites != null) {
+ boolean flag = false;
+ for (int[] white : whites) {
+ if(white[0] == node.getX() && white[1] == node.getY()) {
+ flag = true;
+ break;
+ }
+ }
+
+ if (flag) {//鐧藉悕鍗曡烦杩囬攣瀹�
+ continue;
+ }
+ }
+ lockNode.add(node.clone());
+ }
+
+ List<ShuttleCommand> commands = new ArrayList<>();
+ //鑾峰彇鍒嗘璺緞
+ ArrayList<ArrayList<NavigateNode>> data = navigateUtils.getSectionPath(nodeList);
+ //灏嗘瘡涓�娈佃矾寰勫垎鎴恈ommand鎸囦护
+ for (ArrayList<NavigateNode> nodes : data) {
+ //寮�濮嬭矾寰�
+ NavigateNode startPath = nodes.get(0);
+
+ //鐩爣璺緞
+ NavigateNode endPath = nodes.get(nodes.size() - 1);
+ Integer allDistance = navigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
+ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
+ String startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ());
+ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
+ String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ());
+ //鑾峰彇绉诲姩鍛戒护
+ ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes);
+ command.setNodes(nodes);//灏嗚璧拌妭鐐规坊鍔犲埌姣忎竴姝ュ懡浠や腑
+ commands.add(command);
+ }
+
+ assignCommand.setNodes(allNode);//褰撳墠浠诲姟鎵�鍗犵敤鐨勮妭鐐筶ist
+
+ boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(startLocNo), shuttleNo, lockNode, true);//閿佸畾璺緞
+ if (!result) {
+ News.error("{} dash {} can't lock path!", startLocNo, endLocNo);
+ shuttleThread.offerSystemMsg("{} dash {} can't lock path!", startLocNo, endLocNo);
+ return null;//璺緞閿佸畾澶辫触
+ }
+ return commands;
+ }
+
+ public synchronized List<ShuttleCommand> shuttleInOutLiftCommand(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
+ NavigateNode startNode = NavigatePositionConvert.locNoToNode(startLocNo);
+ NavigateNode endNode = NavigatePositionConvert.locNoToNode(endLocNo);
+ List<NavigateNode> unlockPath = new ArrayList<>();
+ unlockPath.add(startNode);
+ unlockPath.add(endNode);
+
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+ if (shuttleProtocol == null) {
+ return null;
+ }
+
+ Integer shuttleNo = shuttleProtocol.getShuttleNo();
+ //鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹�/瑙i攣
+ boolean lockResult = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(endLocNo), shuttleProtocol.getShuttleNo(), unlockPath, false);//鎵�浣跨敤鐨勮矾寰勮繘琛岃В閿�
+ if (!lockResult) {
+ News.error("{} dash {} can't find unlock path!", startLocNo, endLocNo);
+ shuttleThread.offerSystemMsg("{} dash {} can't find unlock path!", startLocNo, endLocNo);
+ return null;//瑙i攣澶辫触
+ }
+
+ //鑾峰彇灏忚溅绉诲姩閫熷害
+ Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000);
List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), null);
if (nodeList == null) {
News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo);
+ shuttleThread.offerSystemMsg("{} dash {} can't find navigate path!", startLocNo, endLocNo);
return null;
}
@@ -81,62 +165,27 @@
return commands;
}
- public synchronized List<ShuttleCommand> shuttleInOutLiftCommand(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
- NavigateNode startNode = NavigatePositionConvert.locNoToNode(startLocNo);
- NavigateNode endNode = NavigatePositionConvert.locNoToNode(endLocNo);
- List<NavigateNode> unlockPath = new ArrayList<>();
- unlockPath.add(startNode);
- unlockPath.add(endNode);
-
- ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
- if (shuttleProtocol == null) {
- return null;
- }
-
- Integer shuttleNo = shuttleProtocol.getShuttleNo();
- //鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹�/瑙i攣
- boolean lockResult = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(endLocNo), shuttleProtocol.getShuttleNo(), unlockPath, false);//鎵�浣跨敤鐨勮矾寰勮繘琛岃В閿�
- if (!lockResult) {
- News.error("{} dash {} can't find unlock path!", startLocNo, endLocNo);
- return null;//瑙i攣澶辫触
- }
-
- //鑾峰彇灏忚溅绉诲姩閫熷害
- Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000);
- List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), null);
- if (nodeList == null) {
- News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo);
- return null;
- }
-
- List<NavigateNode> allNode = new ArrayList<>();
- for (NavigateNode node : nodeList) {
- allNode.add(node.clone());
- }
-
+ /**
+ * 鑾峰彇鍏呯數鍛戒护
+ */
+ public synchronized List<ShuttleCommand> getShuttleChargeCommand(ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread, Boolean openCharge) {
List<ShuttleCommand> commands = new ArrayList<>();
- //鑾峰彇鍒嗘璺緞
- ArrayList<ArrayList<NavigateNode>> data = navigateUtils.getSectionPath(nodeList);
- //灏嗘瘡涓�娈佃矾寰勫垎鎴恈ommand鎸囦护
- for (ArrayList<NavigateNode> nodes : data) {
- //寮�濮嬭矾寰�
- NavigateNode startPath = nodes.get(0);
- //鐩爣璺緞
- NavigateNode endPath = nodes.get(nodes.size() - 1);
- Integer allDistance = navigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
- //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
- String startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ());
- //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
- String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ());
- //鑾峰彇绉诲姩鍛戒护
- ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes);
- command.setNodes(nodes);//灏嗚璧拌妭鐐规坊鍔犲埌姣忎竴姝ュ懡浠や腑
- commands.add(command);
- }
+ //鑾峰彇鍏呯數鍛戒护
+ ShuttleCommand command = shuttleThread.getChargeCommand(assignCommand.getDeviceTaskNo(), openCharge);
+ commands.add(command);
+ return commands;
+ }
- assignCommand.setNodes(allNode);//褰撳墠浠诲姟鎵�鍗犵敤鐨勮妭鐐筶ist
+ /**
+ * 鑾峰彇椤跺崌鍛戒护
+ */
+ public synchronized List<ShuttleCommand> getShuttleLiftCommand(ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread, Boolean lift) {
+ List<ShuttleCommand> commands = new ArrayList<>();
+ //鑾峰彇椤跺崌鍛戒护
+ ShuttleCommand command = shuttleThread.getLiftCommand(assignCommand.getDeviceTaskNo(), lift);
+ commands.add(command);
return commands;
}
--
Gitblit v1.9.1