From 0a5f26e9c08fad252507c386254cdeedd0bf73d6 Mon Sep 17 00:00:00 2001 From: chenqi Date: Thu, 2 Apr 2026 18:44:06 +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'=20-=20=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 PaymentRecServiceImpl.java 第 2472 行 groupingBy(Account::getId) - 修复 PaymentRecServiceImpl.java 第 264 行 groupingBy(ChargeItem::getAccountId) - 修复 IChargeBillServiceImpl.java 多处 groupingBy 可能遇到的 null key 问题 --- .../appservice/impl/IChargeBillServiceImpl.java | 8 ++++++-- .../appservice/impl/PaymentRecServiceImpl.java | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 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 64311b46..79098fb5 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 @@ -487,7 +487,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { return getMap(map); } Map> paymentDetailsKV - = paymentDetails.stream().collect(Collectors.groupingBy(PaymentRecDetail::getReconciliationId)); + = paymentDetails.stream() + .filter(detail -> detail.getReconciliationId() != null) + .collect(Collectors.groupingBy(PaymentRecDetail::getReconciliationId)); // 声明变量,符合要求的付款记录 Collection PaymentReconciliationList; List accountList = new ArrayList<>(); @@ -568,7 +570,9 @@ public class IChargeBillServiceImpl implements IChargeBillService { throw new ServiceException("未查询到收费记录,无收费项信息"); } Map> chargeItemDefKV - = chargeItemDefinitions.stream().collect(Collectors.groupingBy(ChargeItemDefinition::getId)); + = chargeItemDefinitions.stream() + .filter(def -> def.getId() != null) + .collect(Collectors.groupingBy(ChargeItemDefinition::getId)); // 查询医保结算id List settleIds = new ArrayList<>(); 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 8ed7ea4a..71de68d9 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 @@ -261,7 +261,9 @@ public class PaymentRecServiceImpl implements IPaymentRecService { // 账户id,对应的账单列表 Map> chargeItemMapByAccountId - = chargeItemList.stream().collect(Collectors.groupingBy(ChargeItem::getAccountId)); + = chargeItemList.stream() + .filter(item -> item.getAccountId() != null) + .collect(Collectors.groupingBy(ChargeItem::getAccountId)); // 查询合同信息 List contractList = contractService.list(); @@ -2469,7 +2471,9 @@ public class PaymentRecServiceImpl implements IPaymentRecService { if (accountList.isEmpty()) { throw new ServiceException("未查询到账户信息"); } - Map> accountKVById = accountList.stream().collect(Collectors.groupingBy(Account::getId)); + Map> accountKVById = accountList.stream() + .filter(acc -> acc.getId() != null) + .collect(Collectors.groupingBy(Account::getId)); com.openhis.financial.model.PaymentResult paymentResult; List paymentResultList = new ArrayList<>(); @@ -2479,7 +2483,9 @@ public class PaymentRecServiceImpl implements IPaymentRecService { // <3>收费详情按照收费批次进行分组后结算 Map> payTransNoMap - = paymentRecDetails.stream().collect(Collectors.groupingBy(PaymentRecDetail::getAccountId)); + = paymentRecDetails.stream() + .filter(detail -> detail.getAccountId() != null) + .collect(Collectors.groupingBy(PaymentRecDetail::getAccountId)); for (Map.Entry> stringListEntry : payTransNoMap.entrySet()) { // paymentResult = new PaymentResult();