| | |
| | | * 3. 若当前库区没有满足条件的空库位,再补充其他库区的堆垛机。 |
| | | * 4. 当 {@code locType1 = 1} 时,先返回低库位堆垛机,再把同批堆垛机的高库位追加到后面。 |
| | | * 5. 对不存在、故障、不可入以及无空库位的堆垛机直接剔除。 |
| | | * 6. 当物料为 {@code emptyPallet} 时,按空板入库优先规则重新排序。 |
| | | * |
| | | * <p>这里是只读排序工具,不再写回 {@code asr_row_lastno.crn_qty}。 |
| | | * {@code crn_qty} 在主数据里表示“堆垛机数量”,不能再被拿来当轮询游标,否则会把整仓配置写坏。 |
| | | * |
| | | * <p>返回结果中的每一项格式为: |
| | | * {@code {crnNo: 堆垛机号, locType1: 库位高低类型}} |
| | |
| | | if (areaRowLastno == null) { |
| | | return new ArrayList<>(crnNos); |
| | | } |
| | | Integer startCrnNo = resolveAreaStartCrnNo(areaRowLastno, rowLastno); |
| | | Integer endCrnNo = resolveAreaEndCrnNo(areaRowLastno, rowLastno); |
| | | if (startCrnNo != null && endCrnNo != null && startCrnNo <= endCrnNo) { |
| | | for (int crnNo = startCrnNo; crnNo <= endCrnNo; crnNo++) { |
| | | addAreaCrnNo(crnNos, crnNo, 1, endCrnNo); |
| | | } |
| | | for (int crnNo = areaRowLastno.getsCrnNo(); crnNo <= startCrnNo; crnNo++) { |
| | | addAreaCrnNo(crnNos, crnNo, 1, endCrnNo); |
| | | } |
| | | Integer nextCrnQty = startCrnNo + 1; |
| | | if (areaRowLastno.geteCrnNo() != null && nextCrnQty > areaRowLastno.geteCrnNo()) { |
| | | nextCrnQty = areaRowLastno.getsCrnNo() == null ? 1 : areaRowLastno.getsCrnNo(); |
| | | } |
| | | areaRowLastno.setCrnQty(nextCrnQty); |
| | | SpringUtils.getBean(RowLastnoService.class).updateById(areaRowLastno); |
| | | Integer startCrnNo = resolveAreaStartCrnNo(areaRowLastno); |
| | | List<Integer> orderedCrnNos = getOrderedCrnNos(areaRowLastno, startCrnNo); |
| | | if (!orderedCrnNos.isEmpty()) { |
| | | crnNos.addAll(orderedCrnNos); |
| | | } |
| | | |
| | | if (crnNos.isEmpty()) { |
| | |
| | | return defaultRowLastno; |
| | | } |
| | | |
| | | private static Integer resolveAreaStartCrnNo(RowLastno areaRowLastno, RowLastno defaultRowLastno) { |
| | | if (areaRowLastno != null && areaRowLastno.getCrnQty() != null && areaRowLastno.getCrnQty() > 0) { |
| | | return areaRowLastno.getCrnQty(); |
| | | private static Integer resolveAreaStartCrnNo(RowLastno areaRowLastno) { |
| | | if (areaRowLastno == null) { |
| | | return null; |
| | | } |
| | | if (areaRowLastno != null && areaRowLastno.getsCrnNo() != null && areaRowLastno.getsCrnNo() > 0) { |
| | | return areaRowLastno.getsCrnNo(); |
| | | Integer startCrnNo = areaRowLastno.getsCrnNo(); |
| | | Integer endCrnNo = areaRowLastno.geteCrnNo(); |
| | | Integer currentRow = areaRowLastno.getCurrentRow(); |
| | | Integer rowSpan = getCrnRowSpan(areaRowLastno.getTypeId()); |
| | | if (startCrnNo == null || startCrnNo <= 0) { |
| | | return 1; |
| | | } |
| | | if (defaultRowLastno != null && defaultRowLastno.getsCrnNo() != null && defaultRowLastno.getsCrnNo() > 0) { |
| | | return defaultRowLastno.getsCrnNo(); |
| | | if (endCrnNo == null || endCrnNo < startCrnNo || currentRow == null || rowSpan == null || rowSpan <= 0) { |
| | | return startCrnNo; |
| | | } |
| | | return 1; |
| | | int startRow = areaRowLastno.getsRow() == null ? 1 : areaRowLastno.getsRow(); |
| | | int offset = Math.max(currentRow - startRow, 0) / rowSpan; |
| | | int resolvedCrnNo = startCrnNo + offset; |
| | | if (resolvedCrnNo < startCrnNo || resolvedCrnNo > endCrnNo) { |
| | | return startCrnNo; |
| | | } |
| | | return resolvedCrnNo; |
| | | } |
| | | |
| | | private static Integer resolveAreaEndCrnNo(RowLastno areaRowLastno, RowLastno defaultRowLastno) { |
| | | if (areaRowLastno != null && areaRowLastno.geteCrnNo() != null && areaRowLastno.geteCrnNo() > 0) { |
| | | return areaRowLastno.geteCrnNo(); |
| | | private static List<Integer> getOrderedCrnNos(RowLastno rowLastno, Integer startCrnNo) { |
| | | List<Integer> orderedCrnNos = new ArrayList<>(); |
| | | if (rowLastno == null) { |
| | | return orderedCrnNos; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private static void addAreaCrnNo(LinkedHashSet<Integer> crnNos, Integer crnNo, Integer startCrnNo, Integer endCrnNo) { |
| | | if (crnNos == null || crnNo == null || startCrnNo == null || endCrnNo == null) { |
| | | return; |
| | | int start = rowLastno.getsCrnNo() == null ? 1 : rowLastno.getsCrnNo(); |
| | | int end = rowLastno.geteCrnNo() == null ? start + ((rowLastno.getCrnQty() == null ? 1 : rowLastno.getCrnQty()) - 1) : rowLastno.geteCrnNo(); |
| | | int first = startCrnNo == null ? start : startCrnNo; |
| | | if (first < start || first > end) { |
| | | first = start; |
| | | } |
| | | if (crnNo < startCrnNo || crnNo > endCrnNo) { |
| | | return; |
| | | for (int crnNo = first; crnNo <= end; crnNo++) { |
| | | orderedCrnNos.add(crnNo); |
| | | } |
| | | crnNos.add(crnNo); |
| | | for (int crnNo = start; crnNo < first; crnNo++) { |
| | | orderedCrnNos.add(crnNo); |
| | | } |
| | | return orderedCrnNos; |
| | | } |
| | | |
| | | private static List<Integer> getAllCrnNos(RowLastno rowLastno) { |