|  |  |  | 
|---|
|  |  |  | * @param whsType 类型 1:双深式货架 | 
|---|
|  |  |  | * @param staDescId 路径工作类型 | 
|---|
|  |  |  | * @param sourceStaNo 源站 | 
|---|
|  |  |  | * @param matNos 商品编号集合 | 
|---|
|  |  |  | * @param matNos 品号集合 | 
|---|
|  |  |  | * @return locNo 检索到的库位号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | 
|---|
|  |  |  | if (row == 1) { | 
|---|
|  |  |  | shallowLocNo = locNo; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | shallowLocNo = Utils.getShallowLoc(slaveProperties, locNo); | 
|---|
|  |  |  | shallowLocNo = zerofill(String.valueOf(2), 2) + locNo.substring(2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 检测目标库位是否为空库位 | 
|---|
|  |  |  | LocMast shallowLoc = locMastService.selectById(shallowLocNo); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | //} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int row = Integer.parseInt(loc.getLocNo().substring(0, 2)); | 
|---|
|  |  |  | //如果为浅库位则判断深库位是否使用 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String shallowLocNo = ""; | 
|---|
|  |  |  | if (row == 1) { | 
|---|
|  |  |  | shallowLocNo = loc.getLocNo(); | 
|---|
|  |  |  | } else if (row == 2){ | 
|---|
|  |  |  | LocMast deepLoc = locMastService.selectById(zerofill(String.valueOf(3), 2) + locMast.getLocNo().substring(2)); | 
|---|
|  |  |  | if (!deepLoc.getLocSts().equals("F") && !deepLoc.getLocSts().equals("D") && !deepLoc.getLocSts().equals("X")) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | shallowLocNo = loc.getLocNo(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | LocMast deepLoc = locMastService.selectById(zerofill(String.valueOf(2), 2) + locMast.getLocNo().substring(2)); | 
|---|
|  |  |  | if (!deepLoc.getLocSts().equals("F") && !deepLoc.getLocSts().equals("D") && !deepLoc.getLocSts().equals("X")) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | shallowLocNo = loc.getLocNo(); | 
|---|
|  |  |  | if (row == 1 || row == 2) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocMast trgerLoc = locMastService.selectById(zerofill(String.valueOf(2), 2) + loc.getLocNo().substring(2)); | 
|---|
|  |  |  | if (!trgerLoc.getLocSts().equals("O")) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | shallowLocNo = trgerLoc.getLocNo(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 检测目标库位是否为空库位 | 
|---|
|  |  |  | LocMast shallowLoc = locMastService.selectById(shallowLocNo); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 更新库位排号 | 
|---|
|  |  |  | rowLastno.setCurrentRow(curRow); | 
|---|
|  |  |  | rowLastnoService.updateById(rowLastno); | 
|---|
|  |  |  | rowLastnoService.updateById(rowLastno); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 开始查找库位 ==============================>> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1()); | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("row1", curRow) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .orderBy("lev1", true).orderBy("bay1", true)); | 
|---|
|  |  |  | for(LocMast locMast1 :locMasts){ | 
|---|
|  |  |  | // 目标库位 ===>> 浅库位, 则校验其深库位是否为 F D X | 
|---|
|  |  |  | if (null != locMast1 && Integer.parseInt(locMast1.getLocNo().substring(0, 2)) == 2) { | 
|---|
|  |  |  | LocMast deepLoc = locMastService.selectById(zerofill(String.valueOf(3), 2) + locMast1.getLocNo().substring(2)); | 
|---|
|  |  |  | if (!deepLoc.getLocSts().equals("F") && !deepLoc.getLocSts().equals("D") && !deepLoc.getLocSts().equals("X") && !deepLoc.getLocSts().equals("P")) { | 
|---|
|  |  |  | locMast = null; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | if (!Cools.isEmpty(locMast1)) { | 
|---|
|  |  |  | locMast = locMast1; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 目标库位 ===>> 深库位, 则校验其浅库位是否为 O | 
|---|
|  |  |  | if (null != locMast1 && Integer.parseInt(locMast1.getLocNo().substring(0, 2)) == 3) { | 
|---|
|  |  |  | LocMast shallowLoc = locMastService.selectById(zerofill(String.valueOf(2), 2) + locMast1.getLocNo().substring(2)); | 
|---|
|  |  |  | if (!Cools.isEmpty(shallowLoc)) { | 
|---|
|  |  |  | if (!shallowLoc.getLocSts().equals("O")) { | 
|---|
|  |  |  | locMast = null; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | if (!Cools.isEmpty(locMast1)) { | 
|---|
|  |  |  | locMast = locMast1; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 因库位移转、需预留空库位 | 
|---|
|  |  |  | if (!locMastService.checkEmptyCount(locMast)) { | 
|---|
|  |  |  | locMast = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 目标库位 ===>> 浅库位, 则校验其深库位是否为 F D X | 
|---|
|  |  |  | if (null != locMast && Integer.parseInt(locMast.getLocNo().substring(0, 2)) == 2) { | 
|---|
|  |  |  | LocMast deepLoc = locMastService.selectById(zerofill(String.valueOf(3), 2) + locMast.getLocNo().substring(2)); | 
|---|
|  |  |  | if (!deepLoc.getLocSts().equals("F") && !deepLoc.getLocSts().equals("D") && !deepLoc.getLocSts().equals("X")) { | 
|---|
|  |  |  | locMast = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //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 && Integer.parseInt(locMast.getLocNo().substring(0, 2)) == 3) { | 
|---|
|  |  |  | LocMast shallowLoc = locMastService.selectById(zerofill(String.valueOf(2), 2) + locMast.getLocNo().substring(2)); | 
|---|
|  |  |  | if (!Cools.isEmpty(shallowLoc)) { | 
|---|
|  |  |  | if (!shallowLoc.getLocSts().equals("O")) { | 
|---|
|  |  |  | locMast = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //if (null != locMast && Utils.isDeepLoc(slaveProperties, locMast.getLocNo())) { | 
|---|
|  |  |  | //    LocMast shallowLoc = locMastService.selectById(Utils.getShallowLoc(slaveProperties, locMast.getLocNo())); | 
|---|
|  |  |  | //    if (!Cools.isEmpty(shallowLoc)) { | 
|---|
|  |  |  | //        if (!shallowLoc.getLocSts().equals("O")) { | 
|---|
|  |  |  | //            locMast = null; | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | //                // 目标库位 ===>> 浅库位, 则校验其深库位是否为 F D X | 
|---|
|  |  |  | //                if (null != locMast && Integer.parseInt(locMast.getLocNo().substring(0, 2)) == 2) { | 
|---|
|  |  |  | //                    LocMast deepLoc = locMastService.selectById(zerofill(String.valueOf(3), 2) + locMast.getLocNo().substring(2)); | 
|---|
|  |  |  | //                    if (!deepLoc.getLocSts().equals("F") && !deepLoc.getLocSts().equals("D") && !deepLoc.getLocSts().equals("X") && !deepLoc.getLocSts().equals("P")) { | 
|---|
|  |  |  | //                        locMast = null; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                // 目标库位 ===>> 深库位, 则校验其浅库位是否为 O | 
|---|
|  |  |  | //                if (null != locMast && Integer.parseInt(locMast.getLocNo().substring(0, 2)) == 3) { | 
|---|
|  |  |  | //                    LocMast shallowLoc = locMastService.selectById(zerofill(String.valueOf(2), 2) + locMast.getLocNo().substring(2)); | 
|---|
|  |  |  | //                    if (!Cools.isEmpty(shallowLoc)) { | 
|---|
|  |  |  | //                        if (!shallowLoc.getLocSts().equals("O")) { | 
|---|
|  |  |  | //                            locMast = null; | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 2.库位当前所属尺寸无空库位时,调整尺寸参数,向上兼容检索库位 | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归 | 
|---|
|  |  |  | if (times < rowCount) { | 
|---|
|  |  |  | if (times < 4) { | 
|---|
|  |  |  | times = times + 1; | 
|---|
|  |  |  | if(locTypeDto.getLocType1() == 1 && times == 2){ | 
|---|
|  |  |  | locTypeDto.setLocType1((short) 2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return getLocNo(1, staDescId, sourceStaNo, matNos, locTypeDto, times); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param whsType 类型 1:双深式货架 | 
|---|
|  |  |  | * @param staDescId 路径工作类型 | 
|---|
|  |  |  | * @param sourceStaNo 源站 | 
|---|
|  |  |  | * @param matnr 商品编号集合 | 
|---|
|  |  |  | * @param matnr 品号集合 | 
|---|
|  |  |  | * @return locNo 检索到的库位号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public StartupDto getLocNoRun(Integer whsType, Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, Integer moveCrnNo, LocTypeDto locTypeDto, int times) { | 
|---|
|  |  |  | if (Cools.isEmpty(matnr)) {  //物料号 | 
|---|
|  |  |  | if (Cools.isEmpty(matnr)) {  //品号 | 
|---|
|  |  |  | matnr = ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(batch)) {  //箱号 | 
|---|
|  |  |  | 
|---|
|  |  |  | return getLocNoRun(1, staDescId, sourceStaNo, matnr, batch, grade,moveCrnNo, locTypeDto, times); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 轻货物找轻库位为空时,可以去找重库位仓 | 
|---|
|  |  |  | //if (locTypeDto.getLocType1() == 1) { | 
|---|
|  |  |  | //    locTypeDto.setLocType1((short) 2); | 
|---|
|  |  |  | //    return getLocNoRun(1, staDescId, sourceStaNo, matnr, batch, grade,moveCrnNo, locTypeDto, times); | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | ////             轻货物找轻库位为空时,可以去找重库位仓 | 
|---|
|  |  |  | //            if (locTypeDto.getLocType1() == 1) { | 
|---|
|  |  |  | //                locTypeDto.setLocType1((short) 2); | 
|---|
|  |  |  | //                return getLocNoRun(1, staDescId, sourceStaNo, matnr, batch, grade,moveCrnNo, locTypeDto, times); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); | 
|---|
|  |  |  | throw new CoolException("没有空库位"); | 
|---|
|  |  |  | } | 
|---|