| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Component |
| | | public class InboundCrnMoveDispatchScheduler { |
| | |
| | | return; |
| | | } |
| | | |
| | | // 同堆垛机没有未完成出库任务时,优先直接到当前入库任务取货位等待。 |
| | | if (!hasPendingOutboundTask(crnNo)) { |
| | | // 同堆垛机没有需要参与当前调度判断的出库任务时,优先直接到当前入库任务取货位等待。 |
| | | if (!hasBlockingOutboundTask(crnNo)) { |
| | | boolean dispatched = crnOperateProcessUtils.dispatchCrnMove(crnNo, inboundPickupLocNo); |
| | | if (dispatched) { |
| | | News.info("检测到仅有入库任务,已触发堆垛机直接移动到入库任务取货位等待,工作号={},堆垛机号={},取货位={}", |
| | |
| | | return null; |
| | | } |
| | | |
| | | private boolean hasPendingOutboundTask(Integer crnNo) { |
| | | private boolean hasBlockingOutboundTask(Integer crnNo) { |
| | | if (crnNo == null) { |
| | | return false; |
| | | } |
| | | return wrkMastService.count(new QueryWrapper<WrkMast>() |
| | | List<WrkMast> pendingOutboundTasks = wrkMastService.list(new QueryWrapper<WrkMast>() |
| | | .eq("crn_no", crnNo) |
| | | .eq("io_type", WrkIoType.OUT.id) |
| | | .in("wrk_sts", |
| | |
| | | WrkStsType.OUTBOUND_RUN_COMPLETE.sts, |
| | | WrkStsType.STATION_RUN.sts, |
| | | WrkStsType.STATION_RUN_COMPLETE.sts, |
| | | WrkStsType.OUTBOUND_MANUAL.sts)) > 0; |
| | | WrkStsType.OUTBOUND_MANUAL.sts) |
| | | .orderByAsc("wrk_no")); |
| | | if (pendingOutboundTasks == null || pendingOutboundTasks.isEmpty()) { |
| | | return false; |
| | | } |
| | | |
| | | // 非批次任务或缺少批次序号的任务仍按原逻辑处理,避免放宽到无法确认执行顺序的出库任务。 |
| | | boolean hasNonBatchTask = pendingOutboundTasks.stream().anyMatch(task -> !isBatchTaskWithSeq(task)); |
| | | if (hasNonBatchTask) { |
| | | return true; |
| | | } |
| | | |
| | | String activeBatch = resolveActiveOutboundBatch(pendingOutboundTasks); |
| | | if (Cools.isEmpty(activeBatch)) { |
| | | return true; |
| | | } |
| | | |
| | | return pendingOutboundTasks.stream() |
| | | .filter(this::isBatchTaskWithSeq) |
| | | .anyMatch(task -> Objects.equals(activeBatch, task.getBatch())); |
| | | } |
| | | |
| | | private String resolveActiveOutboundBatch(List<WrkMast> pendingOutboundTasks) { |
| | | if (pendingOutboundTasks == null || pendingOutboundTasks.isEmpty()) { |
| | | return null; |
| | | } |
| | | Set<String> activeBatchSet = pendingOutboundTasks.stream() |
| | | .filter(this::isBatchTaskWithSeq) |
| | | .filter(task -> !Objects.equals(task.getWrkSts(), WrkStsType.NEW_OUTBOUND.sts)) |
| | | .map(WrkMast::getBatch) |
| | | .filter(batch -> !Cools.isEmpty(batch)) |
| | | .collect(Collectors.toSet()); |
| | | if (activeBatchSet.size() != 1) { |
| | | return null; |
| | | } |
| | | return activeBatchSet.iterator().next(); |
| | | } |
| | | |
| | | private boolean isBatchTaskWithSeq(WrkMast wrkMast) { |
| | | return wrkMast != null |
| | | && Objects.equals(wrkMast.getIoType(), WrkIoType.OUT.id) |
| | | && !Cools.isEmpty(wrkMast.getBatch()) |
| | | && wrkMast.getBatchSeq() != null; |
| | | } |
| | | |
| | | private boolean isInboundCrnMoveDispatchWindow(WrkMast wrkMast, StationMoveSession session) { |