diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java index cf06aad0..fbe89c2b 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java @@ -200,4 +200,13 @@ public interface DlRepairTicketsService extends IService { * @param respVO 主要有两个参数,主表ID,itemList(这个需要前端处理成子表的对象能接收的数据) **/ void addItems(DlRepairTicketsRespVO respVO); + + /** + * 用于同步一个工单的所有配件申请表的数据到维修工单,主要针对已领取数量小于申请数量的情况 + * + * @author 小李 + * @date 9:52 2024/10/26 + * @param id 维修工单ID + **/ + boolean syncTicketWaresToTicket(String id); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java index 65f79d55..3a83af0d 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java @@ -679,6 +679,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl status = new ArrayList<>(); status.add("01"); // 待审核 status.add("05"); // 已驳回 // 查工单所有已通过的配件申请单 List list = ticketWaresService.list(new LambdaQueryWrapper().and(item -> { - item.eq(DlTicketWares::getTicketId, respVO.getId()) + item.eq(DlTicketWares::getTicketId, id) .notIn(DlTicketWares::getStatus, status); })); // 查配件申请表的所有已领取数量小于申请数量的子表信息 @@ -825,12 +851,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl waresId = twItems.stream().map(DlTwItem::getWaresId).collect(Collectors.toSet()); List items = titemService.list(new LambdaQueryWrapper().and(item -> { - item.eq(DlRepairTitem::getTicketId, respVO.getId()) + item.eq(DlRepairTitem::getTicketId, id) .eq(DlRepairTitem::getItemType, "02") .in(DlRepairTitem::getPartId, waresId); })); // 同一个配件可能申请过多次,属于是一个工单配件可能是对应多个申请表配件 - List updateItems = items.stream().map(item -> { + List AllItems = items.stream().map(item -> { DlRepairTitem titem = new DlRepairTitem(); titem.setId(item.getId()); List wares = twItems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).collect(Collectors.toList()); @@ -841,19 +867,27 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl delItems = AllItems.stream().filter(item -> item.getItemCount() == 0).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(delItems)){ + // 删除需要删的 + titemService.removeBatchByIds(delItems); + Set delIds = delItems.stream().map(DlRepairTitem::getId).collect(Collectors.toSet()); + // 得到需要改的 + List updateItems = AllItems.stream().filter(item -> delIds.contains(item.getId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(updateItems)){ + titemService.updateBatchById(updateItems); + } + }else { + // 没有需要删的就是全部都需要改 + titemService.updateBatchById(AllItems); + } // 重新计算维修工单 - boolean flag = computeTicket(respVO.getId()); - if (!flag){ - throw exception0(500, "系统异常"); - } + return computeTicket(id); } - - // 通知服务顾问 - DlRepairTickets tickets = baseMapper.selectById(respVO.getId()); - repairWorkerService.sentMessage(Long.valueOf(tickets.getAdviserId()), "您有新的工单可以出厂检验"); + return true; } /**