#
luxiaotao1123
2024-10-23 7a68bbe9a032df8c54b2263be097002e01383bce
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -93,11 +93,15 @@
    @SuppressWarnings("all")
    @Transactional
    public void generateBusAndTask(OpenBusSubmitParam busSubmitParam, String memo) {
    public Bus generateBusAndTask(OpenBusSubmitParam busSubmitParam, String memo) {
        String errorMsg = busService.checkoutValid(busSubmitParam);
        if (!Cools.isEmpty(errorMsg)) {
            throw new BusinessException(errorMsg);
        }
        String batch = busSubmitParam.getBatch();
        List<TaskDto> taskDtoList = busSubmitParam.getTaskList();
        if (Cools.isEmpty(taskDtoList)) {
            throw new BusinessException("taskDtoList 不能为空");
            throw new BusinessException("taskList can't be empty!");
        }
        // 优先级排序
@@ -116,7 +120,7 @@
        bus.setMemo(memo);
        if (!busService.save(bus)) {
            throw new BusinessException("任务保存失败");
            throw new BusinessException("Internal Server Error!");
        }
        // 保存任务
@@ -124,7 +128,7 @@
            task.setBusId(bus.getId());
            task.setTaskSts(TaskStsType.INIT.val());
            if (!taskService.save(task)) {
                throw new BusinessException(task.getSeqNum() + "任务保存失败");
                throw new BusinessException("seqNum:" + task.getSeqNum() + " failed to save!");
            }
            // 修改库位状态
@@ -136,44 +140,44 @@
                case LOC_TO_LOC:
                    oriLoc = locService.getById(task.getOriLoc());
                    if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
                        throw new BusinessException("oriLoc:" + task.getOriLoc$() + " 不是在库状态");
                        throw new BusinessException("oriLoc:" + task.getOriLoc$() + " is not in STOCK status");
                    }
                    oriLoc.setLocSts(LocStsType.PAKOUT.val());
                    oriLoc.setUpdateTime(now);
                    if (!locService.updateById(oriLoc)) {
                        throw new BusinessException("oriLoc:" + task.getOriLoc$() + " 修改库位状态失败");
                        throw new BusinessException("oriLoc:" + task.getOriLoc$() + " failed to update");
                    }
                    destLoc = locService.getById(task.getDestLoc());
                    if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
                        throw new BusinessException("destLoc:" + task.getDestLoc$() + " 不是空闲状态");
                        throw new BusinessException("destLoc:" + task.getDestLoc$() + " is not in IDLE status");
                    }
                    destLoc.setLocSts(LocStsType.PAKIN.val());
                    destLoc.setUpdateTime(now);
                    if (!locService.updateById(destLoc)) {
                        throw new BusinessException("destLoc:" + task.getDestLoc$() + " 修改库位状态失败");
                        throw new BusinessException("destLoc:" + task.getDestLoc$() + " failed to update");
                    }
                    break;
                case LOC_TO_STA:
                    oriLoc = locService.getById(task.getOriLoc());
                    if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
                        throw new BusinessException("oriLoc:" + task.getOriLoc$() + " 不是在库状态");
                        throw new BusinessException("oriLoc:" + task.getOriLoc$() + " is not in STOCK status");
                    }
                    oriLoc.setLocSts(LocStsType.PAKOUT.val());
                    oriLoc.setUpdateTime(now);
                    if (!locService.updateById(oriLoc)) {
                        throw new BusinessException("oriLoc:" + task.getOriLoc$() + " 修改库位状态失败");
                        throw new BusinessException("oriLoc:" + task.getOriLoc$() + " failed to update");
                    }
                    break;
                case STA_TO_LOC:
                    destLoc = locService.getById(task.getDestLoc());
                    if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
                        throw new BusinessException("destLoc:" + task.getDestLoc$() + " 不是空闲状态");
                        throw new BusinessException("destLoc:" + task.getDestLoc$() + " is not in IDLE status");
                    }
                    destLoc.setLocSts(LocStsType.PAKIN.val());
                    destLoc.setUpdateTime(now);
                    if (!locService.updateById(destLoc)) {
                        throw new BusinessException("destLoc:" + task.getDestLoc$() + " 修改库位状态失败");
                        throw new BusinessException("destLoc:" + task.getDestLoc$() + " failed to update");
                    }
                    break;
                case STA_TO_STA:
@@ -183,7 +187,7 @@
            }
        }
        return bus;
    }
    /**
@@ -203,7 +207,7 @@
                bus.setBusSts(BusStsType.PROGRESS.val());
                bus.setUpdateTime(now);
                if (!busService.updateById(bus)) {
                    log.error("Bus [{}] 更新失败 !!!", bus.getUuid());
                    log.error("Bus [{}] failed to Update !!!", bus.getUuid());
                }
                return;
            }
@@ -213,7 +217,7 @@
            for (Task task : taskList) {
                Agv agv = missionAssignService.execute(task, taskAllot, taskIds);
                if (null == agv) {
                    log.warn("{}任务异常,无法检索空闲Agv...", task.getSeqNum());
                    log.warn("Task[{}] has an issue, because it failed to checkout agv which is idle...", task.getSeqNum());
                    continue;
                }
@@ -223,7 +227,7 @@
                task.setIoTime(now);
                task.setUpdateTime(now);
                if (!taskService.updateById(task)) {
                    throw new BusinessException(task.getSeqNum() + "任务更新失败");
                    throw new BusinessException("seqNum: " + task.getSeqNum() + " failed to update");
                }
                if (taskAllot.containsKey(agv.getUuid())) {
@@ -281,8 +285,9 @@
                    return 0;
                }
            });
            if (taskList.size() > agv.getStage()) {
                taskList = taskList.subList(0, agv.getStage());
            Integer backpack = agvService.getBackpack(agv);
            if (taskList.size() > backpack) {
                taskList = taskList.subList(0, backpack);
            }
            /**
@@ -349,7 +354,7 @@
                }
                if (backpackLev > agv.getStage()) {
                if (backpackLev > backpack) {
                    throw new BusinessException("解析Task失败,AGV背篓已满......");
                }
@@ -994,6 +999,7 @@
            }
            for (Action action : actionList) {
                action.setActionSts(ActionStsType.ISSUED.val());
                action.setStartTime(now);
                action.setUpdateTime(now);
                if (!actionService.updateById(action)) {
                    throw new BusinessException(action.getPriority() + " - " + action.getName() + "动作更新失败");
@@ -1143,6 +1149,7 @@
                            if (null != action) {
                                action.setActionSts(ActionStsType.FINISH.val());
                                action.setEndTime(now);
                                action.setUpdateTime(now);
                                if (!actionService.updateById(action)) {
                                    log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + action.getName());
@@ -1175,6 +1182,7 @@
                            );
                            if (null != action) {
                                action.setActionSts(ActionStsType.FINISH.val());
                                action.setEndTime(now);
                                action.setUpdateTime(now);
                                if (!actionService.updateById(action)) {
                                    log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + action.getName());
@@ -1249,6 +1257,7 @@
                );
                for (Action action : actionList) {
                    action.setActionSts(ActionStsType.FINISH.val());
                    action.setEndTime(now);
                    action.setUpdateTime(now);
                    if (!actionService.updateById(action)) {
                        log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + action.getName());