| | |
| | | private PatrolService patrolService; |
| | | @Autowired |
| | | private StaReserveService staReserveService; |
| | | @Autowired |
| | | private AgvAreaDispatcher agvAreaDispatcher; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:agv:update')") |
| | | @OperationLog("Locate All Agv") |
| | |
| | | task.setPriority(999); |
| | | task.setIoTime(now); |
| | | task.setStartTime(now); |
| | | task.setMemo("AUTO"); |
| | | if (!taskService.save(task)) { |
| | | throw new BusinessException(task.getSeqNum() + "任务保存失败"); |
| | | } |
| | |
| | | if (null == endCode) { |
| | | return R.error(); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), endCode.getId())) { |
| | | throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + endCode.getData()); |
| | | } |
| | | if (!taskService.removeById(task.getId())) { |
| | | throw new BusinessException("failed to remove task"); |
| | | } |
| | | task = null; |
| | | if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), endCode.getData(), null)) { |
| | | return R.error(); |
| | | } |
| | | break; |
| | | case TO_CHARGE: |
| | | case TO_STANDBY: |
| | | if (!taskService.removeById(task.getId())) { |
| | | throw new BusinessException("failed to remove task"); |
| | | } |
| | | task = null; |
| | | if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), null, null)) { |
| | | return R.error(); |
| | | } |
| | |
| | | } |
| | | if (null == oriLoc) { |
| | | return R.error(); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), oriLoc.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriLoc.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达起始库位【" + oriLoc.getLocNo() + "】"); |
| | | } |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLoc:" + oriLoc.getLocNo() + " 不是在库状态"); |
| | |
| | | } |
| | | if (null == destLoc) { |
| | | return R.error(); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), destLoc.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destLoc.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达目标库位【" + destLoc.getLocNo() + "】"); |
| | | } |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLoc:" + destLoc.getLocNo() + " 不是空闲状态"); |
| | |
| | | if (null == oriLoc) { |
| | | return R.error(); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), oriLoc.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriLoc.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达起始库位【" + oriLoc.getLocNo() + "】"); |
| | | } |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLoc:" + oriLoc.getLocNo() + " 不是在库状态"); |
| | | } |
| | |
| | | if (null == destSta) { |
| | | return R.error(); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), destSta.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destSta.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达目标站点【" + destSta.getStaNo() + "】"); |
| | | } |
| | | if (null == staReserveService.reserveStaIn(destSta, task, 1)) { |
| | | throw new BusinessException("destSta:" + destSta.getStaNo() + " 预约失败"); |
| | | } |
| | | |
| | | // task |
| | | task.setOriLoc(oriLoc.getId()); |
| | | task.setOriCode(oriLoc.getCode()); |
| | | task.setDestSta(destSta.getId()); |
| | | task.setDestCode(destSta.getCode()); |
| | | |
| | | staReserveService.allocateCallBack(task, agv.getId()); |
| | | break; |
| | | case STA_TO_LOC: |
| | | // oriSta |
| | |
| | | } |
| | | if (null == oriSta) { |
| | | return R.error(); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), oriSta.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriSta.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达起始站点【" + oriSta.getStaNo() + "】"); |
| | | } |
| | | if (null == staReserveService.reserveStaOut(oriSta, task, 1)) { |
| | | throw new BusinessException("oriSta:" + oriSta.getStaNo() + " 预约失败"); |
| | |
| | | if (null == destLoc) { |
| | | return R.error(); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), destLoc.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destLoc.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达目标库位【" + destLoc.getLocNo() + "】"); |
| | | } |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLoc:" + destLoc.getLocNo() + " 不是空闲状态"); |
| | | } |
| | |
| | | task.setOriCode(oriSta.getCode()); |
| | | task.setDestLoc(destLoc.getId()); |
| | | task.setDestCode(destLoc.getCode()); |
| | | |
| | | staReserveService.allocateCallBack(task, agv.getId()); |
| | | break; |
| | | case STA_TO_STA: |
| | | // oriSta |
| | |
| | | if (null == oriSta) { |
| | | return R.error(); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), oriSta.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriSta.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达起始站点【" + oriSta.getStaNo() + "】"); |
| | | } |
| | | if (null == staReserveService.reserveStaOut(oriSta, task, 1)) { |
| | | throw new BusinessException("oriSta:" + oriSta.getStaNo() + " 预约失败"); |
| | | } |
| | | |
| | | |
| | | // destSta |
| | | if (!Cools.isEmpty(param.getEndStaNo())) { |
| | |
| | | if (null == destSta) { |
| | | return R.error(); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), destSta.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destSta.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达目标站点【" + destSta.getStaNo() + "】"); |
| | | } |
| | | if (null == staReserveService.reserveStaIn(destSta, task, 1)) { |
| | | throw new BusinessException("destSta:" + destSta.getStaNo() + " 预约失败"); |
| | | } |
| | |
| | | task.setOriCode(oriSta.getCode()); |
| | | task.setDestSta(destSta.getId()); |
| | | task.setDestCode(destSta.getCode()); |
| | | |
| | | staReserveService.allocateCallBack(task, agv.getId()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | if (!taskService.updateById(task)) { |
| | | throw new BusinessException("任务更新失败"); |
| | | if (null != task) { |
| | | if (!taskService.updateById(task)) { |
| | | throw new BusinessException("任务更新失败"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |