Junjie
2023-12-24 df835e2b2da1d8b33be2040595f9a641ca31eecf
#提升机
1个文件已修改
74 ■■■■ 已修改文件
src/main/java/com/zy/core/thread/LiftThread.java 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/LiftThread.java
@@ -363,12 +363,41 @@
        //总步序
        int size = commands.size();
        //取出命令
        NyLiftCommand command = commands.get(commandStep);
        if (!redisCommand.getLiftNo().equals(liftProtocol.getLiftNo())) {
            return false;
        }
        if (commandStep != 0) {
            //判断上一条指令是否做完
            NyLiftCommand lastCommand = commands.get(commandStep - 1);//上一条指令
            if (!liftProtocol.getBusy() && liftProtocol.getTaskNo().equals(lastCommand.getTaskNo())) {
                //提升机空闲、且提升机工作号与上一条指令工作号相同
                lastCommand.setComplete(true);//标记任务完成
            }
            //任务数据保存到redis
            redisUtil.set(RedisKeyType.LIFT.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand));
            if (!lastCommand.getComplete()) {
                //上一条任务未完成,禁止下发命令
                return false;
            }
            //判断是否为最后一条命令且命令执行完成,抛出等待确认状态
            NyLiftCommand endCommand = commands.get(commands.size() - 1);
            if (endCommand.getComplete()) {
                //已执行完成
                //删除redis
                redisUtil.del(RedisKeyType.LIFT.key + redisCommand.getWrkNo());
                //对主线程抛出等待确认状态waiting
                liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING);
                News.info("提升机任务执行下发完成执行结束,提升机号={},任务数据={}", redisCommand.getLiftNo(), JSON.toJSON(redisCommand));
            }
        }
        //取出命令
        NyLiftCommand command = commands.get(commandStep);
        //下发命令
        if (!write(command)) {
@@ -400,23 +429,30 @@
            liftOptService.insert(opt);
        }
        //判断数据是否执行完成
        if (commandStep < size - 1) {
            //更新redis数据
            //步序增加
            commandStep++;
            redisCommand.setCommandStep(commandStep);
            //任务数据保存到redis
            redisUtil.set(RedisKeyType.LIFT.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand));
        }else {
            //已执行完成
            //删除redis
            redisUtil.del(RedisKeyType.LIFT.key + redisCommand.getWrkNo());
        //更新redis数据
        //步序增加
        commandStep++;
        redisCommand.setCommandStep(commandStep);
        //任务数据保存到redis
        redisUtil.set(RedisKeyType.LIFT.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand));
            //对主线程抛出等待确认状态waiting
            liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING);
            News.info("提升机任务执行下发完成等待执行结束,提升机号={},任务数据={}", command.getLiftNo(), JSON.toJSON(command));
        }
//        //判断数据是否执行完成
//        if (commandStep < size - 1) {
//            //更新redis数据
//            //步序增加
//            commandStep++;
//            redisCommand.setCommandStep(commandStep);
//            //任务数据保存到redis
//            redisUtil.set(RedisKeyType.LIFT.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand));
//        }else {
//            //已执行完成
//            //删除redis
//            redisUtil.del(RedisKeyType.LIFT.key + redisCommand.getWrkNo());
//
//            //对主线程抛出等待确认状态waiting
//            liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING);
//            News.info("提升机任务执行下发完成等待执行结束,提升机号={},任务数据={}", command.getLiftNo(), JSON.toJSON(command));
//        }
        if (redisCommand.getAssignCommand().getTaskMode() == NyLiftTaskModelType.RESET.id.shortValue()) {
            //复位命令