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/thread/impl/ZyStationV4Thread.java | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java b/src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java
index 19b3642..d8ec936 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java
@@ -30,6 +30,7 @@
import com.zy.core.network.DeviceConnectPool;
import com.zy.core.network.ZyStationConnectDriver;
import com.zy.core.network.entity.ZyStationStatusEntity;
+import com.zy.core.thread.impl.v5.StationMoveSegmentExecutor;
import com.zy.core.utils.DeviceLogRedisKeyBuilder;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
@@ -51,6 +52,7 @@
private DeviceConfig deviceConfig;
private RedisUtil redisUtil;
private ZyStationConnectDriver zyStationConnectDriver;
+ private StationMoveSegmentExecutor segmentExecutor;
private int deviceLogCollectTime = 200;
private boolean initStatus = false;
private long deviceDataLogTime = System.currentTimeMillis();
@@ -59,6 +61,7 @@
public ZyStationV4Thread(DeviceConfig deviceConfig, RedisUtil redisUtil) {
this.deviceConfig = deviceConfig;
this.redisUtil = redisUtil;
+ this.segmentExecutor = new StationMoveSegmentExecutor(deviceConfig, redisUtil, this::sendCommand);
}
@Override
@@ -92,7 +95,7 @@
}
if (step == 2) {
StationCommand cmd = (StationCommand) task.getData();
- executor.submit(() -> executeMoveWithSeg(cmd));
+ executor.submit(() -> segmentExecutor.execute(cmd));
}
Thread.sleep(100);
} catch (Exception e) {
@@ -153,6 +156,7 @@
stationProtocol.setEnableIn(statusEntity.isEnableIn());
stationProtocol.setWeight(statusEntity.getWeight());
stationProtocol.setTaskWriteIdx(statusEntity.getTaskWriteIdx());
+ stationProtocol.setTaskBufferItems(statusEntity.getTaskBufferItems());
}
if (!Cools.isEmpty(stationProtocol.getSystemWarning())) {
@@ -214,6 +218,16 @@
@Override
public StationCommand getCommand(StationCommandType commandType, Integer taskNo, Integer stationId, Integer targetStationId, Integer palletSize) {
+ return getCommand(commandType, taskNo, stationId, targetStationId, palletSize, null);
+ }
+
+ @Override
+ public StationCommand getCommand(StationCommandType commandType,
+ Integer taskNo,
+ Integer stationId,
+ Integer targetStationId,
+ Integer palletSize,
+ Double pathLenFactor) {
StationCommand stationCommand = new StationCommand();
stationCommand.setTaskNo(taskNo);
stationCommand.setStationId(stationId);
@@ -223,7 +237,7 @@
if (commandType == StationCommandType.MOVE) {
if (!stationId.equals(targetStationId)) {
- List<NavigateNode> nodes = calcPathNavigateNodes(stationId, targetStationId);
+ List<NavigateNode> nodes = calcPathNavigateNodes(taskNo, stationId, targetStationId, pathLenFactor);
List<Integer> path = new ArrayList<>();
List<Integer> liftTransferPath = new ArrayList<>();
for (NavigateNode n : nodes) {
@@ -261,6 +275,9 @@
e.printStackTrace();
} finally {
BasStationOptService optService = SpringUtils.getBean(BasStationOptService.class);
+ if (optService == null) {
+ return commandResponse;
+ }
List<ZyStationStatusEntity> statusListEntity = zyStationConnectDriver.getStatus();
ZyStationStatusEntity matched = null;
if (statusListEntity != null) {
@@ -283,12 +300,10 @@
null,
JSON.toJSONString(command),
JSON.toJSONString(matched),
- 1,
+ commandResponse != null && Boolean.TRUE.equals(commandResponse.getResult()) ? 1 : 0,
JSON.toJSONString(commandResponse)
);
- if (optService != null) {
- optService.save(basStationOpt);
- }
+ optService.save(basStationOpt);
}
return commandResponse;
}
@@ -303,12 +318,15 @@
return zyStationConnectDriver.readOriginCommand(address, length);
}
- private List<NavigateNode> calcPathNavigateNodes(Integer startStationId, Integer targetStationId) {
+ private List<NavigateNode> calcPathNavigateNodes(Integer taskNo,
+ Integer startStationId,
+ Integer targetStationId,
+ Double pathLenFactor) {
NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
if (navigateUtils == null) {
return new ArrayList<>();
}
- return navigateUtils.calcByStationId(startStationId, targetStationId);
+ return navigateUtils.calcByStationId(startStationId, targetStationId, taskNo, pathLenFactor);
}
private void executeMoveWithSeg(StationCommand original) {
--
Gitblit v1.9.1