#
Junjie
2025-07-26 c7b3edb405149d76e0e71d7e754bd46c42b05eb3
src/main/java/com/zy/core/action/ShuttleAction.java
@@ -16,14 +16,12 @@
import com.zy.common.model.NavigateNode;
import com.zy.common.service.CommonService;
import com.zy.common.utils.NavigateMapUtils;
import com.zy.common.utils.NavigatePositionConvert;
import com.zy.common.utils.RedisUtil;
import com.zy.core.News;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.dispatcher.ShuttleDispatchUtils;
import com.zy.core.enums.*;
import com.zy.core.model.CommandResponse;
import com.zy.core.model.TrafficControlDataModel;
import com.zy.core.model.command.ShuttleAssignCommand;
import com.zy.core.model.command.ShuttleCommand;
import com.zy.core.model.command.ShuttleRedisCommand;
@@ -71,11 +69,8 @@
            return false;
        }
        //清空下发索引
        Set<String> keys = redisUtil.searchKeys(RedisKeyType.SHUTTLE_SEND_COMMAND_INDEX.key + shuttleNo);
        for (String key : keys) {
            redisUtil.del(key);
        }
        //Clear Traffic Control
        trafficControlThread.forceCancelTrafficControl(shuttleNo);
        ShuttleRedisCommand redisCommand = new ShuttleRedisCommand();
@@ -214,9 +209,6 @@
        shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.WORKING);
        //存储下发指令索引
        redisUtil.set(RedisKeyType.SHUTTLE_SEND_COMMAND_INDEX.key + shuttleNo + "_" + taskNo + "_" + commandStep, commandStep);
        commandStep += 1;
        //更新redis数据
        redisCommand.setCommandStep(commandStep);
