| | |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | //存货分类编码规则 |
| | | locMast = getLocNoCodeStepRule(matNos, locTypeDto); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | // 靠近摆放规则 --- 相同订单号, 同天同规格物料 |
| | | locMast = getLocNoStep3(staDescId, matNos, locTypeDto); |
| | | if (locMast != null) { |
| | |
| | | } |
| | | |
| | | List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd()); |
| | | for (LocMast locMast0 : locMasts) { |
| | | //预留空库位 |
| | | if (locMastService.checkEmptyCount(locMast0, 10)) { |
| | | return locMast0; |
| | | } |
| | | } |
| | | locMast = locFilter(locMasts, matNos,locTypeDto); |
| | | |
| | | } |
| | | |
| | | if (locRules.get(0).getKeepGo() == 0) { |
| | |
| | | throw new CoolException("规则区域没有空库位"); |
| | | } |
| | | } |
| | | |
| | | return locMast; |
| | | } |
| | | |
| | | /** |
| | | * 库位编码规则 |
| | | */ |
| | | private LocMast getLocNoCodeStepRule(List<String> matNos, LocTypeDto locTypeDto) { |
| | | LocMast locMast = null; |
| | | |
| | | //库位编码规则只能在相同编码货物中生效 |
| | | String matnr = ""; |
| | | for(String matNo : matNos){ |
| | | if("".equals(matnr)){ |
| | | matnr = matNo.substring(0, 4); |
| | | } |
| | | if(!matnr.equals(matNo.substring(0, 4))){ |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | // 库区锁定 |
| | | List<LocRule> locRules = locRuleService.findCode(Cools.isEmpty(matNos) ? null : matNos.get(0),null); |
| | | if (locRules == null || locRules.isEmpty()) { |
| | | return null;//没有库位规则,跳出当前任务 |
| | | } |
| | | |
| | | for (LocRule locRule : locRules) { |
| | | if (locRule == null) { |
| | | continue; |
| | | } |
| | | List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd()); |
| | | locMast = locFilter(locMasts, matNos,locTypeDto); |
| | | } |
| | | |
| | | // if (locRules.get(0).getKeepGo() == 0) { |
| | | // //找不到空库位,且禁止继续寻找其他非混载区域库位 |
| | | // //找不到库位,抛出异常 |
| | | // throw new CoolException("规则区域没有空库位"); |
| | | // } |
| | | |
| | | return locMast; |
| | | } |
| | |
| | | //再判断库存明细档,料号相同的明细库位 |
| | | List<String> locNos = locDetlService.getSameDetl(matNos.get(0)); |
| | | for (String locNo : locNos) { |
| | | LocMast locMast0 = locMastService.findNearloc(locNo); |
| | | LocMast locMast0 = locMastService.findInnerLoc(locNo); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.checkLocType(locMast0, locTypeDto)) { |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (locMast == null) { |
| | | //单品找不到库位,允许尝试从混放区域中进行搜索 |
| | | List<LocMast> locMasts2 = locMastService.selectAreaEmpty(locTypeDto.getLocType1(), 1);//搜索单品库位 |
| | | //混放区域直接取第一个即可 |
| | | for (LocMast mast : locMasts2) { |
| | | //预留空库位 |
| | | if (locMastService.checkEmptyCount(mast, 10)) { |
| | | locMast = mast; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return locMast; |
| | | } |
| | | |
| | | /* |
| | | 库存规则搜索到的库位确认 |
| | | */ |
| | | private LocMast locFilter(List<LocMast> locMasts,List<String> matNos,LocTypeDto locTypeDto){ |
| | | for (LocMast locMast0 : locMasts) { |
| | | if(!VersionUtils.checkLocType(locMast0,locTypeDto)){ |
| | | continue; |
| | | } |
| | | if (matNos.size() == 1) { |
| | | //单品物料 |
| | | if(Cools.isEmpty(Utils.getGroupDeepLoc(locMast0.getLocNo()))){ |
| | | return locMast0; |
| | | }else{ |
| | | List<String> groupInnerLoc = Utils.getGroupInnerLoc(locMast0.getLocNo()); |
| | | if (Cools.isEmpty(groupInnerLoc)) { |
| | | return locMast0; |
| | | }else { |
| | | //获取最深的库位 |
| | | String loc = groupInnerLoc.get(groupInnerLoc.size() - 1); |
| | | LocMast locMast1 = locMastService.selectByLoc(loc); |
| | | if("O".equals(locMast1.getLocSts())){ |
| | | return locMast1; |
| | | }else { |
| | | if(!"F".equals(locMast1.getLocSts())){ |
| | | continue; |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.selectByLocNo(loc); |
| | | if(!Cools.eq(locDetls.get(0).getMatnr(),matNos.get(0))){ |
| | | continue; |
| | | } |
| | | for (int i=groupInnerLoc.size()-1; i>=0 ;i--){ |
| | | LocMast locMast2 = locMastService.selectByLoc(groupInnerLoc.get(i)); |
| | | if("O".equals(locMast2.getLocSts())){ |
| | | return locMast2; |
| | | }else if("F".equals(locMast2.getLocSts())){ |
| | | if(i==0){ |
| | | return locMast1; |
| | | }else { |
| | | continue; |
| | | } |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | }else { |
| | | if(Cools.isEmpty(Utils.getGroupDeepLoc(locMast0.getLocNo()))){ |
| | | return locMast0; |
| | | } |
| | | } |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //返回dto |
| | | private StartupDto getLocNoStep6(Integer staDescId, Integer sourceStaNo, LocMast locMast) { |
| | | StartupDto startupDto = new StartupDto(); |