自动化立体仓库 - WMS系统
dubin
昨天 cc4e0bd14edeeb43268216f18c70be62e482b8f0
src/main/java/com/zy/common/service/CommonService.java
@@ -172,6 +172,11 @@
//            }
            int rowCount = params[0];
            int nearRow = params[3];
            int MIN_SPARE_SLOTS = 0;
            if (rowLastno.getTypeId() == 1){
                MIN_SPARE_SLOTS = 2;
            }
            // 只取数量判断,避免拉整 list
            int availableLocCount = locMastService.selectCount(new EntityWrapper<LocMast>()
@@ -180,7 +185,7 @@
                    .eq("whs_type", rowLastnoType.getType().longValue()));
            int crnCountO = wrkMastService.selectCount(new EntityWrapper<WrkMast>()
                    .eq("crn_no", crnNo).le("io_type", 100));
            if (availableLocCount - crnCountO <= 2) { // 可以提成常量,比如 MIN_SPARE_SLOTS = 2
            if (availableLocCount - crnCountO <= MIN_SPARE_SLOTS) { // 可以提成常量,比如 MIN_SPARE_SLOTS = 2
                log.error("{}号堆垛机没有空库位!!! 尺寸规格: {}, 轮询次数:{}", crnNo, JSON.toJSONString(locTypeDto), attempt);
                attempt++;
                continue;
@@ -242,15 +247,21 @@
        //此程序用于优化堆垛机异常时的运行时间
        Optional<CrnRowInfo> infoOpt = findAvailableCrnAndNearRow(rowLastno, curRow, crnNumber, times, findLocNoAttributeVo, locTypeDto, rowLastnoType);
        if (!infoOpt.isPresent()) {
            throw new CoolException("无可用堆垛机");
        if (infoOpt.isPresent()) {
//            throw new CoolException("无可用堆垛机");
            CrnRowInfo info = infoOpt.get();
            crnNo = info.getCrnNo();
            nearRow = info.getNearRow();
            curRow = info.getCurRow();
            rowCount = info.getRowCount();
            times = info.getTimes();
        }
        CrnRowInfo info = infoOpt.get();
        crnNo = info.getCrnNo();
        nearRow = info.getNearRow();
        curRow = info.getCurRow();
        rowCount = info.getRowCount();
        times = info.getTimes();
//        CrnRowInfo info = infoOpt.get();
//        crnNo = info.getCrnNo();
//        nearRow = info.getNearRow();
//        curRow = info.getCurRow();
//        rowCount = info.getRowCount();
//        times = info.getTimes();
        boolean signRule1 = false;
@@ -440,19 +451,26 @@
            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                    .eq("row1", nearRow)
                    .eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
                    .orderBy("lev1", true).orderBy("bay1", false));
                    .orderBy("lev1", true).orderBy("bay1", true));
            for (LocMast locMast1 : locMasts) {
                if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                    continue;
                }
                if (Utils.BooleanWhsTypeStaIoType(rowLastno)) {
                    String shallowLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo());
                    LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
                            .eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()));
                    if (!Cools.isEmpty(locMast2)) {
                        locMast = locMast2;
                    if (locMast1.getCrnNo() == 2) {
                        String shallowLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo());
                        LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
                                .eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()));
                        if (!Cools.isEmpty(locMast2)) {
                            locMast = locMast2;
                            break;
                        }
                    } else if (locMast1.getCrnNo() == 1) {
                        locMast = locMast1;
                        break;
                    }
                } else {
                    if (!Cools.isEmpty(locMast1)) {
                        locMast = locMast1;
@@ -505,9 +523,10 @@
        // 递归查询
        if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) {
            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归
            if (times < rowCount * 2) {
            if (times <= rowCount * 2) {
                times = times + 1;
                return getLocNoRun(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, moveCrnNo, locTypeDto, times);
//                return getLocNoRun(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, moveCrnNo, locTypeDto, times);
                return getLocNoRun(5, staDescId, sourceStaNo, findLocNoAttributeVo, moveCrnNo, locTypeDto, times);
            }
//            // 2.库位当前所属尺寸无空库位时,调整尺寸参数,向上兼容检索库位
//            if (locTypeDto.getLocType1() < 2) {
@@ -1007,7 +1026,7 @@
        //此程序用于优化堆垛机异常时的运行时间
        int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRow, crnNumber);
        curRow = locNecessaryParameters[1];
        crnNo = locNecessaryParameters[2];
        crnNo = 6;
        rowCount = locNecessaryParameters[0];
        nearRow = locNecessaryParameters[3];
@@ -1015,7 +1034,7 @@
        StaDesc staDesc = null;
        BasDevp staNo = null;
        if (Utils.BooleanWhsTypeSta(rowLastno, staDescId)) {
//        if (Utils.BooleanWhsTypeSta(rowLastno, staDescId)) {
            // 获取目标站
//            wrapper = new EntityWrapper<StaDesc>()
//                    .eq("type_no", staDescId)
@@ -1036,7 +1055,7 @@
//                }
//                startupDto.setStaNo(staNo.getDevNo());
//            }
        }
//        }
        // 更新库位排号
        if (Utils.BooleanWhsTypeSta(rowLastno, staDescId) && Cools.isEmpty(locMast)) {
@@ -1046,18 +1065,17 @@
        // 开始查找库位 ==============================>>
        // 1.按规则查找库位
        if (Cools.isEmpty(locMast) && crnNo != 0) {
            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
        if (Cools.isEmpty(locMast) && sourceStaNo != 4006) {//si'lou'p四楼盘点选择区域
                 List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                    .eq("row1", nearRow)
                    .eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
                    .orderBy("lev1", true).orderBy("bay1", true));//最浅库位
                    .orderBy("lev1", true).orderBy("bay1", true)); // 最浅库位
            for (LocMast locMast1 : locMasts) {
                if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                    continue;
                }
                if (Utils.BooleanWhsTypeStaIoType(rowLastno)) {
                    //获取目标库位所在巷道最深空库位
                    // 获取目标库位所在巷道最深空库位
                    LocMast locMast2 = locMastService.selectLocByLocStsPakInO(curRow, nearRow, locMast1, rowLastnoType.getType().longValue());
                    if (!Cools.isEmpty(locMast2) && locMast2.getRow1() == curRow) {
                        locMast = locMast2;
@@ -1065,8 +1083,104 @@
                    }
                }
            }
        } else {
            // 根据 findLocNoAttributeVo.getOutArea() 设置列范围
            int startBay = 1;
            int endBay = 19;
            switch (findLocNoAttributeVo.getOutArea()) {
                case 3:
                    startBay = 15;
                    endBay = 19;
                    break;
                case 2:
                    startBay = 8;
                    endBay = 14;
                    break;
                case 1:
                    startBay = 1;
                    endBay = 8;
                    break;
                default:
                    break;
            }
            // 优先从指定列范围查找
            boolean found = false;
            // 按照排号从38到32递减查找,优先查找指定列范围(如1-8、8-14、15-19)
            for (int row = 38; row >= 32; row--) {
                List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("row1", row)
                        .ge("bay1", startBay)
                        .le("bay1", endBay)
                        .eq("loc_sts", "O")
                        .eq("whs_type", rowLastnoType.getType().longValue())
                        .orderBy("lev1", true)
                        .orderBy("bay1", true)); // 最浅库位
                for (LocMast locMast1 : locMasts) {
                    if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                        continue;
                    }
                    if(locMast1!= null){
                        locMast = locMast1;
                        found = true;
                        break;
                    }
//                    if (Utils.BooleanWhsTypeStaIoType(rowLastno)) {
//                        // 获取目标库位所在巷道最深空库位
//                        LocMast locMast2 = locMastService.selectLocByLocStsPakInO(curRow, nearRow, locMast1, rowLastnoType.getType().longValue());
//                        if (!Cools.isEmpty(locMast2) && locMast2.getRow1() == curRow) {
//                            locMast = locMast2;
//                            found = true;
//                            break;
//                        }
//                    }
                }
                if (found) {
                    break; // 找到目标库位后跳出循环
                }
            }
            // 如果没有在优先范围内找到合适库位,继续进行全局查找(1-19列)
            if (!found) {
                // 从排号38到32查找所有列(1-19)
                for (int row = 38; row >= 32; row--) {
                    List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                            .eq("row1", row)
                            .ge("bay1", 1)  // 查找1到19列
                            .le("bay1", 19)
                            .eq("loc_sts", "O")
                            .eq("whs_type", rowLastnoType.getType().longValue())
                            .orderBy("lev1", true)
                            .orderBy("bay1", true)); // 最浅库位
                    for (LocMast locMast1 : locMasts) {
                        if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                            continue;
                        }
                        if (Utils.BooleanWhsTypeStaIoType(rowLastno)) {
                            // 获取目标库位所在巷道最深空库位
                            LocMast locMast2 = locMastService.selectLocByLocStsPakInO(curRow, nearRow, locMast1, rowLastnoType.getType().longValue());
                            if (!Cools.isEmpty(locMast2) && locMast2.getRow1() == curRow) {
                                locMast = locMast2;
                                found = true;
                                break;
                            }
                        }
                    }
                    if (found) {
                        break; // 找到目标库位后跳出循环
                    }
                }
            }
        }
        // 递归查询
        if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) {
            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归