| | |
| | | * <p>处理规则: |
| | | * 1. 先根据入库站点查询所属库区。 |
| | | * 2. 先提取该库区内的堆垛机,并按可用空库位过滤不可用堆垛机。 |
| | | * 3. 若当前库区没有满足条件的空库位,再补充其他库区的堆垛机。 |
| | | * 4. 当 {@code locType1 = 1} 时,先返回低库位堆垛机,再把同批堆垛机的高库位追加到后面。 |
| | | * 5. 对不存在、故障、不可入以及无空库位的堆垛机直接剔除。 |
| | | * 3. 当 {@code locType1 = 1} 时,先返回低库位堆垛机,再把同批堆垛机的高库位追加到后面。 |
| | | * 4. 对不存在、故障、不可入以及无空库位的堆垛机直接剔除。 |
| | | * |
| | | * <p>这里是只读排序工具,不再写回 {@code asr_row_lastno.crn_qty}。 |
| | | * {@code crn_qty} 在主数据里表示“堆垛机数量”,不能再被拿来当轮询游标,否则会把整仓配置写坏。 |
| | |
| | | // 先取当前库区对应的堆垛机。 |
| | | List<Integer> preferredCrnNos = getAreaCrnNos(storageArea, rowLastno); |
| | | List<Integer> preferredAvailableCrnNos = getAvailableCrnNos(preferredCrnNos, locType1, emptyPallet, basCrnpService, locMastService); |
| | | appendCrnLocTypeEntries(result, preferredAvailableCrnNos, locType1, locMastService); |
| | | appendCrnLocTypeEntries(result, preferredAvailableCrnNos, locType1, emptyPallet, locMastService); |
| | | |
| | | // 当前库区没有可用容量时,再补充其他库区堆垛机。 |
| | | if (!hasAvailableCapacity(preferredCrnNos, locType1, basCrnpService, locMastService)) { |
| | | List<Integer> otherAreaCrnNos = getOtherAreaCrnNos(storageArea, rowLastno); |
| | | List<Integer> otherAvailableCrnNos = getAvailableCrnNos(otherAreaCrnNos, locType1, emptyPallet, basCrnpService, locMastService); |
| | | appendCrnLocTypeEntries(result, otherAvailableCrnNos, locType1, locMastService); |
| | | } |
| | | return result; |
| | | } |
| | | private static void appendCrnLocTypeEntries(List<Map<String, Integer>> result, List<Integer> crnNos, Integer locType1, LocMastService locMastService) { |
| | | private static void appendCrnLocTypeEntries(List<Map<String, Integer>> result, List<Integer> crnNos, Integer locType1, boolean emptyPallet, LocMastService locMastService) { |
| | | Short normalizedLocType1 = normalizeLocType1(locType1); |
| | | if (normalizedLocType1 == null) { |
| | | appendCrnLocTypeEntries(result, crnNos, (short) 1, locMastService); |
| | | appendCrnLocTypeEntries(result, crnNos, (short) 2, locMastService); |
| | | appendCrnLocTypeEntries(result, crnNos, (short) 1, emptyPallet, locMastService); |
| | | appendCrnLocTypeEntries(result, crnNos, (short) 2, emptyPallet, locMastService); |
| | | return; |
| | | } |
| | | appendCrnLocTypeEntries(result, crnNos, normalizedLocType1, locMastService); |
| | | appendCrnLocTypeEntries(result, crnNos, normalizedLocType1, emptyPallet, locMastService); |
| | | if (normalizedLocType1 == 1) { |
| | | appendCrnLocTypeEntries(result, crnNos, (short) 2, locMastService); |
| | | appendCrnLocTypeEntries(result, crnNos, (short) 2, emptyPallet, locMastService); |
| | | } |
| | | } |
| | | |
| | | private static void appendCrnLocTypeEntries(List<Map<String, Integer>> result, List<Integer> crnNos, Short targetLocType1, LocMastService locMastService) { |
| | | private static void appendCrnLocTypeEntries(List<Map<String, Integer>> result, List<Integer> crnNos, Short targetLocType1, boolean emptyPallet, LocMastService locMastService) { |
| | | if (targetLocType1 == null || Cools.isEmpty(crnNos)) { |
| | | return; |
| | | } |
| | | for (Integer crnNo : crnNos) { |
| | | if (!hasAvailableLoc(crnNo, targetLocType1, locMastService) || containsCrnLocType(result, crnNo, targetLocType1)) { |
| | | if (!hasAvailableLoc(crnNo, targetLocType1, emptyPallet, locMastService) || containsCrnLocType(result, crnNo, targetLocType1)) { |
| | | continue; |
| | | } |
| | | Map<String, Integer> item = new LinkedHashMap<>(); |
| | |
| | | if (crnNo == null || !basCrnpService.checkSiteError(crnNo, true)) { |
| | | continue; |
| | | } |
| | | if (!hasAvailableLocForRequest(crnNo, locType1, locMastService)) { |
| | | if (!hasAvailableLocForRequest(crnNo, locType1, emptyPallet, locMastService)) { |
| | | continue; |
| | | } |
| | | availableCrnNos.add(crnNo); |
| | |
| | | return "Y".equalsIgnoreCase(basCrnp.getEmpIn()) ? 1 : 0; |
| | | } |
| | | |
| | | private static boolean hasAvailableLocForRequest(Integer crnNo, Integer locType1, LocMastService locMastService) { |
| | | private static boolean hasAvailableLocForRequest(Integer crnNo, Integer locType1, boolean emptyPallet, LocMastService locMastService) { |
| | | Short normalizedLocType1 = normalizeLocType1(locType1); |
| | | if (normalizedLocType1 == null) { |
| | | return hasAvailableLoc(crnNo, (short) 1, locMastService) || hasAvailableLoc(crnNo, (short) 2, locMastService); |
| | | return hasAvailableLoc(crnNo, (short) 1, emptyPallet, locMastService) |
| | | || hasAvailableLoc(crnNo, (short) 2, emptyPallet, locMastService); |
| | | } |
| | | if (hasAvailableLoc(crnNo, normalizedLocType1, locMastService)) { |
| | | if (hasAvailableLoc(crnNo, normalizedLocType1, emptyPallet, locMastService)) { |
| | | return true; |
| | | } |
| | | return normalizedLocType1 == 1 && hasAvailableLoc(crnNo, (short) 2, locMastService); |
| | | return normalizedLocType1 == 1 && hasAvailableLoc(crnNo, (short) 2, emptyPallet, locMastService); |
| | | } |
| | | |
| | | private static boolean hasAvailableLoc(Integer crnNo, Short locType1, LocMastService locMastService) { |
| | | private static boolean hasAvailableLoc(Integer crnNo, Short locType1, boolean emptyPallet, LocMastService locMastService) { |
| | | if (crnNo == null || locType1 == null) { |
| | | return false; |
| | | } |
| | | return locMastService.selectCount(new EntityWrapper<LocMast>() |
| | | .eq("crn_no", crnNo) |
| | | .eq("loc_sts", "O") |
| | | .eq("loc_type1", locType1)) > 0; |
| | | EntityWrapper<LocMast> wrapper = new EntityWrapper<LocMast>(); |
| | | wrapper.eq("crn_no", crnNo); |
| | | wrapper.eq("loc_sts", "O"); |
| | | wrapper.eq("loc_type1", locType1); |
| | | if (!emptyPallet) { |
| | | wrapper.ne("loc_type2", 1); |
| | | } |
| | | return locMastService.selectCount(wrapper) > 0; |
| | | } |
| | | |
| | | private static Short normalizeLocType1(Integer locType1) { |