| | |
| | | return getCommand(StationCommandType.MOVE, taskNo, stationId, targetStationId, palletSize, pathLenFactor); |
| | | } |
| | | |
| | | long startNs = System.nanoTime(); |
| | | StationTaskLoopService taskLoopService = loadStationTaskLoopService(); |
| | | StationTaskLoopService.LoopEvaluation loopEvaluation = taskLoopService == null |
| | | ? new StationTaskLoopService.LoopEvaluation(taskNo, stationId, StationTaskLoopService.LoopIdentitySnapshot.empty(), 0, 0, false) |
| | | : taskLoopService.evaluateLoop(taskNo, stationId, true); |
| | | long loopEvalNs = System.nanoTime(); |
| | | log.info("输送线堵塞重规划环线识别,taskNo={}, stationId={}, scopeType={}, localStationCount={}, sourceLoopStationCount={}", |
| | | taskNo, |
| | | stationId, |
| | |
| | | loopEvaluation.getLoopIdentity().getLocalStationCount(), |
| | | loopEvaluation.getLoopIdentity().getSourceLoopStationCount()); |
| | | List<List<NavigateNode>> candidatePathList = calcCandidatePathNavigateNodes(taskNo, stationId, targetStationId, pathLenFactor); |
| | | long candidatePathNs = System.nanoTime(); |
| | | List<StationCommand> candidateCommandList = new ArrayList<>(); |
| | | for (List<NavigateNode> candidatePath : candidatePathList) { |
| | | StationCommand rerouteCommand = buildMoveCommand(taskNo, stationId, targetStationId, palletSize, candidatePath); |
| | |
| | | } |
| | | candidateCommandList.add(rerouteCommand); |
| | | } |
| | | long buildCommandNs = System.nanoTime(); |
| | | |
| | | StationV5RunBlockReroutePlanner.PlanResult planResult = runBlockReroutePlanner.plan( |
| | | taskNo, |
| | |
| | | loopEvaluation, |
| | | candidateCommandList |
| | | ); |
| | | long planNs = System.nanoTime(); |
| | | logRunBlockRerouteCost(taskNo, |
| | | stationId, |
| | | targetStationId, |
| | | candidatePathList == null ? 0 : candidatePathList.size(), |
| | | candidateCommandList.size(), |
| | | startNs, |
| | | loopEvalNs, |
| | | candidatePathNs, |
| | | buildCommandNs, |
| | | planNs); |
| | | if (candidateCommandList.isEmpty()) { |
| | | log.warn("输送线堵塞重规划失败,候选路径为空,taskNo={}, planCount={}, stationId={}, targetStationId={}", |
| | | taskNo, planResult.getPlanCount(), stationId, targetStationId); |
| | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private void logRunBlockRerouteCost(Integer taskNo, |
| | | Integer stationId, |
| | | Integer targetStationId, |
| | | int candidatePathCount, |
| | | int candidateCommandCount, |
| | | long startNs, |
| | | long loopEvalNs, |
| | | long candidatePathNs, |
| | | long buildCommandNs, |
| | | long planNs) { |
| | | long totalMs = nanosToMillis(planNs - startNs); |
| | | if (totalMs < 1000L) { |
| | | return; |
| | | } |
| | | log.warn("输送线堵塞重规划耗时较长, taskNo={}, stationId={}, targetStationId={}, total={}ms, loopEval={}ms, candidatePath={}ms, buildCommand={}ms, planner={}ms, candidatePathCount={}, candidateCommandCount={}", |
| | | taskNo, |
| | | stationId, |
| | | targetStationId, |
| | | totalMs, |
| | | nanosToMillis(loopEvalNs - startNs), |
| | | nanosToMillis(candidatePathNs - loopEvalNs), |
| | | nanosToMillis(buildCommandNs - candidatePathNs), |
| | | nanosToMillis(planNs - buildCommandNs), |
| | | candidatePathCount, |
| | | candidateCommandCount); |
| | | } |
| | | |
| | | private long nanosToMillis(long nanos) { |
| | | return nanos <= 0L ? 0L : nanos / 1_000_000L; |
| | | } |
| | | } |