@@ -257,69 +249,60 @@
            return 0;
        }
        //上一条指令
        String searchKey = RedisKeyType.SHUTTLE_SEND_COMMAND_INDEX.key + shuttleNo + "_" + redisCommand.getWrkNo() + "_";
        Set<String> keys = redisUtil.searchKeys(searchKey);
        TreeSet<Integer> treeSet = new TreeSet<>();
        for (String key : keys) {
            String[] split = key.split(searchKey);
            treeSet.add(Integer.parseInt(split[1]));
        boolean supportContinuously = false;
        int checkIdx = commandStep - 2;
        if (checkIdx < 0) {
            checkIdx = commandStep - 1;
        }
        if (treeSet.isEmpty()) {
            return 1;
        ShuttleCommand last2Command = commands.get(checkIdx);
        if(last2Command.getComplete()){
            supportContinuously = true;
            checkIdx = commandStep - 1;
        }
        String firstKey = searchKey + treeSet.first();
        Integer lastCommandIdx = (Integer) redisUtil.get(firstKey);
        ShuttleCommand lastCommand = commands.get(lastCommandIdx);
        ShuttleCommand lastCommand = commands.get(checkIdx);
        if (!lastCommand.getComplete()) {
            //检测更新命令完成
            boolean checked = updateCommandComplete(lastCommandIdx, commands, shuttleNo);
            boolean checked = updateCommandComplete(checkIdx, commands, shuttleNo);
            if (checked) {
                //删除索引
                redisUtil.del(firstKey);
                // 更新redis数据
                redisUtil.set(RedisKeyType.SHUTTLE_WORK_FLAG.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand, SerializerFeature.DisableCircularReferenceDetect));
            }else {
                //小车移动连续下发指令
                if (assignCommand.getShuttleMoveCommandsContinuously()) {
                    if (treeSet.size() <= 1) {
                        if(commandStep >= commands.size()) {
                            return 0;
                        }
                    if (!supportContinuously) {
                        return 0;
                    }
                        //移动指令
                        if(lastCommand.getMode() != ShuttleCommandModeType.MOVE.id) {
                            return 0;
                        }
                    //移动指令
                    if(lastCommand.getMode() != ShuttleCommandModeType.MOVE.id) {
                        return 0;
                    }
                        List<NavigateNode> nodes = lastCommand.getNodes();
                        NavigateNode startNode = nodes.get(0);
                        if (!startNode.getLinePartAllowGo()) {//直线段部分,允许直接行走
                            return 0;
                        }
                    List<NavigateNode> nodes = lastCommand.getNodes();
                    NavigateNode startNode = nodes.get(0);
                    if (!startNode.getLinePartAllowGo()) {//直线段部分,允许直接行走
                        return 0;
                    }
                        //直线段数据标识
                        Long linePartFlag = startNode.getLinePartFlag();
                    //直线段数据标识
                    Long linePartFlag = startNode.getLinePartFlag();
                        //取指令
                        ShuttleCommand currentCommand = commands.get(commandStep);
                        if(currentCommand.getMode() != ShuttleCommandModeType.MOVE.id) {
                            return 0;
                        }
                    //取指令
                    ShuttleCommand currentCommand = commands.get(commandStep);
                    if(currentCommand.getMode() != ShuttleCommandModeType.MOVE.id) {
                        return 0;
                    }
                        List<NavigateNode> currentNodes = currentCommand.getNodes();
                        NavigateNode currentStartNode = currentNodes.get(0);
                        if(!currentStartNode.getLinePartAllowGo()) {//直线段部分,允许直接行走
                            return 0;
                        }
                    List<NavigateNode> currentNodes = currentCommand.getNodes();
                    NavigateNode currentStartNode = currentNodes.get(0);
                    if(!currentStartNode.getLinePartAllowGo()) {//直线段部分,允许直接行走
                        return 0;
                    }
                        if(currentStartNode.getLinePartFlag().equals(linePartFlag)) {
                            //数据标识一致
                            return 2;//允许小车移动连续下发指令
                        }
                    if(currentStartNode.getLinePartFlag().equals(linePartFlag)) {
                        //数据标识一致
                        return 2;//允许小车移动连续下发指令
                    }
                }
@@ -420,27 +403,13 @@
            if (trafficControlThread == null) {
                return false;
            }
            TrafficControlDataModel trafficControlDataModel = trafficControlThread.queryTrafficControl(shuttleNo);
            if (trafficControlDataModel != null) {
                //有管制信息,进行检测
                if (!trafficControlDataModel.getTaskNo().equals(shuttleProtocol.getTaskNo())) {
                    return false;//任务不一致
                }
                //检测是否到终点
                List<NavigateNode> totalNodeList = trafficControlDataModel.getTotalNodeList();
                NavigateNode trafficTargetNode = totalNodeList.get(totalNodeList.size() - 1);
                String trafficTargetLoc = Utils.getLocNo(trafficTargetNode.getX(), trafficTargetNode.getY(), trafficTargetNode.getZ());
                //判断小车是否到终点
                if(shuttleProtocol.getCurrentLocNo().equals(trafficTargetLoc)) {
                    //上报交管
                    trafficControlThread.trafficReport(command.getNodesDeepCopy(), shuttleNo, shuttleProtocol.getTaskNo());
                }
            }
            //上报交管
            trafficControlThread.trafficReport(command.getNodesDeepCopy(), shuttleNo, shuttleProtocol.getTaskNo());
            String currentLocNo = shuttleProtocol.getCurrentLocNo();
            if (currentLocNo == null) {
                return false;
            }
            if (targetPoints.contains(Utils.getRow(currentLocNo) + "-" + Utils.getBay(currentLocNo))) {
                command.setComplete(true);
                boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(shuttleProtocol.getCurrentLocNo()), shuttleProtocol.getShuttleNo(), nodes, false);//解锁路径
@@ -503,19 +472,12 @@
            return false;
        }
        NavigateNode startNode = nodeList.get(0);
        Long linePartFlag = startNode.getLinePartFlag();
        List<NavigateNode> totalNodeList = new ArrayList<>();
        for (ShuttleCommand command : commands) {
            if (command.getMode() == ShuttleCommandModeType.MOVE.id) {
                NavigateNode node = command.getNodes().get(0);
                Long nodeLinePartFlag = node.getLinePartFlag();
                if (nodeLinePartFlag.equals(linePartFlag)) {
                    List<NavigateNode> deepCopy = command.getNodesDeepCopy();
                    if (deepCopy != null) {
                        totalNodeList.addAll(deepCopy);
                    }
                List<NavigateNode> deepCopy = command.getNodesDeepCopy();
                if (deepCopy != null) {
                    totalNodeList.addAll(deepCopy);
                }
            }
        }