| | |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 供 6.15 重分配接口复用:按外部指定的堆垛机顺序,在指定库区内找新的入库位。 |
| | | * 供重分配接口复用:按外部指定的堆垛机顺序找新的入库位。 |
| | | * |
| | | * 这里不推进 row_lastno 游标,只负责一次性的路径校验 + 设备校验 + 空库位搜索。 |
| | | */ |
| | | public StartupDto findRun2InboundLocByCandidateCrnNos(Integer sourceStaNo, Integer staDescId, |
| | | List<Integer> candidateCrnNos, LocTypeDto locTypeDto) { |
| | | return findRun2InboundLocByCandidateCrnNos(sourceStaNo, staDescId, null, candidateCrnNos, locTypeDto, null); |
| | | } |
| | | |
| | | public StartupDto findRun2InboundLocByCandidateCrnNos(Integer sourceStaNo, Integer staDescId, |
| | | List<Integer> candidateCrnNos, LocTypeDto locTypeDto, |
| | | Integer targetLev) { |
| | | return findRun2InboundLocByCandidateCrnNos(sourceStaNo, staDescId, null, candidateCrnNos, locTypeDto, targetLev); |
| | | } |
| | | |
| | | /** |
| | | * 兼容旧调用:按外部指定的堆垛机顺序,在指定库区内找新的入库位。 |
| | | */ |
| | | public StartupDto findRun2InboundLocByCandidateCrnNos(Integer sourceStaNo, Integer staDescId, Integer preferredArea, |
| | | List<Integer> candidateCrnNos, LocTypeDto locTypeDto) { |
| | | return findRun2InboundLocByCandidateCrnNos(sourceStaNo, staDescId, preferredArea, candidateCrnNos, locTypeDto, null); |
| | | } |
| | | |
| | | private StartupDto findRun2InboundLocByCandidateCrnNos(Integer sourceStaNo, Integer staDescId, Integer preferredArea, |
| | | List<Integer> candidateCrnNos, LocTypeDto locTypeDto, |
| | | Integer targetLev) { |
| | | if (sourceStaNo == null) { |
| | | throw new CoolException("源站不能为空"); |
| | | } |
| | |
| | | if (Cools.isEmpty(rowLastnoType)) { |
| | | throw new CoolException("数据异常,请联系管理员===》库位规则类型未知"); |
| | | } |
| | | if (rowLastnoType.getType() != 1 && rowLastnoType.getType() != 2) { |
| | | throw new CoolException("当前仓库不支持重新分配入库位"); |
| | | } |
| | | StartupDto startupDto = new StartupDto(); |
| | | LocMast locMast = findRun2EmptyLocByCrnNos(searchRowLastno, rowLastnoType, candidateCrnNos, locTypeDto, |
| | | staDescId, sourceStaNo, startupDto, preferredArea, null, "reassign-inbound"); |
| | | staDescId, sourceStaNo, startupDto, preferredArea, null, "reassign-inbound", targetLev); |
| | | if (Cools.isEmpty(locMast) || !"O".equals(locMast.getLocSts())) { |
| | | return null; |
| | | } |
| | |
| | | private LocMast findRun2EmptyLocByCrnNos(RowLastno rowLastno, RowLastnoType rowLastnoType, List<Integer> candidateCrnNos, |
| | | LocTypeDto locTypeDto, Integer staDescId, Integer sourceStaNo, StartupDto startupDto, |
| | | Integer preferredArea, FindLocNoAttributeVo findLocNoAttributeVo, String stage, boolean routeRequired) { |
| | | return findRun2EmptyLocByCrnNos(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto, |
| | | staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, routeRequired, null); |
| | | } |
| | | |
| | | private LocMast findRun2EmptyLocByCrnNos(RowLastno rowLastno, RowLastnoType rowLastnoType, List<Integer> candidateCrnNos, |
| | | LocTypeDto locTypeDto, Integer staDescId, Integer sourceStaNo, StartupDto startupDto, |
| | | Integer preferredArea, FindLocNoAttributeVo findLocNoAttributeVo, String stage, |
| | | Integer targetLev) { |
| | | return findRun2EmptyLocByCrnNos(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto, |
| | | staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, true, targetLev); |
| | | } |
| | | |
| | | private LocMast findRun2EmptyLocByCrnNos(RowLastno rowLastno, RowLastnoType rowLastnoType, List<Integer> candidateCrnNos, |
| | | LocTypeDto locTypeDto, Integer staDescId, Integer sourceStaNo, StartupDto startupDto, |
| | | Integer preferredArea, FindLocNoAttributeVo findLocNoAttributeVo, String stage, |
| | | boolean routeRequired, Integer targetLev) { |
| | | if (Cools.isEmpty(candidateCrnNos)) { |
| | | log.warn("run2 skip empty candidate list. stage={}, sourceStaNo={}, preferredArea={}, spec={}", |
| | | stage, sourceStaNo, preferredArea, JSON.toJSONString(locTypeDto)); |
| | |
| | | List<Integer> locTypeBlockedCrns = new ArrayList<>(); |
| | | return findRun2EmptyLocByCrnNosRecursively(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto, |
| | | staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, routeRequired, 0, |
| | | crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns); |
| | | crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns, targetLev); |
| | | } |
| | | |
| | | private LocMast findRun2EmptyLocByCrnNosRecursively(RowLastno rowLastno, RowLastnoType rowLastnoType, |
| | |
| | | Integer preferredArea, FindLocNoAttributeVo findLocNoAttributeVo, |
| | | String stage, boolean routeRequired, int index, |
| | | List<Integer> crnErrorCrns, List<Integer> routeBlockedCrns, |
| | | List<Integer> noEmptyCrns, List<Integer> locTypeBlockedCrns) { |
| | | List<Integer> noEmptyCrns, List<Integer> locTypeBlockedCrns, |
| | | Integer targetLev) { |
| | | if (index >= candidateCrnNos.size()) { |
| | | logRun2NoMatch(stage, sourceStaNo, preferredArea, candidateCrnNos, locTypeDto, |
| | | crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns); |
| | |
| | | crnErrorCrns.add(candidateCrnNo); |
| | | return findRun2EmptyLocByCrnNosRecursively(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto, |
| | | staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, routeRequired, index + 1, |
| | | crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns); |
| | | crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns, targetLev); |
| | | } |
| | | Integer targetStaNo = routeRequired ? resolveTargetStaNo(rowLastno, staDescId, sourceStaNo, candidateCrnNo) : null; |
| | | if (routeRequired && Utils.BooleanWhsTypeSta(rowLastno, staDescId) && targetStaNo == null) { |
| | | routeBlockedCrns.add(candidateCrnNo); |
| | | return findRun2EmptyLocByCrnNosRecursively(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto, |
| | | staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, routeRequired, index + 1, |
| | | crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns); |
| | | crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns, targetLev); |
| | | } |
| | | Integer preferredNearRow = getCrnStartRow(rowLastno, candidateCrnNo); |
| | | LocMast candidateLoc = findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, candidateCrnNo, |
| | | preferredNearRow, locTypeDto, findLocNoAttributeVo); |
| | | preferredNearRow, locTypeDto, findLocNoAttributeVo, targetLev); |
| | | if (Cools.isEmpty(candidateLoc)) { |
| | | int availableLocCount = countAssignableLocForCrn(rowLastno, rowLastnoType, candidateCrnNo, |
| | | preferredNearRow == null ? 0 : preferredNearRow, locTypeDto); |
| | |
| | | } |
| | | return findRun2EmptyLocByCrnNosRecursively(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto, |
| | | staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, routeRequired, index + 1, |
| | | crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns); |
| | | crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns, targetLev); |
| | | } |
| | | if (targetStaNo != null) { |
| | | startupDto.setStaNo(targetStaNo); |
| | |
| | | return locTypeDto == null || VersionUtils.locMoveCheckLocTypeComplete(locMast, locTypeDto); |
| | | } |
| | | |
| | | private boolean matchesTargetLev(LocMast locMast, Integer targetLev) { |
| | | return targetLev == null || targetLev <= 0 || (locMast != null && Objects.equals(locMast.getLev1(), targetLev)); |
| | | } |
| | | |
| | | /** |
| | | * 查询某一排上的所有空库位,并按单伸/双伸策略与频次排序。 |
| | | */ |
| | |
| | | private List<LocMast> findOpenLocsByRow(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer row, |
| | | Integer crnNo, LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo, |
| | | boolean singleExtension, boolean ignoreFreqType) { |
| | | return findOpenLocsByRow(rowLastno, rowLastnoType, row, crnNo, locTypeDto, findLocNoAttributeVo, |
| | | singleExtension, ignoreFreqType, null); |
| | | } |
| | | |
| | | private List<LocMast> findOpenLocsByRow(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer row, |
| | | Integer crnNo, LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo, |
| | | boolean singleExtension, boolean ignoreFreqType, Integer targetLev) { |
| | | List<LocMast> result = new ArrayList<LocMast>(); |
| | | if (row == null) { |
| | | return result; |
| | |
| | | if (crnNo != null) { |
| | | wrapper.eq("crn_no", crnNo); |
| | | } |
| | | if (targetLev != null && targetLev > 0) { |
| | | wrapper.eq("lev1", targetLev); |
| | | } |
| | | applyLocTypeFilters(wrapper, locTypeDto, true); |
| | | List<LocMast> locMasts = locMastService.selectList(wrapper); |
| | | List<LocMast> sortedLocMasts = sortLocCandidates(locMasts, findLocNoAttributeVo, ignoreFreqType); |
| | | for (LocMast locMast : sortedLocMasts) { |
| | | if (matchesLocType(locMast, locTypeDto)) { |
| | | if (matchesLocType(locMast, locTypeDto) && matchesTargetLev(locMast, targetLev)) { |
| | | result.add(locMast); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 双伸堆垛机同货优先: |
| | | * 先找深库位中 standby1 相同且状态为 F 的货位,再检查其对应浅库位是否为空。 |
| | | * 先找深库位中同货且状态为 F 的货位,再检查其对应浅库位是否为空。 |
| | | * 空托盘请求则按 matnr=emptyPallet 识别,深位已有空托盘时优先返回对应浅位。 |
| | | */ |
| | | private LocMast findDoubleExtensionSameGoodsPreferredLoc(RowLastno rowLastno, RowLastnoType rowLastnoType, |
| | | Integer crnNo, CrnDepthRuleProfile profile, |
| | | LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo) { |
| | | if (profile == null || !profile.isDoubleExtension() || findLocNoAttributeVo == null |
| | | || Cools.isEmpty(findLocNoAttributeVo.getStandby1())) { |
| | | if (profile == null || !profile.isDoubleExtension() || findLocNoAttributeVo == null) { |
| | | return null; |
| | | } |
| | | boolean emptyPalletRequest = "emptyPallet".equalsIgnoreCase(findLocNoAttributeVo.getMatnr()); |
| | | String standby1 = findLocNoAttributeVo.getStandby1(); |
| | | LinkedHashSet<Integer> processedDeepRows = new LinkedHashSet<Integer>(); |
| | | for (Integer searchRow : profile.getSearchRows()) { |
| | | if (searchRow == null || !profile.isDeepRow(searchRow) || !processedDeepRows.add(searchRow)) { |
| | | if (!emptyPalletRequest && Cools.isEmpty(standby1)) { |
| | | return null; |
| | | } |
| | | List<Integer> orderedShallowRows = orderDoubleExtensionShallowRows(rowLastno, rowLastnoType, crnNo, profile); |
| | | for (Integer shallowRow : orderedShallowRows) { |
| | | Integer deepRow = profile.getPairedDeepRow(shallowRow); |
| | | if (deepRow == null) { |
| | | continue; |
| | | } |
| | | Integer shallowRow = profile.getPairedShallowRow(searchRow); |
| | | if (shallowRow == null) { |
| | | continue; |
| | | } |
| | | List<LocMast> deepLocs = findOccupiedLocsByRow(searchRow, crnNo, findLocNoAttributeVo); |
| | | List<LocMast> deepLocs = findOccupiedLocsByRow(deepRow, crnNo, findLocNoAttributeVo); |
| | | if (Cools.isEmpty(deepLocs)) { |
| | | continue; |
| | | } |
| | |
| | | if (Cools.isEmpty(deepLocNos)) { |
| | | continue; |
| | | } |
| | | List<LocDetl> sameGoodsLocDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("standby1", standby1) |
| | | .in("loc_no", deepLocNos)); |
| | | EntityWrapper<LocDetl> detlWrapper = new EntityWrapper<LocDetl>(); |
| | | detlWrapper.in("loc_no", deepLocNos); |
| | | if (emptyPalletRequest) { |
| | | detlWrapper.eq("matnr", findLocNoAttributeVo.getMatnr()); |
| | | } else { |
| | | detlWrapper.eq("standby1", standby1); |
| | | } |
| | | List<LocDetl> sameGoodsLocDetls = locDetlService.selectList(detlWrapper); |
| | | if (Cools.isEmpty(sameGoodsLocDetls)) { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 双伸堆垛机按当前两侧负载排序浅位搜索顺序。 |
| | | * |
| | | * 负载越低的浅/深配对越优先,避免长期只命中同一侧。 |
| | | */ |
| | | private List<Integer> orderDoubleExtensionShallowRows(RowLastno rowLastno, RowLastnoType rowLastnoType, |
| | | Integer crnNo, CrnDepthRuleProfile profile) { |
| | | List<Integer> orderedShallowRows = new ArrayList<Integer>(); |
| | | if (profile == null || !profile.isDoubleExtension() || Cools.isEmpty(profile.getShallowRows())) { |
| | | return orderedShallowRows; |
| | | } |
| | | orderedShallowRows.addAll(profile.getShallowRows()); |
| | | final Map<Integer, Integer> originalOrder = new HashMap<Integer, Integer>(); |
| | | for (int index = 0; index < orderedShallowRows.size(); index++) { |
| | | originalOrder.put(orderedShallowRows.get(index), index); |
| | | } |
| | | final Map<Integer, Integer> pairLoadCache = new HashMap<Integer, Integer>(); |
| | | for (Integer shallowRow : orderedShallowRows) { |
| | | pairLoadCache.put(shallowRow, countDoubleExtensionPairLoad(rowLastno, rowLastnoType, crnNo, profile, shallowRow)); |
| | | } |
| | | orderedShallowRows.sort(Comparator |
| | | .comparingInt((Integer row) -> pairLoadCache.getOrDefault(row, Integer.MAX_VALUE)) |
| | | .thenComparingInt(row -> originalOrder.getOrDefault(row, Integer.MAX_VALUE))); |
| | | return rotateEqualLoadGroupsByCurrentRow(orderedShallowRows, rowLastno, pairLoadCache); |
| | | } |
| | | |
| | | /** |
| | | * 等载时,按当前排游标旋转组内顺序,避免长期固定命中同一侧深库位。 |
| | | */ |
| | | private List<Integer> rotateEqualLoadGroupsByCurrentRow(List<Integer> orderedRows, RowLastno rowLastno, |
| | | Map<Integer, Integer> pairLoadCache) { |
| | | if (Cools.isEmpty(orderedRows) || rowLastno == null) { |
| | | return orderedRows; |
| | | } |
| | | Integer currentRow = rowLastno.getCurrentRow(); |
| | | if (currentRow == null || currentRow <= 0) { |
| | | return orderedRows; |
| | | } |
| | | List<Integer> rotatedRows = new ArrayList<Integer>(orderedRows.size()); |
| | | int index = 0; |
| | | while (index < orderedRows.size()) { |
| | | Integer currentLoad = pairLoadCache.get(orderedRows.get(index)); |
| | | int groupStart = index; |
| | | while (index < orderedRows.size() && Objects.equals(pairLoadCache.get(orderedRows.get(index)), currentLoad)) { |
| | | index++; |
| | | } |
| | | List<Integer> sameLoadRows = new ArrayList<Integer>(orderedRows.subList(groupStart, index)); |
| | | rotateShallowRowsByCurrentRow(sameLoadRows, currentRow); |
| | | rotatedRows.addAll(sameLoadRows); |
| | | } |
| | | return rotatedRows; |
| | | } |
| | | |
| | | private void rotateShallowRowsByCurrentRow(List<Integer> shallowRows, Integer currentRow) { |
| | | if (Cools.isEmpty(shallowRows) || shallowRows.size() <= 1 || currentRow == null) { |
| | | return; |
| | | } |
| | | int pivotIndex = -1; |
| | | for (int i = 0; i < shallowRows.size(); i++) { |
| | | Integer row = shallowRows.get(i); |
| | | if (row != null && row > currentRow) { |
| | | pivotIndex = i; |
| | | break; |
| | | } |
| | | } |
| | | if (pivotIndex <= 0) { |
| | | return; |
| | | } |
| | | List<Integer> rotated = new ArrayList<Integer>(shallowRows.size()); |
| | | rotated.addAll(shallowRows.subList(pivotIndex, shallowRows.size())); |
| | | rotated.addAll(shallowRows.subList(0, pivotIndex)); |
| | | shallowRows.clear(); |
| | | shallowRows.addAll(rotated); |
| | | } |
| | | |
| | | /** |
| | | * 统计双伸浅/深配对的当前已占用库位数量。 |
| | | */ |
| | | private int countDoubleExtensionPairLoad(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo, |
| | | CrnDepthRuleProfile profile, Integer shallowRow) { |
| | | if (profile == null || shallowRow == null) { |
| | | return Integer.MAX_VALUE; |
| | | } |
| | | int count = countOccupiedLocsByRow(rowLastno, rowLastnoType, shallowRow, crnNo); |
| | | Integer deepRow = profile.getPairedDeepRow(shallowRow); |
| | | if (deepRow != null) { |
| | | count += countOccupiedLocsByRow(rowLastno, rowLastnoType, deepRow, crnNo); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * 统计某一排当前已占用/预约的库存数量。 |
| | | * |
| | | * 这里把 S/R/P/Q/D/X 都算作负载,避免批量入库时只看 F 导致刚预约出去的库位不参与均衡。 |
| | | */ |
| | | private int countOccupiedLocsByRow(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer row, Integer crnNo) { |
| | | if (row == null) { |
| | | return Integer.MAX_VALUE; |
| | | } |
| | | Wrapper<LocMast> wrapper = new EntityWrapper<LocMast>() |
| | | .eq("row1", row) |
| | | .in("loc_sts", Arrays.asList("F", "S", "R", "P", "Q", "D", "X")); |
| | | if (crnNo != null) { |
| | | wrapper.eq("crn_no", crnNo); |
| | | } |
| | | return locMastService.selectCount(wrapper); |
| | | } |
| | | |
| | | /** |
| | |
| | | private LocMast findPairAssignableLoc(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo, |
| | | Integer shallowRow, Integer deepRow, LocTypeDto locTypeDto, |
| | | FindLocNoAttributeVo findLocNoAttributeVo) { |
| | | List<LocMast> shallowOpenLocs = findOpenLocsByRow(rowLastno, rowLastnoType, shallowRow, crnNo, locTypeDto, findLocNoAttributeVo, false); |
| | | return findPairAssignableLoc(rowLastno, rowLastnoType, crnNo, shallowRow, deepRow, locTypeDto, findLocNoAttributeVo, null); |
| | | } |
| | | |
| | | private LocMast findPairAssignableLoc(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo, |
| | | Integer shallowRow, Integer deepRow, LocTypeDto locTypeDto, |
| | | FindLocNoAttributeVo findLocNoAttributeVo, Integer targetLev) { |
| | | List<LocMast> shallowOpenLocs = findOpenLocsByRow(rowLastno, rowLastnoType, shallowRow, crnNo, locTypeDto, findLocNoAttributeVo, false, false, targetLev); |
| | | if (Cools.isEmpty(shallowOpenLocs)) { |
| | | return null; |
| | | } |
| | |
| | | |
| | | private LocMast findConfiguredEmptyLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo, |
| | | Integer preferredNearRow, LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo, |
| | | Integer targetLev) { |
| | | return findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, crnNo, preferredNearRow, locTypeDto, findLocNoAttributeVo, |
| | | false, targetLev); |
| | | } |
| | | |
| | | private LocMast findConfiguredEmptyLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo, |
| | | Integer preferredNearRow, LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo, |
| | | boolean ignoreFreqType) { |
| | | return findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, crnNo, preferredNearRow, locTypeDto, findLocNoAttributeVo, |
| | | ignoreFreqType, null); |
| | | } |
| | | |
| | | private LocMast findConfiguredEmptyLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo, |
| | | Integer preferredNearRow, LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo, |
| | | boolean ignoreFreqType, Integer targetLev) { |
| | | if (rowLastno == null || crnNo == null) { |
| | | return null; |
| | | } |
| | |
| | | } |
| | | LocMast sameGoodsPreferredLoc = findDoubleExtensionSameGoodsPreferredLoc(rowLastno, rowLastnoType, crnNo, |
| | | profile, locTypeDto, findLocNoAttributeVo); |
| | | if (!Cools.isEmpty(sameGoodsPreferredLoc)) { |
| | | if (!Cools.isEmpty(sameGoodsPreferredLoc) && matchesTargetLev(sameGoodsPreferredLoc, targetLev)) { |
| | | return sameGoodsPreferredLoc; |
| | | } |
| | | LinkedHashSet<Integer> processedShallowRows = new LinkedHashSet<Integer>(); |
| | | boolean singleExtension = profile.isSingleExtension(); |
| | | if (!singleExtension) { |
| | | List<Integer> orderedShallowRows = orderDoubleExtensionShallowRows(rowLastno, rowLastnoType, crnNo, profile); |
| | | for (Integer shallowRow : orderedShallowRows) { |
| | | if (shallowRow == null) { |
| | | continue; |
| | | } |
| | | LocMast candidateLoc = findPairAssignableLoc(rowLastno, rowLastnoType, crnNo, shallowRow, |
| | | profile.getPairedDeepRow(shallowRow), locTypeDto, findLocNoAttributeVo, targetLev); |
| | | if (!Cools.isEmpty(candidateLoc)) { |
| | | return candidateLoc; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | LinkedHashSet<Integer> processedShallowRows = new LinkedHashSet<Integer>(); |
| | | for (Integer searchRow : profile.getSearchRows()) { |
| | | if (searchRow == null) { |
| | | continue; |
| | | } |
| | | if (!singleExtension) { |
| | | if (profile.isShallowRow(searchRow)) { |
| | | if (!processedShallowRows.add(searchRow)) { |
| | | if (profile.isShallowRow(searchRow)) { |
| | | if (!processedShallowRows.add(searchRow)) { |
| | | continue; |
| | | } |
| | | LocMast candidateLoc = findPairAssignableLoc(rowLastno, rowLastnoType, crnNo, searchRow, |
| | | profile.getPairedDeepRow(searchRow), locTypeDto, findLocNoAttributeVo, targetLev); |
| | | if (!Cools.isEmpty(candidateLoc)) { |
| | | return candidateLoc; |
| | | } |
| | | continue; |
| | | } |
| | | if (profile.isDeepRow(searchRow)) { |
| | | Integer shallowRow = profile.getPairedShallowRow(searchRow); |
| | | if (shallowRow != null) { |
| | | if (!processedShallowRows.add(shallowRow)) { |
| | | continue; |
| | | } |
| | | LocMast candidateLoc = findPairAssignableLoc(rowLastno, rowLastnoType, crnNo, searchRow, |
| | | profile.getPairedDeepRow(searchRow), locTypeDto, findLocNoAttributeVo); |
| | | LocMast candidateLoc = findPairAssignableLoc(rowLastno, rowLastnoType, crnNo, shallowRow, |
| | | searchRow, locTypeDto, findLocNoAttributeVo, targetLev); |
| | | if (!Cools.isEmpty(candidateLoc)) { |
| | | return candidateLoc; |
| | | } |
| | | continue; |
| | | } |
| | | if (profile.isDeepRow(searchRow)) { |
| | | Integer shallowRow = profile.getPairedShallowRow(searchRow); |
| | | if (shallowRow != null) { |
| | | if (!processedShallowRows.add(shallowRow)) { |
| | | continue; |
| | | } |
| | | LocMast candidateLoc = findPairAssignableLoc(rowLastno, rowLastnoType, crnNo, shallowRow, |
| | | searchRow, locTypeDto, findLocNoAttributeVo); |
| | | if (!Cools.isEmpty(candidateLoc)) { |
| | | return candidateLoc; |
| | | } |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | List<LocMast> locMasts = findOpenLocsByRow(rowLastno, rowLastnoType, searchRow, crnNo, locTypeDto, findLocNoAttributeVo, singleExtension, ignoreFreqType); |
| | | List<LocMast> locMasts = findOpenLocsByRow(rowLastno, rowLastnoType, searchRow, crnNo, locTypeDto, findLocNoAttributeVo, singleExtension, ignoreFreqType, targetLev); |
| | | if (!Cools.isEmpty(locMasts)) { |
| | | return locMasts.get(0); |
| | | } |