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

---
 src/main/java/com/zy/core/action/ShuttleAction.java |   41 +++++++++++++++++++++++++++++++----------
 1 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/zy/core/action/ShuttleAction.java b/src/main/java/com/zy/core/action/ShuttleAction.java
index a0a88b1..2486dd8 100644
--- a/src/main/java/com/zy/core/action/ShuttleAction.java
+++ b/src/main/java/com/zy/core/action/ShuttleAction.java
@@ -119,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;
         }
@@ -165,10 +167,20 @@
             }
 
             List<NavigateNode> nodes = JSON.parseArray(JSON.toJSONString(command.getNodes()), NavigateNode.class);
-            //鐢宠绠″埗
-            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;//鐢宠澶辫触
             }
@@ -348,7 +360,8 @@
             }
 
             //鐢宠鍙栨秷绠″埗
-            trafficControlThread.cancelTrafficControl(shuttleNo, shuttleProtocol.getTaskNo());
+            cancelTrafficControl(shuttleNo, shuttleProtocol.getTaskNo());
+
             //鍒犻櫎redis
             redisUtil.del(RedisKeyType.SHUTTLE_WORK_FLAG.key + redisCommand.getWrkNo());
             return 0;//绂佹鍐嶄笅鍙戝懡浠�
@@ -415,7 +428,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) {
@@ -497,16 +512,18 @@
 
     //鏌ヨ鏄惁鐢宠绠″埗鎴愬姛
     public boolean queryTrafficControl(Integer shuttleNo, Integer taskNo) {
-        TrafficControlThread trafficControlThread = (TrafficControlThread) SlaveConnection.get(SlaveType.TrafficControl, 1);
-        if (trafficControlThread == null) {
+        Object object = redisUtil.get(RedisKeyType.TRAFFIC_CONTROL_SUCCESS_APPLY.key + shuttleNo + "_" + taskNo);
+        if (object == null) {
             return false;
         }
+        return true;
+    }
 
-        TrafficControlDataModel trafficControlDataModel = trafficControlThread.queryTrafficControl(shuttleNo, taskNo);
-        if (trafficControlDataModel == null) {
-            return false;
-        }
-
+    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;
     }
 
@@ -768,6 +785,10 @@
         }
     }
 
+    public synchronized boolean clearPath(Integer shuttleNo) {
+        return navigateMapUtils.clearPath(shuttleNo);
+    }
+
 //    //璺戝簱绋嬪簭
 //    public synchronized void moveLoc(Integer shuttleNo) {
 //        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);

--
Gitblit v1.9.1