| | |
| | | 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) { |
| | | return; |
| | | } |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if (stationThread == null) { |
| | | return; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(stationId); |
| | | if (stationProtocol == null |
| | | || !stationProtocol.isAutoing() |
| | | || !stationProtocol.isLoading() |
| | | || stationProtocol.getTaskNo() <= 0 |
| | | || !stationProtocol.isRunBlock()) { |
| | | return; |
| | | } |
| | | |
| | | List<Integer> runBlockReassignLocStationList = new ArrayList<>(); |
| | | for (StationObjModel stationObjModel : basDevp.getRunBlockReassignLocStationList$()) { |
| | |
| | | } |
| | | List<Integer> outOrderStationIds = basDevp.getOutOrderIntList(); |
| | | |
| | | for (StationProtocol stationProtocol : stationThread.getStatus()) { |
| | | if (stationProtocol.isAutoing() |
| | | && stationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() > 0 |
| | | && stationProtocol.isRunBlock()) { |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | News.info("输送站点号={} 运行阻塞,但无法找到对应任务,工作号={}", stationProtocol.getStationId(), stationProtocol.getTaskNo()); |
| | | continue; |
| | | return; |
| | | } |
| | | |
| | | Object lock = redisUtil.get(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo()); |
| | | if (lock != null) { |
| | | continue; |
| | | return; |
| | | } |
| | | redisUtil.set(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo(), "lock", 15); |
| | | |
| | | if (shouldUseRunBlockDirectReassign(wrkMast, stationProtocol.getStationId(), runBlockReassignLocStationList)) { |
| | | executeRunBlockDirectReassign(basDevp, stationThread, stationProtocol, wrkMast); |
| | | continue; |
| | | return; |
| | | } |
| | | |
| | | Double pathLenFactor = stationOutboundDecisionSupport.resolveOutboundPathLenFactor(wrkMast); |
| | |
| | | .withCancelSessionBeforeDispatch() |
| | | .withResetSegmentCommandsBeforeDispatch(); |
| | | executeSharedReroute(context); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | |
| | | for (StationProtocol stationProtocol : stationThread.getStatus()) { |
| | | if (stationProtocol.isAutoing() |
| | | && stationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() > 0 |
| | | && !stationProtocol.isRunBlock()) { |
| | | checkStationIdleRecover(basDevp, stationThread, stationProtocol, basDevp.getOutOrderIntList()); |
| | | if (stationProtocol != null && stationProtocol.getStationId() != null) { |
| | | checkStationIdleRecover(basDevp, stationProtocol.getStationId()); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public void checkStationIdleRecover(BasDevp basDevp, Integer stationId) { |
| | | try { |
| | | if (basDevp == null || basDevp.getDevpNo() == null || stationId == null) { |
| | | return; |
| | | } |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if (stationThread == null) { |
| | | return; |
| | | } |
| | | Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(stationId); |
| | | if (stationProtocol == null |
| | | || !stationProtocol.isAutoing() |
| | | || !stationProtocol.isLoading() |
| | | || stationProtocol.getTaskNo() <= 0 |
| | | || stationProtocol.isRunBlock()) { |
| | | return; |
| | | } |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void checkStationOutOrder(BasDevp basDevp, StationObjModel stationObjModel) { |
| | | try { |
| | | if (basDevp == null || basDevp.getDevpNo() == null || stationObjModel == null || stationObjModel.getStationId() == null) { |
| | | return; |
| | | } |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | return; |
| | | } |
| | | Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap(); |
| | | List<StationObjModel> orderList = basDevp.getOutOrderList$(); |
| | | List<Integer> outOrderStationIds = basDevp.getOutOrderIntList(); |
| | | for (StationObjModel stationObjModel : orderList) { |
| | | StationProtocol stationProtocol = statusMap.get(stationObjModel.getStationId()); |
| | | StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(stationObjModel.getStationId()); |
| | | if (stationProtocol == null |
| | | || !stationProtocol.isAutoing() |
| | | || !stationProtocol.isLoading() |
| | | || stationProtocol.getTaskNo() <= 0 |
| | | || stationProtocol.isRunBlock() |
| | | || !stationProtocol.getStationId().equals(stationProtocol.getTargetStaNo())) { |
| | | continue; |
| | | return; |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo()); |
| | | if (wrkMast == null |
| | | || !Objects.equals(wrkMast.getWrkSts(), WrkStsType.STATION_RUN.sts) |
| | | || Objects.equals(stationProtocol.getStationId(), wrkMast.getStaNo())) { |
| | | continue; |
| | | return; |
| | | } |
| | | if (stationOutboundDecisionSupport.shouldSkipOutOrderDispatchForExistingRoute(wrkMast.getWrkNo(), stationProtocol.getStationId())) { |
| | | continue; |
| | | return; |
| | | } |
| | | |
| | | Double pathLenFactor = stationOutboundDecisionSupport.resolveOutboundPathLenFactor(wrkMast); |
| | |
| | | stationThread, |
| | | stationProtocol, |
| | | wrkMast, |
| | | outOrderStationIds, |
| | | basDevp.getOutOrderIntList(), |
| | | pathLenFactor, |
| | | "checkStationOutOrder" |
| | | ).withDispatchDeviceNo(stationObjModel.getDeviceNo()) |
| | |
| | | .withOutOrderDispatchLock() |
| | | .withResetSegmentCommandsBeforeDispatch(); |
| | | executeSharedReroute(context); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | List<Integer> outOrderList = basDevp.getOutOrderIntList(); |
| | | for (StationProtocol stationProtocol : stationThread.getStatus()) { |
| | | if (!stationProtocol.isAutoing() |
| | | if (stationProtocol == null || stationProtocol.getStationId() == null) { |
| | | continue; |
| | | } |
| | | watchCircleStation(basDevp, stationProtocol.getStationId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void watchCircleStation(BasDevp basDevp, Integer stationId) { |
| | | try { |
| | | if (basDevp == null || basDevp.getDevpNo() == null || stationId == null) { |
| | | return; |
| | | } |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if (stationThread == null) { |
| | | return; |
| | | } |
| | | Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(stationId); |
| | | if (stationProtocol == null |
| | | || !stationProtocol.isAutoing() |
| | | || !stationProtocol.isLoading() |
| | | || stationProtocol.getTaskNo() <= 0 |
| | | || !stationOutboundDecisionSupport.isWatchingCircleArrival(stationProtocol.getTaskNo(), stationProtocol.getStationId())) { |
| | | continue; |
| | | return; |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo()); |
| | | if (wrkMast == null |
| | | || !Objects.equals(wrkMast.getWrkSts(), WrkStsType.STATION_RUN.sts) |
| | | || Objects.equals(stationProtocol.getStationId(), wrkMast.getStaNo())) { |
| | | continue; |
| | | return; |
| | | } |
| | | |
| | | Double pathLenFactor = stationOutboundDecisionSupport.resolveOutboundPathLenFactor(wrkMast); |
| | |
| | | stationThread, |
| | | stationProtocol, |
| | | wrkMast, |
| | | outOrderList, |
| | | basDevp.getOutOrderIntList(), |
| | | pathLenFactor, |
| | | "watchCircleStation" |
| | | ).withSuppressDispatchGuard() |
| | | .withOutOrderDispatchLock() |
| | | .withResetSegmentCommandsBeforeDispatch(); |
| | | executeSharedReroute(context); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |