From bdf43f554f9bc7f0de94e7530e79af9193341334 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 19 三月 2026 15:38:49 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java | 46 ++++++++++++++++++----
src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java | 43 ++++++++++++++++++---
src/main/resources/sql/20260319_add_fake_run_block_timeout_config.sql | 15 +++++++
3 files changed, 89 insertions(+), 15 deletions(-)
diff --git a/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java b/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
index df51cce..a0f0ae3 100644
--- a/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
@@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Random;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -31,6 +32,7 @@
* 杈撻�佺珯鍋囪繛鎺ワ紙妯℃嫙锛�
*/
public class ZyStationFakeConnect implements ZyStationConnectApi {
+ private static final long DEFAULT_FAKE_RUN_BLOCK_TIMEOUT_MS = 10000L;
private static int LOCK_STATION = 0;
private HashMap<Integer, List<ZyStationStatusEntity>> deviceStatusMap = new HashMap<>();
@@ -346,6 +348,7 @@
Integer targetStationDeviceNo = null;
long executeTime = System.currentTimeMillis();
+ long runBlockTimeoutMs = getFakeRunBlockTimeoutMs();
int i = 0;
while (i < navigateNodes.size()) {
if (Thread.currentThread().isInterrupted()) {
@@ -372,16 +375,9 @@
}
if (!checkTaskNoInArea(taskNo)) {
- boolean fakeAllowCheckBlock = true;
- Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
- if (systemConfigMapObj != null) {
- HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
- if (!systemConfigMap.get("fakeAllowCheckBlock").equals("Y")) {
- fakeAllowCheckBlock = false;
- }
- }
+ boolean fakeAllowCheckBlock = getFakeAllowCheckBlock();
- if (fakeAllowCheckBlock && System.currentTimeMillis() - executeTime > 1000 * 10) {
+ if (fakeAllowCheckBlock && System.currentTimeMillis() - executeTime > runBlockTimeoutMs) {
//璁ゅ畾鍫靛
boolean result = runBlockStation(taskNo, currentStationId, currentStationDeviceNo, taskNo, currentStationId);
if(!result) {
@@ -687,6 +683,38 @@
return result;
}
+ private boolean getFakeAllowCheckBlock() {
+ boolean fakeAllowCheckBlock = true;
+ Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+ if (systemConfigMapObj instanceof Map) {
+ Map<?, ?> systemConfigMap = (Map<?, ?>) systemConfigMapObj;
+ Object value = systemConfigMap.get("fakeAllowCheckBlock");
+ if (value != null && !"Y".equals(String.valueOf(value))) {
+ fakeAllowCheckBlock = false;
+ }
+ }
+ return fakeAllowCheckBlock;
+ }
+
+ private long getFakeRunBlockTimeoutMs() {
+ long timeoutMs = DEFAULT_FAKE_RUN_BLOCK_TIMEOUT_MS;
+ Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+ if (systemConfigMapObj instanceof Map) {
+ Map<?, ?> systemConfigMap = (Map<?, ?>) systemConfigMapObj;
+ Object value = systemConfigMap.get("fakeRunBlockTimeoutMs");
+ if (value != null) {
+ try {
+ long parsed = Long.parseLong(String.valueOf(value).trim());
+ if (parsed > 0) {
+ timeoutMs = parsed;
+ }
+ } catch (Exception ignore) {
+ }
+ }
+ }
+ return timeoutMs;
+ }
+
private boolean checkTaskNoInArea(Integer taskNo) {
Object fakeTaskNoAreaObj = redisUtil.get(RedisKeyType.FAKE_TASK_NO_AREA.key);
if (fakeTaskNoAreaObj == null) {
diff --git a/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java b/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java
index e6bd3be..d2cfe98 100644
--- a/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java
@@ -27,6 +27,7 @@
import java.util.Arrays;
public class ZyStationFakeSegConnect implements ZyStationConnectApi {
+ private static final long DEFAULT_FAKE_RUN_BLOCK_TIMEOUT_MS = 10000L;
// 绔欑偣绾ч攣锛氭瘡涓珯鐐圭嫭绔嬩竴鎶婇攣锛屾彁鍗囧苟鍙戞�ц兘
private final Map<Integer, ReentrantLock> stationLocks = new ConcurrentHashMap<>();
@@ -128,6 +129,7 @@
boolean initialized = false;
// 涓婁竴姝ユ墽琛屾椂闂达紙鐢ㄤ簬鍫靛妫�娴嬶級
long stepExecuteTime = System.currentTimeMillis();
+ long runBlockTimeoutMs = getFakeRunBlockTimeoutMs();
// 浠呭湪姣忔鍒拌揪鐩爣鏃舵墽琛屼竴娆″埌浣嶅鐞嗭紝閬垮厤閲嶅鐢熸垚鏉$爜
boolean arrivalHandled = false;
@@ -145,6 +147,15 @@
StationCommand command = commandQueue.poll(100, TimeUnit.MILLISECONDS);
if (command != null) {
taskLastUpdateTime.put(taskNo, System.currentTimeMillis());
+ List<Integer> newPath = command.getNavigatePath();
+ Integer lastInQueue = getLastInQueue(pendingPathQueue);
+ int startIndex = getPathAppendStartIndex(newPath, currentStationId, lastInQueue);
+
+ if (newPath != null && !newPath.isEmpty() && startIndex < 0) {
+ News.info("[WCS Debug] 浠诲姟{}蹇界暐鏃犳硶琛旀帴鐨勬棫璺緞娈�: {}, 褰撳墠浣嶇疆: {}, 闃熷垪灏�: {}", taskNo,
+ newPath, currentStationId, lastInQueue);
+ continue;
+ }
// 姣忔鎺ユ敹鍛戒护閮藉埛鏂扮洰鏍囷紝閬垮厤娌跨敤鏃х洰鏍囧鑷寸姸鎬佹姈鍔�
Integer commandTargetStationId = command.getTargetStaNo();
@@ -164,12 +175,7 @@
}
// 灏嗘柊璺緞杩藉姞鍒板緟鎵ц闃熷垪
- List<Integer> newPath = command.getNavigatePath();
if (newPath != null && !newPath.isEmpty()) {
- // 鑾峰彇闃熷垪涓渶鍚庝竴涓珯鐐癸紙鐢ㄤ簬琛旀帴鐐瑰幓閲嶏級
- Integer lastInQueue = getLastInQueue(pendingPathQueue);
- int startIndex = getPathAppendStartIndex(newPath, currentStationId, lastInQueue);
-
for (int i = startIndex; i < newPath.size(); i++) {
pendingPathQueue.offer(newPath.get(i));
}
@@ -244,7 +250,8 @@
if (!checkTaskNoInArea(taskNo)) {
boolean fakeAllowCheckBlock = getFakeAllowCheckBlock();
- if (fakeAllowCheckBlock && System.currentTimeMillis() - stepExecuteTime > 10000) {
+ if (fakeAllowCheckBlock
+ && System.currentTimeMillis() - stepExecuteTime > runBlockTimeoutMs) {
// 璁ゅ畾鍫靛
boolean result = runBlockStation(taskNo, currentStationId, currentDeviceNo, taskNo,
currentStationId);
@@ -330,6 +337,11 @@
if (idx >= 0) {
return idx + 1;
}
+ return -1;
+ }
+
+ if (lastInQueue != null) {
+ return -1;
}
return 0;
@@ -387,6 +399,25 @@
return fakeAllowCheckBlock;
}
+ private long getFakeRunBlockTimeoutMs() {
+ long timeoutMs = DEFAULT_FAKE_RUN_BLOCK_TIMEOUT_MS;
+ Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+ if (systemConfigMapObj instanceof Map) {
+ Map<?, ?> systemConfigMap = (Map<?, ?>) systemConfigMapObj;
+ Object value = systemConfigMap.get("fakeRunBlockTimeoutMs");
+ if (value != null) {
+ try {
+ long parsed = Long.parseLong(String.valueOf(value).trim());
+ if (parsed > 0) {
+ timeoutMs = parsed;
+ }
+ } catch (Exception ignore) {
+ }
+ }
+ }
+ return timeoutMs;
+ }
+
@Override
public CommandResponse sendOriginCommand(String address, short[] data) {
return new CommandResponse(true, "鍘熷鍛戒护宸插彈鐞嗭紙寮傛鎵ц锛�");
diff --git a/src/main/resources/sql/20260319_add_fake_run_block_timeout_config.sql b/src/main/resources/sql/20260319_add_fake_run_block_timeout_config.sql
new file mode 100644
index 0000000..d8d78ee
--- /dev/null
+++ b/src/main/resources/sql/20260319_add_fake_run_block_timeout_config.sql
@@ -0,0 +1,15 @@
+-- 杈撻�佺嚎浠跨湡鍒ゅ畾鍫靛瓒呮椂鏃堕棿锛屽崟浣嶆绉�
+-- 榛樿 10000ms锛屼笌鐜版湁纭紪鐮佽涓轰繚鎸佷竴鑷�
+
+INSERT INTO sys_config(name, code, value, type, status, select_type)
+SELECT '杈撻�佺嚎浠跨湡鍒ゅ畾鍫靛瓒呮椂鏃堕棿(姣)', 'fakeRunBlockTimeoutMs', '10000', 1, 1, 'fake'
+FROM dual
+WHERE NOT EXISTS (
+ SELECT 1
+ FROM sys_config
+ WHERE code = 'fakeRunBlockTimeoutMs'
+);
+
+SELECT id, name, code, value, type, status, select_type
+FROM sys_config
+WHERE code = 'fakeRunBlockTimeoutMs';
--
Gitblit v1.9.1