From 707f8db2227a6031f230e35895ea1c5f7ff03bd6 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 18 十二月 2025 14:43:52 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java | 97 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 80 insertions(+), 17 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 3df812f..7d1b449 100644
--- a/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
@@ -14,6 +14,7 @@
import com.zy.core.network.api.ZyStationConnectApi;
import com.zy.core.network.entity.ZyStationStatusEntity;
+import java.util.HashMap;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -63,6 +64,7 @@
status.setOutEnable(true);// 妯℃嫙鍙嚭
status.setEmptyMk(false);// 妯℃嫙绌烘澘淇″彿
status.setFullPlt(false);// 妯℃嫙婊℃墭鐩�
+ status.setRunBlock(false);// 杩愯鏃犲牭濉�
status.setPalletHeight(0);// 妯℃嫙鎵樼洏楂樺害涓�0
status.setError(0);// 妯℃嫙鏃犳姤璀�
status.setBarcode("");// 妯℃嫙鏃犳潯鐮�
@@ -263,15 +265,21 @@
return;
}
- stationMove(navigateNodes, taskNo, stationId, true, generateBarcode);
- stationMove(targetNavigateNodes, taskNo, targetStationId, false, generateBarcode);
+ boolean result = stationMove(navigateNodes, taskNo, stationId, true, generateBarcode);
+ if(result) {
+ stationMove(targetNavigateNodes, taskNo, targetStationId, false, generateBarcode);
+ }
}
- private void stationMove(List<NavigateNode> navigateNodes, Integer taskNo, Integer targetStationId, boolean clearData, boolean generateBarcode) {
+ private boolean stationMove(List<NavigateNode> navigateNodes, Integer taskNo, Integer targetStationId, boolean clearData, boolean generateBarcode) {
Integer lastStationId = null;
+ long executeTime = System.currentTimeMillis();
int i = 0;
while (i < navigateNodes.size()) {
+ if (Thread.currentThread().isInterrupted()) {
+ return false;
+ }
NavigateNode navigateNode = navigateNodes.get(i);
JSONObject valueObject = JSON.parseObject(navigateNode.getNodeValue());
Integer currentStationId = valueObject.getInteger("stationId");
@@ -285,8 +293,24 @@
}
- if (nextStationId != null) {
+ 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;
+ }
+ }
+ if (fakeAllowCheckBlock && System.currentTimeMillis() - executeTime > 1000 * 10) {
+ //璁ゅ畾鍫靛
+ boolean result = runBlockStation(taskNo, currentStationId, taskNo, currentStationId);
+ if(!result) {
+ continue;
+ }
+ return false;
+ }
}
if (i == 0) {
@@ -295,6 +319,9 @@
continue;
}
sleep(1000);
+ if (Thread.currentThread().isInterrupted()) {
+ return false;
+ }
}
if(nextStationId != null) {
@@ -306,12 +333,19 @@
}
i++;
+ executeTime = System.currentTimeMillis();
sleep(1000);
+ if (Thread.currentThread().isInterrupted()) {
+ return false;
+ }
}
if (generateBarcode) {
if (lastStationId != null) {
while (true) {
+ if (Thread.currentThread().isInterrupted()) {
+ break;
+ }
boolean result = generateStationBarcode(taskNo, targetStationId);
sleep(1000);
if (!result) {
@@ -324,8 +358,14 @@
if (clearData) {
sleep(10000);
+ if (Thread.currentThread().isInterrupted()) {
+ return true;
+ }
if (lastStationId != null) {
while (true) {
+ if (Thread.currentThread().isInterrupted()) {
+ break;
+ }
boolean result = clearStation(taskNo, targetStationId);
sleep(1000);
if (!result) {
@@ -335,13 +375,15 @@
}
}
}
+
+ return true;
}
private void sleep(long ms) {
try {
Thread.sleep(ms);
} catch (InterruptedException e) {
- e.printStackTrace();
+ Thread.currentThread().interrupt();
}
}
@@ -366,7 +408,7 @@
return true;
}
- public synchronized boolean updateStationData(Integer lockTaskNo, Integer stationId, Integer taskNo, Integer targetStaNo, Boolean isLoading, String barcode) {
+ public synchronized boolean updateStationData(Integer lockTaskNo, Integer stationId, Integer taskNo, Integer targetStaNo, Boolean isLoading, String barcode, Boolean runBlock) {
if (LOCK_STATION != lockTaskNo) {
return false;
}
@@ -393,6 +435,10 @@
if (barcode != null) {
currentStatus.setBarcode(barcode);
}
+
+ if(runBlock != null) {
+ currentStatus.setRunBlock(runBlock);
+ }
return true;
}
@@ -405,15 +451,13 @@
return false;
}
- if(currentStatus.getTaskNo().equals(taskNo)) {
- return true;
+ if (currentStatus.getTaskNo() > 0) {
+ if (!currentStatus.getTaskNo().equals(taskNo) && currentStatus.isLoading()) {
+ return false;
+ }
}
- if (currentStatus.getTaskNo() > 0 || currentStatus.isLoading()) {
- return false;
- }
-
- boolean result = updateStationData(taskNo, currentStationId, taskNo, targetStationId, isLoading, barcode);
+ boolean result = updateStationData(taskNo, currentStationId, taskNo, targetStationId, isLoading, barcode, false);
if (!result) {
return false;
}
@@ -439,12 +483,12 @@
return false;
}
- boolean result = updateStationData(lockTaskNo, nextStationId, taskNo, targetStaNo, true, null);
+ boolean result = updateStationData(lockTaskNo, nextStationId, taskNo, targetStaNo, true, null, false);
if (!result) {
return false;
}
- boolean result2 = updateStationData(lockTaskNo, currentStationId, 0, 0, false, null);
+ boolean result2 = updateStationData(lockTaskNo, currentStationId, 0, 0, false, null, false);
if (!result2) {
return false;
}
@@ -466,7 +510,7 @@
String barcodeTime = String.valueOf(System.currentTimeMillis());
String barcode = barcodeTime.substring(5);
- boolean result = updateStationData(lockTaskNo, currentStationId, null, null, null, barcode);
+ boolean result = updateStationData(lockTaskNo, currentStationId, null, null, null, barcode, null);
if (!result) {
return false;
}
@@ -485,7 +529,26 @@
return false;
}
- boolean result = updateStationData(lockTaskNo, currentStationId, 0, 0, false, "");
+ boolean result = updateStationData(lockTaskNo, currentStationId, 0, 0, false, "", false);
+ if (!result) {
+ return false;
+ }
+ return true;
+ });
+
+ return executeResult;
+ }
+
+ public synchronized boolean runBlockStation(Integer lockTaskNo, Integer currentStationId, Integer taskNo, Integer blockStationId) {
+ boolean executeResult = lockExecute(lockTaskNo, () -> {
+ ZyStationStatusEntity currentStatus = statusList.stream()
+ .filter(item -> item.getStationId().equals(currentStationId)).findFirst().orElse(null);
+
+ if (currentStatus == null) {
+ return false;
+ }
+
+ boolean result = updateStationData(lockTaskNo, currentStationId, taskNo, blockStationId, true, "", true);
if (!result) {
return false;
}
--
Gitblit v1.9.1