自动化立体仓库 - WMS系统
LSH
2022-11-29 6682a037f43649d40a94dbf59e40a5b2cc59dc37
src/main/java/com/zy/common/service/CommonService.java
@@ -10,6 +10,7 @@
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.asrs.utils.VersionUtils;
import com.zy.common.entity.Parameter;
import com.zy.common.model.LocTypeDto;
import com.zy.common.model.Shelves;
import com.zy.common.model.StartupDto;
@@ -112,74 +113,49 @@
        int crn_qty = rowLastno.getCrnQty();
        int rowCount = eRow - sRow + 1;
        // 目标堆垛机号
        int crnNo = 0;
        int crnNo = crn_qty;
        // 目标库位
        LocMast locMast = null;
//        // 靠近摆放规则 --- 同天同规格物料
//        if (!Cools.isEmpty(matNos)) {
//            List<String> locNos = locDetlService.getSameDetlToday(matNos.get(0), sRow, eRow);
//            for (String locNo : locNos) {
//                if (Utils.isShallowLoc(slaveProperties, locNo)) {
//                    continue;
//                }
//                String shallowLocNo = Utils.getShallowLoc(slaveProperties, locNo);
//                // 检测目标库位是否为空库位
//                LocMast shallowLoc = locMastService.selectById(shallowLocNo);
//                if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) {
//                    if (VersionUtils.locMoveCheckLocType(shallowLoc, locTypeDto)) {
//                        if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) {
//                            locMast = shallowLoc;
//                            crnNo = locMast.getCrnNo();
//                            break;
//                        }
//                    }
//                }
//            }
//        }
//        // 靠近摆放规则 --- 空托
//        if (staDescId == 10) {
//            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow));
//            if (locMasts.size() > 0) {
//                for (LocMast loc : locMasts) {
//                    if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) {
//                        continue;
//                    }
//                    String shallowLocNo = Utils.getShallowLoc(slaveProperties,  loc.getLocNo());
//                    // 检测目标库位是否为空库位
//                    LocMast shallowLoc = locMastService.selectById(shallowLocNo);
//                    if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) {
//                        if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) {
//                            locMast = shallowLoc;
//                            crnNo = locMast.getCrnNo();
//                            break;
//                        }
//                    }
//                }
//            }
//        }
        // 如果没有相近物料,则按规则轮询货架
        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;
            switch (curRow){
                case 2:
                    curRow = 4;
                    break;
                }
                case 4:
                    curRow = 6;
                    break;
                case 6:
                    curRow = 8;
                    break;
                case 8:
                    curRow = 11;
                    break;
                case 11:
                    curRow = 13;
                    break;
                case 13:
                    curRow = 3;
                    break;
                case 3:
                    curRow = 5;
                    break;
                case 5:
                    curRow = 7;
                    break;
                case 7:
                    curRow = 9;
                    break;
                case 9:
                    curRow = 12;
                    break;
                case 12:
                    curRow = 14;
                    break;
                case 14:
                    curRow = 2;
                    break;
            }
        }
@@ -219,25 +195,18 @@
//                }
//            }
            if (Cools.isEmpty(locMast)) {
                locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1());
                // 因库位移转、需预留空库位
//                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;
//                    }
//                }
//                // 目标库位 ===>> 深库位, 则校验其浅库位是否为 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;
//                    }
//                }
                Integer ruleId = Integer.parseInt(Parameter.get().getFindLocRule());
                if (ruleId == 0){//默认规则
                    locMast = locMastService.queryFreeLocMast(2, locTypeDto.getLocType1());
                } else if (ruleId == 1){ //按测试设备排序,优先排满单台设备
                    locMast = locMastService.queryFreeLocMast1(2, locTypeDto.getLocType1());
                } else if (ruleId == 2){//按通道排序,均匀分配每台设备
                    locMast = locMastService.queryFreeLocMast2(2, locTypeDto.getLocType1(), curRow);
                } else {
                    locMast = locMastService.queryFreeLocMast(2, locTypeDto.getLocType1());
                }
            }
//        }
@@ -249,11 +218,6 @@
                return getLocNo(1, staDescId, sourceStaNo, matNos, locTypeDto, times);
            }
//            // 轻货物找轻库位为空时,可以去找重库位仓
//            if (locTypeDto.getLocType1() == 1) {
//                locTypeDto.setLocType1((short) 2);
//                return getLocNo(1, staDescId, sourceStaNo, matNos, locTypeDto, times);
//            }
            log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times);
            throw new CoolException("没有空库位");
        }