| | |
| | | 调用 generateStoreWrkFile() 请求 WMS 生成真实任务 |
| | | 调用 crnOperateUtils.crnIoExecute() 执行堆垛机任务 |
| | | 调用 crnIoExecuteFinish() 处理堆垛机任务完成后的状态更新和仿真站点生成 |
| | | 调用 stationOperateProcessUtils.stationInExecute() 执行输送站入库任务 |
| | | 调用 stationOperateProcessUtils.submitStationInTasks(...) 按 lane 提交输送站入库任务 |
| | | 调用 stationOperateProcessUtils.stationOutExecute() 执行输送站出库任务 |
| | | 调用 stationOperateProcessUtils.stationOutExecuteFinish() 检查输送站出库任务完成 |
| | | |
| | |
| | | @Slf4j |
| | | @Component |
| | | public class NormalProcess implements MainProcessPluginApi, StoreInTaskPolicy { |
| | | private static final long DISPATCH_INTERVAL_MS = 200L; |
| | | |
| | | @Autowired |
| | | private CrnOperateProcessUtils crnOperateUtils; |
| | |
| | | //请求生成入库任务 |
| | | generateStoreWrkFile(); |
| | | |
| | | //执行堆垛机任务 |
| | | crnOperateUtils.crnIoExecute(); |
| | | //堆垛机任务执行完成 |
| | | crnOperateUtils.crnIoExecuteFinish(); |
| | | //执行输送站点入库任务 |
| | | stationOperateProcessUtils.stationInExecute(); |
| | | //执行输送站点出库任务 |
| | | stationOperateProcessUtils.crnStationOutExecute(); |
| | | //执行堆垛机任务,按 lane 串行提交 |
| | | crnOperateUtils.submitCrnIoTasks(DISPATCH_INTERVAL_MS); |
| | | //堆垛机任务执行完成,按 lane 串行提交 |
| | | crnOperateUtils.submitCrnIoExecuteFinishTasks(DISPATCH_INTERVAL_MS); |
| | | //执行输送站点入库任务,按 lane 串行提交 |
| | | stationOperateProcessUtils.submitStationInTasks(DISPATCH_INTERVAL_MS); |
| | | //执行输送站点出库任务,按 lane 串行提交 |
| | | stationOperateProcessUtils.submitCrnStationOutTasks(DISPATCH_INTERVAL_MS); |
| | | |
| | | //检测输送站点是否运行堵塞 |
| | | stationOperateProcessUtils.checkStationRunBlock(); |
| | | //检测输送站点任务停留超时后重新计算路径 |
| | | stationOperateProcessUtils.checkStationIdleRecover(); |
| | | //检测输送站点是否运行堵塞,按 lane 串行提交 |
| | | stationOperateProcessUtils.submitCheckStationRunBlockTasks(DISPATCH_INTERVAL_MS); |
| | | //检测输送站点任务停留超时后重新计算路径,按 lane 串行提交 |
| | | stationOperateProcessUtils.submitCheckStationIdleRecoverTasks(DISPATCH_INTERVAL_MS); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Slf4j |
| | | @Component |
| | | public class XiaosongProcess implements MainProcessPluginApi, StoreInTaskPolicy { |
| | | private static final long DISPATCH_INTERVAL_MS = 200L; |
| | | |
| | | @Autowired |
| | | private CrnOperateProcessUtils crnOperateUtils; |
| | |
| | | //请求生成入库任务 |
| | | generateStoreWrkFile(); |
| | | |
| | | //执行堆垛机任务 |
| | | crnOperateUtils.crnIoExecute(); |
| | | //堆垛机任务执行完成 |
| | | crnOperateUtils.crnIoExecuteFinish(); |
| | | //执行输送站点入库任务 |
| | | stationOperateProcessUtils.stationInExecute(); |
| | | //执行堆垛机输送站点出库任务 |
| | | stationOperateProcessUtils.crnStationOutExecute(); |
| | | //执行双工位堆垛机输送站点出库任务 |
| | | stationOperateProcessUtils.dualCrnStationOutExecute(); |
| | | //检测输送站点是否运行堵塞 |
| | | stationOperateProcessUtils.checkStationRunBlock(); |
| | | //检测输送站点任务停留超时后重新计算路径 |
| | | stationOperateProcessUtils.checkStationIdleRecover(); |
| | | //执行堆垛机任务,按 lane 串行提交 |
| | | crnOperateUtils.submitCrnIoTasks(DISPATCH_INTERVAL_MS); |
| | | //堆垛机任务执行完成,按 lane 串行提交 |
| | | crnOperateUtils.submitCrnIoExecuteFinishTasks(DISPATCH_INTERVAL_MS); |
| | | //执行输送站点入库任务,按 lane 串行提交 |
| | | stationOperateProcessUtils.submitStationInTasks(DISPATCH_INTERVAL_MS); |
| | | //执行堆垛机输送站点出库任务,按 lane 串行提交 |
| | | stationOperateProcessUtils.submitCrnStationOutTasks(DISPATCH_INTERVAL_MS); |
| | | //执行双工位堆垛机输送站点出库任务,按 lane 串行提交 |
| | | stationOperateProcessUtils.submitDualCrnStationOutTasks(DISPATCH_INTERVAL_MS); |
| | | //检测输送站点是否运行堵塞,按 lane 串行提交 |
| | | stationOperateProcessUtils.submitCheckStationRunBlockTasks(DISPATCH_INTERVAL_MS); |
| | | //检测输送站点任务停留超时后重新计算路径,按 lane 串行提交 |
| | | stationOperateProcessUtils.submitCheckStationIdleRecoverTasks(DISPATCH_INTERVAL_MS); |
| | | |
| | | // 执行双工位堆垛机任务 |
| | | dualCrnOperateProcessUtils.dualCrnIoExecute(); |
| | | // 双工位堆垛机任务执行完成 |
| | | dualCrnOperateProcessUtils.dualCrnIoExecuteFinish(); |
| | | // 执行双工位堆垛机任务,按 lane 串行提交 |
| | | dualCrnOperateProcessUtils.submitDualCrnIoTasks(DISPATCH_INTERVAL_MS); |
| | | // 双工位堆垛机任务执行完成,按 lane 串行提交 |
| | | dualCrnOperateProcessUtils.submitDualCrnIoExecuteFinishTasks(DISPATCH_INTERVAL_MS); |
| | | |
| | | } |
| | | |
| | |
| | | STATION("station"), |
| | | STATION_IN("station-in-"), |
| | | STATION_OUT("station-out-"), |
| | | DUAL_STATION_OUT("dual-station-out-"), |
| | | STATION_OUT_FINISH("station-out-finish-"), |
| | | STATION_IN_ARRIVAL("station-in-arrival-"), |
| | | STATION_COMPLETE("station-complete-"), |
| | |
| | | |
| | | private static final String CRN_OUT_REQUIRE_STATION_OUT_ENABLE_CONFIG = "crnOutRequireStationOutEnable"; |
| | | |
| | | public synchronized void crnIoExecute() { |
| | | List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | crnIoExecute(basCrnp); |
| | | } |
| | | } |
| | | |
| | | public void crnIoExecute(BasCrnp basCrnp) { |
| | | if (basCrnp == null || basCrnp.getCrnNo() == null) { |
| | | return; |
| | |
| | | return defaultValue; |
| | | } |
| | | |
| | | //堆垛机任务执行完成 |
| | | public synchronized void crnIoExecuteFinish() { |
| | | List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | crnIoExecuteFinish(basCrnp); |
| | | } |
| | | } |
| | | |
| | | public void crnIoExecuteFinish(BasCrnp basCrnp) { |
| | | if (basCrnp == null || basCrnp.getCrnNo() == null) { |
| | | return; |
| | |
| | | } |
| | | |
| | | redisUtil.set(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo(), "lock",10); |
| | | } |
| | | } |
| | | |
| | | public synchronized void plannerExecute() { |
| | | List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | plannerExecute(basCrnp); |
| | | } |
| | | } |
| | | |
| | |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | |
| | | //执行输送站点入库任务 |
| | | public synchronized void stationInExecute() { |
| | | stationRegularDispatchProcessor.stationInExecute(); |
| | | } |
| | | |
| | | // 执行单个站点的入库任务下发 |
| | | public void stationInExecute(BasDevp basDevp, StationObjModel stationObjModel) { |
| | | stationRegularDispatchProcessor.stationInExecute(basDevp, stationObjModel); |
| | | } |
| | | |
| | | //执行堆垛机输送站点出库任务 |
| | | public synchronized void crnStationOutExecute() { |
| | | stationOutboundDispatchProcessor.crnStationOutExecute(); |
| | | } |
| | | |
| | | // 执行单个出库任务对应的输送站点下发 |
| | |
| | | stationOutboundDispatchProcessor.crnStationOutExecute(wrkMast); |
| | | } |
| | | |
| | | //执行双工位堆垛机输送站点出库任务 |
| | | public synchronized void dualCrnStationOutExecute() { |
| | | stationOutboundDispatchProcessor.dualCrnStationOutExecute(); |
| | | // 执行单个双工位出库任务对应的输送站点下发 |
| | | public void dualCrnStationOutExecute(WrkMast wrkMast) { |
| | | stationOutboundDispatchProcessor.dualCrnStationOutExecute(wrkMast); |
| | | } |
| | | |
| | | // 检测单个出库任务是否到达目标站台 |
| | |
| | | } |
| | | } |
| | | |
| | | // 检测任务转完成 |
| | | public void checkTaskToComplete() { |
| | | stationRegularDispatchProcessor.checkTaskToComplete(); |
| | | } |
| | | |
| | | // 检测单个出库任务是否可以转完成 |
| | | public void checkTaskToComplete(WrkMast wrkMast) { |
| | | stationRegularDispatchProcessor.checkTaskToComplete(wrkMast); |
| | | } |
| | | |
| | | //检测输送站点是否运行堵塞 |
| | | public void checkStationRunBlock() { |
| | | stationRerouteProcessor.checkStationRunBlock(); |
| | | } |
| | | |
| | | // 检测单个站点是否运行堵塞 |
| | | public void checkStationRunBlock(BasDevp basDevp, Integer stationId) { |
| | | stationRerouteProcessor.checkStationRunBlock(basDevp, stationId); |
| | | } |
| | | |
| | | //检测输送站点任务停留超时后重新计算路径 |
| | | public void checkStationIdleRecover() { |
| | | stationRerouteProcessor.checkStationIdleRecover(); |
| | | } |
| | | |
| | | // 检测单个站点任务停留超时后的恢复处理 |
| | |
| | | WrkStsType.STATION_RUN.sts)); |
| | | } |
| | | |
| | | // 检测出库排序 |
| | | public synchronized void checkStationOutOrder() { |
| | | stationRerouteProcessor.checkStationOutOrder(); |
| | | } |
| | | |
| | | // 检测单个站点的出库排序 |
| | | public void checkStationOutOrder(BasDevp basDevp, StationObjModel stationObjModel) { |
| | | stationRerouteProcessor.checkStationOutOrder(basDevp, stationObjModel); |
| | | } |
| | | |
| | | // 监控绕圈站点 |
| | | public synchronized void watchCircleStation() { |
| | | stationRerouteProcessor.watchCircleStation(); |
| | | } |
| | | |
| | | // 监控单个绕圈站点 |
| | |
| | | } |
| | | } |
| | | |
| | | public void submitDualCrnStationOutTasks(long minIntervalMs) { |
| | | submitDualCrnStationOutTasks(MainProcessLane.DUAL_STATION_OUT, minIntervalMs); |
| | | } |
| | | |
| | | public void submitDualCrnStationOutTasks(MainProcessLane lane, long minIntervalMs) { |
| | | List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>() |
| | | .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts) |
| | | .isNotNull("dual_crn_no")); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | Integer laneKey = wrkMast == null ? null : wrkMast.getSourceStaNo(); |
| | | if (laneKey == null) { |
| | | laneKey = wrkMast == null ? null : wrkMast.getWrkNo(); |
| | | } |
| | | mainProcessTaskSubmitter.submitKeyedSerialTask( |
| | | lane, |
| | | laneKey, |
| | | "dualCrnStationOutExecute", |
| | | minIntervalMs, |
| | | () -> dualCrnStationOutExecute(wrkMast) |
| | | ); |
| | | } |
| | | } |
| | | |
| | | public void submitStationOutExecuteFinishTasks(long minIntervalMs) { |
| | | submitStationOutExecuteFinishTasks(MainProcessLane.STATION_OUT_FINISH, minIntervalMs); |
| | | } |
| | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | // 申请入库任务 |
| | | public String applyInTask(String barcode, Integer sourceStaNo, Integer locType1) { |
| | | InTaskApplyRequest request = new InTaskApplyRequest(); |
| | | request.setBarcode(barcode); |
| | | request.setSourceStaNo(sourceStaNo); |
| | | request.setLocType1(locType1); |
| | | return applyInTask(request); |
| | | } |
| | | |
| | | public String applyInTask(InTaskApplyRequest request) { |
| | | long startMs = System.currentTimeMillis(); |
| | | Map<String, Long> stepCostMap = new LinkedHashMap<>(); |
| | |
| | | @Value("${station.outbound.recent-dispatch-protect-seconds:60}") |
| | | private long recentDispatchProtectSeconds; |
| | | |
| | | public void crnStationOutExecute() { |
| | | try { |
| | | List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>() |
| | | .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts) |
| | | .isNotNull("crn_no")); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | crnStationOutExecute(wrkMast); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void crnStationOutExecute(WrkMast wrkMast) { |
| | | try { |
| | | if (wrkMast == null || wrkMast.getWrkNo() == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | public void dualCrnStationOutExecute() { |
| | | public void dualCrnStationOutExecute(WrkMast wrkMast) { |
| | | try { |
| | | List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>() |
| | | .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts) |
| | | .isNotNull("dual_crn_no")); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | if (wrkMast == null || wrkMast.getWrkNo() == null) { |
| | | return; |
| | | } |
| | | if (hasPendingDispatch(wrkMast.getWrkNo())) { |
| | | continue; |
| | | return; |
| | | } |
| | | StationObjModel stationObjModel = getOutboundSourceStation(wrkMast); |
| | | if (stationObjModel == null || stationObjModel.getDeviceNo() == null || stationObjModel.getStationId() == null) { |
| | | continue; |
| | | return; |
| | | } |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | return; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId()); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | return; |
| | | } |
| | | |
| | | Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId()); |
| | | if (lock != null) { |
| | | continue; |
| | | return; |
| | | } |
| | | |
| | | if (stationProtocol.isAutoing() |
| | |
| | | ); |
| | | if (command == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败"); |
| | | continue; |
| | | return; |
| | | } |
| | | |
| | | boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "dualCrnStationOutExecute"); |
| | | if (!offered) { |
| | | continue; |
| | | return; |
| | | } |
| | | if (stationMoveCoordinator != null) { |
| | | stationMoveCoordinator.recordDispatch( |
| | |
| | | News.info("输送站点出库命令已入设备执行链路,等待源站接单。站点号={},工作号={},命令数据={}", |
| | | stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command)); |
| | | redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | @Autowired |
| | | private StationDispatchLoadSupport stationDispatchLoadSupport; |
| | | |
| | | public void stationInExecute() { |
| | | try { |
| | | List<BasDevp> basDevps = basDevpService.list(new QueryWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | List<StationObjModel> stationList = basDevp.getBarcodeStationList$(); |
| | | for (StationObjModel entity : stationList) { |
| | | stationInExecute(basDevp, entity); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void stationOutExecuteFinish(StationObjModel stationObjModel) { |
| | | try { |
| | | if (stationObjModel == null) { |
| | |
| | | } |
| | | |
| | | completeOutboundStationRun(stationObjModel, stationThread, wrkMast, matchedByRecentArrival); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void checkTaskToComplete() { |
| | | try { |
| | | List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN_COMPLETE.sts)); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | checkTaskToComplete(wrkMast); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | @Autowired |
| | | private StationDispatchRuntimeStateSupport stationDispatchRuntimeStateSupport; |
| | | |
| | | public void checkStationRunBlock() { |
| | | try { |
| | | List<BasDevp> basDevps = basDevpService.list(new QueryWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | for (StationProtocol stationProtocol : stationThread.getStatus()) { |
| | | if (stationProtocol == null || stationProtocol.getStationId() == null) { |
| | | continue; |
| | | } |
| | | checkStationRunBlock(basDevp, stationProtocol.getStationId()); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void checkStationRunBlock(BasDevp basDevp, Integer stationId) { |
| | | try { |
| | | if (basDevp == null || basDevp.getDevpNo() == null || stationId == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | public void checkStationIdleRecover() { |
| | | try { |
| | | List<BasDevp> basDevps = basDevpService.list(new QueryWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | for (StationProtocol stationProtocol : stationThread.getStatus()) { |
| | | if (stationProtocol != null && stationProtocol.getStationId() != null) { |
| | | checkStationIdleRecover(basDevp, stationProtocol.getStationId()); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void checkStationIdleRecover(BasDevp basDevp, Integer stationId) { |
| | | try { |
| | | if (basDevp == null || basDevp.getDevpNo() == null || stationId == null) { |
| | |
| | | checkStationIdleRecover(basDevp, stationThread, stationProtocol, basDevp.getOutOrderIntList()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void checkStationOutOrder() { |
| | | List<BasDevp> basDevps = basDevpService.list(new QueryWrapper<BasDevp>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | List<StationObjModel> orderList = basDevp.getOutOrderList$(); |
| | | for (StationObjModel stationObjModel : orderList) { |
| | | checkStationOutOrder(basDevp, stationObjModel); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | executeSharedReroute(context); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void watchCircleStation() { |
| | | List<BasDevp> basDevps = basDevpService.list(new QueryWrapper<BasDevp>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | for (StationProtocol stationProtocol : stationThread.getStatus()) { |
| | | if (stationProtocol == null || stationProtocol.getStationId() == null) { |
| | | continue; |
| | | } |
| | | watchCircleStation(basDevp, stationProtocol.getStationId()); |
| | | } |
| | | } |
| | | } |
| | | |