| | |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.LiftProtocolStatusType; |
| | | import com.zy.core.enums.LiftTaskModeType; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.enums.SlaveType; |
| | |
| | | redisCommand.setCommandStep(commandStep); |
| | | // 更新redis数据 |
| | | redisUtil.set(RedisKeyType.LIFT_WORK_FLAG.key + taskNo, JSON.toJSONString(redisCommand)); |
| | | }else { |
| | | if (!liftThread.isDeviceIdle()) { |
| | | return false; |
| | | } |
| | | |
| | | LiftCommand lastCommand = commands.get(commandStep - 1); |
| | | if (lastCommand.getMode() == LiftTaskModeType.PICK_PUT.id) { |
| | | if (liftProtocol.getLev() == lastCommand.getPut()) { |
| | | lastCommand.setComplete(true); |
| | | } |
| | | } else if (lastCommand.getMode() == LiftTaskModeType.SHUTTLE_SWITCH.id) { |
| | | if (liftProtocol.getLev() == lastCommand.getPut()) { |
| | | lastCommand.setComplete(true); |
| | | } |
| | | } else if (lastCommand.getMode() == LiftTaskModeType.MOVE.id) { |
| | | if (liftProtocol.getLev() == lastCommand.getPut()) { |
| | | lastCommand.setComplete(true); |
| | | } |
| | | } |
| | | |
| | | //任务数据保存到redis |
| | | redisUtil.set(RedisKeyType.LIFT_WORK_FLAG.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | |
| | | if (!lastCommand.getComplete()) { |
| | | //上一条任务未完成,禁止下发命令 |
| | | return false; |
| | | } |
| | | |
| | | //判断是否为最后一条命令且命令执行完成,抛出等待确认状态 |
| | | LiftCommand endCommand = commands.get(commands.size() - 1); |
| | | if (endCommand.getComplete()) { |
| | | //已执行完成 |
| | | //删除redis |
| | | redisUtil.del(RedisKeyType.LIFT_WORK_FLAG.key + redisCommand.getWrkNo()); |
| | | |
| | | //对主线程抛出等待确认状态waiting |
| | | liftThread.setProtocolStatus(LiftProtocolStatusType.WAITING); |
| | | News.info("提升机任务执行下发完成执行结束,提升机号={},任务数据={}", redisCommand.getLiftNo(), JSON.toJSON(redisCommand)); |
| | | } |
| | | } |
| | | |
| | | return true; |