#
Junjie
1 天以前 058d7bbb714634e42bff1dd71fdfca3a378421d3
src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -32,6 +32,7 @@
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.common.SpringUtils;
@@ -1224,18 +1225,46 @@
                    graph.computeIfAbsent(stationId, key -> new LinkedHashSet<>());
                    List<NavigateNode> nextNodeList = navigateSolution.extend_current_node(stationMap, node);
                    for (NavigateNode nextNode : safeList(nextNodeList)) {
                        Integer nextStationId = extractStationId(nextNode);
                        if (nextStationId == null || stationId.equals(nextStationId)) {
                            continue;
                        for (Integer nextStationId : resolveConnectedStationIds(stationId, nextNode)) {
                            if (nextStationId == null || stationId.equals(nextStationId)) {
                                continue;
                            }
                            graph.computeIfAbsent(nextStationId, key -> new LinkedHashSet<>());
                            graph.get(stationId).add(nextStationId);
                            graph.get(nextStationId).add(stationId);
                        }
                        graph.computeIfAbsent(nextStationId, key -> new LinkedHashSet<>());
                        graph.get(stationId).add(nextStationId);
                        graph.get(nextStationId).add(stationId);
                    }
                }
            }
        }
        return graph;
    }
    private Set<Integer> resolveConnectedStationIds(Integer currentStationId, NavigateNode nextNode) {
        Set<Integer> stationIdSet = new LinkedHashSet<>();
        if (nextNode == null || nextNode.getNodeValue() == null) {
            return stationIdSet;
        }
        try {
            JSONObject value = JSON.parseObject(nextNode.getNodeValue());
            if (value == null) {
                return stationIdSet;
            }
            Integer directStationId = value.getInteger("stationId");
            if (directStationId != null && !directStationId.equals(currentStationId)) {
                stationIdSet.add(directStationId);
            }
            JSONArray bridgeStationIds = value.getJSONArray("bridgeStationIds");
            if (bridgeStationIds != null) {
                for (Integer bridgeStationId : bridgeStationIds.toJavaList(Integer.class)) {
                    if (bridgeStationId != null && !bridgeStationId.equals(currentStationId)) {
                        stationIdSet.add(bridgeStationId);
                    }
                }
            }
        } catch (Exception ignore) {
        }
        return stationIdSet;
    }
    private List<Integer> loadStationLevList() {
@@ -1965,8 +1994,8 @@
    }
    private List<NavigateNode> normalizeStationPath(List<NavigateNode> path) {
        HashSet<Integer> stationIdSet = new HashSet<>();
        List<NavigateNode> filterList = new ArrayList<>();
        Integer lastStationId = null;
        for (NavigateNode navigateNode : safeList(path)) {
            if (navigateNode == null) {
                continue;
@@ -1981,9 +2010,14 @@
                continue;
            }
            Integer stationId = valueObject.getInteger("stationId");
            if (stationId == null || !stationIdSet.add(stationId)) {
            if (stationId == null) {
                continue;
            }
            // 仅压缩连续重复站点,保留环线重算场景下后续再次经过的同一站点。
            if (lastStationId != null && lastStationId.equals(stationId)) {
                continue;
            }
            lastStationId = stationId;
            NavigateNode clonedNode = navigateNode.clone();
            if (clonedNode == null) {
                continue;