From 690e7ca22cb682a4b16f09bc7bd58c4ff033064c Mon Sep 17 00:00:00 2001 From: chenqi Date: Mon, 15 Jun 2026 16:47:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(charge):=20=E9=97=A8=E8=AF=8A=E6=97=A5?= =?UTF-8?q?=E7=BB=93=20groupingBy=20null=20key=20=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Collectors.groupingBy 遇到 contractNo/busNo 为 null 的元素会抛 NullPointerException: Element cannot be mapped to a null key 修复: 在 groupingBy 前增加 .filter(e -> key != null && !key.isEmpty()) --- .../impl/IChargeBillServiceImpl.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/paymentmanage/appservice/impl/IChargeBillServiceImpl.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/paymentmanage/appservice/impl/IChargeBillServiceImpl.java index 695026be5..bd2b7ac6e 100755 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/paymentmanage/appservice/impl/IChargeBillServiceImpl.java +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/paymentmanage/appservice/impl/IChargeBillServiceImpl.java @@ -970,7 +970,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { // } // 根据省市医保分组 Map> paymentDetailsMapByContract = PaymentRecDetailAccountResultList - .stream().collect(Collectors.groupingBy(PaymentRecDetailAccountResult::getContractNo)); + .stream() + .filter(e -> e.getContractNo() != null && !e.getContractNo().isEmpty()) + .collect(Collectors.groupingBy(PaymentRecDetailAccountResult::getContractNo)); // 查询所有的收费项 List chargeItemIdStrs = paymentReconciliationList.stream().map(PaymentReconciliation::getChargeItemIds) @@ -1043,7 +1045,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { // 长大版本要显示出来省市医保的区别 List redisContractList = iContractService.getRedisContractList(); Map> contractMapByBusNo - = redisContractList.stream().collect(Collectors.groupingBy(Contract::getBusNo)); + = redisContractList.stream() + .filter(e -> e.getBusNo() != null && !e.getBusNo().isEmpty()) + .collect(Collectors.groupingBy(Contract::getBusNo)); for (Map.Entry> stringListEntry : paymentDetailsMapByContract .entrySet()) { String key = stringListEntry.getKey(); @@ -1445,7 +1449,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { // 医保人次自费人次计算 List list = iEncounterService.getEncounterInfoByTime(startDate, endDate); Map> encounterAccountDtoMapByContract - = list.stream().collect(Collectors.groupingBy(EncounterAccountDto::getContractNo)); + = list.stream() + .filter(e -> e.getContractNo() != null && !e.getContractNo().isEmpty()) + .collect(Collectors.groupingBy(EncounterAccountDto::getContractNo)); for (Map.Entry> stringListEntry : encounterAccountDtoMapByContract .entrySet()) { String key = stringListEntry.getKey(); @@ -1519,7 +1525,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { // 根据省市医保分组 Map> paymentDetailsMapByContract = PaymentRecDetailAccountResultList - .stream().collect(Collectors.groupingBy(PaymentRecDetailAccountResult::getContractNo)); + .stream() + .filter(e -> e.getContractNo() != null && !e.getContractNo().isEmpty()) + .collect(Collectors.groupingBy(PaymentRecDetailAccountResult::getContractNo)); BigDecimal cashSum = BigDecimal.ZERO;// 现金总数 = rmbCashSum + vxCashSum + aliCashSum + uniCashSum BigDecimal rmbCashSum = BigDecimal.ZERO;// 现金总数 @@ -1535,7 +1543,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { // 长大版本要显示出来省市医保的区别 List redisContractList = iContractService.getRedisContractList(); Map> contractMapByBusNo - = redisContractList.stream().collect(Collectors.groupingBy(Contract::getBusNo)); + = redisContractList.stream() + .filter(e -> e.getBusNo() != null && !e.getBusNo().isEmpty()) + .collect(Collectors.groupingBy(Contract::getBusNo)); for (Map.Entry> stringListEntry : paymentDetailsMapByContract .entrySet()) { @@ -1922,7 +1932,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { // 医保人次自费人次计算 List list = iEncounterService.getEncounterInfoByTime(startDate, endDate); Map> encounterAccountDtoMapByContract - = list.stream().collect(Collectors.groupingBy(EncounterAccountDto::getContractNo)); + = list.stream() + .filter(e -> e.getContractNo() != null && !e.getContractNo().isEmpty()) + .collect(Collectors.groupingBy(EncounterAccountDto::getContractNo)); for (Map.Entry> stringListEntry : encounterAccountDtoMapByContract .entrySet()) { String key = stringListEntry.getKey();