From d16c9af7bb89a7e3abb4071003c63b3a6f6b9e4b Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 07 四月 2026 14:45:27 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/utils/station/StationOutboundDispatchProcessor.java |  123 ++++++++++++++++++-----------------------
 1 files changed, 54 insertions(+), 69 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/station/StationOutboundDispatchProcessor.java b/src/main/java/com/zy/core/utils/station/StationOutboundDispatchProcessor.java
index b86e1f5..c736296 100644
--- a/src/main/java/com/zy/core/utils/station/StationOutboundDispatchProcessor.java
+++ b/src/main/java/com/zy/core/utils/station/StationOutboundDispatchProcessor.java
@@ -72,19 +72,6 @@
     @Value("${station.outbound.recent-dispatch-protect-seconds:60}")
     private long recentDispatchProtectSeconds;
 
-    public void crnStationOutExecute() {
-        try {
-            List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>()
-                    .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
-                    .isNotNull("crn_no"));
-            for (WrkMast wrkMast : wrkMasts) {
-                crnStationOutExecute(wrkMast);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
     public void crnStationOutExecute(WrkMast wrkMast) {
         try {
             if (wrkMast == null || wrkMast.getWrkNo() == null) {
@@ -249,69 +236,67 @@
         }
     }
 
-    public void dualCrnStationOutExecute() {
+    public void dualCrnStationOutExecute(WrkMast wrkMast) {
         try {
-            List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>()
-                    .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
-                    .isNotNull("dual_crn_no"));
-            for (WrkMast wrkMast : wrkMasts) {
-                if (hasPendingDispatch(wrkMast.getWrkNo())) {
-                    continue;
-                }
-                StationObjModel stationObjModel = getOutboundSourceStation(wrkMast);
-                if (stationObjModel == null || stationObjModel.getDeviceNo() == null || stationObjModel.getStationId() == null) {
-                    continue;
-                }
-                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
-                if (stationThread == null) {
-                    continue;
+            if (wrkMast == null || wrkMast.getWrkNo() == null) {
+                return;
+            }
+            if (hasPendingDispatch(wrkMast.getWrkNo())) {
+                return;
+            }
+            StationObjModel stationObjModel = getOutboundSourceStation(wrkMast);
+            if (stationObjModel == null || stationObjModel.getDeviceNo() == null || stationObjModel.getStationId() == null) {
+                return;
+            }
+            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
+            if (stationThread == null) {
+                return;
+            }
+
+            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
+            StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
+            if (stationProtocol == null) {
+                return;
+            }
+
+            Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
+            if (lock != null) {
+                return;
+            }
+
+            if (stationProtocol.isAutoing()
+                    && stationProtocol.isLoading()
+                    && stationProtocol.getTaskNo() == 0) {
+                Double pathLenFactor = stationOutboundDecisionSupport.resolveOutboundPathLenFactor(wrkMast);
+                StationCommand command = stationOutboundDecisionSupport.buildOutboundMoveCommand(
+                        stationThread,
+                        wrkMast,
+                        stationProtocol.getStationId(),
+                        wrkMast.getStaNo(),
+                        pathLenFactor
+                );
+                if (command == null) {
+                    News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+                    return;
                 }
 
-                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
-                StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
-                if (stationProtocol == null) {
-                    continue;
+                boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "dualCrnStationOutExecute");
+                if (!offered) {
+                    return;
                 }
-
-                Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
-                if (lock != null) {
-                    continue;
-                }
-
-                if (stationProtocol.isAutoing()
-                        && stationProtocol.isLoading()
-                        && stationProtocol.getTaskNo() == 0) {
-                    Double pathLenFactor = stationOutboundDecisionSupport.resolveOutboundPathLenFactor(wrkMast);
-                    StationCommand command = stationOutboundDecisionSupport.buildOutboundMoveCommand(
-                            stationThread,
-                            wrkMast,
+                if (stationMoveCoordinator != null) {
+                    stationMoveCoordinator.recordDispatch(
+                            wrkMast.getWrkNo(),
                             stationProtocol.getStationId(),
-                            wrkMast.getStaNo(),
-                            pathLenFactor
+                            "dualCrnStationOutExecute",
+                            command,
+                            false
                     );
-                    if (command == null) {
-                        News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
-                        continue;
-                    }
-
-                    boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "dualCrnStationOutExecute");
-                    if (!offered) {
-                        continue;
-                    }
-                    if (stationMoveCoordinator != null) {
-                        stationMoveCoordinator.recordDispatch(
-                                wrkMast.getWrkNo(),
-                                stationProtocol.getStationId(),
-                                "dualCrnStationOutExecute",
-                                command,
-                                false
-                        );
-                    }
-                    markPendingDispatch(wrkMast.getWrkNo());
-                    News.info("杈撻�佺珯鐐瑰嚭搴撳懡浠ゅ凡鍏ヨ澶囨墽琛岄摼璺紝绛夊緟婧愮珯鎺ュ崟銆傜珯鐐瑰彿={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}",
-                            stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
-                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                 }
+                markPendingDispatch(wrkMast.getWrkNo());
+                News.info("杈撻�佺珯鐐瑰嚭搴撳懡浠ゅ凡鍏ヨ澶囨墽琛岄摼璺紝绛夊緟婧愮珯鎺ュ崟銆傜珯鐐瑰彿={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}",
+                        stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
+                redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
             }
         } catch (Exception e) {
             e.printStackTrace();

--
Gitblit v1.9.1