From a4257f3bd3a350758e8520bb5ad86e884c4931ab Mon Sep 17 00:00:00 2001 From: xiaofajia <1665375861@qq.com> Date: Fri, 25 Oct 2024 22:04:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=86=E6=96=99=E3=80=81?= =?UTF-8?q?=E9=80=80=E6=96=99=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DlRepairSoServiceImpl.java | 296 +++++++++++------- .../impl/DlTicketWaresServiceImpl.java | 97 +++++- 2 files changed, 261 insertions(+), 132 deletions(-) diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java index 44536258..4e5fecc2 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java @@ -92,6 +92,10 @@ public class DlRepairSoServiceImpl extends ServiceImpl sois = repairSoiService.list(new LambdaQueryWrapper().in(DlRepairSoi::getSoId, so.getId())); + // 查要操作申请表子表 + List oldTwItems = twItemService.list(new LambdaQueryWrapper().and(item -> { + item.eq(DlTwItem::getTwId, so.getTwId()) + .in(DlTwItem::getWaresId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); + })); + // 查要操作的配件 + List oldWares = repairWaresService.list(new LambdaQueryWrapper().in(RepairWares::getId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()))); + // 新的申请表子表数据和配件数据 + List newTwItems = new ArrayList<>(); + List newWares = new ArrayList<>(); + // 需要区分是领料还是退料 + // 得到新申请表子表数据 + oldTwItems.forEach(item -> { + DlTwItem dlTwItem = new DlTwItem(); + dlTwItem.setId(item.getId()); + sois.stream().filter(i -> i.getGoodsId().equals(item.getWaresId())).findFirst().ifPresent(repairSoiByTwItem -> { + if (so.getSoType().equals("02")){ + dlTwItem.setWaresAlreadyCount(item.getWaresAlreadyCount() - repairSoiByTwItem.getGoodsCount()); + dlTwItem.setWaresCouldCount(item.getWaresCouldCount() + repairSoiByTwItem.getGoodsCount()); + dlTwItem.setWaresStatus("02"); + }else { + dlTwItem.setWaresAlreadyCount(item.getWaresAlreadyCount() + repairSoiByTwItem.getGoodsCount()); + dlTwItem.setWaresCouldCount(item.getWaresCouldCount() - repairSoiByTwItem.getGoodsCount()); + } + }); + newTwItems.add(dlTwItem); + }); + // 得到新配件数据 + oldWares.forEach(item -> { + RepairWares wares = new RepairWares(); + wares.setId(item.getId()); + sois.stream().filter(i -> i.getGoodsId().equals(wares.getId())).findFirst().ifPresent(repairSoiByWares -> { + if (so.getSoType().equals("02")){ + wares.setStock(item.getStock().add(BigDecimal.valueOf(repairSoiByWares.getGoodsCount()))); + }else { + wares.setStock(item.getStock().subtract(BigDecimal.valueOf(repairSoiByWares.getGoodsCount()))); + } + }); + newWares.add(wares); + }); + + // 更新申请表子表 + twItemService.updateBatchById(newTwItems); + // 更新配件 + repairWaresService.updateBatchById(newWares); } } @@ -235,53 +287,54 @@ public class DlRepairSoServiceImpl extends ServiceImpl() .eq(DlRepairSoi::getSoId, id) ); - // 查库存 - List wares = waresService - .list(new LambdaQueryWrapper() - .in(RepairWares::getId, sois.stream() - .map(DlRepairSoi::getGoodsId) - .collect(Collectors.toList()) - )); - // 更新库存 - List newWares = wares.stream().map(item -> { - RepairWares ware = new RepairWares(); - ware.setId(item.getId()); - sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> { - ware.setStock(item.getStock().subtract(BigDecimal.valueOf(i.getGoodsCount()))); - }); - return ware; - }).collect(Collectors.toList()); - waresService.updateBatchById(newWares); + // 查库存---生成领料单的时候更新了 +// List wares = waresService +// .list(new LambdaQueryWrapper() +// .in(RepairWares::getId, sois.stream() +// .map(DlRepairSoi::getGoodsId) +// .collect(Collectors.toList()) +// )); +// // 更新库存 +// List newWares = wares.stream().map(item -> { +// RepairWares ware = new RepairWares(); +// ware.setId(item.getId()); +// sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> { +// ware.setStock(item.getStock().subtract(BigDecimal.valueOf(i.getGoodsCount()))); +// }); +// return ware; +// }).collect(Collectors.toList()); +// waresService.updateBatchById(newWares); // 更新主表状态 为已领料 DlRepairSo dlRepairSo = new DlRepairSo(); dlRepairSo.setId(id); dlRepairSo.setSoStatus(SoStatusEnum.PICKED.getCode()); baseMapper.updateById(dlRepairSo); - // 更新申请表的数据 - DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper().eq(DlRepairSo::getId, id)); - // 查申请表的子表对应的配件信息 - List twItems = twItemService.list(new LambdaQueryWrapper().and(item -> { - item.eq(DlTwItem::getTwId, so.getTwId()) - .in(DlTwItem::getWaresId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); - })); - // 更新子表 - List newTwItems = twItems.stream().map(item -> { - DlTwItem dlTwItem = new DlTwItem(); - dlTwItem.setId(item.getId()); - dlTwItem.setWaresAlreadyCount(ObjectUtil.isNotEmpty(item.getWaresAlreadyCount()) ? item.getWaresAlreadyCount() + item.getWaresCouldCount() : item.getWaresCouldCount()); - dlTwItem.setWaresStatus(dlTwItem.getWaresAlreadyCount().equals(item.getWaresCount()) ? "01" : item.getWaresStatus()); - return dlTwItem; - }).collect(Collectors.toList()); - twItemService.updateBatchById(newTwItems); + // 更新申请表的数据----生成领料单的时候更新了 +// // 查申请表的子表对应的配件信息 +// List twItems = twItemService.list(new LambdaQueryWrapper().and(item -> { +// item.eq(DlTwItem::getTwId, so.getTwId()) +// .in(DlTwItem::getWaresId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); +// })); +// // 更新子表 +// List newTwItems = twItems.stream().map(item -> { +// DlTwItem dlTwItem = new DlTwItem(); +// dlTwItem.setId(item.getId()); +// dlTwItem.setWaresAlreadyCount(ObjectUtil.isNotEmpty(item.getWaresAlreadyCount()) ? item.getWaresAlreadyCount() + item.getWaresCouldCount() : item.getWaresCouldCount()); +// dlTwItem.setWaresStatus(dlTwItem.getWaresAlreadyCount().equals(item.getWaresCount()) ? "01" : item.getWaresStatus()); +// return dlTwItem; +// }).collect(Collectors.toList()); +// twItemService.updateBatchById(newTwItems); // 查最新的子表信息 + DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper().eq(DlRepairSo::getId, id)); List list = twItemService.list(new LambdaQueryWrapper().eq(DlTwItem::getTwId, so.getTwId())); // 判断是部分完成还是全部完成 DlTicketWares dlTicketWares = new DlTicketWares(); dlTicketWares.setId(so.getTwId()); List flag = list.stream().filter(item -> !item.getWaresStatus().equals("01")).collect(Collectors.toList()); dlTicketWares.setStatus(CollectionUtil.isEmpty(flag) ? "03" : "04"); + // 更新主表的状态 ticketWaresService.updateById(dlTicketWares); // 查主表记录 @@ -305,92 +358,94 @@ public class DlRepairSoServiceImpl extends ServiceImpl().eq(DlRepairSo::getId, id)); - // 查配件退料表子表 - List sois = repairSoiService.list(new LambdaQueryWrapper().eq(DlRepairSoi::getSoId, so.getId())); - // 查申请表子表 - List twItems = twItemService.list(new LambdaQueryWrapper().eq(DlTwItem::getTwId, so.getTwId())); - // 得到需要更新的数据 - List newTwItems = twItems.stream().map(item -> { - DlTwItem dlTwItem = new DlTwItem(); - dlTwItem.setId(item.getId()); - sois.stream().filter(i -> i.getGoodsId().equals(item.getWaresId())).findFirst().ifPresent(i -> { - dlTwItem.setWaresBackCount( - ObjectUtil.isNotEmpty(item.getWaresBackCount()) - ? item.getWaresCount() + item.getWaresBackCount() - : i.getGoodsCount()); - // 如果退料数就是领料申请数,那就是全退了 - if (i.getGoodsCount().equals(dlTwItem.getWaresCount())) { - dlTwItem.setWaresStatus("03"); - } - }); - return dlTwItem; - }).collect(Collectors.toList()); - twItemService.updateBatchById(newTwItems); - // 更新库存 - // 查库存 - List wares = waresService.list(new LambdaQueryWrapper().in(RepairWares::getId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()))); - // 构建新数据 - List newWares = wares.stream().map(item -> { - RepairWares ware = new RepairWares(); - ware.setId(item.getId()); - sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> { - ware.setStock(item.getStock().add(BigDecimal.valueOf(i.getGoodsCount()))); - }); - return ware; - }).collect(Collectors.toList()); - waresService.updateBatchById(newWares); + // 更新配件申请表----生成退料单的时候更新了 +// DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper().eq(DlRepairSo::getId, id)); +// // 查配件退料表子表 +// List sois = repairSoiService.list(new LambdaQueryWrapper().eq(DlRepairSoi::getSoId, so.getId())); +// // 查申请表子表 +// List twItems = twItemService.list(new LambdaQueryWrapper().eq(DlTwItem::getTwId, so.getTwId())); +// // 得到需要更新的数据 +// List newTwItems = twItems.stream().map(item -> { +// DlTwItem dlTwItem = new DlTwItem(); +// dlTwItem.setId(item.getId()); +// sois.stream().filter(i -> i.getGoodsId().equals(item.getWaresId())).findFirst().ifPresent(i -> { +// dlTwItem.setWaresBackCount( +// ObjectUtil.isNotEmpty(item.getWaresBackCount()) +// ? item.getWaresCount() + item.getWaresBackCount() +// : i.getGoodsCount()); +// // 如果退料数就是领料申请数,那就是全退了 +// if (i.getGoodsCount().equals(dlTwItem.getWaresCount())) { +// dlTwItem.setWaresStatus("03"); +// } +// }); +// return dlTwItem; +// }).collect(Collectors.toList()); +// twItemService.updateBatchById(newTwItems); +// // 更新库存 +// // 查库存 +// List wares = waresService.list(new LambdaQueryWrapper().in(RepairWares::getId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()))); +// // 构建新数据 +// List newWares = wares.stream().map(item -> { +// RepairWares ware = new RepairWares(); +// ware.setId(item.getId()); +// sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> { +// ware.setStock(item.getStock().add(BigDecimal.valueOf(i.getGoodsCount()))); +// }); +// return ware; +// }).collect(Collectors.toList()); +// waresService.updateBatchById(newWares); - // 更新维修工单 - // 查申请表主表 - DlTicketWares ticketWares = ticketWaresService.getOne(new LambdaQueryWrapper().eq(DlTicketWares::getId, so.getTwId())); - // 查维修工单子表为配件的数据 - List titems = titemService.list(new LambdaQueryWrapper().and(item -> { - item.eq(DlRepairTitem::getTicketId, ticketWares.getTicketId()) - .eq(DlRepairTitem::getItemType, "02") - .in(DlRepairTitem::getPartId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); - })); - // 构建新数据,更新维修工单子表 - List newTitems = titems.stream().map(item -> { - DlRepairTitem titem = new DlRepairTitem(); - titem.setId(item.getId()); - sois.stream().filter(i -> i.getGoodsId().equals(item.getPartId())).findFirst().ifPresent(i -> { - titem.setItemCount(item.getItemCount() - i.getGoodsCount()); - BigDecimal itemDiscount = ObjectUtil.isNotEmpty(item.getItemDiscount()) ? item.getItemDiscount() : BigDecimal.ONE; - titem.setItemMoney(new BigDecimal(titem.getItemCount()).multiply(item.getItemPrice()).multiply(itemDiscount)); - }); - return titem; - }).collect(Collectors.toList()); - // 分开全部退料了的和没有全部退料的数据 - List delTitems = newTitems.stream().filter(item -> item.getItemCount() == 0).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(delTitems)) { - titemService.updateBatchById(newTitems); - } else { - titemService.removeBatchByIds(delTitems); - List updateTitems = newTitems.stream().filter(item -> !delTitems.contains(item)).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(updateTitems)) { - titemService.updateBatchById(updateTitems); - } - - } - // 更新维修工单 - DlRepairTickets tickets = ticketsService.getOne(new LambdaQueryWrapper().eq(DlRepairTickets::getId, ticketWares.getTicketId())); - // 查最新的子表信息 - List list = titemService.list(new LambdaQueryWrapper().in(DlRepairTitem::getTicketId, tickets.getId())); - // 计算工单总子项、工单配件总价、工单总价 - DlRepairTickets newTickets = new DlRepairTickets(); - newTickets.setId(tickets.getId()); - newTickets.setCount(list.stream().mapToInt(DlRepairTitem::getItemCount).sum()); - newTickets.setPartPrice(list.stream() - .filter(item -> item.getItemType().equals("02")) - .map(DlRepairTitem::getItemMoney) - .reduce(BigDecimal.ZERO, BigDecimal::add)); - BigDecimal projectPrice = tickets.getProjectPrice() == null ? BigDecimal.ZERO : tickets.getProjectPrice(); - BigDecimal otherPrice = tickets.getOtherPrice() != null ? tickets.getOtherPrice() : BigDecimal.ZERO; - BigDecimal partPrice = newTickets.getPartPrice() == null ? BigDecimal.ZERO : newTickets.getPartPrice(); - newTickets.setTotalPrice(projectPrice.add(partPrice).add(otherPrice)); - ticketsService.updateById(newTickets); + // 更新维修工单----最后完成工单的时候来更新 +// // 查配件退料表子表 +// List sois = repairSoiService.list(new LambdaQueryWrapper().eq(DlRepairSoi::getSoId, so.getId())); +// // 查申请表主表 +// DlTicketWares ticketWares = ticketWaresService.getOne(new LambdaQueryWrapper().eq(DlTicketWares::getId, so.getTwId())); +// // 查维修工单子表为配件的数据 +// List titems = titemService.list(new LambdaQueryWrapper().and(item -> { +// item.eq(DlRepairTitem::getTicketId, ticketWares.getTicketId()) +// .eq(DlRepairTitem::getItemType, "02") +// .in(DlRepairTitem::getPartId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); +// })); +// // 构建新数据,更新维修工单子表 +// List newTitems = titems.stream().map(item -> { +// DlRepairTitem titem = new DlRepairTitem(); +// titem.setId(item.getId()); +// sois.stream().filter(i -> i.getGoodsId().equals(item.getPartId())).findFirst().ifPresent(i -> { +// titem.setItemCount(item.getItemCount() - i.getGoodsCount()); +// BigDecimal itemDiscount = ObjectUtil.isNotEmpty(item.getItemDiscount()) ? item.getItemDiscount() : BigDecimal.ONE; +// titem.setItemMoney(new BigDecimal(titem.getItemCount()).multiply(item.getItemPrice()).multiply(itemDiscount)); +// }); +// return titem; +// }).collect(Collectors.toList()); +// // 分开全部退料了的和没有全部退料的数据 +// List delTitems = newTitems.stream().filter(item -> item.getItemCount() == 0).collect(Collectors.toList()); +// if (CollectionUtil.isEmpty(delTitems)) { +// titemService.updateBatchById(newTitems); +// } else { +// titemService.removeBatchByIds(delTitems); +// List updateTitems = newTitems.stream().filter(item -> !delTitems.contains(item)).collect(Collectors.toList()); +// if (CollectionUtil.isEmpty(updateTitems)) { +// titemService.updateBatchById(updateTitems); +// } +// +// } +// // 更新维修工单 +// DlRepairTickets tickets = ticketsService.getOne(new LambdaQueryWrapper().eq(DlRepairTickets::getId, ticketWares.getTicketId())); +// // 查最新的子表信息 +// List list = titemService.list(new LambdaQueryWrapper().in(DlRepairTitem::getTicketId, tickets.getId())); +// // 计算工单总子项、工单配件总价、工单总价 +// DlRepairTickets newTickets = new DlRepairTickets(); +// newTickets.setId(tickets.getId()); +// newTickets.setCount(list.stream().mapToInt(DlRepairTitem::getItemCount).sum()); +// newTickets.setPartPrice(list.stream() +// .filter(item -> item.getItemType().equals("02")) +// .map(DlRepairTitem::getItemMoney) +// .reduce(BigDecimal.ZERO, BigDecimal::add)); +// BigDecimal projectPrice = tickets.getProjectPrice() == null ? BigDecimal.ZERO : tickets.getProjectPrice(); +// BigDecimal otherPrice = tickets.getOtherPrice() != null ? tickets.getOtherPrice() : BigDecimal.ZERO; +// BigDecimal partPrice = newTickets.getPartPrice() == null ? BigDecimal.ZERO : newTickets.getPartPrice(); +// newTickets.setTotalPrice(projectPrice.add(partPrice).add(otherPrice)); +// ticketsService.updateById(newTickets); // 查主表 DlRepairSo newSo = baseMapper.selectById(id); @@ -455,7 +510,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl wareMap = filterWare.stream().collect(Collectors.toMap(DlRepairSoi::getWareId, soi -> soi)); waresList.forEach(item -> { DlRepairSoi filterSoi = wareMap.get(item.getId()); - item.setStock((item.getStock()==null?new BigDecimal(0):item.getStock()).add(new BigDecimal(filterSoi.getInCount()))); + item.setStock((item.getStock() == null ? new BigDecimal(0) : item.getStock()).add(new BigDecimal(filterSoi.getInCount()))); }); waresService.updateBatchById(waresList); - } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java index 6e944f66..c5060b16 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java @@ -340,7 +340,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl oldData = twItemService.list(new LambdaQueryWrapper().in(DlTwItem::getId, respVO.getItems().stream().map(DlTwItem::getId).collect(Collectors.toList()))); + // 分领料和退料 + // 先取出要操作的子表数据 + List oldData = twItemService.list(new LambdaQueryWrapper().and(item -> { + item.eq(DlTwItem::getTwId, respVO.getRepairSo().getTwId()) + .in(DlTwItem::getWaresId, respVO.getRepairSois().stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); + })); + // 要操作的库存数据 + List wares = repairWaresService.list(new LambdaQueryWrapper().in(RepairWares::getId, respVO.getRepairSois().stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()))); + if (type.equals("02")) { // 领料 // 构造新数据 List newData = oldData.stream().map(item -> { DlTwItem dlTwItem = new DlTwItem(); @@ -464,13 +467,85 @@ public class DlTicketWaresServiceImpl extends ServiceImpl i.getGoodsId().equals(item.getWaresId())) .findFirst() .ifPresent(repairSoi -> { - dlTwItem.setWaresCouldCount(repairSoi.getGoodsCount()); - dlTwItem.setWaresStatus(repairSoi.getGoodsCount().equals(item.getWaresCount()) ? "04" : item.getWaresStatus()); + // 先取该申请配件的已领料数量,如过是第一次就是0 + Integer waresAlreadyCount = item.getWaresAlreadyCount() == null ? 0 : item.getWaresAlreadyCount(); + // 取本来的已领取数量+本次要领取的数量 + dlTwItem.setWaresAlreadyCount(repairSoi.getGoodsCount() + waresAlreadyCount); + // 可领取数量就是申请数量-已领料数量 + // item是操作的申请配件的数量,dlTwItem取最新的已领取数量 + dlTwItem.setWaresCouldCount(item.getWaresCount() - dlTwItem.getWaresAlreadyCount()); +// dlTwItem.setWaresStatus(repairSoi.getGoodsCount().equals(item.getWaresCount()) ? "04" : item.getWaresStatus()); + // 如果已领取数量等于申请数量,那这个配件就是领料完了,为01已领料,反之不变 + dlTwItem.setWaresStatus(item.getWaresCount().equals(dlTwItem.getWaresAlreadyCount()) ? "01" : item.getWaresStatus()); }); return dlTwItem; }).collect(Collectors.toList()); twItemService.updateBatchById(newData); + + // 同时操作库存扣减 + // 构造新数据 + List newWares = wares.stream().map(item -> { + RepairWares ware = new RepairWares(); + ware.setId(item.getId()); + respVO.getRepairSois().stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(repairSoi -> ware.setStock(item.getStock().subtract(BigDecimal.valueOf(repairSoi.getGoodsCount())))); + return ware; + }).collect(Collectors.toList()); + // 更新库存 + repairWaresService.updateBatchById(newWares); + } else { // 退料 + // 构造新数据 + List newData = oldData.stream().map(item -> { + DlTwItem dlTwItem = new DlTwItem(); + dlTwItem.setId(item.getId()); + respVO.getRepairSois().stream() + .filter(i -> i.getGoodsId().equals(item.getWaresId())) + .findFirst() + .ifPresent(repairSoi -> { + // 取本来的已领取数量-本次要退料的数量 + dlTwItem.setWaresAlreadyCount(item.getWaresAlreadyCount() - repairSoi.getGoodsCount()); + // 可领取数量就是上次的可领取+退料数量 + // item是操作的可领取数量,repairSoi是取本次退料的数量 + dlTwItem.setWaresCouldCount(item.getWaresCouldCount() + repairSoi.getGoodsCount()); +// dlTwItem.setWaresStatus(repairSoi.getGoodsCount().equals(item.getWaresCount()) ? "04" : item.getWaresStatus()); + // 如果可领料数量等于申请数量,那这个配件就是退料完了,为03已退料,反之不变 + dlTwItem.setWaresStatus(item.getWaresCount().equals(dlTwItem.getWaresCouldCount()) ? "03" : "02"); + }); + return dlTwItem; + }).collect(Collectors.toList()); + twItemService.updateBatchById(newData); + + // 同时操作库存新增 + // 构造新数据 + List newWares = wares.stream().map(item -> { + RepairWares ware = new RepairWares(); + ware.setId(item.getId()); + respVO.getRepairSois().stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(repairSoi -> ware.setStock(item.getStock().add(BigDecimal.valueOf(repairSoi.getGoodsCount())))); + return ware; + }).collect(Collectors.toList()); + // 更新库存 + repairWaresService.updateBatchById(newWares); } +// /* +// 同理,通知领料的数量可能与实际需要的数量不一致,需要重新计算状态 +// */ +// // 先查老数据,领料才需要更新 +// if (type.equals("02")) { +// List oldData = twItemService.list(new LambdaQueryWrapper().in(DlTwItem::getId, respVO.getItems().stream().map(DlTwItem::getId).collect(Collectors.toList()))); +// // 构造新数据 +// List newData = oldData.stream().map(item -> { +// DlTwItem dlTwItem = new DlTwItem(); +// dlTwItem.setId(item.getId()); +// respVO.getRepairSois().stream() +// .filter(i -> i.getGoodsId().equals(item.getWaresId())) +// .findFirst() +// .ifPresent(repairSoi -> { +// dlTwItem.setWaresCouldCount(repairSoi.getGoodsCount()); +// dlTwItem.setWaresStatus(repairSoi.getGoodsCount().equals(item.getWaresCount()) ? "04" : item.getWaresStatus()); +// }); +// return dlTwItem; +// }).collect(Collectors.toList()); +// twItemService.updateBatchById(newData); +// } // 通知维修工 // 查维修工的userId @@ -482,7 +557,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl