#
Junjie
4 天以前 517966d4dbed6ef6e5d591720b971af427e6b63a
src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -4,6 +4,8 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import com.zy.core.News;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
@@ -14,9 +16,9 @@
@Component
public class NavigateUtils {
    public synchronized List<NavigateNode> calcByStationId(Integer startStationId, Integer endStationId) {
    public synchronized List<NavigateNode> calcByStationId(int lev, Integer startStationId, Integer endStationId) {
        NavigateSolution navigateSolution = new NavigateSolution();
        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap();
        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(lev);
        NavigateNode startNode = navigateSolution.findStationNavigateNode(stationMap, startStationId);
        if (startNode == null){
@@ -28,10 +30,13 @@
            throw new CoolException("未找到该 终点 对应的节点");
        }
        long startTime = System.currentTimeMillis();
        News.info("[WCS Debug] 站点路径开始计算,startStationId={},endStationId={}", startStationId, endStationId);
        NavigateNode res_node = navigateSolution.astarSearchJava(stationMap, startNode, endNode);
        if (res_node == null) {
            throw new CoolException("未找到该路径");
        }
        News.info("[WCS Debug] 站点路径计算完成,耗时:{}ms", System.currentTimeMillis() - startTime);
        ArrayList<NavigateNode> list = new ArrayList<>();
        // 使用 visited 集合防止父链出现环导致死循环,同时设置安全步数上限
@@ -66,9 +71,9 @@
        return fitlerList;
    }
    public synchronized List<NavigateNode> calcByTrackSiteNo(Integer startTrackSiteNo, Integer endTrackSiteNo) {
    public synchronized List<NavigateNode> calcByTrackSiteNo(int lev, Integer startTrackSiteNo, Integer endTrackSiteNo) {
        NavigateSolution navigateSolution = new NavigateSolution();
        List<List<NavigateNode>> rgvTrackMap = navigateSolution.getRgvTrackMap();
        List<List<NavigateNode>> rgvTrackMap = navigateSolution.getRgvTrackMap(lev);
        NavigateNode startNode = navigateSolution.findTrackSiteNoNavigateNode(rgvTrackMap, startTrackSiteNo);
        if (startNode == null){
@@ -80,10 +85,13 @@
            throw new CoolException("未找到该 终点 对应的节点");
        }
        long startTime = System.currentTimeMillis();
        News.info("[WCS Debug] RGV路径开始计算,startTrackSiteNo:{},endTrackSiteNo={}", startTrackSiteNo, endTrackSiteNo);
        NavigateNode res_node = navigateSolution.astarSearchJava(rgvTrackMap, startNode, endNode);
        if (res_node == null) {
            throw new CoolException("未找到该路径");
        }
        News.info("[WCS Debug] RGV路径计算完成,耗时:{}ms", System.currentTimeMillis() - startTime);
        ArrayList<NavigateNode> list = new ArrayList<>();
        // 使用 visited 集合防止父链出现环导致死循环,同时设置安全步数上限
@@ -118,4 +126,30 @@
        return fitlerList;
    }
    public synchronized List<NavigateNode> findLiftStationList(int lev) {
        NavigateSolution navigateSolution = new NavigateSolution();
        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(lev);
        List<NavigateNode> liftStationList = new ArrayList<>();
        for (List<NavigateNode> navigateNodes : stationMap) {
            for (NavigateNode navigateNode : navigateNodes) {
                String nodeType = navigateNode.getNodeType();
                if(nodeType == null){
                    continue;
                }
                if(!nodeType.equals("devp")){
                    continue;
                }
                JSONObject valuObject = JSON.parseObject(navigateNode.getNodeValue());
                if(valuObject == null){
                    continue;
                }
                if (valuObject.containsKey("liftNo")) {
                    liftStationList.add(navigateNode);
                }
            }
        }
        return liftStationList;
    }
}