自动化立体仓库 - WMS系统
#
luxiaotao1123
2023-02-02 c78a960e4b93f5074cbed9cda38a0aba103bbec4
src/main/java/com/zy/common/service/CommonService.java
@@ -57,6 +57,8 @@
    private SlaveProperties slaveProperties;
    @Autowired
    private MatService matService;
    @Autowired
    private LocRuleService locRuleService;
    /**
     * 生成工作号
@@ -121,19 +123,19 @@
                whsType = 1;
                start = 1;
                end = 14;
                if (null != wrkMastService.selectPakoutOfStaNo(104)) {
                    start = 8;
                    theCrnNo = 2;
                }
//                if (null != wrkMastService.selectPakoutOfStaNo(104)) {
//                    start = 8;
//                    theCrnNo = 2;
//                }
                break;
            case 203:
                whsType = 2;
                start = 8;
                end = 21;
                if (null != wrkMastService.selectPakoutOfStaNo(204)) {
                    end = 14;
                    theCrnNo = 2;
                }
//                if (null != wrkMastService.selectPakoutOfStaNo(204)) {
//                    end = 14;
//                    theCrnNo = 2;
//                }
                break;
            default:
                throw new CoolException("检索库位失败,请联系管理员");
@@ -310,24 +312,106 @@
        // 1.当检索库排为浅库位排时,优先寻找当前库排的深库位排
        if (locMast == null) {
            List<Integer> rows = Utils.getGroupLoc(curRow);
            List<LocMast> locMasts = locMastService.queryFreeLocMast0(rows, rows.size(), locTypeDto.getLocType1(), inoutEveryday);
            if (!Cools.isEmpty(locMasts)) {
                Integer innermostRow = Utils.getInnermostRow(locMasts.get(0).getLocNo());
                for (LocMast one : locMasts) {
                    if (one.getRow1().equals(innermostRow)) {
                        locMast = one;
                        break;
            // 库区锁定
            LocRule locRule = locRuleService.find(Cools.isEmpty(matNos) ? null : matNos.get(0), null, start, end);
            if (!Cools.isEmpty(locRule)) {
                List<Integer> rows = Utils.getGroupLoc(locRule.getRowBeg());
                List<LocMast> locMasts = locMastService.queryFreeLocMast1(rows, rows.size(), locTypeDto.getLocType1(), inoutEveryday
                        , locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
                if (!Cools.isEmpty(locMasts)) {
                    Integer innermostRow = Utils.getInnermostRow(locMasts.get(0).getLocNo());
                    for (LocMast one : locMasts) {
                        if (one.getRow1().equals(innermostRow)) {
                            locMast = one;
                            break;
                        }
                    }
                }
            }
            if (locMast == null) {
                List<Integer> rows = Utils.getGroupLoc(curRow);
                List<LocMast> locMasts = locMastService.queryFreeLocMast0(rows, rows.size(), locTypeDto.getLocType1(), inoutEveryday);
                if (!Cools.isEmpty(locMasts)) {
                    Integer innermostRow = Utils.getInnermostRow(locMasts.get(0).getLocNo());
                    for (LocMast one : locMasts) {
                        if (one.getRow1().equals(innermostRow)) {
                            locMast = one;
                            break;
                        }
                    }
                }
            }
//            LocMast locMast0 = locMastService.findOutMost(locMasts.stream().map(LocMast::getLocNo).distinct().collect(Collectors.toList()));
//            if (!Cools.isEmpty(locMast0)) {
//                locMast = locMast0;
//            }
            // 因库位移转、需预留空库位 todo:luxiaotao
//            if (!locMastService.checkEmptyCount(locMast)) {
//                locMast = null;
//            }
        }
        // 2.库位当前所属尺寸无空库位时,调整尺寸参数,向上兼容检索库位
        // 2.无库位时,无视区域锁定,重新查找库位
        if (Cools.isEmpty(locMast)) {
            int sign = curRow;
            while (sign != 0) {
                List<LocMast> locMasts = locMastService.queryFreeLocMastEnd(sign, locTypeDto.getLocType1());
                for (LocMast loc : locMasts) {
                    // 同库位组对应其钱库位是否为 O.空库位
                    boolean success = true;
                    List<String> outerLoc = Utils.getGroupOuterLoc(loc.getLocNo());
                    for (String outerLocNo : outerLoc) {
                        if (!locMastService.selectById(outerLocNo).getLocSts().equals("O")) {
                            success = false; break;
                        }
                    }
                    if (success) {
                        locMast = loc;
                        break;
                    }
                }
                sign = getCurRow(sign);
            }
        }
//        if (Cools.isEmpty(locMast)){
//            List<LocMast> locMasts = locMastService.queryFreeLocMastEnd(curRow, locTypeDto.getLocType1());
//            int sign=curRow;
//            while (true){
//                if (locMasts.size()==0){
//                    sign = getCurRow(sign);
//                    if (sign != 0){
//                        locMasts = locMastService.queryFreeLocMastEnd(sign, locTypeDto.getLocType1());
//                    }else {
//                        break;
//                    }
//                }else {
//                    break;
//                }
//            }
//            for (LocMast locMast1 : locMasts){
//                List<LocMast> locMasts1 = locMastService.queryFreeLocMastEnd0(locMast1.getBay1(), locMast1.getLev1(),locMast1.getRow1(), locTypeDto.getLocType1());
//                Integer innermostRow = Utils.getInnermostRow(locMasts1.get(0).getLocNo());
//                for (LocMast locMast2:locMasts1){
//                    if (locMast2.getLocSts().equals("O")){
//                        locMast = locMast2;
//                        break;
//                    }else if (!locMast2.getLocSts().equals("F")){
//                        break;
//                    }
//                }
//                if (!Cools.isEmpty(locMast)){
//                    break;
//                }
//            }
//        }
        // 3.库位当前所属尺寸无空库位时,调整尺寸参数,向上兼容检索库位
        if (Cools.isEmpty(locMast)) {
            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归
            if (times < rowCount) {
@@ -369,4 +453,28 @@
        }
    }
    public int getCurRow(int curRow){
        switch (curRow){
            case 1:
            case 2:
            case 8:
            case 9:
            case 10:
            case 15:
            case 16:
            case 17:
                return curRow+1;
            case 5:
            case 6:
            case 7:
            case 13:
            case 14:
            case 20:
            case 21:
                return curRow-1;
            default:
                return 0;
        }
    }
}