| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.serializer.SerializerFeature; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.enums.NotifyMsgType; |
| | | import com.zy.asrs.domain.param.CreateLocMoveTaskParam; |
| | |
| | | ); |
| | | |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | if (!allowBatchOutboundExecute(wrkMast)) { |
| | | continue; |
| | | } |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if (stationThread == null) { |
| | |
| | | |
| | | Integer crnNo = basCrnp.getCrnNo(); |
| | | |
| | | if (!allowBatchOutboundExecute(wrkMast)) { |
| | | return false; |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if (stationThread == null) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | private boolean allowBatchOutboundExecute(WrkMast wrkMast) { |
| | | if (wrkMast == null || Cools.isEmpty(wrkMast.getBatch())) { |
| | | return true; |
| | | } |
| | | |
| | | if (Cools.isEmpty(wrkMast.getBatchSeq())) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "批次:{} 缺少批次序号,暂不允许堆垛机出库", wrkMast.getBatch()); |
| | | return false; |
| | | } |
| | | |
| | | WrkMast firstBatchWrkMast = wrkMastService.getOne(new QueryWrapper<WrkMast>() |
| | | .eq("io_type", WrkIoType.OUT.id) |
| | | .eq("batch", wrkMast.getBatch()) |
| | | .orderByAsc("batch_seq") |
| | | .orderByAsc("wrk_no") |
| | | .last("limit 1")); |
| | | if (firstBatchWrkMast == null) { |
| | | return true; |
| | | } |
| | | |
| | | if (Cools.isEmpty(firstBatchWrkMast.getBatchSeq())) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "批次:{} 存在未配置批次序号的任务,暂不允许堆垛机出库", wrkMast.getBatch()); |
| | | return false; |
| | | } |
| | | |
| | | boolean currentIsFirstBatchTask = wrkMast.getWrkNo().equals(firstBatchWrkMast.getWrkNo()); |
| | | boolean firstBatchTaskExecuted = firstBatchWrkMast.getWrkSts() != null |
| | | && !firstBatchWrkMast.getWrkSts().equals(WrkStsType.NEW_OUTBOUND.sts); |
| | | if (!currentIsFirstBatchTask && !firstBatchTaskExecuted) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "批次:{} 首个序号任务:{} 尚未执行,当前任务暂不允许出库", wrkMast.getBatch(), firstBatchWrkMast.getWrkNo()); |
| | | return false; |
| | | } |
| | | |
| | | int batchRunningLimit = getSystemConfigInt("crnOutBatchRunningLimit", 5); |
| | | if (batchRunningLimit <= 0) { |
| | | return true; |
| | | } |
| | | |
| | | long batchRunningCount = wrkMastService.count(new QueryWrapper<WrkMast>() |
| | | .eq("io_type", WrkIoType.OUT.id) |
| | | .eq("batch", wrkMast.getBatch()) |
| | | .notIn("wrk_sts", |
| | | WrkStsType.NEW_OUTBOUND.sts, |
| | | WrkStsType.COMPLETE_OUTBOUND.sts, |
| | | WrkStsType.SETTLE_OUTBOUND.sts)); |
| | | if (batchRunningCount >= batchRunningLimit) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "批次:{} 执行中任务数达到上限,当前={},上限={}", wrkMast.getBatch(), batchRunningCount, batchRunningLimit); |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | private int getSystemConfigInt(String code, int defaultValue) { |
| | | Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key); |
| | | if (systemConfigMapObj == null) { |
| | | return defaultValue; |
| | | } |
| | | try { |
| | | HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj; |
| | | return Integer.parseInt(systemConfigMap.getOrDefault(code, String.valueOf(defaultValue))); |
| | | } catch (Exception ignore) { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | private synchronized boolean crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) { |
| | | CrnProtocol crnProtocol = crnThread.getStatus(); |
| | | if(crnProtocol == null){ |