| | |
| | | public class CommonService { |
| | | |
| | | public static final List<Integer> FIRST_GROUP_ROW_LIST = new ArrayList<Integer>() {{ |
| | | add(1);add(2);add(3);add(4);add(5);add(6);add(7);add(8);add(9);add(10); |
| | | }}; |
| | | public static final List<Integer> FIRST_GROUP_ROW_LIST_SHORT = new ArrayList<Integer>() {{ |
| | | add(8);add(9);add(10); |
| | | add(1); |
| | | }}; |
| | | public static final List<Integer> SECOND_GROUP_ROW_LIST = new ArrayList<Integer>() {{ |
| | | add(12);add(13);add(14);add(15);add(16);add(17);add(18); |
| | | add(3);add(4); |
| | | }}; |
| | | public static final List<Integer> THIRD_GROUP_ROW_LIST = new ArrayList<Integer>() {{ |
| | | add(20);add(21);add(22);add(23); |
| | | add(6);add(7); |
| | | }}; |
| | | public static final List<Integer> FOURTH_GROUP_ROW_LIST = new ArrayList<Integer>() {{ |
| | | add(8); |
| | | }}; |
| | | public static final List<Integer> FIFTH_GROUP_ROW_LIST = new ArrayList<Integer>() {{ |
| | | add(10);add(11); |
| | | }}; |
| | | public static final List<Integer> SIXTH_GROUP_ROW_LIST = new ArrayList<Integer>() {{ |
| | | add(13);add(14);add(15);add(16); |
| | | }}; |
| | | public static final List<Integer> SEVENTH_GROUP_ROW_LIST = new ArrayList<Integer>() {{ |
| | | add(13);add(14); |
| | | }}; |
| | | public static final List<Integer> EIGHTH_GROUP_ROW_LIST = new ArrayList<Integer>() {{ |
| | | add(16); |
| | | }}; |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * 检索库位号 |
| | | * @param staDescId 路径ID |
| | | * |
| | | * @param staDescId 路径ID |
| | | * @param sourceStaNo 源站 |
| | | * @param matNos 物料号集合 |
| | | * @param matNos 物料号集合 |
| | | * @return locNo 检索到的库位号 |
| | | */ |
| | | public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, List<String> matNos, LocTypeDto locTypeDto,int times) { |
| | | public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, List<String> matNos, LocTypeDto locTypeDto, int times) { |
| | | // 目标库位 |
| | | LocMast locMast = null; |
| | | |
| | | //混载找库位 |
| | | locMast = getLocNoStep1(matNos, locTypeDto); |
| | | // 靠近摆放规则 --- 空托 |
| | | locMast = getLocNoStep4(staDescId, locTypeDto); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | //库位规则 |
| | | locMast = getLocNoStep2(matNos, locTypeDto); |
| | | locMast = getLocNoStepRule(matNos, locTypeDto); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | // 靠近摆放规则 --- 空托 |
| | | locMast = getLocNoStep4(staDescId, locTypeDto); |
| | | //搜索单品 |
| | | locMast = getLocNoStepSingle(matNos, locTypeDto); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | // 如果没有相近物料,则按规则轮询货架 |
| | | // 开始查找库位 ==============================>> |
| | | locMast = getLocNoStep5(locTypeDto, times); |
| | | //搜索混放 |
| | | locMast = getLocNoStepMixed(matNos, locTypeDto, times); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | if(locTypeDto.getLocType1()==1){ |
| | | locTypeDto.setLocType1((short)2); |
| | | return getLocNo(staDescId, 1, sourceStaNo, matNos, locTypeDto,0); |
| | | }else if(locTypeDto.getLocType1()==2){ |
| | | locTypeDto.setLocType1((short)3); |
| | | return getLocNo(staDescId, 1, sourceStaNo, matNos, locTypeDto,0); |
| | | } |
| | | //找不到库位,抛出异常 |
| | | throw new CoolException("没有空库位"); |
| | | } |
| | | |
| | | /** |
| | | * 混载找库位 |
| | | */ |
| | | private LocMast getLocNoStep1(List<String> matNos, LocTypeDto locTypeDto) { |
| | | //判断当前货物是否为混载货物 |
| | | String firstMatNos = matNos.get(0); |
| | | boolean mixed = false;//默认不是混载货物 |
| | | for (String matNo : matNos) { |
| | | if (!firstMatNos.equals(matNo)) { |
| | | mixed = true;//混载货物 |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (!mixed) { |
| | | return null;//不是混载货物,直接跳出当前任务 |
| | | } |
| | | |
| | | // 找混载库位规则 |
| | | List<LocRule> locRules = locRuleService.findMixed(); |
| | | if (locRules == null || locRules.size() == 0) { |
| | | 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()); |
| | | |
| | | for (LocMast one : locMasts) { |
| | | LocMast locMast0 = locMastService.findOutMost(one.getLocNo()); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) { |
| | | // 因库位移转、需预留空库位 |
| | | if (locMastService.checkEmptyCount(locMast0, 10)) { |
| | | return locMast0;//找到空余的混载库位 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | if (locRules.get(0).getKeepGo() == 0) { |
| | | //找不到空库位,且禁止继续寻找其他非混载区域库位 |
| | | //找不到库位,抛出异常 |
| | | throw new CoolException("混载区域没有空库位"); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 库位规则 |
| | | */ |
| | | private LocMast getLocNoStep2(List<String> matNos, LocTypeDto locTypeDto) { |
| | | private LocMast getLocNoStepRule(List<String> matNos, LocTypeDto locTypeDto) { |
| | | LocMast locMast = null; |
| | | // 库区锁定 |
| | | List<LocRule> locRules = locRuleService.find(Cools.isEmpty(matNos) ? null : matNos.get(0)); |
| | | if (locRules == null || locRules.size() == 0) { |
| | | return null;//没有库位规则,跳出当前任务 |
| | | } |
| | | |
| | | for (LocRule locRule : locRules) { |
| | | if (locRule == null) { |
| | | continue; |
| | | //库位规则只能在单品货物中生效 |
| | | if (matNos.size() == 1) { |
| | | // 库区锁定 |
| | | List<LocRule> locRules = locRuleService.find(Cools.isEmpty(matNos) ? null : matNos.get(0)); |
| | | if (locRules == null || locRules.isEmpty()) { |
| | | return null;//没有库位规则,跳出当前任务 |
| | | } |
| | | |
| | | List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd()); |
| | | for (LocMast one : locMasts) { |
| | | LocMast locMast0 = locMastService.findOutMost(one.getLocNo()); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) { |
| | | // 因库位移转、需预留空库位 |
| | | if (locMastService.checkEmptyCount(locMast0, 10)) { |
| | | return locMast0; |
| | | } |
| | | 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()); |
| | | for (LocMast locMast0 : locMasts) { |
| | | //预留空库位 |
| | | if (locMastService.checkEmptyCount(locMast0, 10)) { |
| | | return locMast0; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (locRules.get(0).getKeepGo() == 0) { |
| | | //找不到空库位,且禁止继续寻找其他非混载区域库位 |
| | | //找不到库位,抛出异常 |
| | | throw new CoolException("规则区域没有空库位"); |
| | | if (locRules.get(0).getKeepGo() == 0) { |
| | | //找不到空库位,且禁止继续寻找其他非混载区域库位 |
| | | //找不到库位,抛出异常 |
| | | throw new CoolException("规则区域没有空库位"); |
| | | } |
| | | } |
| | | |
| | | return locMast; |
| | |
| | | LocMast locMast0 = locMastService.findNearloc(wrkMast.getLocNo()); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) { |
| | | if (VersionUtils.checkLocType(locMast0, locTypeDto)) { |
| | | locMast = locMast0; |
| | | } |
| | | } |
| | |
| | | LocMast locMast0 = locMastService.findNearloc(locNo); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) { |
| | | if (VersionUtils.checkLocType(locMast0, locTypeDto)) { |
| | | locMast = locMast0; |
| | | break; |
| | | } |
| | |
| | | LocMast locMast0 = locMastService.findNearloc(wrkMast.getLocNo()); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) { |
| | | if (VersionUtils.checkLocType(locMast0, locTypeDto)) { |
| | | locMast = locMast0; |
| | | break; |
| | | } |
| | |
| | | } |
| | | if (Cools.isEmpty(locMast)){ |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "D")); |
| | | .eq("loc_sts", "O")); |
| | | if (locMasts.size() > 0) { |
| | | for (LocMast loc : locMasts) { |
| | | LocMast locMast0 = locMastService.findNearloc(loc.getLocNo()); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) { |
| | | if (VersionUtils.checkLocType(locMast0, locTypeDto)) { |
| | | locMast = locMast0; |
| | | break; |
| | | } |
| | |
| | | return locMast; |
| | | } |
| | | |
| | | // 如果没有相近物料,则按规则轮询货架 |
| | | private LocMast getLocNoStep5(LocTypeDto locTypeDto, int times) { |
| | | // 搜索混放 |
| | | private LocMast getLocNoStepMixed(List<String> matNos, LocTypeDto locTypeDto, int times) { |
| | | LocMast locMast = null; |
| | | // 1.当检索库排为浅库位排时,优先寻找当前库排的深库位排 |
| | | List<LocMast> peakLocs = locMastService.selectAllPeakLoc(); |
| | | for (LocMast peakLoc : peakLocs) { |
| | | List<String> groupInsideLoc = Utils.getGroupInsideLoc(peakLoc.getLocNo()); |
| | | if (!Cools.isEmpty(groupInsideLoc)) { |
| | | if (!locMastService.checkAllLocEmpty(groupInsideLoc)) continue; |
| | | locMast = peakLoc; |
| | | break; |
| | | } else { |
| | | locMast = peakLoc; |
| | | break; |
| | | |
| | | if (matNos.size() > 1) { |
| | | List<LocMast> locMasts = locMastService.selectAreaEmpty(locTypeDto.getLocType1(), 1);//搜索混放库位 |
| | | //混放区域直接取第一个即可 |
| | | for (LocMast mast : locMasts) { |
| | | //预留空库位 |
| | | if (locMastService.checkEmptyCount(mast, 10)) { |
| | | locMast = mast; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | return locMast; |
| | | } |
| | | |
| | | // 搜索单品 |
| | | private LocMast getLocNoStepSingle(List<String> matNos, LocTypeDto locTypeDto) { |
| | | LocMast locMast = null; |
| | | // 1.先搜索单品 |
| | | if (matNos.size() == 1) { |
| | | //单品 |
| | | List<LocMast> locMasts = locMastService.selectAreaEmpty(locTypeDto.getLocType1(), 2);//搜索单品库位 |
| | | |
| | | for (LocMast mast : locMasts) { |
| | | List<String> groupLoc = Utils.getGroupLoc(mast.getLocNo()); |
| | | if (!locMastService.checkAllLocEmpty(groupLoc)) { |
| | | continue; |
| | | } |
| | | |
| | | LocMast tmp = null; |
| | | for (String loc : groupLoc) { |
| | | LocMast locMast1 = locMastService.selectByLoc(loc); |
| | | if (locMast1 == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (!locMast1.getLocSts().equals("O")) { |
| | | continue; |
| | | } |
| | | |
| | | tmp = locMast1; |
| | | break; |
| | | } |
| | | |
| | | //预留空库位 |
| | | if (tmp != null && locMastService.checkEmptyCount(mast, 10)) { |
| | | locMast = tmp; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return locMast; |
| | | } |
| | | |
| | | //返回dto |
| | | private StartupDto getLocNoStep6(Integer staDescId, Integer sourceStaNo, LocMast locMast) { |
| | | StartupDto startupDto = new StartupDto(); |
| | | |
| | | String locNo = locMast.getLocNo(); |
| | | // 获取目标站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", staDescId) |
| | | .eq("stn_no", sourceStaNo); |
| | | .eq("stn_no", sourceStaNo) |
| | | .eq("crn_no",Utils.stnNoToLiftNo(sourceStaNo));//借用堆垛机号字段充当提升机号 |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | log.error("入库路径不存在, staDescId={}, sourceStaNo={}", staDescId, sourceStaNo); |