From 12633568e27fcb9046367d6db981e2b4d1462cc7 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 21 三月 2026 14:36:53 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java |   50 +++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java b/src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java
index d5497fe..af286c8 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java
@@ -339,7 +339,9 @@
             segCmd.setCommandType(original.getCommandType());
             segCmd.setPalletSize(original.getPalletSize());
             segCmd.setNavigatePath(new ArrayList<>(path.subList(0, currentEndIdx + 1)));
-            sendCommand(segCmd);
+            if (!sendSegmentWithRetry(segCmd, original.getTaskNo())) {
+                return;
+            }
 
             long runTime = System.currentTimeMillis();
             boolean firstRun = true;
@@ -390,18 +392,8 @@
                         nextCmd.setPalletSize(original.getPalletSize());
                         nextCmd.setNavigatePath(new ArrayList<>(path.subList(currentStartIdx, currentEndIdx + 1)));
                         nextCmd.setOriginalNavigatePath(path);
-                        while (true) {
-                            CommandResponse commandResponse = sendCommand(nextCmd);
-                            if (commandResponse == null) {
-                                Thread.sleep(200);
-                                continue;
-                            }
-
-                            if (commandResponse.getResult()) {
-                                break;
-                            }
-
-                            Thread.sleep(200);
+                        if (!sendSegmentWithRetry(nextCmd, original.getTaskNo())) {
+                            break;
                         }
                     }
                     Thread.sleep(500);
@@ -443,4 +435,36 @@
         }
         return null;
     }
+
+    private boolean sendSegmentWithRetry(StationCommand command, Integer taskNo) {
+        while (true) {
+            if (isTaskMoveReset(taskNo)) {
+                return false;
+            }
+            CommandResponse commandResponse = sendCommand(command);
+            if (commandResponse == null) {
+                sleepQuietly(200L);
+                continue;
+            }
+            if (commandResponse.getResult()) {
+                return true;
+            }
+            sleepQuietly(200L);
+        }
+    }
+
+    private boolean isTaskMoveReset(Integer taskNo) {
+        if (taskNo == null || redisUtil == null) {
+            return false;
+        }
+        Object cancel = redisUtil.get(RedisKeyType.DEVICE_STATION_MOVE_RESET.key + taskNo);
+        return cancel != null;
+    }
+
+    private void sleepQuietly(long millis) {
+        try {
+            Thread.sleep(millis);
+        } catch (Exception ignore) {
+        }
+    }
 }

--
Gitblit v1.9.1