From 7294ef58d1a343bdc765773ba69928820ce0d20f Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期一, 20 四月 2026 21:30:43 +0800
Subject: [PATCH] 1.出库任务下发 2.新增双伸堆垛机入库找库位 3.12天入库体积统计
---
src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java | 142 +++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 125 insertions(+), 17 deletions(-)
diff --git a/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java b/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
index 582ec1d..3d39bb7 100644
--- a/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
+++ b/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
@@ -35,6 +35,7 @@
import java.io.IOException;
import java.math.BigDecimal;
+import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -203,6 +204,7 @@
List<String> failMsgs = new ArrayList<>();
List<WorkTaskParams> lastSentChunk = null;
String skipGroupKey = null;
+ Set<String> blockedOutboundUserKeys = new HashSet<>();
for (List<WorkTaskParams> chunk : chunks) {
if (chunk == null || chunk.isEmpty()) {
@@ -211,8 +213,22 @@
WorkTaskParams head = chunk.get(0);
WrkMast headMast = wrkMastMap.get(head.getTaskNo());
String key = buildBatchGroupKey(head, headMast);
+ String outboundUserKey = buildOutboundUserKey(head, headMast);
if (skipGroupKey != null && skipGroupKey.equals(key)) {
+ continue;
+ }
+ if (outboundUserKey != null && blockedOutboundUserKeys.contains(outboundUserKey)) {
+ continue;
+ }
+
+ String batchBlockMsg = validateOutboundBatchSeqReady(chunk, wrkMastMap);
+ if (!Cools.isEmpty(batchBlockMsg)) {
+ skipMsgs.add(batchBlockMsg);
+ skipGroupKey = key;
+ if (outboundUserKey != null) {
+ blockedOutboundUserKeys.add(outboundUserKey);
+ }
continue;
}
@@ -464,6 +480,56 @@
return outboundPltSlotReleasedInWms(userNo, batchGroup, minPlt - 1);
}
+ private String validateOutboundBatchSeqReady(List<WorkTaskParams> chunk, Map<String, WrkMast> wrkMastMap) {
+ if (chunk == null || chunk.isEmpty()) {
+ return null;
+ }
+ WorkTaskParams head = chunk.get(0);
+ if (!"out".equalsIgnoreCase(head.getType())) {
+ return null;
+ }
+ WrkMast headMast = wrkMastMap.get(head.getTaskNo());
+ String userNo = sortUserNoForPub(head, headMast);
+ if (Cools.isEmpty(userNo)) {
+ return null;
+ }
+ String batchSeq = sortBatchGroupForPub(head, headMast);
+ String blockingBatchSeq = findFirstUnfinishedOutboundBatchSeq(userNo);
+ if (blockingBatchSeq == null || compareBatchSeqNatural(batchSeq, blockingBatchSeq) == 0) {
+ return null;
+ }
+ return "鍑哄簱鎵规鏈畬鎴愶紝鏆傚仠鍚庣画涓嬪彂, userNo=" + userNo
+ + ", blockingBatchSeq=" + normalizeBatchSeq(blockingBatchSeq)
+ + ", nextBatchSeq=" + normalizeBatchSeq(batchSeq);
+ }
+
+ private String findFirstUnfinishedOutboundBatchSeq(String userNo) {
+ EntityWrapper<WrkMast> wrapper = new EntityWrapper<>();
+ if (Cools.isEmpty(userNo)) {
+ wrapper.isNull("user_no");
+ } else {
+ wrapper.eq("user_no", userNo);
+ }
+ wrapper.eq("io_type", 101);
+ wrapper.last(" and (wrk_sts < 14 or wrk_sts in ("
+ + OUT_LOCK_REPORT_SUCCESS_WRK_STS + "," + OUT_LOCK_REPORT_FAIL_WRK_STS + "))");
+ List<WrkMast> rows = wrkMastService.selectList(wrapper);
+ if (rows == null || rows.isEmpty()) {
+ return null;
+ }
+ String firstBatchSeq = null;
+ for (WrkMast row : rows) {
+ if (row == null) {
+ continue;
+ }
+ String batchSeq = sortBatchGroupForPub(null, row);
+ if (firstBatchSeq == null || compareBatchSeqNatural(batchSeq, firstBatchSeq) < 0) {
+ firstBatchSeq = batchSeq;
+ }
+ }
+ return firstBatchSeq;
+ }
+
private boolean outboundPltSlotReleasedInWms(String userNo, String batchSeq, int pltType) {
EntityWrapper<WrkMast> mastWrapper = new EntityWrapper<>();
mastWrapper.eq("user_no", userNo);
@@ -521,7 +587,7 @@
return Comparator
.comparing((WorkTaskParams p) -> Optional.ofNullable(p.getType()).orElse(""), String.CASE_INSENSITIVE_ORDER)
.thenComparing(p -> sortUserNoForPub(p, wrkMastMap.get(p.getTaskNo())), Comparator.nullsLast(String::compareTo))
- .thenComparing(p -> sortBatchGroupForPub(p, wrkMastMap.get(p.getTaskNo())), Comparator.nullsLast(String::compareTo))
+ .thenComparing(p -> sortBatchGroupForPub(p, wrkMastMap.get(p.getTaskNo())), WcsApiServiceImpl::compareBatchSeqNatural)
.thenComparing(p -> sortPltForPub(p, wrkMastMap.get(p.getTaskNo())), Comparator.nullsLast(Integer::compareTo));
}
@@ -545,6 +611,64 @@
return wrkMast.getBatchSeq();
}
return null;
+ }
+
+ private static String buildOutboundUserKey(WorkTaskParams params, WrkMast wrkMast) {
+ if (params == null || !"out".equalsIgnoreCase(params.getType())) {
+ return null;
+ }
+ String userNo = sortUserNoForPub(params, wrkMast);
+ if (Cools.isEmpty(userNo)) {
+ return null;
+ }
+ return resolveSafeKey(userNo);
+ }
+
+ private static int compareBatchSeqNatural(String left, String right) {
+ String safeLeft = normalizeBatchSeq(left);
+ String safeRight = normalizeBatchSeq(right);
+ int leftIndex = 0;
+ int rightIndex = 0;
+ while (leftIndex < safeLeft.length() && rightIndex < safeRight.length()) {
+ char leftChar = safeLeft.charAt(leftIndex);
+ char rightChar = safeRight.charAt(rightIndex);
+ if (Character.isDigit(leftChar) && Character.isDigit(rightChar)) {
+ int leftStart = leftIndex;
+ int rightStart = rightIndex;
+ while (leftIndex < safeLeft.length() && Character.isDigit(safeLeft.charAt(leftIndex))) {
+ leftIndex++;
+ }
+ while (rightIndex < safeRight.length() && Character.isDigit(safeRight.charAt(rightIndex))) {
+ rightIndex++;
+ }
+ String leftNumber = safeLeft.substring(leftStart, leftIndex);
+ String rightNumber = safeRight.substring(rightStart, rightIndex);
+ int compare = new BigInteger(leftNumber).compareTo(new BigInteger(rightNumber));
+ if (compare != 0) {
+ return compare;
+ }
+ compare = Integer.compare(leftNumber.length(), rightNumber.length());
+ if (compare != 0) {
+ return compare;
+ }
+ continue;
+ }
+ int compare = Character.compare(leftChar, rightChar);
+ if (compare != 0) {
+ return compare;
+ }
+ leftIndex++;
+ rightIndex++;
+ }
+ return Integer.compare(safeLeft.length(), safeRight.length());
+ }
+
+ private static String normalizeBatchSeq(String value) {
+ return Cools.isEmpty(value) ? "" : value;
+ }
+
+ private static String resolveSafeKey(String value) {
+ return Cools.isEmpty(value) ? "_EMPTY_" : value;
}
private static String buildOutboundBatchCacheKey(String userNo, String batchSeq) {
@@ -608,23 +732,7 @@
//wcs浠诲姟鍙栨秷鎺ュ彛
} else if (params.getMsgType().equals("task_cancel")) {
workService.cancelWrkMast(String.valueOf(mast.getWrkNo()), 9955L);
- } else if (params.getMsgType().equals("task_arrive")) {
- //鍒拌揪鐩殑鍦�
- //濡傛灉鍑哄簱浠诲姟鏄法鍖哄垯闇�瑕佺敓鎴愭柊鐨勫叆搴撲换鍔″叆搴�
- if(!Cools.isEmpty(mast.getLocNo())){
- mast.setOnlineYn("N");//绛夊緟鐢熸垚璺ㄥ尯鍏ュ簱浠诲姟
- }
- mast.setWrkSts(14L);
- if(Cools.isEmpty(mast.getStaNo())){
- mast.setOveMk("Y");
- }
- mast.setModiTime(new Date());
- if (!wrkMastService.updateById(mast)) {
- throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
}
- } else if (params.getNotifyType().equals("weight")) {
-
}
return R.ok();
}
--
Gitblit v1.9.1