chen.lin
7 小时以前 f574055ed80a64cbccd601b200afc437a87b52eb
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -1399,16 +1399,36 @@
        if (Objects.isNull(loc)) {
            throw new CoolException("库位不存在!!");
        }
        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
            throw new CoolException("库位状态不处理于R.出库预约!!");
        }
        List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
        if (taskItems.isEmpty()) {
            throw new CoolException("任务明细不存在!!");
        }
        List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
        // 如果库位状态不是R,检查是否已经处理过
        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
            // 如果库位明细为空,说明已经处理过了,直接更新任务状态为199
            if (locItems.isEmpty()) {
                logger.warn("任务{}的库位{}状态为{},但库位明细为空,可能已经处理过,直接更新任务状态为199",
                        task.getId(), loc.getCode(), loc.getUseStatus());
                if (!this.update(new LambdaUpdateWrapper<Task>()
                        .eq(Task::getId, task.getId())
                        .set(Task::getUpdateBy, loginUserId)
                        .set(Task::getUpdateTime, new Date())
                        .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
                    throw new CoolException("任务状态更新失败!!");
                }
                return; // 跳过后续处理
            } else {
                // 库位明细不为空但状态不是R,记录错误但不抛出异常,让定时任务继续处理其他任务
                logger.error("任务{}的库位{}状态为{},不是R.出库预约状态,但库位明细不为空,跳过处理。任务编码:{},库位编码:{}",
                        task.getId(), loc.getCode(), loc.getUseStatus(), task.getTaskCode(), loc.getCode());
                return; // 跳过处理,避免异常中断定时任务
            }
        }
        // 如果库位明细为空,可能是已经被处理过了,允许继续执行
        if (!locItems.isEmpty()) {
            List<LocItemWorking> workings = new ArrayList<>();
@@ -1761,7 +1781,10 @@
                    // 为每个不同的库位创建一个TaskItemParam
                    for (String locCode : locCodes) {
                        TaskItemParam outItemParam = new TaskItemParam();
                        outItemParam.setTaskNo(task.getTaskCode());
                        String taskNo = locCodes.size() > 1
                                ? task.getTaskCode() + "_" + locCode
                                : task.getTaskCode();
                        outItemParam.setTaskNo(taskNo);
                        outItemParam.setPriority(1);
                        outItemParam.setOriLoc(locCode);
                        outItemParam.setDestSta(task.getTargSite());