| | |
| | | @Transactional |
| | | public R controlAgv(@RequestHeader String appKey, |
| | | @RequestBody HandlerPublishParam param) { |
| | | if (Cools.isEmpty(param.getAgvNo(), param.getTaskMode(), appKey)) { |
| | | return R.error(); |
| | | if (param == null || Cools.isEmpty(param.getAgvNo(), param.getTaskMode(), appKey)) { |
| | | return R.error("参数不完整,请检查AGV和任务模式"); |
| | | } |
| | | if (!APP_KEY.equals(appKey)) { |
| | | return R.error(); |
| | | return R.error("appKey校验失败"); |
| | | } |
| | | |
| | | Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class); |
| | | Date now = new Date(); |
| | | Agv agv = agvService.selectByUuid(param.getAgvNo()); |
| | | if (agv == null) { |
| | | return R.error("AGV不存在"); |
| | | } |
| | | AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId()); |
| | | |
| | | // check |
| | |
| | | .or().eq(Task::getTaskSts, TaskStsType.PROGRESS.val()); |
| | | })) > 0) { |
| | | log.info("{}号AGV不可用,已经存在进行中的任务...", agv.getUuid()); |
| | | return R.error(); |
| | | return R.error("当前AGV存在进行中的任务,无法下发新任务"); |
| | | } |
| | | if (!agvService.judgeEnable(agv.getId())) { |
| | | log.info("{}号AGV不可用,任务无法计算...", agv.getUuid()); |
| | | return R.error(); |
| | | return R.error("当前AGV不可用,无法下发任务"); |
| | | } |
| | | |
| | | Task task = new Task(); |
| | |
| | | endCode = codeService.getCacheByData(param.getEndCodeStr()); |
| | | } |
| | | if (null == endCode) { |
| | | return R.error(); |
| | | return R.error("目标点不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), endCode.getId())) { |
| | | throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + endCode.getData()); |
| | |
| | | } |
| | | task = null; |
| | | if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), endCode.getData(), null)) { |
| | | return R.error(); |
| | | return R.error("移动任务下发失败"); |
| | | } |
| | | break; |
| | | case TO_CHARGE: |
| | |
| | | } |
| | | task = null; |
| | | if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), null, null)) { |
| | | return R.error(); |
| | | return R.error(TaskTypeType.TO_CHARGE.equals(param.getTaskMode()) ? "去充电任务下发失败" : "去待机位任务下发失败"); |
| | | } |
| | | break; |
| | | case LOC_TO_LOC: |
| | |
| | | oriLoc = locService.selectByLocNo(param.getStartLocNoStr()); |
| | | } |
| | | if (null == oriLoc) { |
| | | return R.error(); |
| | | return R.error("起始库位不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), oriLoc.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriLoc.getCode$()); |
| | |
| | | destLoc = locService.selectByLocNo(param.getEndLocNoStr()); |
| | | } |
| | | if (null == destLoc) { |
| | | return R.error(); |
| | | return R.error("目标库位不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), destLoc.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destLoc.getCode$()); |
| | |
| | | oriLoc = locService.selectByLocNo(param.getStartLocNoStr()); |
| | | } |
| | | if (null == oriLoc) { |
| | | return R.error(); |
| | | return R.error("起始库位不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), oriLoc.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriLoc.getCode$()); |
| | |
| | | destSta = staService.selectByStaNo(param.getEndStaNoStr()); |
| | | } |
| | | if (null == destSta) { |
| | | return R.error(); |
| | | return R.error("目标站点不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), destSta.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destSta.getCode$()); |
| | |
| | | oriSta = staService.selectByStaNo(param.getStartStaNoStr()); |
| | | } |
| | | if (null == oriSta) { |
| | | return R.error(); |
| | | return R.error("起始站点不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), oriSta.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriSta.getCode$()); |
| | |
| | | destLoc = locService.selectByLocNo(param.getEndLocNoStr()); |
| | | } |
| | | if (null == destLoc) { |
| | | return R.error(); |
| | | return R.error("目标库位不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), destLoc.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destLoc.getCode$()); |
| | |
| | | oriSta = staService.selectByStaNo(param.getStartStaNoStr()); |
| | | } |
| | | if (null == oriSta) { |
| | | return R.error(); |
| | | return R.error("起始站点不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), oriSta.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriSta.getCode$()); |
| | |
| | | destSta = staService.selectByStaNo(param.getEndStaNoStr()); |
| | | } |
| | | if (null == destSta) { |
| | | return R.error(); |
| | | return R.error("目标站点不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), destSta.getCode())) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destSta.getCode$()); |
| | |
| | | @PostMapping("/control/agv/charge/stop") |
| | | public R stopCharging(@RequestHeader String appKey, |
| | | @RequestBody HandlerPublishParam param) { |
| | | if (Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error(); |
| | | if (param == null || Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error("参数不完整,请检查AGV"); |
| | | } |
| | | if (!APP_KEY.equals(appKey)) { |
| | | return R.error(); |
| | | return R.error("appKey校验失败"); |
| | | } |
| | | |
| | | Agv agv = agvService.selectByUuid(param.getAgvNo()); |
| | |
| | | |
| | | if (!agvService.judgeEnable(agv.getId())) { |
| | | log.info("{}号AGV不可用,停止充电失败...", agv.getUuid()); |
| | | return R.error(); |
| | | return R.error("当前AGV不可用,无法断开充电"); |
| | | } |
| | | |
| | | AgvModel agvModel = agvModelService.getByAgvId(agv.getId()); |
| | |
| | | @Transactional |
| | | public R cancelAgvTask(@RequestHeader String appKey, |
| | | @RequestBody HandlerPublishParam param) { |
| | | if (Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error(); |
| | | if (param == null || Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error("参数不完整,请检查AGV"); |
| | | } |
| | | if (!APP_KEY.equals(appKey)) { |
| | | return R.error(); |
| | | return R.error("appKey校验失败"); |
| | | } |
| | | |
| | | Agv agv = agvService.selectByUuid(param.getAgvNo()); |
| | |
| | | |
| | | if (!agvService.judgeEnable(agv.getId())) { |
| | | log.info("{}号AGV不可用,取消任务失败...", agv.getUuid()); |
| | | return R.error(); |
| | | return R.error("当前AGV不可用,无法取消任务"); |
| | | } |
| | | |
| | | AgvModel agvModel = agvModelService.getByAgvId(agv.getId()); |
| | |
| | | @PostMapping("/control/agv/load/lift/up") |
| | | public R liftAgvLoadPlatform(@RequestHeader String appKey, |
| | | @RequestBody HandlerPublishParam param) { |
| | | if (Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error(); |
| | | if (param == null || Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error("参数不完整,请检查AGV"); |
| | | } |
| | | if (!APP_KEY.equals(appKey)) { |
| | | return R.error(); |
| | | return R.error("appKey校验失败"); |
| | | } |
| | | |
| | | Agv agv = agvService.selectByUuid(param.getAgvNo()); |
| | |
| | | } |
| | | if (!agvService.judgeEnable(agv.getId())) { |
| | | log.info("{}号AGV不可用,举升失败...", agv.getUuid()); |
| | | return R.error(); |
| | | return R.error("当前AGV不可用,无法执行载货台举升"); |
| | | } |
| | | AgvModel agvModel = agvModelService.getByAgvId(agv.getId()); |
| | | if (agvModel == null || !AgvModelType.UNDERDRIVE_AGV.toString().equals(agvModel.getType())) { |
| | |
| | | @PostMapping("/control/agv/load/lift/down") |
| | | public R downAgvLoadPlatform(@RequestHeader String appKey, |
| | | @RequestBody HandlerPublishParam param) { |
| | | if (Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error(); |
| | | if (param == null || Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error("参数不完整,请检查AGV"); |
| | | } |
| | | if (!APP_KEY.equals(appKey)) { |
| | | return R.error(); |
| | | return R.error("appKey校验失败"); |
| | | } |
| | | |
| | | Agv agv = agvService.selectByUuid(param.getAgvNo()); |
| | |
| | | } |
| | | if (!agvService.judgeEnable(agv.getId())) { |
| | | log.info("{}号AGV不可用,下放失败...", agv.getUuid()); |
| | | return R.error(); |
| | | return R.error("当前AGV不可用,无法执行载货台下降"); |
| | | } |
| | | AgvModel agvModel = agvModelService.getByAgvId(agv.getId()); |
| | | if (agvModel == null || !AgvModelType.UNDERDRIVE_AGV.toString().equals(agvModel.getType())) { |
| | |
| | | @RequestMapping(value = "/restore/agv", method = {RequestMethod.GET, RequestMethod.POST}) |
| | | public R restoreAgv(@RequestHeader String appKey, @RequestBody HandlerPublishParam param) { |
| | | if (Cools.isEmpty(appKey)) { |
| | | return R.error(); |
| | | return R.error("appKey不能为空"); |
| | | } |
| | | if (!APP_KEY.equals(appKey)) { |
| | | return R.error(); |
| | | return R.error("appKey校验失败"); |
| | | } |
| | | |
| | | Agv agv = null; |
| | |
| | | @RequestMapping(value = "/unlock", method = {RequestMethod.GET, RequestMethod.POST}) |
| | | public R unlockPath(@RequestHeader String appKey, |
| | | @RequestBody HandlerPublishParam param) throws ExecutionException, InterruptedException { |
| | | if (Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error(); |
| | | if (param == null || Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error("参数不完整,请检查AGV"); |
| | | } |
| | | if (!APP_KEY.equals(appKey)) { |
| | | return R.error(); |
| | | return R.error("appKey校验失败"); |
| | | } |
| | | |
| | | Agv agv = agvService.selectByUuid(param.getAgvNo()); |
| | | if (agv == null) { |
| | | return R.error("AGV不存在"); |
| | | } |
| | | |
| | | // block |
| | | // Future<R> future = threadPoolRegulator.getInstance().submit(() -> { |
| | |
| | | @RequestMapping(value = "/agv/patrol", method = {RequestMethod.GET, RequestMethod.POST}) |
| | | public R agvPatrol(@RequestHeader String appKey, |
| | | @RequestBody HandlerPublishParam param) throws ExecutionException, InterruptedException { |
| | | if (Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error(); |
| | | if (param == null || Cools.isEmpty(param.getAgvNo(), appKey)) { |
| | | return R.error("参数不完整,请检查AGV"); |
| | | } |
| | | if (!APP_KEY.equals(appKey)) { |
| | | return R.error(); |
| | | return R.error("appKey校验失败"); |
| | | } |
| | | String agvNo = param.getAgvNo(); |
| | | if (patrolService.isPatrolling(agvNo)) { |