| | |
| | | @Autowired |
| | | private StationOperateProcessUtils stationOperateProcessUtils; |
| | | |
| | | private static final String CRN_OUT_REQUIRE_STATION_OUT_ENABLE_CONFIG = "crnOutRequireStationOutEnable"; |
| | | |
| | | public synchronized void crnIoExecute() { |
| | | Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key); |
| | | if (systemConfigMapObj != null) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isOutEnable()) { |
| | | if (isRequireOutboundStationOutEnable() && !stationProtocol.isOutEnable()) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "放货站点:{} 没有可出信号", stationObjModel.getStationId()); |
| | | continue; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isOutEnable()) { |
| | | if (isRequireOutboundStationOutEnable() && !stationProtocol.isOutEnable()) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "放货站点:{} 没有可出信号", stationObjModel.getStationId()); |
| | | continue; |
| | | } |
| | |
| | | return true; |
| | | } |
| | | |
| | | List<WrkMast> unfinishedBatchWrkMasts = listUnfinishedBatchWrkMasts(wrkMast.getBatch()); |
| | | if (hasMissingBatchSeq(unfinishedBatchWrkMasts)) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "批次:{} 存在未配置批次序号的未完成任务,暂不允许堆垛机出库", wrkMast.getBatch()); |
| | | return false; |
| | | } |
| | | |
| | | if (!isWithinBatchExecuteWindow(wrkMast, unfinishedBatchWrkMasts, batchRunningLimit)) { |
| | | Integer windowStartSeq = unfinishedBatchWrkMasts.get(0).getBatchSeq(); |
| | | Integer windowEndSeq = unfinishedBatchWrkMasts.get(Math.min(batchRunningLimit, unfinishedBatchWrkMasts.size()) - 1).getBatchSeq(); |
| | | News.taskInfo(wrkMast.getWrkNo(), |
| | | "批次:{} 当前严格执行窗口序号为[{}-{}],当前序号={},暂不允许堆垛机出库", |
| | | wrkMast.getBatch(), |
| | | windowStartSeq, |
| | | windowEndSeq, |
| | | wrkMast.getBatchSeq()); |
| | | return false; |
| | | } |
| | | |
| | | long batchRunningCount = wrkMastService.count(new QueryWrapper<WrkMast>() |
| | | .eq("io_type", WrkIoType.OUT.id) |
| | | .eq("batch", wrkMast.getBatch()) |
| | |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | private List<WrkMast> listUnfinishedBatchWrkMasts(String batch) { |
| | | if (Cools.isEmpty(batch)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return wrkMastService.list(new QueryWrapper<WrkMast>() |
| | | .eq("io_type", WrkIoType.OUT.id) |
| | | .eq("batch", batch) |
| | | .notIn("wrk_sts", |
| | | WrkStsType.COMPLETE_OUTBOUND.sts, |
| | | WrkStsType.SETTLE_OUTBOUND.sts) |
| | | .orderByAsc("batch_seq") |
| | | .orderByAsc("wrk_no")); |
| | | } |
| | | |
| | | private boolean hasMissingBatchSeq(List<WrkMast> wrkMasts) { |
| | | if (wrkMasts == null || wrkMasts.isEmpty()) { |
| | | return false; |
| | | } |
| | | for (WrkMast item : wrkMasts) { |
| | | if (item == null || Cools.isEmpty(item.getBatchSeq())) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean isWithinBatchExecuteWindow(WrkMast wrkMast, List<WrkMast> unfinishedBatchWrkMasts, int batchRunningLimit) { |
| | | if (wrkMast == null || unfinishedBatchWrkMasts == null || unfinishedBatchWrkMasts.isEmpty()) { |
| | | return true; |
| | | } |
| | | int windowSize = Math.min(batchRunningLimit, unfinishedBatchWrkMasts.size()); |
| | | for (int i = 0; i < windowSize; i++) { |
| | | WrkMast current = unfinishedBatchWrkMasts.get(i); |
| | | if (current != null && wrkMast.getWrkNo().equals(current.getWrkNo())) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean isOutboundStationTaskLimitReached() { |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean isRequireOutboundStationOutEnable() { |
| | | return getSystemConfigBoolean(CRN_OUT_REQUIRE_STATION_OUT_ENABLE_CONFIG, true); |
| | | } |
| | | |
| | | private boolean getSystemConfigBoolean(String code, boolean defaultValue) { |
| | | Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key); |
| | | if (!(systemConfigMapObj instanceof Map)) { |
| | | return defaultValue; |
| | | } |
| | | try { |
| | | Object value = ((Map<?, ?>) systemConfigMapObj).get(code); |
| | | if (value == null) { |
| | | return defaultValue; |
| | | } |
| | | String text = String.valueOf(value).trim(); |
| | | if ("Y".equalsIgnoreCase(text) || "true".equalsIgnoreCase(text) || "1".equals(text)) { |
| | | return true; |
| | | } |
| | | if ("N".equalsIgnoreCase(text) || "false".equalsIgnoreCase(text) || "0".equals(text)) { |
| | | return false; |
| | | } |
| | | } catch (Exception ignore) { |
| | | } |
| | | return defaultValue; |
| | | } |
| | | |
| | | private synchronized boolean crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) { |
| | | CrnProtocol crnProtocol = crnThread.getStatus(); |
| | | if(crnProtocol == null){ |