#
vincentlu
2026-04-22 994743fb1528d845e720db3223177bcac06e49ea
#
1个文件已修改
86 ■■■■ 已修改文件
zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java 86 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java
@@ -142,16 +142,19 @@
    @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
@@ -164,11 +167,11 @@
                            .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();
@@ -204,7 +207,7 @@
                    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());
@@ -214,7 +217,7 @@
                }
                task = null;
                if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), endCode.getData(), null)) {
                    return R.error();
                    return R.error("移动任务下发失败");
                }
                break;
            case TO_CHARGE:
@@ -224,7 +227,7 @@
                }
                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:
@@ -236,7 +239,7 @@
                    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$());
@@ -261,7 +264,7 @@
                    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$());
@@ -293,7 +296,7 @@
                    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$());
@@ -318,7 +321,7 @@
                    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$());
@@ -344,7 +347,7 @@
                    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$());
@@ -362,7 +365,7 @@
                    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$());
@@ -396,7 +399,7 @@
                    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$());
@@ -415,7 +418,7 @@
                    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$());
@@ -449,11 +452,11 @@
    @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());
@@ -463,7 +466,7 @@
        if (!agvService.judgeEnable(agv.getId())) {
            log.info("{}号AGV不可用,停止充电失败...", agv.getUuid());
            return R.error();
            return R.error("当前AGV不可用,无法断开充电");
        }
        AgvModel agvModel = agvModelService.getByAgvId(agv.getId());
@@ -483,11 +486,11 @@
    @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());
@@ -497,7 +500,7 @@
        if (!agvService.judgeEnable(agv.getId())) {
            log.info("{}号AGV不可用,取消任务失败...", agv.getUuid());
            return R.error();
            return R.error("当前AGV不可用,无法取消任务");
        }
        AgvModel agvModel = agvModelService.getByAgvId(agv.getId());
@@ -533,11 +536,11 @@
    @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());
@@ -546,7 +549,7 @@
        }
        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())) {
@@ -567,11 +570,11 @@
    @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());
@@ -580,7 +583,7 @@
        }
        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())) {
@@ -597,10 +600,10 @@
    @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;
@@ -658,14 +661,17 @@
    @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(() -> {
@@ -694,11 +700,11 @@
    @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)) {