This commit is contained in:
zjf committed 2025-09-19 17:13:16 +08:00
1 parent c4939ee479
commit f03701b34b
1 file changed
+12 -2
@@ -251,11 +251,21 @@ public class SmErpInventoryRecordsServiceImpl extends ServiceImpl<SmErpInventory
List<SmErpInventoryRecordsItemEntity> 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<Long> erpSpuIds = cgPlanItemEntities.stream().map(SmErpInventoryRecordsItemEntity::getErpSpuId).collect(Collectors.toSet());
List<SmErpSpuEntity> smErpSpuEntities = smErpSpuMapper.selectList(new LambdaQueryWrapper<SmErpSpuEntity>().in(SmErpSpuEntity::getId, erpSpuIds));
List<SmErpSpuEntity> smErpSpuEntities=new ArrayList<>();
//存在脏数据,判断下,防止空数据查询报错
if (!CollectionUtils.isEmpty(erpSpuIds)){
smErpSpuEntities = smErpSpuMapper.selectList(new LambdaQueryWrapper<SmErpSpuEntity>().in(SmErpSpuEntity::getId, erpSpuIds));
}
Map<Long,SmErpSpuEntity> spuMap = smErpSpuEntities.stream().collect(Collectors.toMap(SmErpSpuEntity::getId, spu -> spu));