bug修复

(cherry picked from commit 6b4ec9c046)
This commit is contained in:
xiaofajia 2024-11-02 16:41:02 +08:00 committed by Vinjor
parent 11c1e759aa
commit bb93d842ec

View File

@ -1178,10 +1178,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
}));
// 查配件申请表的所有已领取数量小于申请数量的子表信息
List<String> ids = list.stream().map(DlTicketWares::getId).collect(Collectors.toList());
List<DlTwItem> twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
item.in(DlTwItem::getTwId, ids)
.apply("wares_already_count < wares_count");
}));
List<DlTwItem> twItems = new ArrayList<>();
if (CollectionUtil.isNotEmpty(ids)){
twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
item.in(DlTwItem::getTwId, ids)
.apply("wares_already_count < wares_count");
}));
}
if (CollectionUtil.isNotEmpty(twItems)) {
// 更新工单子表主要是把已领料的字段同步给工单配件的数量字段
// 查询工单子表三个查询条件属于那个工单属于配件类型属于需要改变的即申请表的已领取数量小于申请数量的
@ -1192,10 +1195,11 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
.in(DlRepairTitem::getPartId, waresId);
}));
// 同一个配件可能申请过多次属于是一个工单配件可能是对应多个申请表配件
List<DlTwItem> finalTwItems = twItems;
List<DlRepairTitem> AllItems = items.stream().map(item -> {
DlRepairTitem titem = new DlRepairTitem();
titem.setId(item.getId());
List<DlTwItem> wares = twItems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).collect(Collectors.toList());
List<DlTwItem> wares = finalTwItems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).collect(Collectors.toList());
int sum = wares.stream().mapToInt(DlTwItem::getWaresAlreadyCount).sum();
titem.setItemCount(sum);
BigDecimal discount = item.getItemDiscount() == null ? BigDecimal.ONE : item.getItemDiscount();