From 9f13307b0ad0d7a0bac431773ec073cb93b170d4 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 02 四月 2026 18:50:23 +0800
Subject: [PATCH] #预调度堆垛机2
---
src/main/java/com/zy/asrs/task/InboundCrnMoveDispatchScheduler.java | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/zy/asrs/task/InboundCrnMoveDispatchScheduler.java b/src/main/java/com/zy/asrs/task/InboundCrnMoveDispatchScheduler.java
index f4eb982..0be9284 100644
--- a/src/main/java/com/zy/asrs/task/InboundCrnMoveDispatchScheduler.java
+++ b/src/main/java/com/zy/asrs/task/InboundCrnMoveDispatchScheduler.java
@@ -22,9 +22,13 @@
import com.zy.core.move.StationMoveSession;
import com.zy.core.thread.StationThread;
import com.zy.core.utils.CrnOperateProcessUtils;
+import com.zy.common.utils.RedisUtil;
+import com.zy.core.enums.RedisKeyType;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
+import java.util.Comparator;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -40,19 +44,22 @@
private final BasCrnpService basCrnpService;
private final CrnOperateProcessUtils crnOperateProcessUtils;
private final StationMoveCoordinator stationMoveCoordinator;
+ private final RedisUtil redisUtil;
public InboundCrnMoveDispatchScheduler(WrkMastService wrkMastService,
BasStationService basStationService,
CommonService commonService,
BasCrnpService basCrnpService,
CrnOperateProcessUtils crnOperateProcessUtils,
- StationMoveCoordinator stationMoveCoordinator) {
+ StationMoveCoordinator stationMoveCoordinator,
+ RedisUtil redisUtil) {
this.wrkMastService = wrkMastService;
this.basStationService = basStationService;
this.commonService = commonService;
this.basCrnpService = basCrnpService;
this.crnOperateProcessUtils = crnOperateProcessUtils;
this.stationMoveCoordinator = stationMoveCoordinator;
+ this.redisUtil = redisUtil;
}
@Scheduled(fixedDelay = 1000L)
@@ -180,6 +187,7 @@
return pendingOutboundTasks.stream()
.filter(this::isBatchTaskWithSeq)
+ .filter(task -> isWithinCurrentBatchExecuteWindow(task, pendingOutboundTasks))
.filter(this::isCrnMoveBlockingOutboundTask)
.anyMatch(task -> Objects.equals(activeBatch, task.getBatch()));
}
@@ -216,6 +224,45 @@
|| Objects.equals(wrkMast.getWrkSts(), WrkStsType.OUTBOUND_MANUAL.sts);
}
+ private boolean isWithinCurrentBatchExecuteWindow(WrkMast wrkMast, List<WrkMast> pendingOutboundTasks) {
+ if (!isBatchTaskWithSeq(wrkMast) || pendingOutboundTasks == null || pendingOutboundTasks.isEmpty()) {
+ return false;
+ }
+ int batchRunningLimit = getSystemConfigInt("crnOutBatchRunningLimit", 5);
+ if (batchRunningLimit <= 0) {
+ return true;
+ }
+ List<WrkMast> sameBatchTasks = pendingOutboundTasks.stream()
+ .filter(this::isBatchTaskWithSeq)
+ .filter(task -> Objects.equals(task.getBatch(), wrkMast.getBatch()))
+ .sorted(Comparator.comparing(WrkMast::getBatchSeq).thenComparing(WrkMast::getWrkNo))
+ .collect(Collectors.toList());
+ if (sameBatchTasks.isEmpty()) {
+ return false;
+ }
+ int windowSize = Math.min(batchRunningLimit, sameBatchTasks.size());
+ for (int i = 0; i < windowSize; i++) {
+ WrkMast current = sameBatchTasks.get(i);
+ if (current != null && Objects.equals(current.getWrkNo(), wrkMast.getWrkNo())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private int getSystemConfigInt(String code, int defaultValue) {
+ Object systemConfigMapObj = redisUtil == null ? null : redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+ if (!(systemConfigMapObj instanceof HashMap)) {
+ return defaultValue;
+ }
+ try {
+ HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
+ return Integer.parseInt(systemConfigMap.getOrDefault(code, String.valueOf(defaultValue)));
+ } catch (Exception ignore) {
+ return defaultValue;
+ }
+ }
+
private boolean isInboundCrnMoveDispatchWindow(WrkMast wrkMast, StationMoveSession session) {
if (wrkMast == null || session == null || !session.isActive() || wrkMast.getStaNo() == null) {
return false;
--
Gitblit v1.9.1