From 045ee53a62cd7866c1395961076426e9c8782b26 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 13 四月 2026 08:42:38 +0800
Subject: [PATCH] #输送命令优化

---
 src/main/java/com/zy/core/utils/station/StationRerouteProcessor.java |  191 -----------------------------------------------
 1 files changed, 0 insertions(+), 191 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/station/StationRerouteProcessor.java b/src/main/java/com/zy/core/utils/station/StationRerouteProcessor.java
index 381aa84..b3f358d 100644
--- a/src/main/java/com/zy/core/utils/station/StationRerouteProcessor.java
+++ b/src/main/java/com/zy/core/utils/station/StationRerouteProcessor.java
@@ -50,8 +50,6 @@
 @Component
 public class StationRerouteProcessor {
     private static final int OUT_ORDER_DISPATCH_LIMIT_SECONDS = 2;
-    private static final int STATION_IDLE_RECOVER_SECONDS = 10;
-    private static final int STATION_IDLE_RECOVER_LIMIT_SECONDS = 30;
     private static final long STATION_MOVE_RESET_WAIT_MS = 1000L;
 
     @Autowired
@@ -149,33 +147,6 @@
         }
     }
 
-    public void checkStationIdleRecover(BasDevp basDevp, Integer stationId) {
-        try {
-            if (basDevp == null || basDevp.getDevpNo() == null || stationId == null) {
-                return;
-            }
-            if (!isIdleRecoverCandidateStation(basDevp, stationId)) {
-                return;
-            }
-            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
-            if (stationThread == null) {
-                return;
-            }
-            Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
-            StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(stationId);
-            if (stationProtocol == null
-                    || !stationProtocol.isAutoing()
-                    || !stationProtocol.isLoading()
-                    || stationProtocol.getTaskNo() <= 0
-                    || stationProtocol.isRunBlock()) {
-                return;
-            }
-            checkStationIdleRecover(basDevp, stationThread, stationProtocol, basDevp.getOutOrderIntList());
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
     public void checkStationOutOrder(BasDevp basDevp, StationObjModel stationObjModel) {
         try {
             if (basDevp == null || basDevp.getDevpNo() == null || stationObjModel == null || stationObjModel.getStationId() == null) {
@@ -218,51 +189,6 @@
                     "checkStationOutOrder"
             ).withDispatchDeviceNo(stationObjModel.getDeviceNo())
                     .withSuppressDispatchGuard()
-                    .withOutOrderDispatchLock()
-                    .withResetSegmentCommandsBeforeDispatch();
-            executeSharedReroute(context);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public void watchCircleStation(BasDevp basDevp, Integer stationId) {
-        try {
-            if (basDevp == null || basDevp.getDevpNo() == null || stationId == null) {
-                return;
-            }
-            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
-            if (stationThread == null) {
-                return;
-            }
-            Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
-            StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(stationId);
-            if (stationProtocol == null
-                    || !stationProtocol.isAutoing()
-                    || !stationProtocol.isLoading()
-                    || stationProtocol.getTaskNo() <= 0
-                    || !stationOutboundDecisionSupport.isWatchingCircleArrival(stationProtocol.getTaskNo(), stationProtocol.getStationId())) {
-                return;
-            }
-
-            WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
-            if (wrkMast == null
-                    || !Objects.equals(wrkMast.getWrkSts(), WrkStsType.STATION_RUN.sts)
-                    || Objects.equals(stationProtocol.getStationId(), wrkMast.getStaNo())) {
-                return;
-            }
-
-            Double pathLenFactor = stationOutboundDecisionSupport.resolveOutboundPathLenFactor(wrkMast);
-            RerouteContext context = RerouteContext.create(
-                    RerouteSceneType.WATCH_CIRCLE,
-                    basDevp,
-                    stationThread,
-                    stationProtocol,
-                    wrkMast,
-                    basDevp.getOutOrderIntList(),
-                    pathLenFactor,
-                    "watchCircleStation"
-            ).withSuppressDispatchGuard()
                     .withOutOrderDispatchLock()
                     .withResetSegmentCommandsBeforeDispatch();
             executeSharedReroute(context);
@@ -396,43 +322,6 @@
                 && runBlockReassignLocStationList.contains(stationId);
     }
 
-    public boolean shouldSkipIdleRecoverForRecentDispatch(Integer taskNo, Integer stationId) {
-        if (taskNo == null || taskNo <= 0 || stationId == null) {
-            return false;
-        }
-        long thresholdMs = STATION_IDLE_RECOVER_SECONDS * 1000L;
-        StationMoveSession session = stationMoveCoordinator == null ? null : stationMoveCoordinator.loadSession(taskNo);
-        if (session != null && session.isActive() && session.getLastIssuedAt() != null) {
-            if (Objects.equals(stationId, session.getCurrentStationId())
-                    || Objects.equals(stationId, session.getDispatchStationId())
-                    || session.containsStation(stationId)) {
-                long elapsedMs = System.currentTimeMillis() - session.getLastIssuedAt();
-                if (elapsedMs < thresholdMs) {
-                    stationDispatchRuntimeStateSupport.saveIdleTrack(new StationTaskIdleTrack(taskNo, stationId, System.currentTimeMillis()));
-                    News.info("杈撻�佺珯鐐逛换鍔″垰瀹屾垚鍛戒护涓嬪彂锛屽凡璺宠繃鍋滅暀閲嶇畻銆傜珯鐐瑰彿={}锛屽伐浣滃彿={}锛岃窛涓婃涓嬪彂={}ms锛宺outeVersion={}",
-                            stationId, taskNo, elapsedMs, session.getRouteVersion());
-                    return true;
-                }
-            }
-        }
-        if (!stationDispatchRuntimeStateSupport.hasRecentIssuedMoveCommand(taskNo, stationId, thresholdMs)) {
-            return false;
-        }
-        stationDispatchRuntimeStateSupport.saveIdleTrack(new StationTaskIdleTrack(taskNo, stationId, System.currentTimeMillis()));
-        News.info("杈撻�佺珯鐐逛换鍔″垰瀹屾垚鍛戒护涓嬪彂锛屽凡璺宠繃鍋滅暀閲嶇畻銆傜珯鐐瑰彿={}锛屽伐浣滃彿={}锛岃窛鏈�杩戝懡浠や笅鍙�<{}ms锛宺outeVersion={}",
-                stationId, taskNo, thresholdMs, session == null ? null : session.getRouteVersion());
-        return true;
-    }
-
-    private boolean isIdleRecoverCandidateStation(BasDevp basDevp, Integer stationId) {
-        if (basDevp == null || stationId == null) {
-            return false;
-        }
-        return !containsStation(basDevp.getBarcodeStationList$(), stationId)
-                && !containsStation(basDevp.getInStationList$(), stationId)
-                && !containsStation(basDevp.getOutStationList$(), stationId);
-    }
-
     private boolean shouldSkipRunBlockStation(BasDevp basDevp, Integer stationId) {
         if (basDevp == null || stationId == null) {
             return false;
@@ -459,18 +348,8 @@
                                                                   Integer taskNo,
                                                                   Integer stationId) {
         boolean runBlockReroute = context.sceneType() == RerouteSceneType.RUN_BLOCK_REROUTE;
-        if (context.checkRecentDispatch()
-                && shouldSkipIdleRecoverForRecentDispatch(taskNo, stationId)) {
-            return RerouteExecutionResult.skip("recent-dispatch");
-        }
         int currentTaskBufferCommandCount = countCurrentTaskBufferCommands(stationProtocol.getTaskBufferItems(), taskNo);
         if (currentTaskBufferCommandCount > 0 && !runBlockReroute) {
-            if (context.sceneType() == RerouteSceneType.IDLE_RECOVER) {
-                News.info("杈撻�佺珯鐐逛换鍔″仠鐣欒秴鏃讹紝浣嗙紦瀛樺尯浠嶅瓨鍦ㄥ綋鍓嶄换鍔″懡浠わ紝宸茶烦杩囬噸绠椼�傜珯鐐瑰彿={}锛屽伐浣滃彿={}锛屽綋鍓嶄换鍔″懡浠ゆ暟={}",
-                        stationId,
-                        taskNo,
-                        currentTaskBufferCommandCount);
-            }
             return RerouteExecutionResult.skip("buffer-has-current-task");
         }
         if (currentTaskBufferCommandCount > 0 && runBlockReroute) {
@@ -499,9 +378,6 @@
         }
 
         int clearedCommandCount = 0;
-        if (context.clearIdleIssuedCommands()) {
-            clearedCommandCount = stationDispatchRuntimeStateSupport.clearIssuedMoveCommandsDuringIdleStay(context.idleTrack(), taskNo, stationId);
-        }
 
         boolean offered = offerDevpCommandWithDedup(context.dispatchDeviceNo(), plan.command(), plan.dispatchScene());
         if (!offered) {
@@ -552,17 +428,6 @@
                     dispatchDecision != null && dispatchDecision.isCircle()
             );
         }
-        if (context.sceneType() == RerouteSceneType.IDLE_RECOVER) {
-            stationDispatchRuntimeStateSupport.saveIdleTrack(new StationTaskIdleTrack(wrkMast.getWrkNo(), stationProtocol.getStationId(), System.currentTimeMillis()));
-            News.info("杈撻�佺珯鐐逛换鍔″仠鐣檣}绉掓湭杩愯锛屽凡閲嶆柊璁$畻璺緞骞堕噸鍚繍琛岋紝绔欑偣鍙�={}锛岀洰鏍囩珯={}锛屽伐浣滃彿={}锛屾竻鐞嗘棫鍒嗘鍛戒护鏁�={}锛屽懡浠ゆ暟鎹�={}",
-                    STATION_IDLE_RECOVER_SECONDS,
-                    stationProtocol.getStationId(),
-                    plan.command().getTargetStaNo(),
-                    wrkMast.getWrkNo(),
-                    clearedCommandCount,
-                    JSON.toJSONString(plan.command()));
-            return;
-        }
         if (context.sceneType() == RerouteSceneType.RUN_BLOCK_REROUTE) {
             News.info("杈撻�佺珯鐐瑰牭濉炲悗閲嶆柊璁$畻璺緞鍛戒护涓嬪彂鎴愬姛锛岀珯鐐瑰彿={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}",
                     stationProtocol.getStationId(),
@@ -573,51 +438,6 @@
         if (context.sceneType() == RerouteSceneType.OUT_ORDER) {
             News.info(dispatchDecision != null && dispatchDecision.isCircle() ? "{}浠诲姟杩涜缁曞湀" : "{}浠诲姟鐩存帴鍘荤洰鏍囩偣", wrkMast.getWrkNo());
         }
-    }
-
-    private void checkStationIdleRecover(BasDevp basDevp,
-                                         StationThread stationThread,
-                                         StationProtocol stationProtocol,
-                                         List<Integer> outOrderList) {
-        if (stationProtocol == null || stationProtocol.getTaskNo() == null || stationProtocol.getTaskNo() <= 0) {
-            return;
-        }
-        if (!Objects.equals(stationProtocol.getStationId(), stationProtocol.getTargetStaNo())) {
-            return;
-        }
-
-        StationTaskIdleTrack idleTrack = stationDispatchRuntimeStateSupport.touchIdleTrack(stationProtocol.getTaskNo(), stationProtocol.getStationId());
-        if (shouldSkipIdleRecoverForRecentDispatch(stationProtocol.getTaskNo(), stationProtocol.getStationId())) {
-            return;
-        }
-        if (idleTrack == null || !idleTrack.isTimeout(STATION_IDLE_RECOVER_SECONDS)) {
-            return;
-        }
-
-        WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
-        if (!canRecoverIdleStationTask(wrkMast, stationProtocol.getStationId())) {
-            return;
-        }
-
-        Object lock = redisUtil.get(RedisKeyType.CHECK_STATION_IDLE_RECOVER_LIMIT_.key + stationProtocol.getTaskNo());
-        if (lock != null) {
-            return;
-        }
-        Double pathLenFactor = stationOutboundDecisionSupport.resolveOutboundPathLenFactor(wrkMast);
-        RerouteContext context = RerouteContext.create(
-                RerouteSceneType.IDLE_RECOVER,
-                basDevp,
-                stationThread,
-                stationProtocol,
-                wrkMast,
-                outOrderList,
-                pathLenFactor,
-                "checkStationIdleRecover"
-        ).withCancelSessionBeforeDispatch()
-                .withExecutionLock(RedisKeyType.CHECK_STATION_IDLE_RECOVER_LIMIT_.key + stationProtocol.getTaskNo(), STATION_IDLE_RECOVER_LIMIT_SECONDS)
-                .withResetSegmentCommandsBeforeDispatch()
-                .clearIdleIssuedCommands(idleTrack);
-        executeSharedReroute(context);
     }
 
     private void executeRunBlockDirectReassign(BasDevp basDevp,
@@ -729,17 +549,6 @@
                     false
             );
         }
-    }
-
-    private boolean canRecoverIdleStationTask(WrkMast wrkMast, Integer currentStationId) {
-        if (wrkMast == null || currentStationId == null || wrkMast.getStaNo() == null) {
-            return false;
-        }
-        if (Objects.equals(currentStationId, wrkMast.getStaNo())) {
-            return false;
-        }
-        return Objects.equals(wrkMast.getWrkSts(), WrkStsType.INBOUND_STATION_RUN.sts)
-                || Objects.equals(wrkMast.getWrkSts(), WrkStsType.STATION_RUN.sts);
     }
 
     private int countCurrentTaskBufferCommands(List<StationTaskBufferItem> taskBufferItems, Integer currentTaskNo) {

--
Gitblit v1.9.1