自动化立体仓库 - WMS系统
src/main/java/com/zy/common/service/CommonService.java
@@ -100,19 +100,33 @@
//        whsType = getWhsType(sourceStaNo, times);
        StartupDto startupDto = new StartupDto();
        if (sourceStaNo < 200){
            whsType = 1;
        } else if (sourceStaNo > 199 && sourceStaNo < 300){
            whsType = 2;
        } else if (sourceStaNo > 299 && sourceStaNo < 400){
//        if (sourceStaNo < 200){
//            whsType = 1;
//        } else if (sourceStaNo > 199 && sourceStaNo < 300){
//            whsType = 2;
//        } else if (sourceStaNo > 299 && sourceStaNo < 400){
//            whsType = 3;
//        } else if (sourceStaNo > 399){
//            whsType = 4;
//        }
        // 目标堆垛机号
        int crnNo = 0;
        if (sourceStaNo ==102) {
            whsType = 3;
        } else if (sourceStaNo > 399){
            whsType = 4;
        }
            crnNo = 3;
        }else if (sourceStaNo ==104) {
            whsType = 2;
            crnNo = 2;
        }else if(sourceStaNo ==106) {
            whsType = 1;
            crnNo = 1;
        }else
            throw new CoolException("站点数据异常,请联系管理员");
        RowLastno rowLastno = rowLastnoService.selectById(whsType);
        if (Cools.isEmpty(rowLastno)) {
            throw new CoolException("数据异常,请联系管理员");
            throw new CoolException("1数据异常,请联系管理员");
        }
        // ===============>>>> 开始执行
@@ -121,8 +135,7 @@
        int eRow = rowLastno.geteRow();
        int crn_qty = rowLastno.getCrnQty();
        int rowCount = eRow - sRow + 1;
        // 目标堆垛机号
        int crnNo = 0;
        // 目标库位
        LocMast locMast = null;
@@ -173,32 +186,35 @@
            }
        }
        // 如果没有相近物料,则按规则轮询货架
        if (null == locMast) {
            Shelves shelves = new Shelves(rowCount, crn_qty);
            int divides = (int) Arith.divides(1, curRow - 1, 4);
            curRow = (int) Arith.remainder(curRow, 4);
            if (curRow == 0) {
                curRow = 4;
            }
            for (int i = 0; i < shelves.group; i ++) {
                curRow = shelves.start(curRow);
                if (curRow < 0) {
                    throw new CoolException("检索库位失败,请联系管理员");
                }
                Integer crnNo1 = shelves.get(curRow);
                crnNo1 = crnNo1 + divides*1;
                if (basCrnpService.checkSiteError(crnNo1, true)) {
                    crnNo = crnNo1;
                    curRow = curRow + divides*4;
                    break;
                }
            }
        }
        if (crnNo == 0) {
            throw new CoolException("没有可用的堆垛机");
        }
//        // 如果没有相近物料,则按规则轮询货架
//        if (null == locMast) {
//            if(crnNo>1) {
//                curRow = curRow -2;
//            }
//            Shelves shelves = new Shelves(rowCount, crn_qty);
//            int divides = (int) Arith.divides(1, curRow - 1, 4);
//            curRow = (int) Arith.remainder(curRow, 4);
//            if (curRow == 0) {
//                curRow = 4;
//            }
//            for (int i = 0; i < shelves.group; i ++) {
//                curRow = shelves.start(curRow);
//                if (curRow < 0) {
//                    throw new CoolException("检索库位失败,请联系管理员");
//                }
//                if (basCrnpService.checkSiteError(crnNo, true)) {
//                    curRow = curRow + divides*4;
//                    break;
//                }
//            }
//            if(crnNo>1) {
//                curRow = curRow +2;
//            }
//        }
//
//        if (crnNo == 0) {
//            throw new CoolException("没有可用的堆垛机");
//        }
        // 获取目标站
        Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                .eq("type_no", staDescId)
@@ -213,7 +229,27 @@
        if (!staNo.getAutoing().equals("Y")) {
            throw new CoolException("目标站"+staDesc.getCrnStn()+"不可用");
        }
        if(curRow==1){
            curRow=2;
        }else if(curRow==2){
            curRow=1;
        }else if(curRow==3){
            curRow=6;
        }else if(curRow==6){
            curRow=3;
        }else if(curRow==7){
            curRow=10;
        }else if(curRow==10){
            curRow=7;
        }else if(curRow==4){
            curRow=5;
        }else if(curRow==5){
            curRow=4;
        }else if(curRow==8){
            curRow=9;
        }else if(curRow==9){
            curRow=8;
        }
        // 更新库位排号
        rowLastno.setCurrentRow(curRow);
        rowLastnoService.updateById(rowLastno);
@@ -237,18 +273,20 @@
                if (!locMastService.checkEmptyCount(locMast)) {
                    locMast = null;
                }
                // 目标库位 ===>> 浅库位, 则校验其深库位是否为 F D X
                if (null != locMast && Utils.isShallowLoc(slaveProperties, locMast.getLocNo())) {
                    LocMast deepLoc = locMastService.selectById(Utils.getDeepLoc(slaveProperties, locMast.getLocNo()));
                    if (!deepLoc.getLocSts().equals("F") && !deepLoc.getLocSts().equals("D") && !deepLoc.getLocSts().equals("X")) {
                        locMast = null;
                if(curRow >2){
                    // 目标库位 ===>> 浅库位, 则校验其深库位是否为 F D X
                    if (null != locMast && Utils.isShallowLoc(slaveProperties, locMast.getLocNo())) {
                        LocMast deepLoc = locMastService.selectById(Utils.getDeepLoc(slaveProperties, locMast.getLocNo()));
                        if (!deepLoc.getLocSts().equals("F") && !deepLoc.getLocSts().equals("D") && !deepLoc.getLocSts().equals("X")) {
                            locMast = null;
                        }
                    }
                }
                // 目标库位 ===>> 深库位, 则校验其浅库位是否为 O
                if (null != locMast && Utils.isDeepLoc(slaveProperties, locMast.getLocNo())) {
                    LocMast shallowLoc = locMastService.selectById(Utils.getShallowLoc(slaveProperties, locMast.getLocNo()));
                    if (!shallowLoc.getLocSts().equals("O")) {
                        locMast = null;
                    // 目标库位 ===>> 深库位, 则校验其浅库位是否为 O
                    if (null != locMast && Utils.isDeepLoc(slaveProperties, locMast.getLocNo())) {
                        LocMast shallowLoc = locMastService.selectById(Utils.getShallowLoc(slaveProperties, locMast.getLocNo()));
                        if (!shallowLoc.getLocSts().equals("O")) {
                            locMast = null;
                        }
                    }
                }
            }
@@ -260,6 +298,18 @@
            if (times < rowCount) {
                times = times + 1;
                return getLocNo(1, staDescId, sourceStaNo, matNos, locTypeDto, times);
            }else if (times == rowCount) {
                LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>()
                        .eq("crn_no", crnNo)
                        .eq("loc_sts", "O")
                        .orderBy("lev1"));
                if(Cools.isEmpty(locMast1)){
                    throw new CoolException("堆垛机="+crnNo+"没有空库位");
                }
                if(!locMastService.checkEmptyCount(locMast1)){
                    throw new CoolException("堆垛机="+crnNo+"没有空库位");
                }
            }
            // 轻货物找轻库位为空时,可以去找重库位仓