自动化立体仓库 - WMS系统
zwl
7 天以前 7294ef58d1a343bdc765773ba69928820ce0d20f
src/main/java/com/zy/asrs/task/WorkMastScheduler.java
@@ -32,6 +32,8 @@
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;
@@ -122,7 +124,7 @@
            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;
@@ -157,7 +159,7 @@
                    .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 + 目标库位。
@@ -191,7 +193,8 @@
            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;
@@ -209,29 +212,40 @@
    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;
        }
        return safeLeft.compareTo(safeRight);
                continue;
    }
    private boolean isDigits(String value) {
        if (Cools.isEmpty(value)) {
            return false;
            int compare = Character.compare(leftChar, rightChar);
            if (compare != 0) {
                return compare;
        }
        for (int i = 0; i < value.length(); i++) {
            if (!Character.isDigit(value.charAt(i))) {
                return false;
            leftIndex++;
            rightIndex++;
            }
        }
        return true;
        return Integer.compare(safeLeft.length(), safeRight.length());
    }
    private String normalizeGroupKey(String value) {