From 6c520b6fefa96176fee458e5a656a94d1cd3dc3f Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 23 三月 2026 22:12:53 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/impl/v5/StationV5SegmentExecutor.java | 55 +++----------------------------------------------------
1 files changed, 3 insertions(+), 52 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/impl/v5/StationV5SegmentExecutor.java b/src/main/java/com/zy/core/thread/impl/v5/StationV5SegmentExecutor.java
index 7e749fb..fecd517 100644
--- a/src/main/java/com/zy/core/thread/impl/v5/StationV5SegmentExecutor.java
+++ b/src/main/java/com/zy/core/thread/impl/v5/StationV5SegmentExecutor.java
@@ -24,8 +24,7 @@
public class StationV5SegmentExecutor {
- private static final String CFG_STATION_COMMAND_SEGMENT_ADVANCE_RATIO = "stationCommandSegmentAdvanceRatio";
- private static final double DEFAULT_STATION_COMMAND_SEGMENT_ADVANCE_RATIO = 0.3d;
+ private static final int NEXT_SEGMENT_ADVANCE_NODE_COUNT = 1;
private static final long CURRENT_STATION_TIMEOUT_MS = 1000L * 60L;
private final DeviceConfig deviceConfig;
@@ -82,7 +81,6 @@
int segCursor = 0;
Integer lastCurrentStationId = null;
boolean firstRun = true;
- double segmentAdvanceRatio = loadSegmentAdvanceRatio();
while (true) {
try {
Object cancel = redisUtil.get(RedisKeyType.DEVICE_STATION_MOVE_RESET.key + original.getTaskNo());
@@ -142,11 +140,9 @@
StationCommand currentSegmentCommand = localPlan.getSegmentCommands().get(segCursor);
int currentSegEndIndex = safeIndex(currentSegmentCommand.getSegmentEndIndex());
- int currentSegStartIndex = safeIndex(currentSegmentCommand.getSegmentStartIndex());
- int segLen = Math.max(1, currentSegEndIndex - currentSegStartIndex + 1);
int remainingSegment = Math.max(0, currentSegEndIndex - currentIndex);
- int thresholdSegment = (int) Math.ceil(segLen * segmentAdvanceRatio);
- if (remainingSegment <= thresholdSegment && segCursor < localPlan.getSegmentCommands().size() - 1) {
+ if (remainingSegment <= NEXT_SEGMENT_ADVANCE_NODE_COUNT
+ && segCursor < localPlan.getSegmentCommands().size() - 1) {
StationCommand nextCommand = localPlan.getSegmentCommands().get(segCursor + 1);
if (sendSegmentWithRetry(nextCommand)) {
segCursor++;
@@ -188,51 +184,6 @@
}
Object cancel = redisUtil.get(RedisKeyType.DEVICE_STATION_MOVE_RESET.key + taskNo);
return cancel != null;
- }
-
- private double loadSegmentAdvanceRatio() {
- try {
- ConfigService configService = SpringUtils.getBean(ConfigService.class);
- if (configService == null) {
- return DEFAULT_STATION_COMMAND_SEGMENT_ADVANCE_RATIO;
- }
- Config config = configService.getOne(new QueryWrapper<Config>()
- .eq("code", CFG_STATION_COMMAND_SEGMENT_ADVANCE_RATIO));
- if (config == null || Cools.isEmpty(config.getValue())) {
- return DEFAULT_STATION_COMMAND_SEGMENT_ADVANCE_RATIO;
- }
- return normalizeSegmentAdvanceRatio(config.getValue());
- } catch (Exception ignore) {
- return DEFAULT_STATION_COMMAND_SEGMENT_ADVANCE_RATIO;
- }
- }
-
- private double normalizeSegmentAdvanceRatio(String valueText) {
- if (valueText == null) {
- return DEFAULT_STATION_COMMAND_SEGMENT_ADVANCE_RATIO;
- }
- String text = valueText.trim();
- if (text.isEmpty()) {
- return DEFAULT_STATION_COMMAND_SEGMENT_ADVANCE_RATIO;
- }
- if (text.endsWith("%")) {
- text = text.substring(0, text.length() - 1).trim();
- }
- try {
- double ratio = Double.parseDouble(text);
- if (ratio > 1d && ratio <= 100d) {
- ratio = ratio / 100d;
- }
- if (ratio < 0d) {
- return 0d;
- }
- if (ratio > 1d) {
- return 1d;
- }
- return ratio;
- } catch (Exception ignore) {
- return DEFAULT_STATION_COMMAND_SEGMENT_ADVANCE_RATIO;
- }
}
private StationProtocol findCurrentStationByTask(Integer taskNo) {
--
Gitblit v1.9.1