Junjie
1 天以前 1c6d2b037844239b907adfe3882d2cc41a99a3d3
src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -127,6 +127,13 @@
                    resolvedPolicy == null ? null : resolvedPolicy.getDefaultProfileCode(),
                    elapsedMillis(totalStartNs));
            StationPathRuntimeSnapshot runtimeSnapshot = loadStationPathRuntimeSnapshot(currentTaskNo);
            List<NavigateNode> shortFallbackPath = buildRerouteShortFallbackPath(
                    startStationId,
                    endStationId,
                    currentTaskNo,
                    resolvedPolicy,
                    runtimeSnapshot
            );
            StationPathSearchContext context = buildStationPathSearchContext(
                    startStationId,
                    endStationId,
@@ -135,9 +142,15 @@
                    runtimeSnapshot
            );
            if (context.allList.isEmpty()) {
                log.warn("站点路径候选计算结束,原因=empty_search_context,startStationId={},endStationId={},taskNo={},totalCostMs={}",
                        startStationId, endStationId, currentTaskNo, elapsedMillis(totalStartNs));
                return new ArrayList<>();
                List<List<NavigateNode>> fallbackCandidateList = normalizeCandidatePaths(Collections.singletonList(shortFallbackPath));
                log.warn("站点路径候选计算结束,原因=empty_search_context,startStationId={},endStationId={},taskNo={},fallbackCandidateCount={},fallbackPath={},totalCostMs={}",
                        startStationId,
                        endStationId,
                        currentTaskNo,
                        fallbackCandidateList.size(),
                        JSON.toJSONString(extractStationIdList(shortFallbackPath)),
                        elapsedMillis(totalStartNs));
                return fallbackCandidateList;
            }
            long orderStartNs = System.nanoTime();
@@ -150,13 +163,15 @@
                    endStationId,
                    runtimeSnapshot
            );
            List<List<NavigateNode>> normalizedPathList = normalizeCandidatePaths(orderedPathList);
            log.info("站点路径候选计算结束,startStationId={},endStationId={},taskNo={},rawCandidateCount={},orderedPathCount={},normalizedPathCount={},orderCostMs={},totalCostMs={}",
            List<List<NavigateNode>> candidatePathList = appendShortFallbackCandidate(orderedPathList, shortFallbackPath);
            List<List<NavigateNode>> normalizedPathList = normalizeCandidatePaths(candidatePathList);
            log.info("站点路径候选计算结束,startStationId={},endStationId={},taskNo={},rawCandidateCount={},orderedPathCount={},fallbackPathLen={},normalizedPathCount={},orderCostMs={},totalCostMs={}",
                    startStationId,
                    endStationId,
                    currentTaskNo,
                    context.allList.size(),
                    orderedPathList == null ? null : orderedPathList.size(),
                    shortFallbackPath == null ? 0 : shortFallbackPath.size(),
                    normalizedPathList.size(),
                    elapsedMillis(orderStartNs),
                    elapsedMillis(totalStartNs));
@@ -447,6 +462,54 @@
        return DirectPathSearchResult.empty(includeWaypoint, includeSoftPreference);
    }
    private List<NavigateNode> buildRerouteShortFallbackPath(Integer startStationId,
                                                             Integer endStationId,
                                                             Integer currentTaskNo,
                                                             StationPathResolvedPolicy resolvedPolicy,
                                                             StationPathRuntimeSnapshot runtimeSnapshot) {
        long startNs = System.nanoTime();
        try {
            List<NavigateNode> path = findStationDirectPath(
                    startStationId,
                    endStationId,
                    currentTaskNo,
                    0.0d,
                    StationPathCalcMode.OPTIMAL,
                    resolvedPolicy,
                    runtimeSnapshot
            );
            List<NavigateNode> normalizedPath = normalizeStationPath(path);
            log.info("站点路径堵塞重规划短路径保底计算完成,startStationId={},endStationId={},taskNo={},pathLen={},path={},costMs={}",
                    startStationId,
                    endStationId,
                    currentTaskNo,
                    normalizedPath.size(),
                    JSON.toJSONString(extractStationIdList(normalizedPath)),
                    elapsedMillis(startNs));
            return normalizedPath;
        } catch (Exception e) {
            log.warn("站点路径堵塞重规划短路径保底计算失败,startStationId={},endStationId={},taskNo={},costMs={},error={}",
                    startStationId,
                    endStationId,
                    currentTaskNo,
                    elapsedMillis(startNs),
                    e.toString());
            return new ArrayList<>();
        }
    }
    private List<List<NavigateNode>> appendShortFallbackCandidate(List<List<NavigateNode>> orderedPathList,
                                                                  List<NavigateNode> shortFallbackPath) {
        List<List<NavigateNode>> candidatePathList = new ArrayList<>();
        if (orderedPathList != null && !orderedPathList.isEmpty()) {
            candidatePathList.addAll(orderedPathList);
        }
        if (shortFallbackPath != null && !shortFallbackPath.isEmpty()) {
            candidatePathList.add(shortFallbackPath);
        }
        return candidatePathList;
    }
    private List<NavigateNode> searchDirectPath(DirectStationPathContext context,
                                                boolean includeWaypoint,
                                                boolean includeSoftPreference) {