|  |  |  | 
|---|
|  |  |  | private ShuttleAction shuttleAction; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LiftAction liftAction; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LiftDispatcher liftDispatcher; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 计算 | 
|---|
|  |  |  | public Boolean accept(Motion motion) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 判断提升机是否空闲 | 
|---|
|  |  |  | if (!liftThread.isIdle()) { | 
|---|
|  |  |  | if (!liftThread.isIdle(MotionCtgType.SHUTTLE_MOVE_FROM_LIFT)) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (liftProtocol.getLev() != Utils.getLev(motion.getTarget())) {//判断提升机是否达到目标层 | 
|---|
|  |  |  | if (liftProtocol.getLev() != liftDispatcher.getLiftLevOffset(liftThread.getDevice().getId().intValue(), Utils.getLev(motion.getTarget()))) {//判断提升机是否达到目标层 | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | })) { | 
|---|
|  |  |  | //锁定提升机 | 
|---|
|  |  |  | LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), true);//获取提升机锁定命令 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LiftAssignCommand liftAssignCommand = new LiftAssignCommand(); | 
|---|
|  |  |  | liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo()); | 
|---|
|  |  |  | liftAssignCommand.setTaskNo(motion.getTaskNo()); | 
|---|
|  |  |  | ArrayList<LiftCommand> list = new ArrayList<>(); | 
|---|
|  |  |  | list.add(lockCommand); | 
|---|
|  |  |  | liftAssignCommand.setCommands(list); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | liftAction.assignWork(liftThread.getDevice(), liftAssignCommand); | 
|---|
|  |  |  | return false;//等待下一次轮询 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断提升机工作号是否和当前任务相同 | 
|---|
|  |  |  | if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                //判断提升机工作号是否和当前任务相同 | 
|---|
|  |  |  | //                if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) { | 
|---|
|  |  |  | //                    return false; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); | 
|---|
|  |  |  | shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; | 
|---|
|  |  |  | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 判断提升机是否空闲 | 
|---|
|  |  |  | if (!liftThread.isIdle()) { | 
|---|
|  |  |  | if (!liftThread.isIdle(MotionCtgType.SHUTTLE_MOVE_TO_LIFT)) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (liftProtocol.getLev() != Utils.getLev(motion.getTarget())) {//判断提升机是否达到目标层 | 
|---|
|  |  |  | if (liftProtocol.getLev() != liftDispatcher.getLiftLevOffset(liftThread.getDevice().getId().intValue(), Utils.getLev(motion.getTarget()))) {//判断提升机是否达到目标层 | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!liftThread.isLock(new ExecuteSupport() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Boolean judgement() { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | return true;//牛眼没有提升机锁,直接返回true | 
|---|
|  |  |  | } | 
|---|
|  |  |  | })) { | 
|---|
|  |  |  | //锁定提升机 | 
|---|
|  |  |  | LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), true);//获取提升机锁定命令 | 
|---|
|  |  |  | if (lockCommand == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LiftAssignCommand liftAssignCommand = new LiftAssignCommand(); | 
|---|
|  |  |  | liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo()); | 
|---|
|  |  |  | liftAssignCommand.setTaskNo(motion.getTaskNo()); | 
|---|
|  |  |  | ArrayList<LiftCommand> list = new ArrayList<>(); | 
|---|
|  |  |  | list.add(lockCommand); | 
|---|
|  |  |  | liftAssignCommand.setCommands(list); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | liftAction.assignWork(liftThread.getDevice(), liftAssignCommand); | 
|---|
|  |  |  | return false;//等待下一次轮询 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断提升机工作号是否和当前任务相同 | 
|---|
|  |  |  | if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                //判断提升机工作号是否和当前任务相同 | 
|---|
|  |  |  | //                if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) { | 
|---|
|  |  |  | //                    return false; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); | 
|---|
|  |  |  | shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; | 
|---|
|  |  |  | 
|---|
|  |  |  | case SHUTTLE_PALLET_DOWN://托盘下降 | 
|---|
|  |  |  | shuttleTaskModeType = ShuttleTaskModeType.PALLET_DOWN; | 
|---|
|  |  |  | shuttleCommands.add(shuttleThread.getLiftCommand(motion.getTaskNo(), false)); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case SHUTTLE_UPDATE_LOCATION://小车坐标更新 | 
|---|
|  |  |  | shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_UPDATE_LOCATION; | 
|---|
|  |  |  | shuttleCommands.add(shuttleThread.getUpdateLocationCommand(motion.getTaskNo(), motion.getTarget())); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | throw new CoolException(motion.getMotionCtgEl() + "没有指定任务作业流程!!!"); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //充电任务 | 
|---|
|  |  |  | if (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl())).equals(MotionCtgType.SHUTTLE_CHARGE_ON)) { | 
|---|
|  |  |  | // 复位穿梭车 | 
|---|
|  |  |  | shuttleThread.setSyncTaskNo(0); | 
|---|
|  |  |  | shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE); | 
|---|
|  |  |  | shuttleThread.setPakMk(true); | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | if (shuttleProtocol.getHasCharge() || shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.CHARGING_WAITING)) { | 
|---|
|  |  |  | // 复位穿梭车 | 
|---|
|  |  |  | shuttleThread.setSyncTaskNo(0); | 
|---|
|  |  |  | shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE); | 
|---|
|  |  |  | shuttleThread.setPakMk(true); | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.WAITING) | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断提升机是否被锁定 | 
|---|
|  |  |  | if (liftThread.isLock(new ExecuteSupport() { | 
|---|
|  |  |  | if (!liftThread.isLock(new ExecuteSupport() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Boolean judgement() { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | })) { | 
|---|
|  |  |  | //解锁提升机 | 
|---|
|  |  |  | LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), false);//获取提升机解锁命令 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LiftAssignCommand liftAssignCommand = new LiftAssignCommand(); | 
|---|
|  |  |  | liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo()); | 
|---|
|  |  |  | liftAssignCommand.setTaskNo(motion.getTaskNo()); | 
|---|
|  |  |  | ArrayList<LiftCommand> list = new ArrayList<>(); | 
|---|
|  |  |  | list.add(lockCommand); | 
|---|
|  |  |  | liftAssignCommand.setCommands(list); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | liftAction.assignWork(liftThread.getDevice(), liftAssignCommand); | 
|---|
|  |  |  | return false;//等待下一次轮询 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断小车是否已到位 | 
|---|
|  |  |  | if (liftProtocol.getHasCar()) { | 
|---|
|  |  |  | LiftCommand signalCommand = liftThread.getShuttleSignalCommand(motion.getTaskNo(), true);//获取小车已到位命令 | 
|---|
|  |  |  | if(signalCommand != null) { | 
|---|
|  |  |  | boolean hasKey = redisUtil.hasKey(DeviceRedisConstant.COMMAND_TMP + motion.getTaskNo()); | 
|---|
|  |  |  | if (!hasKey) { | 
|---|
|  |  |  | LiftAssignCommand liftAssignCommand = new LiftAssignCommand(); | 
|---|
|  |  |  | liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo()); | 
|---|
|  |  |  | liftAssignCommand.setTaskNo(motion.getTaskNo()); | 
|---|
|  |  |  | ArrayList<LiftCommand> list = new ArrayList<>(); | 
|---|
|  |  |  | list.add(signalCommand); | 
|---|
|  |  |  | liftAssignCommand.setCommands(list); | 
|---|
|  |  |  | liftAction.assignWork(liftThread.getDevice(), liftAssignCommand); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断提升机工作号是否和当前任务相同 | 
|---|
|  |  |  | if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (liftProtocol.getTaskNo() != 0) { | 
|---|
|  |  |  | //清空提升机号 | 
|---|
|  |  |  | liftThread.setSyncTaskNo(0); | 
|---|
|  |  |  | //判断小车是否已到位 | 
|---|
|  |  |  | if (!liftProtocol.getHasCar()) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                //判断提升机工作号是否和当前任务相同 | 
|---|
|  |  |  | //                if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) { | 
|---|
|  |  |  | //                    return false; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case SHUTTLE_MOVE_FROM_LIFT: | 
|---|
|  |  |  | liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断提升机是否被锁定 | 
|---|
|  |  |  | if (liftThread.isLock(new ExecuteSupport() { | 
|---|
|  |  |  | if (!liftThread.isLock(new ExecuteSupport() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Boolean judgement() { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | })) { | 
|---|
|  |  |  | //解锁提升机 | 
|---|
|  |  |  | LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), false);//获取提升机解锁命令 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LiftAssignCommand liftAssignCommand = new LiftAssignCommand(); | 
|---|
|  |  |  | liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo()); | 
|---|
|  |  |  | liftAssignCommand.setTaskNo(motion.getTaskNo()); | 
|---|
|  |  |  | ArrayList<LiftCommand> list = new ArrayList<>(); | 
|---|
|  |  |  | list.add(lockCommand); | 
|---|
|  |  |  | liftAssignCommand.setCommands(list); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | liftAction.assignWork(liftThread.getDevice(), liftAssignCommand); | 
|---|
|  |  |  | return false;//等待下一次轮询 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断小车是否已离开 | 
|---|
|  |  |  | if (!liftProtocol.getHasCar()) { | 
|---|
|  |  |  | LiftCommand signalCommand = liftThread.getShuttleSignalCommand(motion.getTaskNo(), false);//获取小车已驾离命令 | 
|---|
|  |  |  | if(signalCommand != null) { | 
|---|
|  |  |  | boolean hasKey = redisUtil.hasKey(DeviceRedisConstant.COMMAND_TMP + motion.getTaskNo()); | 
|---|
|  |  |  | if (!hasKey) { | 
|---|
|  |  |  | redisUtil.set(DeviceRedisConstant.COMMAND_TMP + motion.getTaskNo(), JSON.toJSONString(signalCommand), 120); | 
|---|
|  |  |  | LiftAssignCommand liftAssignCommand = new LiftAssignCommand(); | 
|---|
|  |  |  | liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo()); | 
|---|
|  |  |  | liftAssignCommand.setTaskNo(motion.getTaskNo()); | 
|---|
|  |  |  | ArrayList<LiftCommand> list = new ArrayList<>(); | 
|---|
|  |  |  | list.add(signalCommand); | 
|---|
|  |  |  | liftAssignCommand.setCommands(list); | 
|---|
|  |  |  | liftAction.assignWork(liftThread.getDevice(), liftAssignCommand); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断提升机工作号是否和当前任务相同 | 
|---|
|  |  |  | if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (liftProtocol.getTaskNo() != 0) { | 
|---|
|  |  |  | //清空提升机号 | 
|---|
|  |  |  | liftThread.setSyncTaskNo(0); | 
|---|
|  |  |  | //判断小车是否已离开 | 
|---|
|  |  |  | if (liftProtocol.getHasCar()) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                //判断提升机工作号是否和当前任务相同 | 
|---|
|  |  |  | //                if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) { | 
|---|
|  |  |  | //                    return false; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case SHUTTLE_TRANSPORT_FROM_LIFT: | 
|---|
|  |  |  | case SHUTTLE_TRANSPORT_TO_LIFT: | 
|---|
|  |  |  | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | })) { | 
|---|
|  |  |  | //解锁提升机 | 
|---|
|  |  |  | LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), false);//获取提升机解锁命令 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LiftAssignCommand liftAssignCommand = new LiftAssignCommand(); | 
|---|
|  |  |  | liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo()); | 
|---|
|  |  |  | liftAssignCommand.setTaskNo(motion.getTaskNo()); | 
|---|
|  |  |  | ArrayList<LiftCommand> list = new ArrayList<>(); | 
|---|
|  |  |  | list.add(lockCommand); | 
|---|
|  |  |  | liftAssignCommand.setCommands(list); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | liftAction.assignWork(liftThread.getDevice(), liftAssignCommand); | 
|---|
|  |  |  | return false;//等待下一次轮询 | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断提升机工作号是否和当前任务相同 | 
|---|
|  |  |  | if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (liftProtocol.getTaskNo() != 0) { | 
|---|
|  |  |  | //清空提升机号 | 
|---|
|  |  |  | liftThread.setSyncTaskNo(0); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case SHUTTLE_UPDATE_LOCATION://小车坐标更新 | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case SHUTTLE_PALLET_LIFT://托盘顶升 | 
|---|
|  |  |  | if (!shuttleProtocol.getHasLift()) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case SHUTTLE_PALLET_DOWN://托盘下降 | 
|---|
|  |  |  | if (shuttleProtocol.getHasLift()) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|