| | |
| | | public void genReCheck() { |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() |
| | | .select(Task::getId) |
| | | .eq(Task::getTaskStatus, TaskStsType.GENERATE_OUT.id) |
| | | .eq(Task::getTaskType, TaskType.TASK_TYPE_CHECK_OUT.type)); |
| | | if (tasks.isEmpty()) { |
| | | return; |
| | |
| | | List<CheckDiffItem> list = checkDiffItemService |
| | | .list(new LambdaQueryWrapper<CheckDiffItem>() |
| | | .select(CheckDiffItem::getTaskItemId)); |
| | | if (list.isEmpty()) { |
| | | return; |
| | | } |
| | | Set<Long> taskIds = tasks.stream().map(Task::getId).collect(Collectors.toSet()); |
| | | List<Long> itemIds = list.stream().map(CheckDiffItem::getTaskItemId).collect(Collectors.toList()); |
| | | List<TaskItem> taskItems = taskItemService |
| | | .list(new LambdaQueryWrapper<TaskItem>() |
| | | .in(TaskItem::getTaskId, taskIds) |
| | | .notIn(TaskItem::getId, itemIds)); |
| | | .notIn(!itemIds.isEmpty(), TaskItem::getId, itemIds)); |
| | | if (taskItems.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | .setUpdateBy(loginUserId) |
| | | .setUpdateTime(new Date()) |
| | | .setOrderId(order.getId()); |
| | | if (!checkDiffService.save(checkDiff)) { |
| | | if (!checkDiffService.saveOrUpdate(checkDiff)) { |
| | | throw new CoolException("盘点差异单保存失败!!"); |
| | | } |
| | | } |
| | | |
| | | List<TaskItem> items = taskMps.get(orderId); |
| | | List<CheckDiffItem> diffItems = new ArrayList<>(); |
| | | CheckDiff finalCheckDiff = checkDiff; |
| | | items.forEach(item -> { |
| | | for (TaskItem item : items) { |
| | | Task task = taskService.getById(item.getTaskId()); |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("数据错误:任务不存在!!"); |
| | | } |
| | | CheckDiffItem checkDiffItem = new CheckDiffItem(); |
| | | BeanUtils.copyProperties(item, checkDiffItem); |
| | | checkDiffItem.setCheckId(finalCheckDiff.getId()) |
| | | checkDiffItem.setCheckId(checkDiff.getId()) |
| | | .setTaskItemId(item.getId()) |
| | | .setTaskId(item.getTaskId()) |
| | | .setCreateBy(loginUserId) |
| | |
| | | .setBarcode(task.getBarcode()) |
| | | .setUpdateBy(loginUserId) |
| | | .setUpdateTime(new Date()) |
| | | .setOrderCode(finalCheckDiff.getOrderCode()); |
| | | .setOrderCode(checkDiff.getOrderCode()); |
| | | diffItems.add(checkDiffItem); |
| | | |
| | | if (Objects.isNull(finalCheckDiff.getAreaId())) { |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getCode, task.getOrgLoc()) |
| | | .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_R.type)); |
| | | if (Objects.isNull(loc)) { |
| | | throw new CoolException("盘点库位不存在!!"); |
| | | } |
| | | finalCheckDiff.setAreaId(loc.getAreaId()).setAreaName(loc.getAreaId$()); |
| | | // if (Objects.isNull(checkDiff.getAreaId())) { |
| | | // Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | // .eq(Loc::getCode, task.getOrgLoc()) |
| | | // .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_R.type)); |
| | | // if (Objects.isNull(loc)) { |
| | | // throw new CoolException("盘点库位不存在!!"); |
| | | // } |
| | | //// finalCheckDiff.setAreaId(loc.getAreaId()).setAreaName(loc.getAreaId$()); |
| | | // } |
| | | } |
| | | |
| | | if (!checkDiffService.updateById(finalCheckDiff)) { |
| | | throw new CoolException("库区信息修改失败!!"); |
| | | } |
| | | } |
| | | }); |
| | | // checkDiff.setAreaId(finalCheckDiff.getAreaId()).setAreaName(finalCheckDiff.getAreaName()); |
| | | // |
| | | // if (!checkDiffService.updateById(checkDiff)) { |
| | | // throw new CoolException("库区信息修改失败!!"); |
| | | // } |
| | | |
| | | if (!checkDiffItemService.saveBatch(diffItems)) { |
| | | throw new CoolException("盘点差异单保存失败!!"); |