From f03701b34b489b358a1c9b5cf5c519b135cebac8 Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Fri, 19 Sep 2025 17:13:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SmErpInventoryRecordsServiceImpl.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmErpInventoryRecordsServiceImpl.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmErpInventoryRecordsServiceImpl.java index f7264e93a..962c88bf5 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmErpInventoryRecordsServiceImpl.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmErpInventoryRecordsServiceImpl.java @@ -251,11 +251,21 @@ public class SmErpInventoryRecordsServiceImpl extends ServiceImpl smErpInventoryRecordsItemEntityList = smerpInventoryRecordsItemEntityMap.get(record.getId()); // record.setTotalAmount(totalAmount); //todo 这里有一个问题就是出入库编辑的时候,没有更新主表的totalAmount,所以一直用的子表的totalAmount,子表的totalAmount又存在为空的情况,涉及到多个业务 - record.setTotalAmount(smErpInventoryRecordsItemEntityList.stream().mapToInt(item -> item.getTotalAmount()==null?0:item.getTotalAmount()).sum()); + //存在脏数据,判断下,防止空数据查询报错 + if (!CollectionUtils.isEmpty(smErpInventoryRecordsItemEntityList)) { + record.setTotalAmount(smErpInventoryRecordsItemEntityList.stream().mapToInt(item -> item.getTotalAmount()==null?0:item.getTotalAmount()).sum()); + }else { + record.setTotalAmount(0); + } + }); Set erpSpuIds = cgPlanItemEntities.stream().map(SmErpInventoryRecordsItemEntity::getErpSpuId).collect(Collectors.toSet()); - List smErpSpuEntities = smErpSpuMapper.selectList(new LambdaQueryWrapper().in(SmErpSpuEntity::getId, erpSpuIds)); + List smErpSpuEntities=new ArrayList<>(); + //存在脏数据,判断下,防止空数据查询报错 + if (!CollectionUtils.isEmpty(erpSpuIds)){ + smErpSpuEntities = smErpSpuMapper.selectList(new LambdaQueryWrapper().in(SmErpSpuEntity::getId, erpSpuIds)); + } Map spuMap = smErpSpuEntities.stream().collect(Collectors.toMap(SmErpSpuEntity::getId, spu -> spu));