| | |
| | | import com.zy.common.utils.NavigateUtils; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.move.StationMoveCoordinator; |
| | | import com.zy.core.move.StationMoveDispatchMode; |
| | | import com.zy.core.move.StationMoveSession; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.MessageQueue; |
| | |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | wrkAnalysisService.markInboundStationStart(wrkMast, now); |
| | | offerDevpCommandWithDedup(basDevp.getDevpNo(), command, "stationInExecute"); |
| | | boolean offered = offerDevpCommandWithDedup(basDevp.getDevpNo(), command, "stationInExecute"); |
| | | if (offered && stationMoveCoordinator != null) { |
| | | stationMoveCoordinator.recordDispatch( |
| | | wrkMast.getWrkNo(), |
| | | stationProtocol.getStationId(), |
| | | "stationInExecute", |
| | | command, |
| | | false |
| | | ); |
| | | } |
| | | News.info("输送站点入库命令下发成功,站点号={},工作号={},命令数据={}", stationId, wrkMast.getWrkNo(), JSON.toJSONString(command)); |
| | | redisUtil.set(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId, "lock", 5); |
| | | loadGuardState.reserveLoopTask(loopHitResult.getLoopNo()); |
| | |
| | | wrkMast.setSystemMsg(""); |
| | | wrkMast.setIoTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "dualCrnStationOutExecute"); |
| | | boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "dualCrnStationOutExecute"); |
| | | if (offered && stationMoveCoordinator != null) { |
| | | stationMoveCoordinator.recordDispatch( |
| | | wrkMast.getWrkNo(), |
| | | stationProtocol.getStationId(), |
| | | "dualCrnStationOutExecute", |
| | | command, |
| | | false |
| | | ); |
| | | } |
| | | notifyUtils.notify(String.valueOf(SlaveType.Devp), stationObjModel.getDeviceNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.STATION_OUT_TASK_RUN, null); |
| | | News.info("输送站点出库命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command)); |
| | | redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5); |
| | |
| | | pathLenFactor, |
| | | "checkStationRunBlock_reroute" |
| | | ).withRunBlockCommand() |
| | | .withSuppressDispatchGuard() |
| | | .withCancelSessionBeforeDispatch() |
| | | .withResetSegmentCommandsBeforeDispatch(); |
| | | executeSharedReroute(context); |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (stationProtocol.isRunBlock()) { |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.getStationId().equals(stationProtocol.getTargetStaNo())) { |
| | | continue; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | if (Objects.equals(stationProtocol.getStationId(), wrkMast.getStaNo())) { |
| | | continue; |
| | | } |
| | | if (shouldSkipOutOrderDispatchForExistingRoute(wrkMast.getWrkNo(), stationProtocol.getStationId())) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | continue; |
| | | } |
| | | |
| | | StationCommand circleCommand = getWatchCircleCommand(stationProtocol.getTaskNo()); |
| | | if (circleCommand == null) { |
| | | continue; |
| | | } |
| | | if (!stationProtocol.getStationId().equals(circleCommand.getTargetStaNo())) { |
| | | if (!isWatchingCircleArrival(stationProtocol.getTaskNo(), stationProtocol.getStationId())) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | if (taskNo == null || taskNo <= 0 || stationId == null) { |
| | | return RerouteExecutionResult.skip("invalid-station-task"); |
| | | } |
| | | boolean runBlockReroute = context.sceneType() == RerouteSceneType.RUN_BLOCK_REROUTE; |
| | | if (runBlockReroute) { |
| | | if (context.cancelSessionBeforeDispatch() && stationMoveCoordinator != null) { |
| | | stationMoveCoordinator.cancelSession(taskNo); |
| | | } |
| | | if (context.resetSegmentCommandsBeforeDispatch()) { |
| | | resetSegmentMoveCommandsBeforeReroute(taskNo); |
| | | } |
| | | } |
| | | if (context.checkRecentDispatch() |
| | | && shouldSkipIdleRecoverForRecentDispatch(taskNo, stationId)) { |
| | | return RerouteExecutionResult.skip("recent-dispatch"); |
| | | } |
| | | if (countCurrentTaskBufferCommands(stationProtocol.getTaskBufferItems(), taskNo) > 0) { |
| | | int currentTaskBufferCommandCount = countCurrentTaskBufferCommands(stationProtocol.getTaskBufferItems(), taskNo); |
| | | if (currentTaskBufferCommandCount > 0 && !runBlockReroute) { |
| | | if (context.sceneType() == RerouteSceneType.IDLE_RECOVER) { |
| | | News.info("输送站点任务停留超时,但缓存区仍存在当前任务命令,已跳过重算。站点号={},工作号={},当前任务命令数={}", |
| | | stationId, |
| | | taskNo, |
| | | countCurrentTaskBufferCommands(stationProtocol.getTaskBufferItems(), taskNo)); |
| | | currentTaskBufferCommandCount); |
| | | } |
| | | return RerouteExecutionResult.skip("buffer-has-current-task"); |
| | | } |
| | | if (context.checkSuppressDispatch() |
| | | if (currentTaskBufferCommandCount > 0 && runBlockReroute) { |
| | | News.info("输送站点运行堵塞重规划检测到旧分段命令残留,已先清理本地状态后继续重发。站点号={},工作号={},当前任务命令数={}", |
| | | stationId, |
| | | taskNo, |
| | | currentTaskBufferCommandCount); |
| | | } |
| | | if (!runBlockReroute |
| | | && context.checkSuppressDispatch() |
| | | && stationMoveCoordinator != null |
| | | && stationMoveCoordinator.shouldSuppressDispatch(taskNo, stationId, plan.command())) { |
| | | return RerouteExecutionResult.skip("dispatch-suppressed"); |
| | |
| | | return RerouteExecutionResult.skip("out-order-lock"); |
| | | } |
| | | |
| | | if (context.cancelSessionBeforeDispatch() && stationMoveCoordinator != null) { |
| | | if (!runBlockReroute |
| | | && context.cancelSessionBeforeDispatch() && stationMoveCoordinator != null) { |
| | | stationMoveCoordinator.cancelSession(taskNo); |
| | | } |
| | | if (!isBlank(context.executionLockKey())) { |
| | |
| | | } |
| | | redisUtil.set(context.executionLockKey(), "lock", context.executionLockSeconds()); |
| | | } |
| | | if (context.resetSegmentCommandsBeforeDispatch()) { |
| | | if (!runBlockReroute && context.resetSegmentCommandsBeforeDispatch()) { |
| | | resetSegmentMoveCommandsBeforeReroute(taskNo); |
| | | } |
| | | |
| | |
| | | return true; |
| | | } |
| | | |
| | | private boolean shouldSkipOutOrderDispatchForExistingRoute(Integer wrkNo, Integer stationId) { |
| | | if (stationMoveCoordinator == null || wrkNo == null || wrkNo <= 0 || stationId == null) { |
| | | return false; |
| | | } |
| | | StationMoveSession session = stationMoveCoordinator.loadSession(wrkNo); |
| | | if (session == null) { |
| | | return false; |
| | | } |
| | | if (!session.isActive() || !session.containsStation(stationId)) { |
| | | return false; |
| | | } |
| | | if (StationMoveDispatchMode.CIRCLE == session.getDispatchMode()) { |
| | | return true; |
| | | } |
| | | return !Objects.equals(stationId, session.getCurrentRouteTargetStationId()); |
| | | } |
| | | |
| | | private boolean isWatchingCircleArrival(Integer wrkNo, Integer stationId) { |
| | | if (stationMoveCoordinator != null) { |
| | | StationMoveSession session = stationMoveCoordinator.loadSession(wrkNo); |