| | |
| | | return R.error("当前目标库位不存在"); |
| | | } |
| | | |
| | | Integer preferredArea = resolveReassignArea(wrkMast, currentLoc); |
| | | if (preferredArea == null) { |
| | | LocTypeDto locTypeDto = buildReassignLocTypeDto(currentLoc); |
| | | List<Integer> areaOrder = buildReassignAreaOrder(wrkMast, currentLoc); |
| | | if (Cools.isEmpty(areaOrder)) { |
| | | return R.error("无法确定任务所属库区"); |
| | | } |
| | | |
| | | List<Integer> candidateCrnNos = buildReassignCandidateCrnNos(preferredArea, wrkMast.getCrnNo()); |
| | | if (candidateCrnNos.isEmpty()) { |
| | | return R.error("当前库区没有其他堆垛机可供重分配"); |
| | | StartupDto startupDto = null; |
| | | Integer preferredArea = null; |
| | | for (Integer area : areaOrder) { |
| | | List<Integer> candidateCrnNos = buildReassignCandidateCrnNos(area, wrkMast.getCrnNo()); |
| | | if (candidateCrnNos.isEmpty()) { |
| | | continue; |
| | | } |
| | | startupDto = commonService.findRun2InboundLocByCandidateCrnNos( |
| | | wrkMast.getSourceStaNo(), wrkMast.getIoType(), area, candidateCrnNos, locTypeDto); |
| | | if (startupDto != null && !Cools.isEmpty(startupDto.getLocNo())) { |
| | | preferredArea = area; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | LocTypeDto locTypeDto = buildReassignLocTypeDto(currentLoc); |
| | | StartupDto startupDto = commonService.findRun2InboundLocByCandidateCrnNos( |
| | | wrkMast.getSourceStaNo(), wrkMast.getIoType(), preferredArea, candidateCrnNos, locTypeDto); |
| | | if (startupDto == null || Cools.isEmpty(startupDto.getLocNo())) { |
| | | return R.error("当前库区没有可重新分配的空库位"); |
| | | } |
| | |
| | | } |
| | | |
| | | private Integer resolveReassignArea(WrkMast wrkMast, LocMast currentLoc) { |
| | | Integer stationArea = Utils.getStationStorageArea(wrkMast.getSourceStaNo()); |
| | | if (belongsToArea(stationArea, wrkMast.getCrnNo(), currentLoc)) { |
| | | return stationArea; |
| | | List<Integer> stationAreas = Utils.getStationStorageAreas(wrkMast.getSourceStaNo()); |
| | | if (!Cools.isEmpty(stationAreas)) { |
| | | for (Integer area : stationAreas) { |
| | | if (belongsToArea(area, wrkMast.getCrnNo(), currentLoc)) { |
| | | return area; |
| | | } |
| | | } |
| | | } |
| | | Integer fallbackArea = findAreaByCurrentTask(wrkMast.getCrnNo(), currentLoc); |
| | | if (fallbackArea != null) { |
| | | return fallbackArea; |
| | | } |
| | | return stationArea; |
| | | return Utils.getStationStorageArea(wrkMast.getSourceStaNo()); |
| | | } |
| | | |
| | | private Integer findAreaByCurrentTask(Integer currentCrnNo, LocMast currentLoc) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | private List<Integer> buildReassignAreaOrder(WrkMast wrkMast, LocMast currentLoc) { |
| | | LinkedHashSet<Integer> areaOrder = new LinkedHashSet<>(); |
| | | List<Integer> stationAreas = Utils.getStationStorageAreas(wrkMast.getSourceStaNo()); |
| | | if (!Cools.isEmpty(stationAreas)) { |
| | | areaOrder.addAll(stationAreas); |
| | | } |
| | | Integer currentArea = findAreaByCurrentTask(wrkMast.getCrnNo(), currentLoc); |
| | | if (currentArea != null) { |
| | | areaOrder.add(currentArea); |
| | | } |
| | | if (areaOrder.isEmpty()) { |
| | | Integer resolvedArea = resolveReassignArea(wrkMast, currentLoc); |
| | | if (resolvedArea != null) { |
| | | areaOrder.add(resolvedArea); |
| | | } |
| | | } |
| | | return new ArrayList<>(areaOrder); |
| | | } |
| | | |
| | | private boolean belongsToArea(Integer area, Integer currentCrnNo, LocMast currentLoc) { |
| | | if (area == null || area <= 0) { |
| | | return false; |