From bfb2491842b8d92c0ece182bd9a8b4ba348559bf Mon Sep 17 00:00:00 2001 From: chenqi Date: Thu, 2 Apr 2026 18:22:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=94=B6=E8=B4=B9?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=94=99=E8=AF=AF=20'element=20cannot=20be?= =?UTF-8?q?=20mapped=20to=20a=20null=20key'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 PaymentRecServiceImpl.java 中添加过滤,排除 contractNo 为 null 的数据 - 在 IChargeBillServiceImpl.java 中添加过滤,排除 contractNo 为 null 的数据 - 防止 Java Stream groupingBy 操作时出现 null key 异常 --- .../appservice/impl/IChargeBillServiceImpl.java | 16 ++++++++++++---- .../appservice/impl/PaymentRecServiceImpl.java | 8 ++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/IChargeBillServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/IChargeBillServiceImpl.java index cac8a2bb..64311b46 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/IChargeBillServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/IChargeBillServiceImpl.java @@ -933,7 +933,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { // } // 根据省市医保分组 Map> paymentDetailsMapByContract = PaymentRecDetailAccountResultList - .stream().collect(Collectors.groupingBy(PaymentRecDetailAccountResult::getContractNo)); + .stream() + .filter(dto -> dto.getContractNo() != null && !dto.getContractNo().isEmpty()) + .collect(Collectors.groupingBy(PaymentRecDetailAccountResult::getContractNo)); // 查询所有的收费项 List chargeItemIdStrs = paymentReconciliationList.stream().map(PaymentReconciliation::getChargeItemIds) @@ -1408,7 +1410,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { // 医保人次自费人次计算 List list = iEncounterService.getEncounterInfoByTime(startDate, endDate); Map> encounterAccountDtoMapByContract - = list.stream().collect(Collectors.groupingBy(EncounterAccountDto::getContractNo)); + = list.stream() + .filter(dto -> dto.getContractNo() != null && !dto.getContractNo().isEmpty()) + .collect(Collectors.groupingBy(EncounterAccountDto::getContractNo)); for (Map.Entry> stringListEntry : encounterAccountDtoMapByContract .entrySet()) { String key = stringListEntry.getKey(); @@ -1482,7 +1486,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { // 根据省市医保分组 Map> paymentDetailsMapByContract = PaymentRecDetailAccountResultList - .stream().collect(Collectors.groupingBy(PaymentRecDetailAccountResult::getContractNo)); + .stream() + .filter(dto -> dto.getContractNo() != null && !dto.getContractNo().isEmpty()) + .collect(Collectors.groupingBy(PaymentRecDetailAccountResult::getContractNo)); BigDecimal cashSum = BigDecimal.ZERO;// 现金总数 = rmbCashSum + vxCashSum + aliCashSum + uniCashSum BigDecimal rmbCashSum = BigDecimal.ZERO;// 现金总数 @@ -1885,7 +1891,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { // 医保人次自费人次计算 List list = iEncounterService.getEncounterInfoByTime(startDate, endDate); Map> encounterAccountDtoMapByContract - = list.stream().collect(Collectors.groupingBy(EncounterAccountDto::getContractNo)); + = list.stream() + .filter(dto -> dto.getContractNo() != null && !dto.getContractNo().isEmpty()) + .collect(Collectors.groupingBy(EncounterAccountDto::getContractNo)); for (Map.Entry> stringListEntry : encounterAccountDtoMapByContract .entrySet()) { String key = stringListEntry.getKey(); diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/PaymentRecServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/PaymentRecServiceImpl.java index 5d24d3d6..8ed7ea4a 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/PaymentRecServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/PaymentRecServiceImpl.java @@ -2331,7 +2331,9 @@ public class PaymentRecServiceImpl implements IPaymentRecService { = iChargeItemService.getChargeItemBaseInfoByIds(prePaymentDto.getChargeItemIds()); Map> chargeItemKVByContractNo - = chargeItemBaseInfoByIds.stream().collect(Collectors.groupingBy(ChargeItemBaseInfoDto::getContractNo)); + = chargeItemBaseInfoByIds.stream() + .filter(dto -> dto.getContractNo() != null && !dto.getContractNo().isEmpty()) + .collect(Collectors.groupingBy(ChargeItemBaseInfoDto::getContractNo)); List yb2303OutputSetInfos = new ArrayList<>(); Yb2303OutputSetInfo yb2303OutputSetInfo; @@ -2459,7 +2461,9 @@ public class PaymentRecServiceImpl implements IPaymentRecService { List chargeItemBaseInfoByIds = iChargeItemService.getChargeItemBaseInfoByIds(paymentDto.getChargeItemIds()); Map> chargeItemKVByContractNo - = chargeItemBaseInfoByIds.stream().collect(Collectors.groupingBy(ChargeItemBaseInfoDto::getContractNo)); + = chargeItemBaseInfoByIds.stream() + .filter(dto -> dto.getContractNo() != null && !dto.getContractNo().isEmpty()) + .collect(Collectors.groupingBy(ChargeItemBaseInfoDto::getContractNo)); List accountList = iAccountService.getAccountListByEncounter(paymentDto.getEncounterId()); if (accountList.isEmpty()) {