From cbb00d4729243e4949b3c921fc2f94cb03ca8aaa Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 27 三月 2026 18:47:43 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java | 33 ++++++++++++++++++++++++++++++---
1 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java b/src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java
index af286c8..6accb28 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.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.support.RecentStationArrivalTracker;
import com.zy.core.utils.DeviceLogRedisKeyBuilder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@@ -54,10 +55,12 @@
private int deviceLogCollectTime = 200;
private long deviceDataLogTime = System.currentTimeMillis();
private ExecutorService executor = Executors.newFixedThreadPool(9999);
+ private final RecentStationArrivalTracker recentArrivalTracker;
public ZyStationV3Thread(DeviceConfig deviceConfig, RedisUtil redisUtil) {
this.deviceConfig = deviceConfig;
this.redisUtil = redisUtil;
+ this.recentArrivalTracker = new RecentStationArrivalTracker(redisUtil);
}
@Override
@@ -148,6 +151,7 @@
stationProtocol.setRunBlock(statusEntity.isRunBlock());
stationProtocol.setEnableIn(statusEntity.isEnableIn());
stationProtocol.setWeight(statusEntity.getWeight());
+ recentArrivalTracker.observe(statusEntity.getStationId(), statusEntity.getTaskNo(), statusEntity.isLoading());
}
if (!Cools.isEmpty(stationProtocol.getSystemWarning())) {
@@ -208,7 +212,22 @@
}
@Override
+ public boolean hasRecentArrival(Integer stationId, Integer taskNo) {
+ return recentArrivalTracker.hasRecentArrival(stationId, taskNo);
+ }
+
+ @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);
@@ -218,7 +237,7 @@
if (commandType == StationCommandType.MOVE) {
if (!stationId.equals(targetStationId)) {
- List<Integer> path = calcPathStationIds(stationId, targetStationId);
+ List<Integer> path = calcPathStationIds(taskNo, stationId, targetStationId, pathLenFactor);
if (path == null || path.isEmpty()) {
log.warn("杈撻�佺嚎鍛戒护鐢熸垚澶辫触锛岃矾寰勪负绌猴紝taskNo={}, stationId={}, targetStationId={}",
taskNo, stationId, targetStationId);
@@ -281,12 +300,15 @@
return zyStationConnectDriver.readOriginCommand(address, length);
}
- private List<Integer> calcPathStationIds(Integer startStationId, Integer targetStationId) {
+ private List<Integer> calcPathStationIds(Integer taskNo,
+ Integer startStationId,
+ Integer targetStationId,
+ Double pathLenFactor) {
NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
if (navigateUtils == null) {
return new ArrayList<>();
}
- List<NavigateNode> nodes = navigateUtils.calcByStationId(startStationId, targetStationId);
+ List<NavigateNode> nodes = navigateUtils.calcByStationId(startStationId, targetStationId, taskNo, pathLenFactor);
List<Integer> ids = new ArrayList<>();
for (NavigateNode n : nodes) {
JSONObject v = JSONObject.parseObject(n.getNodeValue());
@@ -467,4 +489,9 @@
} catch (Exception ignore) {
}
}
+
+ @Override
+ public boolean clearPath(Integer taskNo) {
+ return false;
+ }
}
--
Gitblit v1.9.1