From 51a1786ef3e4e016d5f3f7bad8c2e2e8a84247a6 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 22 三月 2026 18:42:19 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java | 136 +++++++++++++++++++++++++++++++++++++++++----
1 files changed, 123 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
index 52cc748..eb997b1 100644
--- a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
@@ -15,6 +15,7 @@
import com.zy.asrs.service.BasCrnpService;
import com.zy.asrs.service.BasStationService;
import com.zy.asrs.service.LocMastService;
+import com.zy.asrs.service.WrkAnalysisService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.NotifyUtils;
import com.zy.asrs.utils.Utils;
@@ -63,6 +64,10 @@
private NotifyUtils notifyUtils;
@Autowired
private StationOperateProcessUtils stationOperateProcessUtils;
+ @Autowired
+ private WrkAnalysisService wrkAnalysisService;
+
+ private static final String CRN_OUT_REQUIRE_STATION_OUT_ENABLE_CONFIG = "crnOutRequireStationOutEnable";
public synchronized void crnIoExecute() {
Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
@@ -125,7 +130,7 @@
List<WrkMast> taskQueue = wrkMastService.list(new QueryWrapper<WrkMast>()
.in("crn_no", new ArrayList<>(dispatchCrnMap.keySet()))
.in("wrk_sts",
- WrkStsType.INBOUND_DEVICE_RUN.sts,
+ WrkStsType.INBOUND_STATION_RUN_COMPLETE.sts,
WrkStsType.NEW_OUTBOUND.sts,
WrkStsType.NEW_LOC_MOVE.sts));
taskQueue.sort(Comparator
@@ -148,7 +153,7 @@
continue;
}
- if (wrkMast.getWrkSts() != null && wrkMast.getWrkSts() == WrkStsType.INBOUND_DEVICE_RUN.sts) {
+ if (wrkMast.getWrkSts() != null && wrkMast.getWrkSts() == WrkStsType.INBOUND_STATION_RUN_COMPLETE.sts) {
boolean result = this.crnExecuteInPlanner(basCrnp, crnThread, wrkMast);
if (result) {
crnProtocol.setLastIo("O");
@@ -273,7 +278,7 @@
continue;
}
- if(wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts){
+ if(wrkMast.getWrkSts() != WrkStsType.INBOUND_STATION_RUN_COMPLETE.sts){
continue;
}
@@ -300,11 +305,14 @@
CrnCommand command = crnThread.getPickAndPutCommand(sourceLocNo, wrkMast.getLocNo(), wrkMast.getWrkNo(), crnNo);
+ Date now = new Date();
wrkMast.setWrkSts(WrkStsType.INBOUND_RUN.sts);
wrkMast.setCrnNo(crnNo);
wrkMast.setSystemMsg("");
- wrkMast.setIoTime(new Date());
+ wrkMast.setIoTime(now);
+ wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
+ wrkAnalysisService.markCraneStart(wrkMast, now);
MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_IN_TASK_RUN, null);
News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
@@ -374,7 +382,7 @@
continue;
}
- if (!stationProtocol.isOutEnable()) {
+ if (isRequireOutboundStationOutEnable() && !stationProtocol.isOutEnable()) {
News.taskInfo(wrkMast.getWrkNo(), "鏀捐揣绔欑偣:{} 娌℃湁鍙嚭淇″彿", stationObjModel.getStationId());
continue;
}
@@ -402,11 +410,14 @@
CrnCommand command = crnThread.getPickAndPutCommand(wrkMast.getSourceLocNo(), targetLocNo, wrkMast.getWrkNo(), crnNo);
+ Date now = new Date();
wrkMast.setWrkSts(WrkStsType.OUTBOUND_RUN.sts);
wrkMast.setCrnNo(crnNo);
wrkMast.setSystemMsg("");
- wrkMast.setIoTime(new Date());
+ wrkMast.setIoTime(now);
+ wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
+ wrkAnalysisService.markCraneStart(wrkMast, now);
MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_OUT_TASK_RUN, null);
News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
@@ -469,7 +480,7 @@
continue;
}
- if (wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
+ if (wrkMast.getWrkSts() != WrkStsType.INBOUND_STATION_RUN_COMPLETE.sts) {
continue;
}
@@ -496,11 +507,14 @@
CrnCommand command = crnThread.getPickAndPutCommand(sourceLocNo, wrkMast.getLocNo(), wrkMast.getWrkNo(), crnNo);
+ Date now = new Date();
wrkMast.setWrkSts(WrkStsType.INBOUND_RUN.sts);
wrkMast.setCrnNo(crnNo);
wrkMast.setSystemMsg("");
- wrkMast.setIoTime(new Date());
+ wrkMast.setIoTime(now);
+ wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
+ wrkAnalysisService.markCraneStart(wrkMast, now);
MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_IN_TASK_RUN, null);
News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
@@ -565,7 +579,7 @@
continue;
}
- if (!stationProtocol.isOutEnable()) {
+ if (isRequireOutboundStationOutEnable() && !stationProtocol.isOutEnable()) {
News.taskInfo(wrkMast.getWrkNo(), "鏀捐揣绔欑偣:{} 娌℃湁鍙嚭淇″彿", stationObjModel.getStationId());
continue;
}
@@ -593,11 +607,14 @@
CrnCommand command = crnThread.getPickAndPutCommand(wrkMast.getSourceLocNo(), targetLocNo, wrkMast.getWrkNo(), crnNo);
+ Date now = new Date();
wrkMast.setWrkSts(WrkStsType.OUTBOUND_RUN.sts);
wrkMast.setCrnNo(crnNo);
wrkMast.setSystemMsg("");
- wrkMast.setIoTime(new Date());
+ wrkMast.setIoTime(now);
+ wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
+ wrkAnalysisService.markCraneStart(wrkMast, now);
MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_OUT_TASK_RUN, null);
News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
@@ -645,6 +662,24 @@
return true;
}
+ List<WrkMast> unfinishedBatchWrkMasts = listUnfinishedBatchWrkMasts(wrkMast.getBatch());
+ if (hasMissingBatchSeq(unfinishedBatchWrkMasts)) {
+ News.taskInfo(wrkMast.getWrkNo(), "鎵规:{} 瀛樺湪鏈厤缃壒娆″簭鍙风殑鏈畬鎴愪换鍔★紝鏆備笉鍏佽鍫嗗灈鏈哄嚭搴�", wrkMast.getBatch());
+ return false;
+ }
+
+ if (!isWithinBatchExecuteWindow(wrkMast, unfinishedBatchWrkMasts, batchRunningLimit)) {
+ Integer windowStartSeq = unfinishedBatchWrkMasts.get(0).getBatchSeq();
+ Integer windowEndSeq = unfinishedBatchWrkMasts.get(Math.min(batchRunningLimit, unfinishedBatchWrkMasts.size()) - 1).getBatchSeq();
+ News.taskInfo(wrkMast.getWrkNo(),
+ "鎵规:{} 褰撳墠涓ユ牸鎵ц绐楀彛搴忓彿涓篬{}-{}]锛屽綋鍓嶅簭鍙�={}锛屾殏涓嶅厑璁稿爢鍨涙満鍑哄簱",
+ wrkMast.getBatch(),
+ windowStartSeq,
+ windowEndSeq,
+ wrkMast.getBatchSeq());
+ return false;
+ }
+
long batchRunningCount = wrkMastService.count(new QueryWrapper<WrkMast>()
.eq("io_type", WrkIoType.OUT.id)
.eq("batch", wrkMast.getBatch())
@@ -658,6 +693,46 @@
}
return true;
+ }
+
+ private List<WrkMast> listUnfinishedBatchWrkMasts(String batch) {
+ if (Cools.isEmpty(batch)) {
+ return new ArrayList<>();
+ }
+ return wrkMastService.list(new QueryWrapper<WrkMast>()
+ .eq("io_type", WrkIoType.OUT.id)
+ .eq("batch", batch)
+ .notIn("wrk_sts",
+ WrkStsType.COMPLETE_OUTBOUND.sts,
+ WrkStsType.SETTLE_OUTBOUND.sts)
+ .orderByAsc("batch_seq")
+ .orderByAsc("wrk_no"));
+ }
+
+ private boolean hasMissingBatchSeq(List<WrkMast> wrkMasts) {
+ if (wrkMasts == null || wrkMasts.isEmpty()) {
+ return false;
+ }
+ for (WrkMast item : wrkMasts) {
+ if (item == null || Cools.isEmpty(item.getBatchSeq())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isWithinBatchExecuteWindow(WrkMast wrkMast, List<WrkMast> unfinishedBatchWrkMasts, int batchRunningLimit) {
+ if (wrkMast == null || unfinishedBatchWrkMasts == null || unfinishedBatchWrkMasts.isEmpty()) {
+ return true;
+ }
+ int windowSize = Math.min(batchRunningLimit, unfinishedBatchWrkMasts.size());
+ for (int i = 0; i < windowSize; i++) {
+ WrkMast current = unfinishedBatchWrkMasts.get(i);
+ if (current != null && wrkMast.getWrkNo().equals(current.getWrkNo())) {
+ return true;
+ }
+ }
+ return false;
}
private boolean isOutboundStationTaskLimitReached() {
@@ -707,6 +782,32 @@
}
}
+ private boolean isRequireOutboundStationOutEnable() {
+ return getSystemConfigBoolean(CRN_OUT_REQUIRE_STATION_OUT_ENABLE_CONFIG, true);
+ }
+
+ private boolean getSystemConfigBoolean(String code, boolean defaultValue) {
+ Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+ if (!(systemConfigMapObj instanceof Map)) {
+ return defaultValue;
+ }
+ try {
+ Object value = ((Map<?, ?>) systemConfigMapObj).get(code);
+ if (value == null) {
+ return defaultValue;
+ }
+ String text = String.valueOf(value).trim();
+ if ("Y".equalsIgnoreCase(text) || "true".equalsIgnoreCase(text) || "1".equals(text)) {
+ return true;
+ }
+ if ("N".equalsIgnoreCase(text) || "false".equalsIgnoreCase(text) || "0".equals(text)) {
+ return false;
+ }
+ } catch (Exception ignore) {
+ }
+ return defaultValue;
+ }
+
private synchronized boolean crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) {
CrnProtocol crnProtocol = crnThread.getStatus();
if(crnProtocol == null){
@@ -747,11 +848,14 @@
CrnCommand command = crnThread.getPickAndPutCommand(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), wrkMast.getWrkNo(), crnNo);
+ Date now = new Date();
wrkMast.setWrkSts(WrkStsType.LOC_MOVE_RUN.sts);
wrkMast.setCrnNo(crnNo);
wrkMast.setSystemMsg("");
- wrkMast.setIoTime(new Date());
+ wrkMast.setIoTime(now);
+ wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
+ wrkAnalysisService.markCraneStart(wrkMast, now);
MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_TRANSFER_TASK_RUN, null);
News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
@@ -792,6 +896,7 @@
}
Long updateWrkSts = null;
+ Date now = new Date();
if(wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts){
updateWrkSts = WrkStsType.COMPLETE_INBOUND.sts;
notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_IN_TASK_COMPLETE, null);
@@ -823,8 +928,10 @@
wrkMast.setWrkSts(updateWrkSts);
wrkMast.setSystemMsg("");
- wrkMast.setIoTime(new Date());
+ wrkMast.setIoTime(now);
+ wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
+ wrkAnalysisService.markCraneComplete(wrkMast, now, updateWrkSts);
CrnCommand resetCommand = crnThread.getResetCommand(crnProtocol.getTaskNo(), crnProtocol.getCrnNo());
MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, resetCommand));
News.info("鍫嗗灈鏈轰换鍔$姸鎬佹洿鏂版垚鍔燂紝鍫嗗灈鏈哄彿={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
@@ -970,11 +1077,14 @@
CrnCommand command = crnThread.getPickAndPutCommand(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), wrkMast.getWrkNo(), crnNo);
+ Date now = new Date();
wrkMast.setWrkSts(WrkStsType.LOC_MOVE_RUN.sts);
wrkMast.setCrnNo(crnNo);
wrkMast.setSystemMsg("");
- wrkMast.setIoTime(new Date());
+ wrkMast.setIoTime(now);
+ wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
+ wrkAnalysisService.markCraneStart(wrkMast, now);
MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_TRANSFER_TASK_RUN, null);
News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
--
Gitblit v1.9.1