| | |
| | | && shuttleProtocol.getFree() == ShuttleStatusType.IDLE.id |
| | | ) { |
| | | //将任务档标记为完成 |
| | | WrkMast wrkMast = wrkMastMapper.selectByWorkNo(shuttleProtocol.getTaskNo().intValue()); |
| | | WrkMast wrkMast = wrkMastMapper.selectByWorkNo(shuttleProtocol.getTaskNo()); |
| | | if (wrkMast != null) { |
| | | switch (wrkMast.getWrkSts().intValue()) { |
| | | case 5://5.小车搬运中 ==> 9.入库完成 |
| | |
| | | break; |
| | | case 24://24.提升机搬运中 ==> 25.提升机搬运完成 |
| | | wrkMast.setWrkSts(25L); |
| | | if (wrkMast.getIoType() == 11) {//库位移转 |
| | | wrkMast.setWrkSts(4L);//4.提升机搬运完成 |
| | | } |
| | | break; |
| | | case 104://104.提升机搬运中 ==> 105.提升机搬运完成 |
| | | wrkMast.setWrkSts(105L); |
| | |
| | | //查询库位移转工作档 |
| | | List<WrkMast> wrkMasts1 = wrkMastMapper.selectLocToLocWrkMast(); |
| | | for (WrkMast wrkMast : wrkMasts1) { |
| | | boolean step1 = this.locToLocExecuteStep1(wrkMast);//库位移转 |
| | | if (wrkMast.getSourceLocNo().equals(wrkMast.getLocNo())) { |
| | | boolean step1 = this.locToLocExecuteStep1(wrkMast);//同楼层库位移转 |
| | | if (!step1) { |
| | | continue; |
| | | } |
| | | }else { |
| | | //跨楼层库位移转 |
| | | boolean step2 = this.locToLocExecuteStep2(wrkMast);//调度车辆取货并运送到出库口 |
| | | if (!step2) { |
| | | continue; |
| | | } |
| | | |
| | | boolean step3 = this.locToLocExecuteStep3(wrkMast);//提升机搬运货物 |
| | | if (!step3) { |
| | | continue; |
| | | } |
| | | |
| | | boolean step4 = this.locToLocExecuteStep4(wrkMast);//调度车辆取货并运送到出库口 |
| | | if (!step4) { |
| | | continue; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 库位移转 |
| | | * 同楼层库位移转 |
| | | * 如需主方法执行continue,请返回false |
| | | * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue |
| | | */ |
| | | private boolean locToLocExecuteStep1(WrkMast wrkMast) { |
| | | if (wrkMast.getWrkSts() == 21) {//21.生成出库任务 |
| | | if (wrkMast.getShuttleNo() == null) { |
| | | shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//调度小车到源库位进行取货 |
| | | return false; |
| | |
| | | assignCommand.setCommands(result.getCommands());//运行命令 |
| | | assignCommand.setNodes(result.getNodes());//路径节点 |
| | | |
| | | wrkMast.setWrkSts(5L);//1.生成入库任务 => 5.小车搬运中 |
| | | wrkMast.setWrkSts(5L);//21.生成出库任务 => 5.小车搬运中 |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //下发任务 |
| | | MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 跨楼层库位移转-调度车辆取货并运送到出库口 |
| | | * 如需主方法执行continue,请返回false |
| | | * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue |
| | | */ |
| | | private boolean locToLocExecuteStep2(WrkMast wrkMast) { |
| | | if (wrkMast.getWrkSts() == 21) {//21.生成出库任务 |
| | | if (wrkMast.getShuttleNo() == null) { |
| | | shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//调度小车到源库位进行取货 |
| | | return false; |
| | | } |
| | | |
| | | //获取四向穿梭车线程 |
| | | NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); |
| | | if (shuttleThread == null) { |
| | | return false; |
| | | } |
| | | NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | if (shuttleProtocol == null) { |
| | | return false; |
| | | } |
| | | if (!shuttleProtocol.isIdle()) { |
| | | return false; |
| | | } |
| | | |
| | | //判断小车是否到达源库位 |
| | | if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) { |
| | | //小车不在源库位位置 |
| | | shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//调度小车到源库位进行取货 |
| | | return false; |
| | | } |
| | | |
| | | //获取穿梭车最近且空闲的提升机输送站点 |
| | | BasDevp liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId()); |
| | | if (liftSta == null) { |
| | | return false;//没有可用且空闲的输送站点 |
| | | } |
| | | |
| | | //小车已抵达源库位,将货物搬运到输送站点 |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getSourceLocNo(), liftSta.getLocNo()); |
| | | if (result == null) {//路径计算失败 |
| | | return false; |
| | | } |
| | | |
| | | //创建分配命令 |
| | | ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); |
| | | assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 |
| | | assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 |
| | | assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_LOC_TO_LOC.id.shortValue());//库位移转模式 |
| | | assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) |
| | | assignCommand.setCommands(result.getCommands());//运行命令 |
| | | assignCommand.setNodes(result.getNodes());//路径节点 |
| | | |
| | | wrkMast.setWrkSts(22L);//21.生成出库任务 => 22.小车搬运中 |
| | | wrkMast.setLiftNo(liftSta.getLiftNo());//设置提升机号 |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //下发任务 |
| | | MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 跨楼层库位移转-提升机搬运货物 |
| | | * 如需主方法执行continue,请返回false |
| | | * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue |
| | | */ |
| | | private boolean locToLocExecuteStep3(WrkMast wrkMast) { |
| | | Date now = new Date(); |
| | | if (wrkMast.getWrkSts() == 23) {//23.小车搬运完成 |
| | | //获取提升机线程 |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); |
| | | if (liftThread == null) { |
| | | return false; |
| | | } |
| | | LiftProtocol liftProtocol = liftThread.getLiftProtocol(); |
| | | if (liftProtocol == null) { |
| | | return false; |
| | | } |
| | | |
| | | if (!liftProtocol.isIdle()) { |
| | | return false; |
| | | } |
| | | |
| | | //搜索是否有其他任务占用了提升机,如果占用提升机的任务和当前任务相同,则运行执行 |
| | | WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); |
| | | if (wrkMast1 != null && wrkMast1.getWrkNo().intValue() != wrkMast.getWrkNo().intValue()) { |
| | | return false; |
| | | } |
| | | |
| | | //获取源站对应的输送站点 |
| | | BasDevp sourceBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getSourceLocNo()), liftProtocol.getLiftNo().intValue()); |
| | | //获取目标站对应的输送站点 |
| | | BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), liftProtocol.getLiftNo().intValue()); |
| | | if (sourceBasDevp == null || targetBasDevp == null) { |
| | | return false;//缺少站点信息 |
| | | } |
| | | |
| | | //获取提升机命令 |
| | | NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, sourceBasDevp.getDevNo(), targetBasDevp.getDevNo(), wrkMast.getWrkNo()); |
| | | |
| | | ArrayList<NyLiftCommand> commands = new ArrayList<>(); |
| | | commands.add(liftCommand); |
| | | |
| | | //提交到线程去工作 |
| | | LiftAssignCommand assignCommand = new LiftAssignCommand(); |
| | | assignCommand.setCommands(commands); |
| | | assignCommand.setLiftNo(liftProtocol.getLiftNo()); |
| | | assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); |
| | | assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_TRAY.id.shortValue()); |
| | | |
| | | wrkMast.setWrkSts(24L);//23.小车搬运完成 ==> 24.提升机搬运中 |
| | | wrkMast.setLiftNo(liftThread.getSlave().getId());//任务档绑定提升机号 |
| | | wrkMast.setShuttleNo(null);//清空小车号,等货物搬运完成后,到目标楼层重新搜索小车 |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //下发任务 |
| | | MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand)); |
| | | } |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 跨楼层库位移转-调度车辆取货并运送到目标枯萎 |
| | | * 如需主方法执行continue,请返回false |
| | | * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue |
| | | */ |
| | | private boolean locToLocExecuteStep4(WrkMast wrkMast) { |
| | | if (wrkMast.getWrkSts() == 4) {//4.提升机搬运完成 |
| | | //获取目标站对应的输送站点 |
| | | BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), wrkMast.getLiftNo()); |
| | | if (targetBasDevp == null) { |
| | | return false;//缺少站点信息 |
| | | } |
| | | |
| | | if (wrkMast.getShuttleNo() == null) { |
| | | shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), targetBasDevp.getLocNo());//调度小车到目标输送站点进行取货 |
| | | return false; |
| | | } |
| | | |
| | | //获取四向穿梭车线程 |
| | | NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); |
| | | if (shuttleThread == null) { |
| | | return false; |
| | | } |
| | | NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | if (shuttleProtocol == null) { |
| | | return false; |
| | | } |
| | | if (!shuttleProtocol.isIdle()) { |
| | | return false; |
| | | } |
| | | |
| | | //判断小车是否到达目标输送站点 |
| | | if (!shuttleProtocol.getCurrentLocNo().equals(targetBasDevp.getLocNo())) { |
| | | //小车不在目标输送站点 |
| | | shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getShuttleNo());//调度小车到目标输送站点进行取货 |
| | | return false; |
| | | } |
| | | |
| | | //小车已抵达目标输送站点,将货物搬运到目标库位 |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), targetBasDevp.getLocNo(), wrkMast.getLocNo()); |
| | | if (result == null) {//路径计算失败 |
| | | return false; |
| | | } |
| | | |
| | | //创建分配命令 |
| | | ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); |
| | | assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 |
| | | assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 |
| | | assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_LOC_TO_LOC.id.shortValue());//库位移转模式 |
| | | assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) |
| | | assignCommand.setCommands(result.getCommands());//运行命令 |
| | | assignCommand.setNodes(result.getNodes());//路径节点 |
| | | |
| | | wrkMast.setWrkSts(5L);//4.提升机搬运完成 => 5.小车搬运中 |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //下发任务 |
| | | MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |