#
vincentlu
1 天以前 43412c20ac444392471ea8ea8bc4a93af39efe87
zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java
@@ -75,6 +75,8 @@
    private PatrolService patrolService;
    @Autowired
    private StaReserveService staReserveService;
    @Autowired
    private AgvAreaDispatcher agvAreaDispatcher;
    @PreAuthorize("hasAuthority('manager:agv:update')")
    @OperationLog("Locate All Agv")
@@ -171,7 +173,7 @@
        task.setPriority(999);
        task.setIoTime(now);
        task.setStartTime(now);
        task.setMemo("HANDLE");
        task.setMemo("AUTO");
        if (!taskService.save(task)) {
            throw new BusinessException(task.getSeqNum() + "任务保存失败");
        }
@@ -193,9 +195,13 @@
                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();
                }
@@ -205,6 +211,7 @@
                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();
                }
@@ -219,6 +226,10 @@
                }
                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() + " 不是在库状态");
@@ -238,6 +249,10 @@
                }
                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() + " 不是空闲状态");
@@ -265,6 +280,10 @@
                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() + " 不是在库状态");
                }
@@ -284,15 +303,20 @@
                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
@@ -304,6 +328,10 @@
                }
                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() + " 预约失败");
@@ -319,6 +347,10 @@
                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() + " 不是空闲状态");
                }
@@ -333,6 +365,8 @@
                task.setOriCode(oriSta.getCode());
                task.setDestLoc(destLoc.getId());
                task.setDestCode(destLoc.getCode());
                staReserveService.allocateCallBack(task, agv.getId());
                break;
            case STA_TO_STA:
                // oriSta
@@ -345,9 +379,14 @@
                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())) {
@@ -359,6 +398,10 @@
                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() + " 预约失败");
                }
@@ -368,13 +411,17 @@
                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();
    }