|  |  | 
 |  |  | import com.zy.asrs.wcs.core.entity.BasLift; | 
 |  |  | import com.zy.asrs.wcs.core.model.command.LiftCommand; | 
 |  |  | import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType; | 
 |  |  | import com.zy.asrs.wcs.core.model.enums.MotionCtgType; | 
 |  |  | import com.zy.asrs.wcs.core.service.BasLiftService; | 
 |  |  | import com.zy.asrs.wcs.core.utils.RedisUtil; | 
 |  |  | import com.zy.asrs.wcs.core.utils.Utils; | 
 |  |  | 
 |  |  | import com.zy.asrs.wcs.rcs.cache.OutputQueue; | 
 |  |  | import com.zy.asrs.wcs.rcs.entity.Device; | 
 |  |  | import com.zy.asrs.wcs.rcs.entity.DeviceDataLog; | 
 |  |  | import com.zy.asrs.wcs.rcs.model.CommandResponse; | 
 |  |  | import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; | 
 |  |  | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; | 
 |  |  | import com.zy.asrs.wcs.rcs.service.DeviceDataLogService; | 
 |  |  | 
 |  |  |         try { | 
 |  |  |             readStatus(); | 
 |  |  |  | 
 |  |  |             //提升机处于运行状态,将标记置为false | 
 |  |  |             //提升机处于运行状态,将标记置为true | 
 |  |  |             if (liftProtocol.getRun()) { | 
 |  |  |                 liftProtocol.setPakMk(false); | 
 |  |  |                 liftProtocol.setPakMk(true); | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             OutputQueue.LIFT.offer(MessageFormat.format("【{0}】读取提升机状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public boolean move(LiftCommand command) { | 
 |  |  |     public CommandResponse move(LiftCommand command) { | 
 |  |  |         return write(command); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public boolean palletInOut(LiftCommand command) { | 
 |  |  |     public CommandResponse palletInOut(LiftCommand command) { | 
 |  |  |         return write(command); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private boolean write(LiftCommand command) { | 
 |  |  |     private CommandResponse write(LiftCommand command) { | 
 |  |  |         CommandResponse response = new CommandResponse(false); | 
 |  |  |         if (null == command) { | 
 |  |  |             News.error("提升机写入命令为空"); | 
 |  |  |             return false; | 
 |  |  |             response.setMessage("提升机写入命令为空"); | 
 |  |  |             return response; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         List<Short> shorts = JSON.parseArray(command.getBody(), Short.class); | 
 |  |  | 
 |  |  |             liftProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 | 
 |  |  |             News.info("提升机命令下发[id:{}] >>>>> {}", device.getId(), JSON.toJSON(command)); | 
 |  |  |             OutputQueue.LIFT.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), device.getId(), JSON.toJSON(command))); | 
 |  |  |             return true; | 
 |  |  |             response.setMessage(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), device.getId(), JSON.toJSON(command))); | 
 |  |  |             response.setResult(true); | 
 |  |  |             return response; | 
 |  |  |         } else { | 
 |  |  |             OutputQueue.LIFT.offer(MessageFormat.format("【{0}】写入提升机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}],次数:{}", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); | 
 |  |  |             News.error("写入提升机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", device.getId(), device.getIp(), device.getPort()); | 
 |  |  |             return false; | 
 |  |  |             response.setMessage(MessageFormat.format("【{0}】写入提升机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}],次数:{}", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); | 
 |  |  |             return response; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public boolean lock(LiftCommand command) { | 
 |  |  |         return true; | 
 |  |  |     public CommandResponse lock(LiftCommand command) { | 
 |  |  |         return new CommandResponse(true); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public boolean unlock(LiftCommand command) { | 
 |  |  |         return true; | 
 |  |  |     public CommandResponse unlock(LiftCommand command) { | 
 |  |  |         return new CommandResponse(true); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public boolean reset(LiftCommand command) { | 
 |  |  |         return false; | 
 |  |  |     public CommandResponse reset(LiftCommand command) { | 
 |  |  |         return new CommandResponse(false); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public boolean isIdle(ExecuteSupport support) { | 
 |  |  |         if (null != support) { | 
 |  |  |             if (!support.judgement()) { | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     public boolean isIdle(MotionCtgType flag) { | 
 |  |  |         // 判断提升机是否自动、就绪、空闲 | 
 |  |  |         if (this.liftProtocol.getModel() | 
 |  |  |                 && !this.liftProtocol.getRun() | 
 |  |  |                 && this.liftProtocol.getReady() | 
 |  |  |                 && this.liftProtocol.getPakMk() | 
 |  |  |                 && this.liftProtocol.getErrorCode().equals("0") | 
 |  |  |                 && this.liftProtocol.getProtocolStatus().equals(LiftProtocolStatusType.IDLE) | 
 |  |  |                 && (this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE) | 
 |  |  |                 || this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.WAITING)) | 
 |  |  |         ) { | 
 |  |  |             return true; | 
 |  |  |         } | 
 |  |  |         return false; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public boolean isDeviceIdle() { | 
 |  |  |         return isDeviceIdle(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public boolean isDeviceIdle(ExecuteSupport support) { | 
 |  |  |         if (null != support) { | 
 |  |  |             Boolean judgement = support.judgement(); | 
 |  |  |             if (judgement != null && !judgement) { | 
 |  |  |                 return true; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         // 判断提升机是否自动、就绪、空闲 | 
 |  |  |         if (this.liftProtocol.getModel() | 
 |  |  |                 && !this.liftProtocol.getRun() | 
 |  |  |                 && this.liftProtocol.getReady() | 
 |  |  |                 && this.liftProtocol.getErrorCode().equals("0") | 
 |  |  |         ) { | 
 |  |  |             return true; | 
 |  |  |         } | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public LiftCommand getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) { | 
 |  |  |     public int generateDeviceTaskNo(int taskNo, MotionCtgType motionCtgType) { | 
 |  |  |         return taskNo; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<LiftCommand> getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) { | 
 |  |  |         /** | 
 |  |  |          * 任务类型 | 
 |  |  |          * 1=移托盘;升降机将源站台托盘移到目标站台 | 
 |  |  | 
 |  |  |         command.setMode(LiftCommandModeType.MOVE.id); | 
 |  |  |         command.setOriginLev(sourceLev); | 
 |  |  |         command.setTargetLev(targetLev); | 
 |  |  |         return command; | 
 |  |  |  | 
 |  |  |         ArrayList<LiftCommand> list = new ArrayList<>(); | 
 |  |  |         list.add(command); | 
 |  |  |         return list; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public LiftCommand getMoveWithShuttleCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) { | 
 |  |  |     public List<LiftCommand> getMoveWithShuttleCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) { | 
 |  |  |         return getMoveCommand(taskNo, sourceLev, targetLev, mode); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public LiftCommand getPalletInOutCommand(Integer taskNo, Integer sourceLev, Integer targetLev, Integer originSta, Integer targetSta, LiftCommandModeType mode) { | 
 |  |  |     public List<LiftCommand> getPalletInOutCommand(Integer taskNo, Integer sourceLev, Integer targetLev, Integer originSta, Integer targetSta, LiftCommandModeType mode) { | 
 |  |  |         return getMoveCommand(taskNo, sourceLev, targetLev, mode); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public LiftCommand getLockCommand(Integer taskNo, Boolean lock) { | 
 |  |  |     public List<LiftCommand> getLockCommand(Integer taskNo, Boolean lock) { | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public LiftCommand getShuttleSignalCommand(Integer taskNo, Boolean signal) { | 
 |  |  |     public List<LiftCommand> getShuttleSignalCommand(Integer taskNo, Boolean signal) { | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  |