| | |
| | | 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; |
| | |
| | | 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() { |
| | | List<Integer> levList = new ArrayList<>(); |
| | | if (basStationService == null) { |