From c97e67b2b569bf9845acbe6a088b7a2b0f8d6a11 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期二, 05 八月 2025 09:22:15 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/action/ShuttleAction.java | 79 ++++++++++++++++++++++++++++++---------
1 files changed, 61 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/zy/core/action/ShuttleAction.java b/src/main/java/com/zy/core/action/ShuttleAction.java
index d25b6cb..55bba24 100644
--- a/src/main/java/com/zy/core/action/ShuttleAction.java
+++ b/src/main/java/com/zy/core/action/ShuttleAction.java
@@ -22,6 +22,7 @@
import com.zy.core.dispatcher.ShuttleDispatchUtils;
import com.zy.core.enums.*;
import com.zy.core.model.CommandResponse;
+import com.zy.core.model.TrafficControlDataModel;
import com.zy.core.model.command.ShuttleAssignCommand;
import com.zy.core.model.command.ShuttleCommand;
import com.zy.core.model.command.ShuttleRedisCommand;
@@ -86,7 +87,7 @@
return false;
}
- public synchronized boolean executeWork(Integer shuttleNo, Integer taskNo) {
+ public boolean executeWork(Integer shuttleNo, Integer taskNo) {
Object obj = redisUtil.get(RedisKeyType.SHUTTLE_WORK_FLAG.key + taskNo);
if (obj == null) {
return false;
@@ -118,8 +119,10 @@
return false;
}
+ News.info("execute check command {},{}", shuttleNo, taskNo);
//妫�娴嬪懡浠�
int checked = checkCommand(redisCommand, shuttleNo);
+ News.info("execute check command complete {},{}", shuttleNo, taskNo);
if (checked == 0) {
return false;
}
@@ -164,8 +167,20 @@
}
List<NavigateNode> nodes = JSON.parseArray(JSON.toJSONString(command.getNodes()), NavigateNode.class);
- //鐢宠绠″埗
- boolean apply = applyTrafficControl(commands, nodes, shuttleNo, taskNo);
+
+ Object object = redisUtil.get(RedisKeyType.TRAFFIC_CONTROL_LOCK_APPLY.key + shuttleNo);
+ if (object == null) {
+ //鐢宠绠″埗
+ News.info("execute apply control {},{}", shuttleNo, taskNo);
+ redisUtil.set(RedisKeyType.TRAFFIC_CONTROL_LOCK_APPLY.key + shuttleNo, "lock", 10);
+ applyTrafficControl(commands, nodes, shuttleNo, taskNo);
+ News.info("execute apply control complete {},{}", shuttleNo, taskNo);
+ }
+
+ News.info("execute query control {},{}", shuttleNo, taskNo);
+ //鏌ヨ绠″埗
+ boolean apply = queryTrafficControl(shuttleNo, taskNo);
+ News.info("execute query control complete {},{}", shuttleNo, taskNo);
if(!apply){
return false;//鐢宠澶辫触
}
@@ -188,8 +203,10 @@
}
}
+ News.info("execute send command {},{}", shuttleNo, taskNo);
// 涓嬪彂鍛戒护
CommandResponse response = write(command, shuttleNo);
+ News.info("execute send command complete {},{}", shuttleNo, taskNo);
//淇濆瓨鍛戒护鏃ュ織
BasShuttleOpt basShuttleOpt = new BasShuttleOpt();
@@ -294,21 +311,23 @@
//鐩寸嚎娈垫暟鎹爣璇�
Long linePartFlag = startNode.getLinePartFlag();
- //鍙栨寚浠�
- ShuttleCommand currentCommand = commands.get(commandStep);
- if(currentCommand.getMode() != ShuttleCommandModeType.MOVE.id) {
- return 0;
- }
+ if(commandStep < commands.size()){
+ //鍙栨寚浠�
+ ShuttleCommand currentCommand = commands.get(commandStep);
+ if(currentCommand.getMode() != ShuttleCommandModeType.MOVE.id) {
+ return 0;
+ }
- List<NavigateNode> currentNodes = currentCommand.getNodes();
- NavigateNode currentStartNode = currentNodes.get(0);
- if(!currentStartNode.getLinePartAllowGo()) {//鐩寸嚎娈甸儴鍒嗭紝鍏佽鐩存帴琛岃蛋
- return 0;
- }
+ List<NavigateNode> currentNodes = currentCommand.getNodes();
+ NavigateNode currentStartNode = currentNodes.get(0);
+ if(!currentStartNode.getLinePartAllowGo()) {//鐩寸嚎娈甸儴鍒嗭紝鍏佽鐩存帴琛岃蛋
+ return 0;
+ }
- if(currentStartNode.getLinePartFlag().equals(linePartFlag)) {
- //鏁版嵁鏍囪瘑涓�鑷�
- return 2;//鍏佽灏忚溅绉诲姩杩炵画涓嬪彂鎸囦护
+ if(currentStartNode.getLinePartFlag().equals(linePartFlag)) {
+ //鏁版嵁鏍囪瘑涓�鑷�
+ return 2;//鍏佽灏忚溅绉诲姩杩炵画涓嬪彂鎸囦护
+ }
}
}
@@ -343,7 +362,8 @@
}
//鐢宠鍙栨秷绠″埗
- trafficControlThread.cancelTrafficControl(shuttleNo, shuttleProtocol.getTaskNo());
+ cancelTrafficControl(shuttleNo, shuttleProtocol.getTaskNo());
+
//鍒犻櫎redis
redisUtil.del(RedisKeyType.SHUTTLE_WORK_FLAG.key + redisCommand.getWrkNo());
return 0;//绂佹鍐嶄笅鍙戝懡浠�
@@ -410,7 +430,9 @@
return false;
}
//涓婃姤浜ょ
+ News.info("execute check command report traffic {},{}", shuttleNo, shuttleProtocol.getTaskNo());
trafficControlThread.trafficReport(command.getNodesDeepCopy(), shuttleNo, shuttleProtocol.getTaskNo());
+ News.info("execute check command report traffic complete {},{}", shuttleNo, shuttleProtocol.getTaskNo());
String currentLocNo = shuttleProtocol.getCurrentLocNo();
if (currentLocNo == null) {
@@ -488,6 +510,23 @@
}
}
return trafficControlThread.applyTrafficControl(totalNodeList, nodeList, shuttleNo, taskNo);
+ }
+
+ //鏌ヨ鏄惁鐢宠绠″埗鎴愬姛
+ public boolean queryTrafficControl(Integer shuttleNo, Integer taskNo) {
+ Object object = redisUtil.get(RedisKeyType.TRAFFIC_CONTROL_SUCCESS_APPLY.key + shuttleNo + "_" + taskNo);
+ if (object == null) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean cancelTrafficControl(Integer shuttleNo, Integer taskNo) {
+ TrafficControlDataModel model = new TrafficControlDataModel();
+ model.setShuttleNo(shuttleNo);
+ model.setTaskNo(taskNo);
+ redisUtil.set(RedisKeyType.TRAFFIC_CONTROL_CANCEL_LIST.key + shuttleNo + "_" + taskNo, model);
+ return true;
}
// /**
@@ -746,6 +785,10 @@
} catch (Exception e) {
e.printStackTrace();
}
+ }
+
+ public synchronized boolean clearPath(Integer shuttleNo) {
+ return navigateMapUtils.clearPath(shuttleNo);
}
// //璺戝簱绋嬪簭
@@ -1117,7 +1160,7 @@
// }
// }
- private synchronized CommandResponse write(ShuttleCommand command, Integer shuttleNo) {
+ private CommandResponse write(ShuttleCommand command, Integer shuttleNo) {
CommandResponse response = new CommandResponse(false);
if (null == command) {
News.error("鍥涘悜绌挎杞﹀啓鍏ュ懡浠や负绌�");
--
Gitblit v1.9.1