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

---
 src/main/java/com/zy/core/utils/StationOperateProcessUtils.java |   72 ++++++++++++++++++++++++++++++++++--
 1 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index 4ec5e35..a053d49 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -523,9 +523,17 @@
                                 continue;
                             }
 
-                            StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), moveStaNo, 0);
+                            StationCommand command = stationThread.getRunBlockRerouteCommand(
+                                    wrkMast.getWrkNo(),
+                                    stationProtocol.getStationId(),
+                                    moveStaNo,
+                                    0
+                            );
                             if (command == null) {
-                                News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+                                News.taskInfo(wrkMast.getWrkNo(),
+                                        "杈撻�佺珯鐐瑰牭濉為噸瑙勫垝鏈壘鍒板彲涓嬪彂璺嚎锛屽綋鍓嶇珯鐐�={}锛岀洰鏍囩珯鐐�={}",
+                                        stationProtocol.getStationId(),
+                                        moveStaNo);
                                 continue;
                             }
 
@@ -786,6 +794,9 @@
                     && currentBatchSeq.equals(wrkMast.getBatchSeq());
         }
         if (toTarget) {
+            if (!hasReachableOutReleaseSlot(currentStationId, wrkMast.getStaNo())) {
+                return null;
+            }
             return new OutOrderDispatchDecision(wrkMast.getStaNo(), false);
         }
 
@@ -847,8 +858,8 @@
 
         try {
             List<NavigateNode> nodes = navigateUtils.calcByStationId(currentStationId, finalTargetStationId);
-            for (int i = nodes.size() - 1; i >= 0; i--) {
-                Integer stationId = getStationIdFromNode(nodes.get(i));
+            for (NavigateNode node : nodes) {
+                Integer stationId = getStationIdFromNode(node);
                 if (stationId == null) {
                     continue;
                 }
@@ -863,6 +874,59 @@
         return finalTargetStationId;
     }
 
+    private boolean hasReachableOutReleaseSlot(Integer currentStationId,
+                                               Integer finalTargetStationId) {
+        if (currentStationId == null || finalTargetStationId == null) {
+            return true;
+        }
+
+        try {
+            List<NavigateNode> nodes = navigateUtils.calcByStationId(currentStationId, finalTargetStationId);
+            if (nodes == null || nodes.isEmpty()) {
+                return true;
+            }
+
+            for (NavigateNode node : nodes) {
+                Integer stationId = getStationIdFromNode(node);
+                if (stationId == null || Objects.equals(stationId, currentStationId)) {
+                    continue;
+                }
+
+                if (!isPathStationBlocked(stationId)) {
+                    return true;
+                }
+            }
+            return false;
+        } catch (Exception ignore) {
+            return true;
+        }
+    }
+
+    private boolean isPathStationBlocked(Integer stationId) {
+        if (stationId == null) {
+            return true;
+        }
+
+        BasStation basStation = basStationService.getOne(new QueryWrapper<BasStation>().eq("station_id", stationId));
+        if (basStation == null) {
+            return true;
+        }
+
+        StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo());
+        if (stationThread == null) {
+            return true;
+        }
+
+        StationProtocol stationProtocol = stationThread.getStatusMap().get(stationId);
+        if (stationProtocol == null) {
+            return true;
+        }
+
+        return !stationProtocol.isAutoing()
+                || stationProtocol.isLoading()
+                || (stationProtocol.getTaskNo() != null && stationProtocol.getTaskNo() > 0);
+    }
+
     private Integer resolveNextCircleOrderTarget(Integer currentStationId, List<Integer> orderedOutStationList) {
         if (currentStationId == null || orderedOutStationList == null || orderedOutStationList.size() <= 1) {
             return null;

--
Gitblit v1.9.1