#
Junjie
4 天以前 6daf900a09adcca981f620744bf89851654d88e0
src/main/java/com/zy/core/action/ShuttleAction.java
@@ -119,8 +119,10 @@
            return false;
        }
        News.info("execute check command {},{}", shuttleNo, taskNo);
        //检测命令
        int checked = checkCommand(redisCommand, shuttleNo);
        News.info("execute check command complete {},{}", shuttleNo, taskNo);
        if (checked == 0) {
            return false;
        }
@@ -165,10 +167,20 @@
            }
            List<NavigateNode> nodes = JSON.parseArray(JSON.toJSONString(command.getNodes()), NavigateNode.class);
            //申请管制
            applyTrafficControl(commands, nodes, shuttleNo, taskNo);
            Object object = redisUtil.get(RedisKeyType.TRAFFIC_CONTROL_LOCK_APPLY.key + shuttleNo);
            if (object == null) {
                //申请管制
                News.info("execute apply control {},{}", shuttleNo, taskNo);
                redisUtil.set(RedisKeyType.TRAFFIC_CONTROL_LOCK_APPLY.key + shuttleNo, "lock", 10);
                applyTrafficControl(commands, nodes, shuttleNo, taskNo);
                News.info("execute apply control complete {},{}", shuttleNo, taskNo);
            }
            News.info("execute query control {},{}", shuttleNo, taskNo);
            //查询管制
            boolean apply = queryTrafficControl(shuttleNo, taskNo);
            News.info("execute query control complete {},{}", shuttleNo, taskNo);
            if(!apply){
                return false;//申请失败
            }
@@ -191,8 +203,10 @@
            }
        }
        News.info("execute send command {},{}", shuttleNo, taskNo);
        // 下发命令
        CommandResponse response = write(command, shuttleNo);
        News.info("execute send command complete {},{}", shuttleNo, taskNo);
        //保存命令日志
        BasShuttleOpt basShuttleOpt = new BasShuttleOpt();
@@ -348,7 +362,8 @@
            }
            //申请取消管制
            trafficControlThread.cancelTrafficControl(shuttleNo, shuttleProtocol.getTaskNo());
            cancelTrafficControl(shuttleNo, shuttleProtocol.getTaskNo());
            //删除redis
            redisUtil.del(RedisKeyType.SHUTTLE_WORK_FLAG.key + redisCommand.getWrkNo());
            return 0;//禁止再下发命令
@@ -415,7 +430,9 @@
                return false;
            }
            //上报交管
            News.info("execute check command report traffic {},{}", shuttleNo, shuttleProtocol.getTaskNo());
            trafficControlThread.trafficReport(command.getNodesDeepCopy(), shuttleNo, shuttleProtocol.getTaskNo());
            News.info("execute check command report traffic complete {},{}", shuttleNo, shuttleProtocol.getTaskNo());
            String currentLocNo = shuttleProtocol.getCurrentLocNo();
            if (currentLocNo == null) {
@@ -497,16 +514,18 @@
    //查询是否申请管制成功
    public boolean queryTrafficControl(Integer shuttleNo, Integer taskNo) {
        TrafficControlThread trafficControlThread = (TrafficControlThread) SlaveConnection.get(SlaveType.TrafficControl, 1);
        if (trafficControlThread == null) {
        Object object = redisUtil.get(RedisKeyType.TRAFFIC_CONTROL_SUCCESS_APPLY.key + shuttleNo + "_" + taskNo);
        if (object == null) {
            return false;
        }
        return true;
    }
        TrafficControlDataModel trafficControlDataModel = trafficControlThread.queryTrafficControl(shuttleNo, taskNo);
        if (trafficControlDataModel == null) {
            return false;
        }
    public boolean cancelTrafficControl(Integer shuttleNo, Integer taskNo) {
        TrafficControlDataModel model = new TrafficControlDataModel();
        model.setShuttleNo(shuttleNo);
        model.setTaskNo(taskNo);
        redisUtil.set(RedisKeyType.TRAFFIC_CONTROL_CANCEL_LIST.key + shuttleNo + "_" + taskNo, model);
        return true;
    }
@@ -766,6 +785,10 @@
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public synchronized boolean clearPath(Integer shuttleNo) {
        return navigateMapUtils.clearPath(shuttleNo);
    }
//    //跑库程序
@@ -1137,7 +1160,7 @@
//        }
//    }
    private synchronized CommandResponse write(ShuttleCommand command, Integer shuttleNo) {
    private CommandResponse write(ShuttleCommand command, Integer shuttleNo) {
        CommandResponse response = new CommandResponse(false);
        if (null == command) {
            News.error("四向穿梭车写入命令为空");