From 0f3582ab4c4d788fa159589a8472012f5d0c20fc Mon Sep 17 00:00:00 2001 From: syruan <15555146157@163.com> Date: Sat, 6 Sep 2025 16:53:50 +0800 Subject: [PATCH] =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E7=89=A9=E8=B5=84?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E6=80=A7?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 getNumListBatch 接口返回类型,从 Map改为 List - 在服务实现中对批量查询结果进行转换,提高数据处理效率 - 更新 XML 配置,调整查询结果映射类型 --- .../clz/service/impl/MaterialLeaseInfoServiceImpl.java | 9 ++++++++- .../java/com/bonus/material/ma/mapper/TypeMapper.java | 4 ++-- .../src/main/resources/mapper/material/ma/TypeMapper.xml | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java index 8a763163..27878621 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java @@ -1457,7 +1457,14 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { .collect(Collectors.toList()); // 批量查询使用数量 - 性能优化关键点 - useNumMap = typeMapper.getNumListBatch(agreementInfo.getAgreementId(), typeIds); + List batchResults = typeMapper.getNumListBatch(agreementInfo.getAgreementId(), typeIds); + + // 转换为Map + if (!CollectionUtils.isEmpty(batchResults)) { + useNumMap = batchResults.stream() + .filter(type -> type.getTypeId() != null && type.getUseNum() != null) + .collect(Collectors.toMap(Type::getTypeId, Type::getUseNum)); + } } // 设置使用数量 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java index 37e8c049..6cec25c9 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java @@ -216,9 +216,9 @@ public interface TypeMapper { * 批量查询数量 - 性能优化 * @param agreementId 协议ID * @param typeIds 类型ID列表 - * @return 类型ID到使用数量的映射 + * @return 类型使用数量列表 */ - Map getNumListBatch(@Param("agreementId") Long agreementId, @Param("typeIds") List typeIds); + List getNumListBatch(@Param("agreementId") Long agreementId, @Param("typeIds") List typeIds); /** * 查询物资类型管理绑定的用户列表 diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 8c9d2701..e9e15522 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -1089,7 +1089,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - SELECT mt.type_id as typeId, SUM( CASE WHEN sai.agreement_id = #{agreementId} AND sai.STATUS = '0' THEN sai.num ELSE 0 END ) AS useNum