| | |
| | | //移动托盘 |
| | | int workNo = commonService.getWorkNo(3);//获取任务号 |
| | | |
| | | LiftStaProtocol sourceLiftSta = NyLiftUtils.getLiftStaByStaNo(param.getSourceStaNo()); |
| | | LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(param.getStaNo()); |
| | | if (sourceLiftSta == null || liftSta == null) { |
| | | throw new CoolException("源站或目标站不存在"); |
| | | } |
| | | // LiftStaProtocol sourceLiftSta = NyLiftUtils.getLiftStaByStaNo(param.getSourceStaNo()); |
| | | // LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(param.getStaNo()); |
| | | // if (sourceLiftSta == null || liftSta == null) { |
| | | // throw new CoolException("源站或目标站不存在"); |
| | | // } |
| | | |
| | | //获取提升机命令 |
| | | NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, sourceLiftSta.getStaNo(), liftSta.getStaNo(), workNo); |
| | | NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, param.getSourceStaNo(), param.getStaNo(), workNo); |
| | | ArrayList<NyLiftCommand> commands = new ArrayList<>(); |
| | | commands.add(liftCommand); |
| | | |
| | |
| | | } else { |
| | | throw new CoolException("命令下发失败"); |
| | | } |
| | | } else if (param.getLiftTaskMode() == 0) { |
| | | //提升机复位 |
| | | int workNo = commonService.getWorkNo(3);//获取任务号 |
| | | |
| | | //获取提升机命令 |
| | | NyLiftCommand liftCommand = NyLiftUtils.getLiftResetCommand(liftProtocol.getLiftNo().intValue()); |
| | | ArrayList<NyLiftCommand> commands = new ArrayList<>(); |
| | | commands.add(liftCommand); |
| | | |
| | | //提交到线程去工作 |
| | | LiftAssignCommand assignCommand = new LiftAssignCommand(); |
| | | assignCommand.setCommands(commands); |
| | | assignCommand.setLiftNo(liftProtocol.getLiftNo()); |
| | | assignCommand.setTaskNo((short) workNo); |
| | | assignCommand.setAuto(false);//手动模式 |
| | | assignCommand.setTaskMode(NyLiftTaskModelType.RESET.id.shortValue()); |
| | | |
| | | if (MessageQueue.offer(SlaveType.Lift, liftSlave.getId(), new Task(3, assignCommand))) { |
| | | return R.ok(); |
| | | } else { |
| | | throw new CoolException("命令下发失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("未知命令"); |
| | | } |
| | |
| | | private String command; |
| | | |
| | | /** |
| | | * 命令 |
| | | */ |
| | | @ApiModelProperty(value= "命令报文(下发)") |
| | | private String commandSend; |
| | | |
| | | /** |
| | | * 系统状态 |
| | | */ |
| | | @ApiModelProperty(value= "系统状态") |
| | |
| | | |
| | | public BasLiftOpt() {} |
| | | |
| | | public BasLiftOpt(Integer wrkNo, Integer liftNo, Date sendTime, Date updateTime, Long updateBy, String memo, String command, String commandSend, String systemStatus) { |
| | | public BasLiftOpt(Integer wrkNo, Integer liftNo, Date sendTime, Date updateTime, Long updateBy, String memo, String command, String systemStatus) { |
| | | this.wrkNo = wrkNo; |
| | | this.liftNo = liftNo; |
| | | this.sendTime = sendTime; |
| | |
| | | this.updateBy = updateBy; |
| | | this.memo = memo; |
| | | this.command = command; |
| | | this.commandSend = commandSend; |
| | | this.systemStatus = systemStatus; |
| | | } |
| | | |
| | |
| | | if (targetStaProtocol == null) { |
| | | return false;//站点不存在 |
| | | } |
| | | |
| | | if (targetStaProtocol.getHasTray()) { |
| | | return false;//提升机站点有托盘,禁止派发 |
| | | } |
| | | |
| | | Integer targetSta = targetStaProtocol.getStaNo(); |
| | | |
| | | //获取提升机命令 |
| | |
| | | return command; |
| | | } |
| | | |
| | | /** |
| | | * 获取提升机复位命令 |
| | | */ |
| | | public static NyLiftCommand getLiftResetCommand(Integer liftNo) { |
| | | NyLiftCommand command = new NyLiftCommand(); |
| | | command.setLiftNo(liftNo.shortValue()); |
| | | command.setTaskNo((short) 0); |
| | | command.setTaskModel((short) 0); |
| | | command.setSourceSta((short) 0); |
| | | command.setTargetSta((short) 0); |
| | | return command; |
| | | } |
| | | |
| | | //获取提升机站点 |
| | | public static LiftStaProtocol getLiftStaByStaNo(Integer staNo) { |
| | | SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); |
| | |
| | | */ |
| | | public enum NyLiftTaskModelType { |
| | | MOVE_TRAY(1, "移托盘"), |
| | | MOVE_CAR(2, "移小车") |
| | | MOVE_CAR(2, "移小车"), |
| | | RESET(3, "提升机复位"), |
| | | ; |
| | | |
| | | public Integer id; |
| | |
| | | null, |
| | | null, |
| | | JSON.toJSONString(command), |
| | | JSON.toJSONString(commandArr), |
| | | JSON.toJSONString(liftProtocol) |
| | | ); |
| | | liftOptService.insert(opt); |
| | |
| | | News.info("提升机任务执行下发完成等待执行结束,提升机号={},任务数据={}", command.getLiftNo(), JSON.toJSON(command)); |
| | | } |
| | | |
| | | if (redisCommand.getAssignCommand().getTaskMode() == NyLiftTaskModelType.RESET.id.shortValue()) { |
| | | //复位命令 |
| | | //工作号清零 |
| | | liftProtocol.setTaskNo((short) 0); |
| | | //令牌清零 |
| | | liftProtocol.setToken(0); |
| | | //设置提升机为空闲状态 |
| | | liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); |
| | | //任务指令清零 |
| | | liftProtocol.setAssignCommand(null); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | <label><input id="staNo" type="text" name="staNo" /></label> |
| | | </div> |
| | | <button class="item" onclick="liftOperator(2)">移动托盘</button> |
| | | <!-- <button class="item" onclick="liftOperator(0)">复位</button>--> |
| | | <button class="item" onclick="liftOperator(0)">复位</button> |
| | | </div> |
| | | </fieldset> |
| | | </div> |