From 7272158c8e133afcdf752ca09a70c0bd969d7393 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 25 三月 2026 19:57:26 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java | 28 +++++++-
src/test/java/com/zy/core/utils/StationOperateProcessUtilsReroutePipelineTest.java | 99 +++++++++++++++++++++++++++++++++
2 files changed, 122 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index 2e2dd5c..631f97a 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -795,20 +795,37 @@
if (taskNo == null || taskNo <= 0 || stationId == null) {
return RerouteExecutionResult.skip("invalid-station-task");
}
+ boolean runBlockReroute = context.sceneType() == RerouteSceneType.RUN_BLOCK_REROUTE;
+ if (runBlockReroute) {
+ if (context.cancelSessionBeforeDispatch() && stationMoveCoordinator != null) {
+ stationMoveCoordinator.cancelSession(taskNo);
+ }
+ if (context.resetSegmentCommandsBeforeDispatch()) {
+ resetSegmentMoveCommandsBeforeReroute(taskNo);
+ }
+ }
if (context.checkRecentDispatch()
&& shouldSkipIdleRecoverForRecentDispatch(taskNo, stationId)) {
return RerouteExecutionResult.skip("recent-dispatch");
}
- if (countCurrentTaskBufferCommands(stationProtocol.getTaskBufferItems(), taskNo) > 0) {
+ int currentTaskBufferCommandCount = countCurrentTaskBufferCommands(stationProtocol.getTaskBufferItems(), taskNo);
+ if (currentTaskBufferCommandCount > 0 && !runBlockReroute) {
if (context.sceneType() == RerouteSceneType.IDLE_RECOVER) {
News.info("杈撻�佺珯鐐逛换鍔″仠鐣欒秴鏃讹紝浣嗙紦瀛樺尯浠嶅瓨鍦ㄥ綋鍓嶄换鍔″懡浠わ紝宸茶烦杩囬噸绠椼�傜珯鐐瑰彿={}锛屽伐浣滃彿={}锛屽綋鍓嶄换鍔″懡浠ゆ暟={}",
stationId,
taskNo,
- countCurrentTaskBufferCommands(stationProtocol.getTaskBufferItems(), taskNo));
+ currentTaskBufferCommandCount);
}
return RerouteExecutionResult.skip("buffer-has-current-task");
}
- if (context.checkSuppressDispatch()
+ if (currentTaskBufferCommandCount > 0 && runBlockReroute) {
+ News.info("杈撻�佺珯鐐硅繍琛屽牭濉為噸瑙勫垝妫�娴嬪埌鏃у垎娈靛懡浠ゆ畫鐣欙紝宸插厛娓呯悊鏈湴鐘舵�佸悗缁х画閲嶅彂銆傜珯鐐瑰彿={}锛屽伐浣滃彿={}锛屽綋鍓嶄换鍔″懡浠ゆ暟={}",
+ stationId,
+ taskNo,
+ currentTaskBufferCommandCount);
+ }
+ if (!runBlockReroute
+ && context.checkSuppressDispatch()
&& stationMoveCoordinator != null
&& stationMoveCoordinator.shouldSuppressDispatch(taskNo, stationId, plan.command())) {
return RerouteExecutionResult.skip("dispatch-suppressed");
@@ -818,7 +835,8 @@
return RerouteExecutionResult.skip("out-order-lock");
}
- if (context.cancelSessionBeforeDispatch() && stationMoveCoordinator != null) {
+ if (!runBlockReroute
+ && context.cancelSessionBeforeDispatch() && stationMoveCoordinator != null) {
stationMoveCoordinator.cancelSession(taskNo);
}
if (!isBlank(context.executionLockKey())) {
@@ -828,7 +846,7 @@
}
redisUtil.set(context.executionLockKey(), "lock", context.executionLockSeconds());
}
- if (context.resetSegmentCommandsBeforeDispatch()) {
+ if (!runBlockReroute && context.resetSegmentCommandsBeforeDispatch()) {
resetSegmentMoveCommandsBeforeReroute(taskNo);
}
diff --git a/src/test/java/com/zy/core/utils/StationOperateProcessUtilsReroutePipelineTest.java b/src/test/java/com/zy/core/utils/StationOperateProcessUtilsReroutePipelineTest.java
index 9fe3b7d..c67961e 100644
--- a/src/test/java/com/zy/core/utils/StationOperateProcessUtilsReroutePipelineTest.java
+++ b/src/test/java/com/zy/core/utils/StationOperateProcessUtilsReroutePipelineTest.java
@@ -444,6 +444,105 @@
}
@Test
+ void executePlan_runBlockReroute_ignoresCurrentTaskBufferAfterReset() {
+ StationOperateProcessUtils utils = new StationOperateProcessUtils();
+ StationMoveCoordinator coordinator = mock(StationMoveCoordinator.class);
+ RedisUtil redisUtil = mock(RedisUtil.class);
+ ReflectionTestUtils.setField(utils, "stationMoveCoordinator", coordinator);
+ ReflectionTestUtils.setField(utils, "redisUtil", redisUtil);
+
+ StationCommand command = new StationCommand();
+ command.setTaskNo(10388);
+ command.setStationId(186);
+ command.setTargetStaNo(124);
+ command.setNavigatePath(List.of(186, 189, 121, 124));
+ command.setOriginalNavigatePath(List.of(186, 189, 121, 124));
+
+ StationTaskBufferItem bufferItem = new StationTaskBufferItem();
+ bufferItem.setTaskNo(10388);
+
+ when(redisUtil.get(anyString())).thenReturn(null);
+
+ StationOperateProcessUtils.RerouteContext context = StationOperateProcessUtils.RerouteContext.create(
+ StationOperateProcessUtils.RerouteSceneType.RUN_BLOCK_REROUTE,
+ buildBasDevp(1),
+ mock(StationThread.class),
+ buildStationProtocol(186, 10388, 189, Collections.singletonList(bufferItem)),
+ buildWrkMast(10388, 124),
+ Collections.emptyList(),
+ 0.0d,
+ "checkStationRunBlock_reroute"
+ ).withCancelSessionBeforeDispatch()
+ .withResetSegmentCommandsBeforeDispatch();
+
+ MessageQueue.init(SlaveType.Devp, 1);
+ try {
+ StationOperateProcessUtils.RerouteExecutionResult result = utils.executeReroutePlan(
+ context,
+ StationOperateProcessUtils.RerouteCommandPlan.dispatch(
+ command,
+ StationOperateProcessUtils.RerouteDecision.proceed(124),
+ "checkStationRunBlock_reroute"
+ )
+ );
+
+ assertTrue(!result.skipped());
+ verify(coordinator, times(1)).cancelSession(10388);
+ } finally {
+ MessageQueue.clear(SlaveType.Devp, 1);
+ }
+ }
+
+ @Test
+ void executePlan_runBlockReroute_bypassesSuppressDispatchAfterReset() {
+ StationOperateProcessUtils utils = new StationOperateProcessUtils();
+ StationMoveCoordinator coordinator = mock(StationMoveCoordinator.class);
+ RedisUtil redisUtil = mock(RedisUtil.class);
+ ReflectionTestUtils.setField(utils, "stationMoveCoordinator", coordinator);
+ ReflectionTestUtils.setField(utils, "redisUtil", redisUtil);
+
+ StationCommand command = new StationCommand();
+ command.setTaskNo(10388);
+ command.setStationId(186);
+ command.setTargetStaNo(124);
+ command.setNavigatePath(List.of(186, 124));
+ command.setOriginalNavigatePath(List.of(186, 124));
+
+ when(redisUtil.get(anyString())).thenReturn(null);
+ when(coordinator.shouldSuppressDispatch(10388, 186, command)).thenReturn(true);
+
+ StationOperateProcessUtils.RerouteContext context = StationOperateProcessUtils.RerouteContext.create(
+ StationOperateProcessUtils.RerouteSceneType.RUN_BLOCK_REROUTE,
+ buildBasDevp(1),
+ mock(StationThread.class),
+ buildStationProtocol(186, 10388, 186),
+ buildWrkMast(10388, 124),
+ Collections.emptyList(),
+ 0.0d,
+ "checkStationRunBlock_reroute"
+ ).withSuppressDispatchGuard()
+ .withCancelSessionBeforeDispatch()
+ .withResetSegmentCommandsBeforeDispatch();
+
+ MessageQueue.init(SlaveType.Devp, 1);
+ try {
+ StationOperateProcessUtils.RerouteExecutionResult result = utils.executeReroutePlan(
+ context,
+ StationOperateProcessUtils.RerouteCommandPlan.dispatch(
+ command,
+ StationOperateProcessUtils.RerouteDecision.proceed(124),
+ "checkStationRunBlock_reroute"
+ )
+ );
+
+ assertTrue(!result.skipped());
+ verify(coordinator, times(1)).cancelSession(10388);
+ } finally {
+ MessageQueue.clear(SlaveType.Devp, 1);
+ }
+ }
+
+ @Test
void stationInExecute_recordsDispatchSessionAfterIssuingMoveCommand() {
StationOperateProcessUtils utils = new StationOperateProcessUtils();
BasDevpService basDevpService = mock(BasDevpService.class);
--
Gitblit v1.9.1