| | |
| | | Integer circleTarget = resolveNextCircleOrderTarget( |
| | | currentStationId, |
| | | outOrderStationIds, |
| | | loopEvaluation.isLargeLoopTriggered() |
| | | loopEvaluation.getExpectedLoopIssueCount() |
| | | ); |
| | | if (circleTarget == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "目标站当前不可进,且未找到可执行的下一排序检测点,当前站点={}", currentStationId); |
| | |
| | | Integer circleTarget = resolveNextCircleOrderTarget( |
| | | currentStationId, |
| | | outOrderStationIds, |
| | | loopEvaluation.isLargeLoopTriggered() |
| | | loopEvaluation.getExpectedLoopIssueCount() |
| | | ); |
| | | if (circleTarget == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "未找到可执行的下一排序检测点,当前站点={}", currentStationId); |
| | |
| | | |
| | | private Integer resolveNextCircleOrderTarget(Integer currentStationId, |
| | | List<Integer> orderedOutStationList, |
| | | boolean preferLargeCircle) { |
| | | Integer expectedLoopIssueCount) { |
| | | if (currentStationId == null || orderedOutStationList == null || orderedOutStationList.size() <= 1) { |
| | | return null; |
| | | } |
| | | |
| | | int startIndex = orderedOutStationList.indexOf(currentStationId); |
| | | int total = orderedOutStationList.size(); |
| | | Integer bestStationId = null; |
| | | int bestPathLength = -1; |
| | | int bestOffset = -1; |
| | | List<Integer> reachableStationIdList = new ArrayList<>(); |
| | | for (int offset = 1; offset < total; offset++) { |
| | | int candidateIndex = (startIndex + offset + total) % total; |
| | | Integer candidateStationId = orderedOutStationList.get(candidateIndex); |
| | |
| | | try { |
| | | List<NavigateNode> path = navigateUtils.calcByStationId(currentStationId, candidateStationId); |
| | | if (path != null && !path.isEmpty()) { |
| | | if (!preferLargeCircle) { |
| | | return candidateStationId; |
| | | } |
| | | int pathLength = path.size(); |
| | | if (pathLength > bestPathLength || (pathLength == bestPathLength && offset > bestOffset)) { |
| | | bestStationId = candidateStationId; |
| | | bestPathLength = pathLength; |
| | | bestOffset = offset; |
| | | } |
| | | reachableStationIdList.add(candidateStationId); |
| | | } |
| | | } catch (Exception ignore) {} |
| | | } |
| | | return bestStationId; |
| | | if (reachableStationIdList.isEmpty()) { |
| | | return null; |
| | | } |
| | | int gradualIndex = resolveGradualCircleTargetIndex(expectedLoopIssueCount, reachableStationIdList.size()); |
| | | return reachableStationIdList.get(gradualIndex); |
| | | } |
| | | |
| | | private int resolveGradualCircleTargetIndex(Integer expectedLoopIssueCount, int candidateCount) { |
| | | if (candidateCount <= 1) { |
| | | return 0; |
| | | } |
| | | if (expectedLoopIssueCount == null || expectedLoopIssueCount <= 2) { |
| | | return 0; |
| | | } |
| | | int gradualIndex = expectedLoopIssueCount - 2; |
| | | if (gradualIndex < 1) { |
| | | gradualIndex = 1; |
| | | } |
| | | return Math.min(gradualIndex, candidateCount - 1); |
| | | } |
| | | |
| | | private boolean tryAcquireOutOrderDispatchLock(Integer wrkNo, Integer stationId) { |