| | |
| | | public class WorkMastScheduler { |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(WorkMastScheduler.class); |
| | | private static final long OUT_LOCK_REPORT_SUCCESS_WRK_STS = 21L; |
| | | private static final long OUT_LOCK_REPORT_FAIL_WRK_STS = 22L; |
| | | |
| | | @Autowired |
| | | private WcsApiService wcsApiService; |
| | |
| | | |
| | | for (String batchSeq : batchSeqs) { |
| | | String blockingBatchSeq = findFirstUnfinishedOutboundBatchSeq(userNo); |
| | | if (!Objects.equals(batchSeq, blockingBatchSeq)) { |
| | | if (blockingBatchSeq != null && compareBatchSeqNatural(batchSeq, blockingBatchSeq) != 0) { |
| | | log.info("出库批次未完成,暂停后续下发, userNo={}, blockingBatchSeq={}, nextBatchSeq={}", |
| | | userNo, blockingBatchSeq, batchSeq); |
| | | break; |
| | |
| | | .setTaskPri(wrkMast.getIoPri().intValue()) |
| | | .setBarcode(wrkMast.getBarcode()); |
| | | if (wrkMast.getPltType() != null && wrkMast.getPltType() > 0) { |
| | | params.setBatch(wrkMast.getUserNo()) |
| | | params.setBatch(wrkMast.getBatchSeq()) |
| | | .setBatchSeq(wrkMast.getPltType()); |
| | | } |
| | | // 2: 入库。入库接口使用 sourceStaNo + 目标库位。 |
| | |
| | | wrapper.eq("user_no", userNo); |
| | | } |
| | | wrapper.eq("io_type", 101); |
| | | wrapper.lt("wrk_sts", 14); |
| | | 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; |
| | |
| | | private int compareBatchSeqNatural(String left, String right) { |
| | | String safeLeft = Cools.isEmpty(left) ? "" : left; |
| | | String safeRight = Cools.isEmpty(right) ? "" : right; |
| | | boolean leftNumeric = isDigits(safeLeft); |
| | | boolean rightNumeric = isDigits(safeRight); |
| | | if (leftNumeric && rightNumeric) { |
| | | BigInteger leftValue = new BigInteger(safeLeft); |
| | | BigInteger rightValue = new BigInteger(safeRight); |
| | | int compare = leftValue.compareTo(rightValue); |
| | | 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 safeLeft.compareTo(safeRight); |
| | | } |
| | | |
| | | private boolean isDigits(String value) { |
| | | if (Cools.isEmpty(value)) { |
| | | return false; |
| | | } |
| | | for (int i = 0; i < value.length(); i++) { |
| | | if (!Character.isDigit(value.charAt(i))) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | return Integer.compare(safeLeft.length(), safeRight.length()); |
| | | } |
| | | |
| | | private String normalizeGroupKey(String value) { |