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

---
 src/main/java/com/zy/core/utils/StationOperateProcessUtils.java |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 58 insertions(+), 2 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..eb1a6a7 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -786,6 +786,9 @@
                     && currentBatchSeq.equals(wrkMast.getBatchSeq());
         }
         if (toTarget) {
+            if (!hasReachableOutReleaseSlot(currentStationId, wrkMast.getStaNo())) {
+                return null;
+            }
             return new OutOrderDispatchDecision(wrkMast.getStaNo(), false);
         }
 
@@ -847,8 +850,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 +866,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