From 728ad81fa10d2879654c5f9ae4314db94eafb865 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 01 八月 2025 08:08:18 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/action/ShuttleAction.java |   50 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 35 insertions(+), 15 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..a0a88b1 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;
@@ -165,7 +166,9 @@
 
             List<NavigateNode> nodes = JSON.parseArray(JSON.toJSONString(command.getNodes()), NavigateNode.class);
             //鐢宠绠″埗
-            boolean apply = applyTrafficControl(commands, nodes, shuttleNo, taskNo);
+            applyTrafficControl(commands, nodes, shuttleNo, taskNo);
+            //鏌ヨ绠″埗
+            boolean apply = queryTrafficControl(shuttleNo, taskNo);
             if(!apply){
                 return false;//鐢宠澶辫触
             }
@@ -294,21 +297,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;//鍏佽灏忚溅绉诲姩杩炵画涓嬪彂鎸囦护
+                        }
                     }
                 }
 
@@ -490,6 +495,21 @@
         return trafficControlThread.applyTrafficControl(totalNodeList, nodeList, shuttleNo, taskNo);
     }
 
+    //鏌ヨ鏄惁鐢宠绠″埗鎴愬姛
+    public boolean queryTrafficControl(Integer shuttleNo, Integer taskNo) {
+        TrafficControlThread trafficControlThread = (TrafficControlThread) SlaveConnection.get(SlaveType.TrafficControl, 1);
+        if (trafficControlThread == null) {
+            return false;
+        }
+
+        TrafficControlDataModel trafficControlDataModel = trafficControlThread.queryTrafficControl(shuttleNo, taskNo);
+        if (trafficControlDataModel == null) {
+            return false;
+        }
+
+        return true;
+    }
+
 //    /**
 //     * 鎼滅储灏忚溅璺緞鏄惁瀛樺湪鍐茬獊
 //     * 0:鏈娴� 1:妫�娴嬫棤鍐茬獊 2:妫�娴嬫湁鍐茬獊

--
Gitblit v1.9.1