| | |
| | | continue; |
| | | } |
| | | |
| | | StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), moveStaNo, 0); |
| | | StationCommand command = stationThread.getRunBlockRerouteCommand( |
| | | wrkMast.getWrkNo(), |
| | | stationProtocol.getStationId(), |
| | | moveStaNo, |
| | | 0 |
| | | ); |
| | | if (command == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败"); |
| | | News.taskInfo(wrkMast.getWrkNo(), |
| | | "输送站点堵塞重规划未找到可下发路线,当前站点={},目标站点={}", |
| | | stationProtocol.getStationId(), |
| | | moveStaNo); |
| | | continue; |
| | | } |
| | | |
| | |
| | | if (!shouldApplyOutOrder(wrkMast, outOrderStationIds)) { |
| | | return new OutOrderDispatchDecision(wrkMast.getStaNo(), false); |
| | | } |
| | | Integer dispatchStationId = resolveDispatchOutOrderTarget( |
| | | wrkMast.getSourceStaNo(), |
| | | wrkMast.getStaNo(), |
| | | outOrderStationIds |
| | | ); |
| | | if (dispatchStationId == null) { |
| | | return null; |
| | | } |
| | | if (isCurrentOutOrderDispatchStation(currentStationId, wrkMast, outOrderStationIds)) { |
| | | return resolveCurrentOutOrderDispatchDecision(currentStationId, wrkMast, outOrderStationIds); |
| | | } |
| | | |
| | | Integer moveStaNo = resolveDispatchOutOrderTarget(currentStationId, wrkMast.getStaNo(), outOrderStationIds, true); |
| | | if (moveStaNo == null) { |
| | | return null; |
| | | if (!Objects.equals(dispatchStationId, wrkMast.getStaNo()) |
| | | && isCurrentOutOrderStation(currentStationId, outOrderStationIds) |
| | | && isWatchingCircleArrival(wrkMast.getWrkNo(), currentStationId)) { |
| | | return new OutOrderDispatchDecision(dispatchStationId, true); |
| | | } |
| | | return new OutOrderDispatchDecision(moveStaNo, false); |
| | | return new OutOrderDispatchDecision(dispatchStationId, false); |
| | | } |
| | | |
| | | private OutOrderDispatchDecision resolveCurrentOutOrderDispatchDecision(Integer currentStationId, |
| | |
| | | if (seq == null) { |
| | | toTarget = currentBatchSeq.equals(wrkMast.getBatchSeq()); |
| | | } else { |
| | | toTarget = Integer.valueOf(seq + 1).equals(wrkMast.getBatchSeq()) |
| | | && currentBatchSeq.equals(wrkMast.getBatchSeq()); |
| | | toTarget = Integer.valueOf(seq + 1).equals(wrkMast.getBatchSeq()); |
| | | } |
| | | if (toTarget) { |
| | | return new OutOrderDispatchDecision(wrkMast.getStaNo(), false); |
| | | if (hasReachableOutReleaseSlot(currentStationId, wrkMast.getStaNo())) { |
| | | return new OutOrderDispatchDecision(wrkMast.getStaNo(), false); |
| | | } |
| | | Integer circleTarget = resolveNextCircleOrderTarget(currentStationId, outOrderStationIds); |
| | | if (circleTarget == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "目标站当前不可进,且未找到可执行的下一排序检测点,当前站点={}", currentStationId); |
| | | return null; |
| | | } |
| | | return new OutOrderDispatchDecision(circleTarget, true); |
| | | } |
| | | |
| | | Integer circleTarget = resolveNextCircleOrderTarget(currentStationId, outOrderStationIds); |
| | |
| | | private boolean isCurrentOutOrderDispatchStation(Integer currentStationId, |
| | | WrkMast wrkMast, |
| | | List<Integer> outOrderStationIds) { |
| | | if (!shouldApplyOutOrder(wrkMast, outOrderStationIds) || currentStationId == null) { |
| | | return false; |
| | | } |
| | | Integer dispatchStationId = resolveDispatchOutOrderTarget( |
| | | wrkMast.getSourceStaNo(), |
| | | wrkMast.getStaNo(), |
| | | outOrderStationIds |
| | | ); |
| | | return dispatchStationId != null |
| | | && !Objects.equals(dispatchStationId, wrkMast.getStaNo()) |
| | | && Objects.equals(currentStationId, dispatchStationId); |
| | | } |
| | | |
| | | private boolean isCurrentOutOrderStation(Integer currentStationId, |
| | | List<Integer> outOrderStationIds) { |
| | | return currentStationId != null |
| | | && shouldApplyOutOrder(wrkMast, outOrderStationIds) |
| | | && !Objects.equals(currentStationId, wrkMast.getStaNo()) |
| | | && outOrderStationIds != null |
| | | && outOrderStationIds.contains(currentStationId); |
| | | } |
| | | |
| | |
| | | List<Integer> outOrderStationIds, |
| | | OutOrderDispatchDecision dispatchDecision, |
| | | StationCommand command) { |
| | | if (dispatchDecision == null || command == null) { |
| | | return; |
| | | } |
| | | if (!isCurrentOutOrderDispatchStation(currentStationId, wrkMast, outOrderStationIds)) { |
| | | if (dispatchDecision == null || command == null || !shouldApplyOutOrder(wrkMast, outOrderStationIds)) { |
| | | return; |
| | | } |
| | | if (dispatchDecision.isCircle()) { |
| | |
| | | } |
| | | } |
| | | |
| | | private Integer resolveDispatchOutOrderTarget(Integer currentStationId, |
| | | private Integer resolveDispatchOutOrderTarget(Integer sourceStationId, |
| | | Integer finalTargetStationId, |
| | | List<Integer> outOrderList, |
| | | boolean skipCurrentStation) { |
| | | List<Integer> outOrderList) { |
| | | if (finalTargetStationId == null) { |
| | | return null; |
| | | } |
| | | if (currentStationId == null || outOrderList == null || outOrderList.isEmpty()) { |
| | | if (sourceStationId == null || outOrderList == null || outOrderList.isEmpty()) { |
| | | return finalTargetStationId; |
| | | } |
| | | |
| | | try { |
| | | List<NavigateNode> nodes = navigateUtils.calcByStationId(currentStationId, finalTargetStationId); |
| | | List<NavigateNode> nodes = navigateUtils.calcByStationId(sourceStationId, finalTargetStationId); |
| | | for (int i = nodes.size() - 1; i >= 0; i--) { |
| | | Integer stationId = getStationIdFromNode(nodes.get(i)); |
| | | if (stationId == null) { |
| | | continue; |
| | | } |
| | | if (skipCurrentStation && currentStationId.equals(stationId)) { |
| | | if (Objects.equals(stationId, finalTargetStationId)) { |
| | | continue; |
| | | } |
| | | if (outOrderList.contains(stationId)) { |
| | |
| | | return finalTargetStationId; |
| | | } |
| | | |
| | | private boolean hasReachableOutReleaseSlot(Integer currentStationId, |
| | | Integer finalTargetStationId) { |
| | | if (currentStationId == null || finalTargetStationId == null) { |
| | | return true; |
| | | } |
| | | |
| | | try { |
| | | List<NavigateNode> nodes = navigateUtils.calcByStationId(currentStationId, finalTargetStationId); |
| | | if (nodes == null || nodes.isEmpty()) { |
| | | return true; |
| | | } |
| | | |
| | | for (NavigateNode node : nodes) { |
| | | Integer stationId = getStationIdFromNode(node); |
| | | if (stationId == null || Objects.equals(stationId, currentStationId)) { |
| | | continue; |
| | | } |
| | | |
| | | if (!isPathStationBlocked(stationId)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } catch (Exception ignore) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | private boolean isPathStationBlocked(Integer stationId) { |
| | | if (stationId == null) { |
| | | return true; |
| | | } |
| | | |
| | | BasStation basStation = basStationService.getOne(new QueryWrapper<BasStation>().eq("station_id", stationId)); |
| | | if (basStation == null) { |
| | | return true; |
| | | } |
| | | |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | return true; |
| | | } |
| | | |
| | | StationProtocol stationProtocol = stationThread.getStatusMap().get(stationId); |
| | | if (stationProtocol == null) { |
| | | return true; |
| | | } |
| | | |
| | | return !stationProtocol.isAutoing() |
| | | || stationProtocol.isLoading() |
| | | || (stationProtocol.getTaskNo() != null && stationProtocol.getTaskNo() > 0); |
| | | } |
| | | |
| | | private Integer resolveNextCircleOrderTarget(Integer currentStationId, List<Integer> orderedOutStationList) { |
| | | if (currentStationId == null || orderedOutStationList == null || orderedOutStationList.size() <= 1) { |
| | | return null; |