From 98d120bd0633e4e0717d584cae5514132a18516b Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 18 十二月 2025 13:36:09 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java | 89 +++++++++++++++++++++++++++++++++++---------
1 files changed, 71 insertions(+), 18 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..0aea24a 100644
--- a/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
@@ -63,6 +63,7 @@
status.setOutEnable(true);// 妯℃嫙鍙嚭
status.setEmptyMk(false);// 妯℃嫙绌烘澘淇″彿
status.setFullPlt(false);// 妯℃嫙婊℃墭鐩�
+ status.setRunBlock(false);// 杩愯鏃犲牭濉�
status.setPalletHeight(0);// 妯℃嫙鎵樼洏楂樺害涓�0
status.setError(0);// 妯℃嫙鏃犳姤璀�
status.setBarcode("");// 妯℃嫙鏃犳潯鐮�
@@ -263,15 +264,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 +292,15 @@
}
- if (nextStationId != null) {
-
+ if (!checkTaskNoInArea(taskNo)) {
+ if (System.currentTimeMillis() - executeTime > 1000 * 10) {
+ //璁ゅ畾鍫靛
+ boolean result = runBlockStation(taskNo, currentStationId, taskNo, currentStationId);
+ if(!result) {
+ continue;
+ }
+ return false;
+ }
}
if (i == 0) {
@@ -295,6 +309,9 @@
continue;
}
sleep(1000);
+ if (Thread.currentThread().isInterrupted()) {
+ return false;
+ }
}
if(nextStationId != null) {
@@ -306,12 +323,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 +348,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 +365,15 @@
}
}
}
+
+ return true;
}
private void sleep(long ms) {
try {
Thread.sleep(ms);
} catch (InterruptedException e) {
- e.printStackTrace();
+ Thread.currentThread().interrupt();
}
}
@@ -366,7 +398,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 +425,10 @@
if (barcode != null) {
currentStatus.setBarcode(barcode);
}
+
+ if(runBlock != null) {
+ currentStatus.setRunBlock(runBlock);
+ }
return true;
}
@@ -405,15 +441,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 +473,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 +500,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 +519,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