| | |
| | | List<LocItemWorking> workings = new ArrayList<>(); |
| | | List<TaskItem> items = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | items.forEach(taskItem -> { |
| | | LocItemWorking itemWorking = new LocItemWorking(); |
| | | BeanUtils.copyProperties(taskItem, itemWorking); |
| | | itemWorking.setTaskId(task.getId()).setLocId(loc1.getId()).setLocCode(loc1.getCode()); |
| | | workings.add(itemWorking); |
| | | if (taskItem.getAnfme() > 0) { |
| | | LocItemWorking itemWorking = new LocItemWorking(); |
| | | BeanUtils.copyProperties(taskItem, itemWorking); |
| | | itemWorking.setTaskId(task.getId()) |
| | | .setLocId(loc1.getId()) |
| | | .setLocCode(loc1.getCode()); |
| | | workings.add(itemWorking); |
| | | } |
| | | }); |
| | | |
| | | if (!locItemWorkingService.saveBatch(workings)) { |
| | |
| | | List<LocItem> locItems = new ArrayList<>(); |
| | | items.forEach(taskItem -> { |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()), false); |
| | | if (Objects.isNull(loc)) { |
| | | throw new CoolException("库位不存在!!"); |
| | | } |
| | | LocItem item = new LocItem(); |
| | | BeanUtils.copyProperties(taskItem, item); |
| | | item.setLocCode(loc.getCode()).setId(null) |
| | | .setLocId(loc.getId()) |
| | | .setUpdateBy(loginUserId) |
| | | .setWkType(taskItem.getWkType()) |
| | | .setType(taskItem.getOrderType()); |
| | | locItems.add(item); |
| | | LocItem locItem = locItemService.getOne(new LambdaQueryWrapper<LocItem>() |
| | | .eq(LocItem::getMatnrId, taskItem.getMatnrId()) |
| | | .eq(LocItem::getLocId, loc.getId()) |
| | | .eq(StringUtils.isNoneBlank(taskItem.getBatch()), LocItem::getBatch, taskItem.getBatch()) |
| | | .eq(StringUtils.isNoneBlank(taskItem.getFieldsIndex()), LocItem::getFieldsIndex, taskItem.getFieldsIndex())); |
| | | if (Objects.isNull(locItem)) { |
| | | BeanUtils.copyProperties(taskItem, item); |
| | | item.setLocCode(loc.getCode()) |
| | | .setId(null) |
| | | .setLocId(loc.getId()) |
| | | .setUpdateBy(loginUserId) |
| | | .setWkType(taskItem.getWkType()) |
| | | .setType(taskItem.getOrderType()); |
| | | locItems.add(item); |
| | | } else { |
| | | locItem.setAnfme(Math.round((locItem.getAnfme() + taskItem.getAnfme()) * 10000) / 10000.0) |
| | | .setUpdateTime(new Date()); |
| | | locItems.add(locItem); |
| | | } |
| | | }); |
| | | if (!locItemService.saveBatch(locItems)) { |
| | | throw new CoolException("库位明细更新失败!!"); |