From a72c3844450381a872e4f0f149210e480679984a Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 24 三月 2026 16:57:24 +0800
Subject: [PATCH] refactor: unify station out-order reroute flow
---
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java | 118 ++++++++++++-----------------------------------------------
1 files changed, 24 insertions(+), 94 deletions(-)
diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index d07ff5e..a75648a 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -742,56 +742,21 @@
continue;
}
- if (countCurrentTaskBufferCommands(stationProtocol.getTaskBufferItems(), stationProtocol.getTaskNo()) > 0) {
- continue;
- }
-
Double pathLenFactor = resolveOutboundPathLenFactor(wrkMast);
- OutOrderDispatchDecision dispatchDecision = resolveOutboundDispatchDecision(
- stationProtocol.getStationId(),
+ RerouteContext context = RerouteContext.create(
+ RerouteSceneType.OUT_ORDER,
+ basDevp,
+ stationThread,
+ stationProtocol,
wrkMast,
outOrderStationIds,
- pathLenFactor
- );
- Integer moveStaNo = dispatchDecision == null ? null : dispatchDecision.getTargetStationId();
- if (moveStaNo == null || Objects.equals(moveStaNo, stationProtocol.getStationId())) {
- continue;
- }
-
- StationCommand command = buildOutboundMoveCommand(
- stationThread,
- wrkMast,
- stationProtocol.getStationId(),
- moveStaNo,
- pathLenFactor
- );
- if (command == null) {
- News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
- continue;
- }
- if (stationMoveCoordinator != null
- && stationMoveCoordinator.shouldSuppressDispatch(wrkMast.getWrkNo(), stationProtocol.getStationId(), command)) {
- continue;
- }
- if (!tryAcquireOutOrderDispatchLock(wrkMast.getWrkNo(), stationProtocol.getStationId())) {
- continue;
- }
- resetSegmentMoveCommandsBeforeReroute(wrkMast.getWrkNo());
- boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "checkStationOutOrder");
- if (!offered) {
- continue;
- }
- syncOutOrderWatchState(wrkMast, stationProtocol.getStationId(), outOrderStationIds, dispatchDecision, command);
- if (stationMoveCoordinator != null) {
- stationMoveCoordinator.recordDispatch(
- wrkMast.getWrkNo(),
- stationProtocol.getStationId(),
- "checkStationOutOrder",
- command,
- dispatchDecision != null && dispatchDecision.isCircle()
- );
- }
- News.info(dispatchDecision.isCircle() ? "{}浠诲姟杩涜缁曞湀" : "{}浠诲姟鐩存帴鍘荤洰鏍囩偣", wrkMast.getWrkNo());
+ pathLenFactor,
+ "checkStationOutOrder"
+ ).withDispatchDeviceNo(stationObjModel.getDeviceNo())
+ .withSuppressDispatchGuard()
+ .withOutOrderDispatchLock()
+ .withResetSegmentCommandsBeforeDispatch();
+ executeSharedReroute(context);
}
}
}
@@ -838,55 +803,20 @@
if (Objects.equals(stationProtocol.getStationId(), wrkMast.getStaNo())) {
continue;
}
- if (countCurrentTaskBufferCommands(stationProtocol.getTaskBufferItems(), stationProtocol.getTaskNo()) > 0) {
- continue;
- }
-
Double pathLenFactor = resolveOutboundPathLenFactor(wrkMast);
- OutOrderDispatchDecision dispatchDecision = resolveOutboundDispatchDecision(
- stationProtocol.getStationId(),
+ RerouteContext context = RerouteContext.create(
+ RerouteSceneType.WATCH_CIRCLE,
+ basDevp,
+ stationThread,
+ stationProtocol,
wrkMast,
outOrderList,
- pathLenFactor
- );
- Integer moveStaNo = dispatchDecision == null ? null : dispatchDecision.getTargetStationId();
- if (moveStaNo == null || Objects.equals(moveStaNo, stationProtocol.getStationId())) {
- continue;
- }
-
- StationCommand command = buildOutboundMoveCommand(
- stationThread,
- wrkMast,
- stationProtocol.getStationId(),
- moveStaNo,
- pathLenFactor
- );
- if (command == null) {
- News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
- continue;
- }
- if (stationMoveCoordinator != null
- && stationMoveCoordinator.shouldSuppressDispatch(wrkMast.getWrkNo(), stationProtocol.getStationId(), command)) {
- continue;
- }
- if (!tryAcquireOutOrderDispatchLock(wrkMast.getWrkNo(), stationProtocol.getStationId())) {
- continue;
- }
- resetSegmentMoveCommandsBeforeReroute(wrkMast.getWrkNo());
- boolean offered = offerDevpCommandWithDedup(basDevp.getDevpNo(), command, "watchCircleStation");
- if (!offered) {
- continue;
- }
- syncOutOrderWatchState(wrkMast, stationProtocol.getStationId(), outOrderList, dispatchDecision, command);
- if (stationMoveCoordinator != null) {
- stationMoveCoordinator.recordDispatch(
- wrkMast.getWrkNo(),
- stationProtocol.getStationId(),
- "watchCircleStation",
- command,
- dispatchDecision != null && dispatchDecision.isCircle()
- );
- }
+ pathLenFactor,
+ "watchCircleStation"
+ ).withSuppressDispatchGuard()
+ .withOutOrderDispatchLock()
+ .withResetSegmentCommandsBeforeDispatch();
+ executeSharedReroute(context);
}
}
}
@@ -1018,7 +948,7 @@
return RerouteExecutionResult.dispatched(plan.command(), clearedCommandCount);
}
- private RerouteDecision resolveSharedRerouteDecision(RerouteContext context) {
+ RerouteDecision resolveSharedRerouteDecision(RerouteContext context) {
if (context == null || context.wrkMast() == null || context.stationProtocol() == null) {
return RerouteDecision.skip("missing-runtime-dependency");
}
--
Gitblit v1.9.1