#
Junjie
12 小时以前 4351d2b4db890de9f5f456f16a68a270788c6434
#
5个文件已修改
650 ■■■■ 已修改文件
src/main/java/com/zy/common/utils/NavigateUtils.java 330 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/RedisKeyType.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/StationThread.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/impl/ZyStationV5Thread.java 300 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -84,110 +84,36 @@
        return calcByStationId(startStationId, endStationId, null, true);
    }
    public synchronized List<List<NavigateNode>> calcCandidatePathByStationId(Integer startStationId,
                                                                              Integer endStationId,
                                                                              Integer currentTaskNo) {
        StationPathSearchContext context = buildStationPathSearchContext(startStationId, endStationId);
        if (context.allList.isEmpty()) {
            return new ArrayList<>();
        }
        List<List<NavigateNode>> orderedPathList = orderStationPathCandidates(
                context.allList,
                context.resolvedPolicy,
                currentTaskNo,
                startStationId,
                endStationId
        );
        return normalizeCandidatePaths(orderedPathList);
    }
    private synchronized List<NavigateNode> calcByStationId(Integer startStationId,
                                                            Integer endStationId,
                                                            Integer currentTaskNo,
                                                            boolean reachabilityOnly) {
        BasStation startStation = basStationService.getById(startStationId);
        if (startStation == null) {
            throw new CoolException("未找到该 起点 对应的站点数据");
        }
        Integer lev = startStation.getStationLev();
        NavigateSolution navigateSolution = new NavigateSolution();
        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(lev);
        NavigateNode startNode = navigateSolution.findStationNavigateNode(stationMap, startStationId);
        if (startNode == null) {
            throw new CoolException("未找到该 起点 对应的节点");
        }
        NavigateNode endNode = navigateSolution.findStationNavigateNode(stationMap, endStationId);
        if (endNode == null) {
            throw new CoolException("未找到该 终点 对应的节点");
        }
        StationPathResolvedPolicy resolvedPolicy = resolveStationPathPolicy(startStationId, endStationId);
        StationPathProfileConfig profileConfig = resolvedPolicy.getProfileConfig() == null
                ? StationPathProfileConfig.defaultConfig()
                : resolvedPolicy.getProfileConfig();
        long startTime = System.currentTimeMillis();
        News.info("[WCS Debug] 站点路径开始计算,startStationId={},endStationId={}", startStationId, endStationId);
        int calcMaxDepth = safeInt(profileConfig.getCalcMaxDepth(), 120);
        int calcMaxPaths = safeInt(profileConfig.getCalcMaxPaths(), 500);
        int calcMaxCost = safeInt(profileConfig.getCalcMaxCost(), 300);
        List<Integer> guideStationSequence = buildGuideStationSequence(startStationId, endStationId, resolvedPolicy.getRuleConfig());
        List<List<NavigateNode>> allList = navigateSolution.allSimplePaths(
                stationMap,
                startNode,
                endNode,
                calcMaxDepth,
                calcMaxPaths,
                calcMaxCost,
                guideStationSequence
        );
        if (allList.isEmpty()) {
//            throw new CoolException("未找到该路径");
        StationPathSearchContext context = buildStationPathSearchContext(startStationId, endStationId);
        if (context.allList.isEmpty()) {
            return new ArrayList<>();
        }
        Map<Integer, StationProtocol> statusMap = loadStationStatusMap();
        allList = filterNonAutoStationPaths(allList, statusMap);
        if (allList.isEmpty()) {
            News.info("[WCS Debug] 站点路径候选全部被过滤,存在非自动站点,startStationId={},endStationId={}", startStationId, endStationId);
            return new ArrayList<>();
        }
        News.info("[WCS Debug] 站点路径计算完成,耗时:{}ms", System.currentTimeMillis() - startTime);
        startTime = System.currentTimeMillis();
        News.info("[WCS Debug] 站点路径权重开始分析,startStationId={},endStationId={}", startStationId, endStationId);
        List<NavigateNode> list = reachabilityOnly
                ? findStationReachablePath(allList, resolvedPolicy, startStationId, endStationId)
                : findStationBestPathTwoStage(allList, resolvedPolicy, currentTaskNo, startStationId, endStationId);
        News.info("[WCS Debug] 站点路径权重分析完成,耗时:{}ms", System.currentTimeMillis() - startTime);
        //去重
        HashSet<Integer> set = new HashSet<>();
        List<NavigateNode> fitlerList = new ArrayList<>();
        for (NavigateNode navigateNode : list) {
            JSONObject valuObject = JSON.parseObject(navigateNode.getNodeValue());
            if (valuObject.containsKey("rgvCalcFlag")) {
                continue;
            }
            if (set.add(valuObject.getInteger("stationId"))) {
                fitlerList.add(navigateNode);
            }
        }
        for (int i = 0; i < fitlerList.size(); i++) {
            NavigateNode currentNode = fitlerList.get(i);
            currentNode.setIsInflectionPoint(false);
            currentNode.setIsLiftTransferPoint(false);
            try {
                JSONObject valueObject = JSON.parseObject(currentNode.getNodeValue());
                if (valueObject != null) {
                    Object isLiftTransfer = valueObject.get("isLiftTransfer");
                    if (isLiftTransfer != null) {
                        String isLiftTransferStr = isLiftTransfer.toString();
                        if ("1".equals(isLiftTransferStr) || "true".equalsIgnoreCase(isLiftTransferStr)) {
                            currentNode.setIsLiftTransferPoint(true);
                        }
                    }
                }
            } catch (Exception ignore) {}
            NavigateNode nextNode = (i + 1 < fitlerList.size()) ? fitlerList.get(i + 1) : null;
            NavigateNode prevNode = (i - 1 >= 0) ? fitlerList.get(i - 1) : null;
            HashMap<String, Object> result = searchInflectionPoint(currentNode, nextNode, prevNode);
            if (Boolean.parseBoolean(result.get("result").toString())) {
                currentNode.setIsInflectionPoint(true);
                currentNode.setDirection(result.get("direction").toString());
            }
        }
        return fitlerList;
                ? findStationReachablePath(context.allList, context.resolvedPolicy, startStationId, endStationId)
                : findStationBestPathTwoStage(context.allList, context.resolvedPolicy, currentTaskNo, startStationId, endStationId);
        return normalizeStationPath(list);
    }
    public synchronized List<NavigateNode> calcByTrackSiteNo(int lev, Integer startTrackSiteNo, Integer endTrackSiteNo) {
@@ -337,6 +263,18 @@
                                                           Integer currentTaskNo,
                                                           Integer startStationId,
                                                           Integer endStationId) {
        List<List<NavigateNode>> orderedPathList = orderStationPathCandidates(allList, resolvedPolicy, currentTaskNo, startStationId, endStationId);
        if (orderedPathList.isEmpty()) {
            return new ArrayList<>();
        }
        return orderedPathList.get(0);
    }
    private List<List<NavigateNode>> orderStationPathCandidates(List<List<NavigateNode>> allList,
                                                                StationPathResolvedPolicy resolvedPolicy,
                                                                Integer currentTaskNo,
                                                                Integer startStationId,
                                                                Integer endStationId) {
        if (allList == null || allList.isEmpty()) {
            return new ArrayList<>();
        }
@@ -423,12 +361,41 @@
        }
        int topK = safeInt(profileConfig.getS1TopK(), 5);
        if (topK > 0 && stage1Selected.size() > topK) {
            stage1Selected = new ArrayList<>(stage1Selected.subList(0, topK));
        List<PathCandidateMetrics> primaryMetrics = new ArrayList<>(stage1Selected);
        List<PathCandidateMetrics> secondaryMetrics = new ArrayList<>();
        if (topK > 0 && primaryMetrics.size() > topK) {
            secondaryMetrics.addAll(primaryMetrics.subList(topK, primaryMetrics.size()));
            primaryMetrics = new ArrayList<>(primaryMetrics.subList(0, topK));
        }
        stage1Selected.sort((a, b) -> compareDouble(a.dynamicCost, b.dynamicCost, a.pathLen, b.pathLen, a.turnCount, b.turnCount));
        return stage1Selected.get(0).path;
        primaryMetrics.sort((a, b) -> compareDouble(a.dynamicCost, b.dynamicCost, a.pathLen, b.pathLen, a.turnCount, b.turnCount));
        secondaryMetrics.sort((a, b) -> compareDouble(a.dynamicCost, b.dynamicCost, a.pathLen, b.pathLen, a.turnCount, b.turnCount));
        List<PathCandidateMetrics> remainingMetrics = new ArrayList<>();
        for (PathCandidateMetrics metrics : metricsList) {
            if (!stage1Selected.contains(metrics)) {
                remainingMetrics.add(metrics);
            }
        }
        remainingMetrics.sort((a, b) -> compareDouble(a.dynamicCost, b.dynamicCost, a.pathLen, b.pathLen, a.turnCount, b.turnCount));
        List<List<NavigateNode>> orderedPathList = new ArrayList<>();
        appendCandidatePathList(orderedPathList, primaryMetrics);
        appendCandidatePathList(orderedPathList, secondaryMetrics);
        appendCandidatePathList(orderedPathList, remainingMetrics);
        return orderedPathList;
    }
    private void appendCandidatePathList(List<List<NavigateNode>> orderedPathList,
                                         List<PathCandidateMetrics> metricsList) {
        if (orderedPathList == null || metricsList == null) {
            return;
        }
        for (PathCandidateMetrics metrics : metricsList) {
            if (metrics != null && metrics.path != null && !metrics.path.isEmpty()) {
                orderedPathList.add(metrics.path);
            }
        }
    }
    private List<List<NavigateNode>> applyRuleFilters(List<List<NavigateNode>> allList,
@@ -1777,10 +1744,171 @@
        return text != null && !text.trim().isEmpty();
    }
    private StationPathSearchContext buildStationPathSearchContext(Integer startStationId, Integer endStationId) {
        BasStation startStation = basStationService.getById(startStationId);
        if (startStation == null) {
            throw new CoolException("未找到该 起点 对应的站点数据");
        }
        Integer lev = startStation.getStationLev();
        NavigateSolution navigateSolution = new NavigateSolution();
        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(lev);
        NavigateNode startNode = navigateSolution.findStationNavigateNode(stationMap, startStationId);
        if (startNode == null) {
            throw new CoolException("未找到该 起点 对应的节点");
        }
        NavigateNode endNode = navigateSolution.findStationNavigateNode(stationMap, endStationId);
        if (endNode == null) {
            throw new CoolException("未找到该 终点 对应的节点");
        }
        StationPathResolvedPolicy resolvedPolicy = resolveStationPathPolicy(startStationId, endStationId);
        StationPathProfileConfig profileConfig = resolvedPolicy.getProfileConfig() == null
                ? StationPathProfileConfig.defaultConfig()
                : resolvedPolicy.getProfileConfig();
        long startTime = System.currentTimeMillis();
        News.info("[WCS Debug] 站点路径开始计算,startStationId={},endStationId={}", startStationId, endStationId);
        int calcMaxDepth = safeInt(profileConfig.getCalcMaxDepth(), 120);
        int calcMaxPaths = safeInt(profileConfig.getCalcMaxPaths(), 500);
        int calcMaxCost = safeInt(profileConfig.getCalcMaxCost(), 300);
        List<Integer> guideStationSequence = buildGuideStationSequence(startStationId, endStationId, resolvedPolicy.getRuleConfig());
        List<List<NavigateNode>> allList = navigateSolution.allSimplePaths(
                stationMap,
                startNode,
                endNode,
                calcMaxDepth,
                calcMaxPaths,
                calcMaxCost,
                guideStationSequence
        );
        if (allList.isEmpty()) {
            return StationPathSearchContext.empty(resolvedPolicy);
        }
        Map<Integer, StationProtocol> statusMap = loadStationStatusMap();
        allList = filterNonAutoStationPaths(allList, statusMap);
        if (allList.isEmpty()) {
            News.info("[WCS Debug] 站点路径候选全部被过滤,存在非自动站点,startStationId={},endStationId={}", startStationId, endStationId);
            return StationPathSearchContext.empty(resolvedPolicy);
        }
        News.info("[WCS Debug] 站点路径计算完成,耗时:{}ms", System.currentTimeMillis() - startTime);
        return new StationPathSearchContext(allList, resolvedPolicy);
    }
    private List<List<NavigateNode>> normalizeCandidatePaths(List<List<NavigateNode>> orderedPathList) {
        List<List<NavigateNode>> result = new ArrayList<>();
        if (orderedPathList == null || orderedPathList.isEmpty()) {
            return result;
        }
        Set<String> seenPathSignatures = new LinkedHashSet<>();
        for (List<NavigateNode> path : orderedPathList) {
            List<NavigateNode> normalizedPath = normalizeStationPath(path);
            String pathSignature = buildPathSignature(normalizedPath);
            if (pathSignature.isEmpty() || !seenPathSignatures.add(pathSignature)) {
                continue;
            }
            result.add(normalizedPath);
        }
        return result;
    }
    private List<NavigateNode> normalizeStationPath(List<NavigateNode> path) {
        HashSet<Integer> stationIdSet = new HashSet<>();
        List<NavigateNode> filterList = new ArrayList<>();
        for (NavigateNode navigateNode : safeList(path)) {
            if (navigateNode == null) {
                continue;
            }
            JSONObject valueObject;
            try {
                valueObject = JSON.parseObject(navigateNode.getNodeValue());
            } catch (Exception ignore) {
                continue;
            }
            if (valueObject == null || valueObject.containsKey("rgvCalcFlag")) {
                continue;
            }
            Integer stationId = valueObject.getInteger("stationId");
            if (stationId == null || !stationIdSet.add(stationId)) {
                continue;
            }
            NavigateNode clonedNode = navigateNode.clone();
            if (clonedNode == null) {
                continue;
            }
            filterList.add(clonedNode);
        }
        for (int i = 0; i < filterList.size(); i++) {
            NavigateNode currentNode = filterList.get(i);
            currentNode.setIsInflectionPoint(false);
            currentNode.setIsLiftTransferPoint(false);
            try {
                JSONObject valueObject = JSON.parseObject(currentNode.getNodeValue());
                if (valueObject != null) {
                    Object isLiftTransfer = valueObject.get("isLiftTransfer");
                    if (isLiftTransfer != null) {
                        String isLiftTransferStr = isLiftTransfer.toString();
                        if ("1".equals(isLiftTransferStr) || "true".equalsIgnoreCase(isLiftTransferStr)) {
                            currentNode.setIsLiftTransferPoint(true);
                        }
                    }
                }
            } catch (Exception ignore) {
            }
            NavigateNode nextNode = (i + 1 < filterList.size()) ? filterList.get(i + 1) : null;
            NavigateNode prevNode = (i - 1 >= 0) ? filterList.get(i - 1) : null;
            HashMap<String, Object> searchResult = searchInflectionPoint(currentNode, nextNode, prevNode);
            if (Boolean.parseBoolean(searchResult.get("result").toString())) {
                currentNode.setIsInflectionPoint(true);
                currentNode.setDirection(searchResult.get("direction").toString());
            }
        }
        return filterList;
    }
    private String buildPathSignature(List<NavigateNode> path) {
        List<Integer> stationIdList = extractStationIdList(path);
        if (stationIdList.isEmpty()) {
            return "";
        }
        StringBuilder builder = new StringBuilder();
        for (Integer stationId : stationIdList) {
            if (stationId == null) {
                continue;
            }
            if (builder.length() > 0) {
                builder.append("->");
            }
            builder.append(stationId);
        }
        return builder.toString();
    }
    private <T> List<T> safeList(List<T> list) {
        return list == null ? Collections.emptyList() : list;
    }
    private static class StationPathSearchContext {
        private final List<List<NavigateNode>> allList;
        private final StationPathResolvedPolicy resolvedPolicy;
        private StationPathSearchContext(List<List<NavigateNode>> allList,
                                         StationPathResolvedPolicy resolvedPolicy) {
            this.allList = allList == null ? new ArrayList<>() : allList;
            this.resolvedPolicy = resolvedPolicy == null ? new StationPathResolvedPolicy() : resolvedPolicy;
        }
        private static StationPathSearchContext empty(StationPathResolvedPolicy resolvedPolicy) {
            return new StationPathSearchContext(new ArrayList<>(), resolvedPolicy);
        }
    }
    private static class PathCandidateMetrics {
        private List<NavigateNode> path;
        private int pathLen;
src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -43,6 +43,7 @@
    STATION_OUT_ORDER_DISPATCH_LIMIT_("station_out_order_dispatch_limit_"),
    STATION_OUT_EXECUTE_COMPLETE_LIMIT("station_out_execute_complete_limit_"),
    CHECK_STATION_RUN_BLOCK_LIMIT_("check_station_run_block_limit_"),
    STATION_RUN_BLOCK_REROUTE_STATE_("station_run_block_reroute_state_"),
    CHECK_STATION_IDLE_RECOVER_LIMIT_("check_station_idle_recover_limit_"),
    CHECK_SHALLOW_LOC_STATUS_LIMIT("check_shallow_loc_status_limit_"),
    GENERATE_ENABLE_IN_STATION_DATA_LIMIT("generate_enable_in_station_data_limit_"),
src/main/java/com/zy/core/thread/StationThread.java
@@ -16,6 +16,13 @@
    StationCommand getCommand(StationCommandType commandType, Integer taskNo, Integer stationId, Integer targetStationId, Integer palletSize);
    default StationCommand getRunBlockRerouteCommand(Integer taskNo,
                                                     Integer stationId,
                                                     Integer targetStationId,
                                                     Integer palletSize) {
        return getCommand(StationCommandType.MOVE, taskNo, stationId, targetStationId, palletSize);
    }
    CommandResponse sendCommand(StationCommand command);
    CommandResponse sendOriginCommand(String address, short[] data);
src/main/java/com/zy/core/thread/impl/ZyStationV5Thread.java
@@ -18,6 +18,7 @@
import com.zy.common.utils.RedisUtil;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.SlaveType;
import com.zy.core.enums.StationCommandType;
import com.zy.core.model.CommandResponse;
@@ -36,14 +37,19 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Data
@Slf4j
public class ZyStationV5Thread implements Runnable, com.zy.core.thread.StationThread {
    private static final int RUN_BLOCK_REROUTE_STATE_EXPIRE_SECONDS = 60 * 60 * 24;
    private List<StationProtocol> statusList = new ArrayList<>();
    private DeviceConfig deviceConfig;
@@ -229,31 +235,75 @@
        if (commandType == StationCommandType.MOVE && !stationId.equals(targetStationId)) {
            List<NavigateNode> nodes = calcPathNavigateNodes(taskNo, stationId, targetStationId);
            List<Integer> path = new ArrayList<>();
            List<Integer> liftTransferPath = new ArrayList<>();
            for (NavigateNode n : nodes) {
                JSONObject v = JSONObject.parseObject(n.getNodeValue());
                if (v == null) {
                    continue;
                }
                Integer stationNo = v.getInteger("stationId");
                if (stationNo == null) {
                    continue;
                }
                path.add(stationNo);
                if (Boolean.TRUE.equals(n.getIsLiftTransferPoint())) {
                    liftTransferPath.add(stationNo);
                }
            }
            if (path.isEmpty()) {
                log.warn("输送线命令生成失败,路径为空,taskNo={}, stationId={}, targetStationId={}",
                        taskNo, stationId, targetStationId);
                return null;
            }
            stationCommand.setNavigatePath(path);
            stationCommand.setLiftTransferPath(liftTransferPath);
            return fillMoveCommandPath(stationCommand, nodes, taskNo, stationId, targetStationId);
        }
        return stationCommand;
    }
    @Override
    public synchronized StationCommand getRunBlockRerouteCommand(Integer taskNo,
                                                                 Integer stationId,
                                                                 Integer targetStationId,
                                                                 Integer palletSize) {
        if (taskNo == null || taskNo <= 0 || stationId == null || targetStationId == null) {
            return null;
        }
        if (Objects.equals(stationId, targetStationId)) {
            return getCommand(StationCommandType.MOVE, taskNo, stationId, targetStationId, palletSize);
        }
        RunBlockRerouteState rerouteState = loadRunBlockRerouteState(taskNo, stationId);
        rerouteState.setTaskNo(taskNo);
        rerouteState.setBlockStationId(stationId);
        rerouteState.setLastTargetStationId(targetStationId);
        rerouteState.setPlanCount((rerouteState.getPlanCount() == null ? 0 : rerouteState.getPlanCount()) + 1);
        rerouteState.setLastPlanTime(System.currentTimeMillis());
        List<List<NavigateNode>> candidatePathList = calcCandidatePathNavigateNodes(taskNo, stationId, targetStationId);
        if (candidatePathList.isEmpty()) {
            saveRunBlockRerouteState(rerouteState);
            log.warn("输送线堵塞重规划失败,候选路径为空,taskNo={}, planCount={}, stationId={}, targetStationId={}",
                    taskNo, rerouteState.getPlanCount(), stationId, targetStationId);
            return null;
        }
        StationCommand rerouteCommand = selectAvailableRerouteCommand(
                rerouteState,
                candidatePathList,
                taskNo,
                stationId,
                targetStationId,
                palletSize
        );
        if (rerouteCommand == null) {
            log.info("输送线堵塞重规划候选路线已全部试过,重置路线历史后重新开始,taskNo={}, planCount={}, stationId={}, targetStationId={}",
                    taskNo, rerouteState.getPlanCount(), stationId, targetStationId);
            rerouteState.resetIssuedRoutes();
            rerouteCommand = selectAvailableRerouteCommand(
                    rerouteState,
                    candidatePathList,
                    taskNo,
                    stationId,
                    targetStationId,
                    palletSize
            );
        }
        if (rerouteCommand != null) {
            saveRunBlockRerouteState(rerouteState);
            log.info("输送线堵塞重规划选中候选路线,taskNo={}, planCount={}, stationId={}, targetStationId={}, route={}",
                    taskNo, rerouteState.getPlanCount(), stationId, targetStationId, JSON.toJSONString(rerouteCommand.getNavigatePath()));
            return rerouteCommand;
        }
        saveRunBlockRerouteState(rerouteState);
        log.warn("输送线堵塞重规划未找到可下发路线,taskNo={}, planCount={}, stationId={}, targetStationId={}, triedRoutes={}",
                taskNo,
                rerouteState.getPlanCount(),
                stationId,
                targetStationId,
                JSON.toJSONString(rerouteState.getIssuedRoutePathList()));
        return null;
    }
    @Override
@@ -314,4 +364,208 @@
        }
        return navigateUtils.calcByStationId(startStationId, targetStationId, taskNo);
    }
    private List<List<NavigateNode>> calcCandidatePathNavigateNodes(Integer taskNo,
                                                                    Integer startStationId,
                                                                    Integer targetStationId) {
        NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
        if (navigateUtils == null) {
            return new ArrayList<>();
        }
        return navigateUtils.calcCandidatePathByStationId(startStationId, targetStationId, taskNo);
    }
    private StationCommand buildMoveCommand(Integer taskNo,
                                            Integer stationId,
                                            Integer targetStationId,
                                            Integer palletSize,
                                            List<NavigateNode> nodes) {
        StationCommand stationCommand = new StationCommand();
        stationCommand.setTaskNo(taskNo);
        stationCommand.setStationId(stationId);
        stationCommand.setTargetStaNo(targetStationId);
        stationCommand.setPalletSize(palletSize);
        stationCommand.setCommandType(StationCommandType.MOVE);
        return fillMoveCommandPath(stationCommand, nodes, taskNo, stationId, targetStationId);
    }
    private StationCommand fillMoveCommandPath(StationCommand stationCommand,
                                               List<NavigateNode> nodes,
                                               Integer taskNo,
                                               Integer stationId,
                                               Integer targetStationId) {
        List<Integer> path = new ArrayList<>();
        List<Integer> liftTransferPath = new ArrayList<>();
        for (NavigateNode node : nodes) {
            JSONObject valueObject;
            try {
                valueObject = JSONObject.parseObject(node.getNodeValue());
            } catch (Exception ignore) {
                continue;
            }
            if (valueObject == null) {
                continue;
            }
            Integer stationNo = valueObject.getInteger("stationId");
            if (stationNo == null) {
                continue;
            }
            path.add(stationNo);
            if (Boolean.TRUE.equals(node.getIsLiftTransferPoint())) {
                liftTransferPath.add(stationNo);
            }
        }
        if (path.isEmpty()) {
            log.warn("输送线命令生成失败,路径为空,taskNo={}, stationId={}, targetStationId={}",
                    taskNo, stationId, targetStationId);
            return null;
        }
        stationCommand.setNavigatePath(path);
        stationCommand.setLiftTransferPath(liftTransferPath);
        stationCommand.setTargetStaNo(path.get(path.size() - 1));
        return stationCommand;
    }
    private StationCommand selectAvailableRerouteCommand(RunBlockRerouteState rerouteState,
                                                         List<List<NavigateNode>> candidatePathList,
                                                         Integer taskNo,
                                                         Integer stationId,
                                                         Integer targetStationId,
                                                         Integer palletSize) {
        if (rerouteState == null || candidatePathList == null || candidatePathList.isEmpty()) {
            return null;
        }
        Set<String> issuedRouteSignatureSet = rerouteState.getIssuedRouteSignatureSet();
        for (List<NavigateNode> candidatePath : candidatePathList) {
            StationCommand rerouteCommand = buildMoveCommand(taskNo, stationId, targetStationId, palletSize, candidatePath);
            if (rerouteCommand == null || rerouteCommand.getNavigatePath() == null || rerouteCommand.getNavigatePath().isEmpty()) {
                continue;
            }
            String routeSignature = buildPathSignature(rerouteCommand.getNavigatePath());
            if (Cools.isEmpty(routeSignature) || issuedRouteSignatureSet.contains(routeSignature)) {
                continue;
            }
            issuedRouteSignatureSet.add(routeSignature);
            rerouteState.getIssuedRoutePathList().add(new ArrayList<>(rerouteCommand.getNavigatePath()));
            rerouteState.setLastSelectedRoute(new ArrayList<>(rerouteCommand.getNavigatePath()));
            return rerouteCommand;
        }
        return null;
    }
    private RunBlockRerouteState loadRunBlockRerouteState(Integer taskNo, Integer blockStationId) {
        if (redisUtil == null || taskNo == null || taskNo <= 0 || blockStationId == null || blockStationId <= 0) {
            return new RunBlockRerouteState();
        }
        Object stateObj = redisUtil.get(buildRunBlockRerouteStateKey(taskNo, blockStationId));
        if (stateObj == null) {
            return new RunBlockRerouteState();
        }
        try {
            RunBlockRerouteState state = JSON.parseObject(String.valueOf(stateObj), RunBlockRerouteState.class);
            return state == null ? new RunBlockRerouteState() : state.normalize();
        } catch (Exception ignore) {
            return new RunBlockRerouteState();
        }
    }
    private void saveRunBlockRerouteState(RunBlockRerouteState rerouteState) {
        if (redisUtil == null
                || rerouteState == null
                || rerouteState.getTaskNo() == null
                || rerouteState.getTaskNo() <= 0
                || rerouteState.getBlockStationId() == null
                || rerouteState.getBlockStationId() <= 0) {
            return;
        }
        rerouteState.normalize();
        redisUtil.set(
                buildRunBlockRerouteStateKey(rerouteState.getTaskNo(), rerouteState.getBlockStationId()),
                JSON.toJSONString(rerouteState),
                RUN_BLOCK_REROUTE_STATE_EXPIRE_SECONDS
        );
    }
    private String buildPathSignature(List<Integer> path) {
        if (path == null || path.isEmpty()) {
            return "";
        }
        StringBuilder builder = new StringBuilder();
        for (Integer stationNo : path) {
            if (stationNo == null) {
                continue;
            }
            if (builder.length() > 0) {
                builder.append("->");
            }
            builder.append(stationNo);
        }
        return builder.toString();
    }
    private String buildRunBlockRerouteStateKey(Integer taskNo, Integer blockStationId) {
        return RedisKeyType.STATION_RUN_BLOCK_REROUTE_STATE_.key + taskNo + "_" + blockStationId;
    }
    @Data
    private static class RunBlockRerouteState {
        private Integer taskNo;
        private Integer blockStationId;
        private Integer planCount = 0;
        private Integer lastTargetStationId;
        private Long lastPlanTime;
        private List<List<Integer>> issuedRoutePathList = new ArrayList<>();
        private List<Integer> lastSelectedRoute = new ArrayList<>();
        private Set<String> issuedRouteSignatureSet = new LinkedHashSet<>();
        private RunBlockRerouteState normalize() {
            if (planCount == null || planCount < 0) {
                planCount = 0;
            }
            if (issuedRoutePathList == null) {
                issuedRoutePathList = new ArrayList<>();
            }
            if (lastSelectedRoute == null) {
                lastSelectedRoute = new ArrayList<>();
            }
            if (issuedRouteSignatureSet == null) {
                issuedRouteSignatureSet = new LinkedHashSet<>();
            }
            for (List<Integer> routePath : issuedRoutePathList) {
                if (routePath == null || routePath.isEmpty()) {
                    continue;
                }
                StringBuilder builder = new StringBuilder(buildPathSignatureText(routePath));
                if (builder.length() > 0) {
                    issuedRouteSignatureSet.add(builder.toString());
                }
            }
            return this;
        }
        private void resetIssuedRoutes() {
            this.issuedRoutePathList = new ArrayList<>();
            this.lastSelectedRoute = new ArrayList<>();
            this.issuedRouteSignatureSet = new LinkedHashSet<>();
        }
        private static String buildPathSignatureText(List<Integer> routePath) {
            if (routePath == null || routePath.isEmpty()) {
                return "";
            }
            StringBuilder builder = new StringBuilder();
            for (Integer stationId : routePath) {
                if (stationId == null) {
                    continue;
                }
                if (builder.length() > 0) {
                    builder.append("->");
                }
                builder.append(stationId);
            }
            return builder.toString();
        }
    }
}
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -523,9 +523,17 @@
                                continue;
                            }
                            StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), moveStaNo, 0);
                            StationCommand command = stationThread.getRunBlockRerouteCommand(
                                    wrkMast.getWrkNo(),
                                    stationProtocol.getStationId(),
                                    moveStaNo,
                                    0
                            );
                            if (command == null) {
                                News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                                News.taskInfo(wrkMast.getWrkNo(),
                                        "输送站点堵塞重规划未找到可下发路线,当前站点={},目标站点={}",
                                        stationProtocol.getStationId(),
                                        moveStaNo);
                                continue;
                            }