Junjie
15 小时以前 71a5ae03389119dc6975d7cfb87e63601f3c5305
src/main/java/com/zy/common/utils/NavigateSolution.java
@@ -2,20 +2,27 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.BasMap;
import com.zy.asrs.service.BasMapService;
import com.zy.common.model.NavigateNode;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.MapNodeType;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
/**
 * A*算法实现类
 */
public class NavigateSolution {
    private static final long REDIS_MAP_CACHE_TTL_SECONDS = 60 * 60 * 24L;
    private static final long MAP_CACHE_TTL_MS = 5000L;
    private static final Map<String, CachedNavigateMap> NAVIGATE_MAP_CACHE = new ConcurrentHashMap<>();
    // Open表用优先队列
    public PriorityQueue<NavigateNode> Open = new PriorityQueue<NavigateNode>();
@@ -25,14 +32,108 @@
    Map<String, Integer> bestGMap = new HashMap<>();
    public List<List<NavigateNode>> getStationMap(int lev) {
        return cloneNavigateMap(loadCachedNavigateMap("station", lev));
    }
    public List<List<NavigateNode>> getRgvTrackMap(int lev) {
        return cloneNavigateMap(loadCachedNavigateMap("rgv", lev));
    }
    private List<List<NavigateNode>> loadCachedNavigateMap(String mapType, int lev) {
        String cacheKey = mapType + ":" + lev;
        long now = System.currentTimeMillis();
        CachedNavigateMap cachedNavigateMap = NAVIGATE_MAP_CACHE.get(cacheKey);
        if (cachedNavigateMap != null && now - cachedNavigateMap.cacheAtMs <= MAP_CACHE_TTL_MS) {
            return cachedNavigateMap.navigateMap;
        }
        List<List<NavigateNode>> redisNavigateMap = loadNavigateMapFromRedis(mapType, lev);
        if (isValidNavigateMap(redisNavigateMap)) {
            NAVIGATE_MAP_CACHE.put(cacheKey, new CachedNavigateMap(now, redisNavigateMap));
            return redisNavigateMap;
        }
        clearMapCache(lev);
        List<List<NavigateNode>> navigateNodeList = buildNavigateMap(mapType, lev);
        cacheNavigateMap(cacheKey, mapType, lev, navigateNodeList, now);
        return navigateNodeList;
    }
    public static void refreshAllMapCaches() {
        BasMapService basMapService = SpringUtils.getBean(BasMapService.class);
        BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev));
        List<Integer> levList = basMapService.getLevList();
        if (levList == null || levList.isEmpty()) {
            NAVIGATE_MAP_CACHE.clear();
            return;
        }
        LinkedHashSet<Integer> distinctLevSet = new LinkedHashSet<>(levList);
        for (Integer lev : distinctLevSet) {
            if (lev == null) {
                continue;
            }
            refreshMapCache(lev);
        }
    }
    public static void refreshMapCache(Integer lev) {
        if (lev == null) {
            return;
        }
        long now = System.currentTimeMillis();
        NavigateSolution navigateSolution = new NavigateSolution();
        List<List<NavigateNode>> stationMap = navigateSolution.buildNavigateMap("station", lev);
        navigateSolution.cacheNavigateMap("station:" + lev, "station", lev, stationMap, now);
        List<List<NavigateNode>> rgvMap = navigateSolution.buildNavigateMap("rgv", lev);
        navigateSolution.cacheNavigateMap("rgv:" + lev, "rgv", lev, rgvMap, now);
    }
    public static void clearMapCache(Integer lev) {
        if (lev == null) {
            return;
        }
        NAVIGATE_MAP_CACHE.remove("station:" + lev);
        NAVIGATE_MAP_CACHE.remove("rgv:" + lev);
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        redisUtil.del(buildRedisCacheKey("station", lev), buildRedisCacheKey("rgv", lev));
    }
    private void cacheNavigateMap(String localCacheKey,
                                  String mapType,
                                  int lev,
                                  List<List<NavigateNode>> navigateNodeList,
                                  long cacheAtMs) {
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        redisUtil.set(buildRedisCacheKey(mapType, lev),
                JSON.toJSONString(navigateNodeList),
                REDIS_MAP_CACHE_TTL_SECONDS);
        NAVIGATE_MAP_CACHE.put(localCacheKey, new CachedNavigateMap(cacheAtMs, navigateNodeList));
    }
    private List<List<NavigateNode>> loadNavigateMapFromRedis(String mapType, int lev) {
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        Object cachedValue = redisUtil.get(buildRedisCacheKey(mapType, lev));
        if (!(cachedValue instanceof String) || ((String) cachedValue).trim().isEmpty()) {
            return null;
        }
        try {
            return JSON.parseObject((String) cachedValue, new TypeReference<List<List<NavigateNode>>>() {});
        } catch (Exception ignore) {
            return null;
        }
    }
    private static String buildRedisCacheKey(String mapType, int lev) {
        return RedisKeyType.NAVIGATE_MAP_TEMPLATE_.key + mapType + "_" + lev;
    }
    private List<List<NavigateNode>> buildNavigateMap(String mapType, int lev) {
        BasMapService basMapService = SpringUtils.getBean(BasMapService.class);
        BasMap basMap = basMapService.getOne(new QueryWrapper<BasMap>().eq("lev", lev));
        if (basMap == null) {
            throw new CoolException("地图不存在");
        }
        List<List<JSONObject>> dataList = JSON.parseObject(basMap.getData(), List.class);
        List<List<NavigateNode>> navigateNodeList = new ArrayList<>();
        for (int i = 0; i < dataList.size(); i++) {
            List<JSONObject> row = dataList.get(i);
@@ -42,24 +143,32 @@
                NavigateNode navigateNode = new NavigateNode(i, j);
                String nodeType = map.getString("type");
                String mergeType = map.getString("mergeType");
                String nodeValue = map.getString("value");
                if(nodeType == null) {
                    navigateNode.setValue(MapNodeType.DISABLE.id);
                }else if(nodeType.equals("devp") || nodeType.equals("merge")){
                } else if ("station".equals(mapType)
                        && (nodeType.equals("devp") || (nodeType.equals("merge") && "devp".equals(mergeType)))) {
                    navigateNode.setValue(MapNodeType.NORMAL_PATH.id);
                    JSONObject valueObj = JSON.parseObject(map.getString("value"));
                    List<String> directionList = valueObj.getJSONArray("direction").toJavaList(String.class);
                    JSONObject valueObj = JSON.parseObject(nodeValue);
                    List<String> directionList = valueObj == null || valueObj.getJSONArray("direction") == null
                            ? new ArrayList<>()
                            : valueObj.getJSONArray("direction").toJavaList(String.class);
                    navigateNode.setDirectionList(directionList);
                } else if (nodeType.equals("rgv")) {
                } else if ("station".equals(mapType) && nodeType.equals("rgv")) {
                    navigateNode.setValue(MapNodeType.NORMAL_PATH.id);
                    JSONObject valueObj = JSON.parseObject(map.getString("value"));
                    JSONObject newNodeValue = new JSONObject();
                    newNodeValue.put("rgvCalcFlag", 1);
                    nodeValue = JSON.toJSONString(newNodeValue);
                    //RGV暂不控制行走方向,默认上下左右都可走
                    List<String> directionList = new ArrayList<>();
                    directionList.add("top");
                    directionList.add("bottom");
                    directionList.add("left");
                    directionList.add("right");
                    navigateNode.setDirectionList(directionList);
                } else if ("rgv".equals(mapType) && nodeType.equals("rgv")) {
                    navigateNode.setValue(MapNodeType.NORMAL_PATH.id);
                    List<String> directionList = new ArrayList<>();
                    directionList.add("top");
                    directionList.add("bottom");
@@ -76,53 +185,103 @@
            }
            navigateNodeList.add(navigateNodeRow);
        }
        return navigateNodeList;
        return cropNavigateMap(navigateNodeList);
    }
    public List<List<NavigateNode>> getRgvTrackMap(int lev) {
        BasMapService basMapService = SpringUtils.getBean(BasMapService.class);
        BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev));
        if (basMap == null) {
            throw new CoolException("地图不存在");
        }
        List<List<JSONObject>> dataList = JSON.parseObject(basMap.getData(), List.class);
        List<List<NavigateNode>> navigateNodeList = new ArrayList<>();
        for (int i = 0; i < dataList.size(); i++) {
            List<JSONObject> row = dataList.get(i);
            List<NavigateNode> navigateNodeRow = new ArrayList<>();
            for (int j = 0; j < row.size(); j++) {
                JSONObject map = row.get(j);
                NavigateNode navigateNode = new NavigateNode(i, j);
                String nodeType = map.getString("type");
                if(nodeType == null) {
                    navigateNode.setValue(MapNodeType.DISABLE.id);
                }else if(nodeType.equals("rgv")){
                    navigateNode.setValue(MapNodeType.NORMAL_PATH.id);
                    JSONObject valueObj = JSON.parseObject(map.getString("value"));
                    //RGV暂不控制行走方向,默认上下左右都可走
                    List<String> directionList = new ArrayList<>();
                    directionList.add("top");
                    directionList.add("bottom");
                    directionList.add("left");
                    directionList.add("right");
                    navigateNode.setDirectionList(directionList);
                }else {
                    navigateNode.setValue(MapNodeType.DISABLE.id);
                }
                navigateNode.setNodeType(nodeType);
                navigateNode.setNodeValue(map.getString("value"));
                navigateNodeRow.add(navigateNode);
    private List<List<NavigateNode>> cloneNavigateMap(List<List<NavigateNode>> sourceMap) {
        List<List<NavigateNode>> cloneMap = new ArrayList<>();
        for (List<NavigateNode> row : sourceMap) {
            List<NavigateNode> cloneRow = new ArrayList<>();
            for (NavigateNode node : row) {
                cloneRow.add(node == null ? null : node.clone());
            }
            navigateNodeList.add(navigateNodeRow);
            cloneMap.add(cloneRow);
        }
        return cloneMap;
    }
    private boolean isValidNavigateMap(List<List<NavigateNode>> navigateMap) {
        if (navigateMap == null || navigateMap.isEmpty() || navigateMap.get(0) == null || navigateMap.get(0).isEmpty()) {
            return false;
        }
        return navigateNodeList;
        int activeNodeCount = 0;
        for (List<NavigateNode> row : navigateMap) {
            if (row == null || row.isEmpty()) {
                return false;
            }
            for (NavigateNode node : row) {
                if (node == null) {
                    return false;
                }
                if (node.getValue() == MapNodeType.DISABLE.id) {
                    continue;
                }
                activeNodeCount++;
                if (node.getNodeType() == null) {
                    return false;
                }
                if (node.getDirectionList() == null || node.getDirectionList().isEmpty()) {
                    return false;
                }
            }
        }
        return activeNodeCount > 0;
    }
    /**
     * 只保留参与路径计算的二维区域,去掉上下左右整片无效空白区。
     */
    private List<List<NavigateNode>> cropNavigateMap(List<List<NavigateNode>> navigateMap) {
        if (navigateMap == null || navigateMap.isEmpty() || navigateMap.get(0) == null || navigateMap.get(0).isEmpty()) {
            return navigateMap;
        }
        int minX = Integer.MAX_VALUE;
        int maxX = Integer.MIN_VALUE;
        int minY = Integer.MAX_VALUE;
        int maxY = Integer.MIN_VALUE;
        boolean hasActiveNode = false;
        for (int x = 0; x < navigateMap.size(); x++) {
            List<NavigateNode> row = navigateMap.get(x);
            if (row == null) {
                continue;
            }
            for (int y = 0; y < row.size(); y++) {
                NavigateNode node = row.get(y);
                if (node == null || node.getValue() == MapNodeType.DISABLE.id) {
                    continue;
                }
                hasActiveNode = true;
                minX = Math.min(minX, x);
                maxX = Math.max(maxX, x);
                minY = Math.min(minY, y);
                maxY = Math.max(maxY, y);
            }
        }
        if (!hasActiveNode) {
            return navigateMap;
        }
        List<List<NavigateNode>> croppedMap = new ArrayList<>();
        for (int x = minX; x <= maxX; x++) {
            List<NavigateNode> sourceRow = navigateMap.get(x);
            List<NavigateNode> croppedRow = new ArrayList<>();
            for (int y = minY; y <= maxY; y++) {
                NavigateNode sourceNode = sourceRow.get(y);
                NavigateNode targetNode = new NavigateNode(x - minX, y - minY);
                targetNode.setValue(sourceNode.getValue());
                targetNode.setNodeType(sourceNode.getNodeType());
                targetNode.setNodeValue(sourceNode.getNodeValue());
                targetNode.setDirectionList(sourceNode.getDirectionList() == null
                        ? null
                        : new ArrayList<>(sourceNode.getDirectionList()));
                croppedRow.add(targetNode);
            }
            croppedMap.add(croppedRow);
        }
        return croppedMap;
    }
    public NavigateNode astarSearchJava(List<List<NavigateNode>> map, NavigateNode start, NavigateNode end) {
@@ -182,6 +341,18 @@
            int maxPaths,    // 最大返回条数. 建议:100/500/2000;<=0 表示不限制(不建议)
            int maxCost      // 最大总代价(含拐点惩罚). <=0 表示不限制
    ) {
        return allSimplePaths(map, start, end, maxDepth, maxPaths, maxCost, Collections.emptyList());
    }
    public List<List<NavigateNode>> allSimplePaths(
            List<List<NavigateNode>> map,
            NavigateNode start,
            NavigateNode end,
            int maxDepth,
            int maxPaths,
            int maxCost,
            List<Integer> guideStationIds
    ) {
        List<List<NavigateNode>> results = new ArrayList<>();
        if (map == null || map.isEmpty() || map.get(0).isEmpty()) return results;
        if (start == null || end == null) return results;
@@ -196,13 +367,16 @@
        path.add(start);
        AtomicInteger pathCount = new AtomicInteger(0);
        Map<Integer, NavigateNode> guideNodeMap = buildGuideNodeMap(map, guideStationIds);
        dfsAllSimplePaths(map, start, end,
                visited, path, results,
                0,  // depth
                0,  // cost
                maxDepth, maxPaths, maxCost,
                pathCount
                pathCount,
                guideStationIds,
                guideNodeMap
        );
        return results;
@@ -223,7 +397,9 @@
            int maxDepth,
            int maxPaths,
            int maxCost,
            AtomicInteger pathCount
            AtomicInteger pathCount,
            List<Integer> guideStationIds,
            Map<Integer, NavigateNode> guideNodeMap
    ) {
        // 防爆:条数限制
        if (maxPaths > 0 && pathCount.get() >= maxPaths) return;
@@ -241,6 +417,7 @@
        // 扩展邻居(严格复用你自己的可行走方向规则)
        ArrayList<NavigateNode> neighbors = extend_current_node(map, current);
        if (neighbors == null || neighbors.isEmpty()) return;
        neighbors = sortNeighborsByGuide(current, path, neighbors, guideStationIds, guideNodeMap);
        for (NavigateNode next : neighbors) {
            // 防爆:条数限制
@@ -270,7 +447,9 @@
                    depth + 1,
                    newCost,
                    maxDepth, maxPaths, maxCost,
                    pathCount
                    pathCount,
                    guideStationIds,
                    guideNodeMap
            );
            // 回溯
@@ -281,6 +460,116 @@
    private String keyOf(NavigateNode n) {
        return n.getX() + "_" + n.getY();
    }
    private Map<Integer, NavigateNode> buildGuideNodeMap(List<List<NavigateNode>> map, List<Integer> guideStationIds) {
        Map<Integer, NavigateNode> guideNodeMap = new HashMap<>();
        if (map == null || map.isEmpty() || guideStationIds == null || guideStationIds.isEmpty()) {
            return guideNodeMap;
        }
        for (Integer stationId : guideStationIds) {
            if (stationId == null || guideNodeMap.containsKey(stationId)) {
                continue;
            }
            NavigateNode stationNode = findStationNavigateNode(map, stationId);
            if (stationNode != null) {
                guideNodeMap.put(stationId, stationNode);
            }
        }
        return guideNodeMap;
    }
    private ArrayList<NavigateNode> sortNeighborsByGuide(NavigateNode current,
                                                         LinkedList<NavigateNode> path,
                                                         ArrayList<NavigateNode> neighbors,
                                                         List<Integer> guideStationIds,
                                                         Map<Integer, NavigateNode> guideNodeMap) {
        if (current == null || neighbors == null || neighbors.size() <= 1
                || guideStationIds == null || guideStationIds.isEmpty()
                || guideNodeMap == null || guideNodeMap.isEmpty()) {
            return neighbors;
        }
        Integer nextGuideStationId = resolveNextGuideStationId(path, guideStationIds);
        if (nextGuideStationId == null) {
            return neighbors;
        }
        NavigateNode guideTargetNode = guideNodeMap.get(nextGuideStationId);
        if (guideTargetNode == null) {
            return neighbors;
        }
        neighbors.sort((left, right) -> compareGuideNeighbor(current, left, right, nextGuideStationId, guideTargetNode));
        return neighbors;
    }
    private Integer resolveNextGuideStationId(LinkedList<NavigateNode> path, List<Integer> guideStationIds) {
        if (path == null || path.isEmpty() || guideStationIds == null || guideStationIds.isEmpty()) {
            return null;
        }
        int cursor = 0;
        Set<Integer> seen = new HashSet<>();
        for (NavigateNode node : path) {
            Integer stationId = extractStationId(node);
            if (stationId == null || !seen.add(stationId)) {
                continue;
            }
            if (cursor < guideStationIds.size() && stationId.equals(guideStationIds.get(cursor))) {
                cursor++;
            }
        }
        if (cursor >= guideStationIds.size()) {
            return null;
        }
        return guideStationIds.get(cursor);
    }
    private int compareGuideNeighbor(NavigateNode current,
                                     NavigateNode left,
                                     NavigateNode right,
                                     Integer nextGuideStationId,
                                     NavigateNode guideTargetNode) {
        int leftDirect = isGuideStation(left, nextGuideStationId) ? 0 : 1;
        int rightDirect = isGuideStation(right, nextGuideStationId) ? 0 : 1;
        if (leftDirect != rightDirect) {
            return Integer.compare(leftDirect, rightDirect);
        }
        int leftDistance = calcNodeCost(left, guideTargetNode);
        int rightDistance = calcNodeCost(right, guideTargetNode);
        if (leftDistance != rightDistance) {
            return Integer.compare(leftDistance, rightDistance);
        }
        int leftTurnCost = calcNodeExtraCost(current, left, guideTargetNode);
        int rightTurnCost = calcNodeExtraCost(current, right, guideTargetNode);
        if (leftTurnCost != rightTurnCost) {
            return Integer.compare(leftTurnCost, rightTurnCost);
        }
        return 0;
    }
    private boolean isGuideStation(NavigateNode node, Integer stationId) {
        Integer nodeStationId = extractStationId(node);
        return nodeStationId != null && nodeStationId.equals(stationId);
    }
    private Integer extractStationId(NavigateNode node) {
        JSONObject valueObj = parseNodeValue(node == null ? null : node.getNodeValue());
        return valueObj == null ? null : valueObj.getInteger("stationId");
    }
    private JSONObject parseNodeValue(String nodeValue) {
        if (nodeValue == null || nodeValue.trim().isEmpty()) {
            return null;
        }
        try {
            return JSON.parseObject(nodeValue);
        } catch (Exception ignore) {
            return null;
        }
    }
    public ArrayList<NavigateNode> extend_current_node(List<List<NavigateNode>> map, NavigateNode current_node) {
@@ -301,22 +590,22 @@
        for(String direction : directionList) {
            if(direction.equals("top")) {
                NavigateNode node = getValidNavigateNode(map, x - 1, y);
                NavigateNode node = getValidNavigateNode(map, current_node, x - 1, y, direction);
                if(node != null) {
                    neighbour_node.add(node);
                }
            }else if(direction.equals("bottom")) {
                NavigateNode node = getValidNavigateNode(map, x + 1, y);
                NavigateNode node = getValidNavigateNode(map, current_node, x + 1, y, direction);
                if(node != null) {
                    neighbour_node.add(node);
                }
            }else if(direction.equals("left")) {
                NavigateNode node = getValidNavigateNode(map, x, y - 1);
                NavigateNode node = getValidNavigateNode(map, current_node, x, y - 1, direction);
                if(node != null) {
                    neighbour_node.add(node);
                }
            }else if(direction.equals("right")) {
                NavigateNode node = getValidNavigateNode(map, x, y + 1);
                NavigateNode node = getValidNavigateNode(map, current_node, x, y + 1, direction);
                if(node != null) {
                    neighbour_node.add(node);
                }
@@ -324,6 +613,22 @@
        }
        return neighbour_node;
    }
    /**
     * 邻接点校验:可达 + 方向一致(当前节点与下一节点对本次行走方向一致)
     */
    public NavigateNode getValidNavigateNode(List<List<NavigateNode>> map, NavigateNode currentNode, int x, int y, String moveDirection) {
        NavigateNode node = getValidNavigateNode(map, x, y);
        if (node == null) {
            return null;
        }
        if (!isDirectionConsistent(currentNode, node, moveDirection)) {
            return null;
        }
        return node;
    }
    public NavigateNode getValidNavigateNode(List<List<NavigateNode>> map, int x, int y) {
@@ -340,19 +645,80 @@
        return node;
    }
    private boolean isDirectionConsistent(NavigateNode currentNode, NavigateNode nextNode, String moveDirection) {
        if (currentNode == null || nextNode == null) {
            return false;
        }
        if (moveDirection == null) {
            return false;
        }
        List<String> currentDirectionList = currentNode.getDirectionList();
        List<String> nextDirectionList = nextNode.getDirectionList();
        if (currentDirectionList == null || nextDirectionList == null) {
            return false;
        }
        // 当前节点允许向 moveDirection 出发,且下一节点在该方向上保持一致,才允许通行
        return currentDirectionList.contains(moveDirection) && nextDirectionList.contains(moveDirection);
    }
    public NavigateNode findStationNavigateNode(List<List<NavigateNode>> map, int stationId) {
        NavigateNode bestNode = null;
        int bestExternalConnectionCount = -1;
        int bestNeighborCount = -1;
        for(int x = 0; x < map.size(); x++) {
            for(int y = 0; y < map.get(0).size(); y++) {
                NavigateNode node = map.get(x).get(y);
                if("devp".equals(node.getNodeType())) {
                    JSONObject valueObj = JSON.parseObject(node.getNodeValue());
                    if(valueObj.getInteger("stationId") == stationId) {
                        return node;
                    }
                Integer currentStationId = extractStationId(node);
                if (currentStationId == null || currentStationId != stationId) {
                    continue;
                }
                ArrayList<NavigateNode> neighbors = extend_current_node(map, node);
                int externalConnectionCount = countExternalConnectionCount(stationId, neighbors);
                int neighborCount = neighbors == null ? 0 : neighbors.size();
                if (externalConnectionCount > bestExternalConnectionCount
                        || (externalConnectionCount == bestExternalConnectionCount && neighborCount > bestNeighborCount)) {
                    bestNode = node;
                    bestExternalConnectionCount = externalConnectionCount;
                    bestNeighborCount = neighborCount;
                }
            }
        }
        return null;
        return bestNode;
    }
    private int countExternalConnectionCount(Integer currentStationId, List<NavigateNode> neighbors) {
        Set<Integer> connectedStationIdSet = new LinkedHashSet<>();
        if (neighbors == null || neighbors.isEmpty()) {
            return 0;
        }
        for (NavigateNode neighbor : neighbors) {
            connectedStationIdSet.addAll(resolveAdjacentStationIds(currentStationId, neighbor));
        }
        return connectedStationIdSet.size();
    }
    private Set<Integer> resolveAdjacentStationIds(Integer currentStationId, NavigateNode node) {
        Set<Integer> stationIdSet = new LinkedHashSet<>();
        JSONObject valueObj = parseNodeValue(node == null ? null : node.getNodeValue());
        if (valueObj == null) {
            return stationIdSet;
        }
        Integer directStationId = valueObj.getInteger("stationId");
        if (directStationId != null && !directStationId.equals(currentStationId)) {
            stationIdSet.add(directStationId);
        }
        if (valueObj.getJSONArray("bridgeStationIds") == null) {
            return stationIdSet;
        }
        for (Integer bridgeStationId : valueObj.getJSONArray("bridgeStationIds").toJavaList(Integer.class)) {
            if (bridgeStationId != null && !bridgeStationId.equals(currentStationId)) {
                stationIdSet.add(bridgeStationId);
            }
        }
        return stationIdSet;
    }
    public NavigateNode findTrackSiteNoNavigateNode(List<List<NavigateNode>> map, int trackSiteNo) {
@@ -401,4 +767,13 @@
    //------------------A*启发函数-end------------------//
    private static class CachedNavigateMap {
        private final long cacheAtMs;
        private final List<List<NavigateNode>> navigateMap;
        private CachedNavigateMap(long cacheAtMs, List<List<NavigateNode>> navigateMap) {
            this.cacheAtMs = cacheAtMs;
            this.navigateMap = navigateMap;
        }
    }
}