|  |  |  | 
|---|
|  |  |  | import com.zy.core.cache.OutputQueue; | 
|---|
|  |  |  | import com.zy.core.cache.SlaveConnection; | 
|---|
|  |  |  | import com.zy.core.enums.*; | 
|---|
|  |  |  | import com.zy.core.model.LiftSlave; | 
|---|
|  |  |  | import com.zy.core.model.ShuttleSlave; | 
|---|
|  |  |  | import com.zy.core.model.Task; | 
|---|
|  |  |  | import com.zy.core.model.command.NyShuttleHttpCommand; | 
|---|
|  |  |  | import com.zy.core.model.command.ShuttleAssignCommand; | 
|---|
|  |  |  | import com.zy.core.model.command.ShuttleCommand; | 
|---|
|  |  |  | import com.zy.core.model.command.ShuttleRedisCommand; | 
|---|
|  |  |  | import com.zy.core.model.command.*; | 
|---|
|  |  |  | import com.zy.core.model.protocol.LiftProtocol; | 
|---|
|  |  |  | import com.zy.core.model.protocol.NyShuttleProtocol; | 
|---|
|  |  |  | import com.zy.core.properties.SlaveProperties; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //检测穿梭车是否在提升机内 | 
|---|
|  |  |  | if (!checkShuttleInTheLift(wrkNo)) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //检查路径是否可行走(检查路径锁定状态,检测路径是否有其他小车) | 
|---|
|  |  |  | //检测当前行走路径,和下一步路径 | 
|---|
|  |  |  | boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(command.getNodes(), shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo())); | 
|---|
|  |  |  | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | WrkMastMapper wrkMastMapper = SpringUtils.getBean(WrkMastMapper.class); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class); | 
|---|
|  |  |  | //当前步序 | 
|---|
|  |  |  | int commandStep = redisCommand.getCommandStep(); | 
|---|
|  |  |  | 
|---|
|  |  |  | return true;//提升机达到小车楼层,放行 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //搜索是否有其他任务占用了提升机,如果占用提升机的任务和当前任务相同,则运行执行 | 
|---|
|  |  |  | WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); | 
|---|
|  |  |  | if (wrkMast1 != null && wrkMast1.getWrkNo() != wrkNo.intValue()) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提升机未到达小车楼层,呼叫提升机 | 
|---|
|  |  |  | //获取提升机命令 | 
|---|
|  |  |  | NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, null, basDevp.getDevNo(), wrkNo.intValue()); | 
|---|
|  |  |  | ArrayList<NyLiftCommand> liftCommands = new ArrayList<>(); | 
|---|
|  |  |  | liftCommands.add(liftCommand); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提交到线程去工作 | 
|---|
|  |  |  | LiftAssignCommand assignCommand = new LiftAssignCommand(); | 
|---|
|  |  |  | assignCommand.setCommands(liftCommands); | 
|---|
|  |  |  | assignCommand.setLiftNo(liftProtocol.getLiftNo()); | 
|---|
|  |  |  | assignCommand.setTaskNo(wrkNo); | 
|---|
|  |  |  | assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_CAR.id.shortValue()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //下发任务 | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return false;//默认不放行 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 检测穿梭车是否在提升机内 | 
|---|
|  |  |  | * 如穿梭车在提升机内,必须等待提升机空闲才可执行穿梭车命令 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private boolean checkShuttleInTheLift(Short wrkNo) { | 
|---|
|  |  |  | //读取redis数据 | 
|---|
|  |  |  | if (wrkNo == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo); | 
|---|
|  |  |  | if (o == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); | 
|---|
|  |  |  | BasLiftService liftService = SpringUtils.getBean(BasLiftService.class); | 
|---|
|  |  |  | for (LiftSlave liftSlave : slaveProperties.getLift()) { | 
|---|
|  |  |  | BasLift basLift = liftService.selectById(liftSlave.getId()); | 
|---|
|  |  |  | if (basLift == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (basLift.getPoint().equals(shuttleProtocol.getPoint())) { | 
|---|
|  |  |  | //小车在提升机内 | 
|---|
|  |  |  | //判断提升机是否空闲 | 
|---|
|  |  |  | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); | 
|---|
|  |  |  | if (liftThread == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|---|
|  |  |  | if (liftProtocol == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (liftProtocol.isIdle()) { | 
|---|
|  |  |  | //提升机处于空闲,放行 | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return false;//默认不放行 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|