优化物资数量批量查询性能
- 修改 getNumListBatch 接口返回类型,从 Map<Long, BigDecimal>改为 List<Type> - 在服务实现中对批量查询结果进行转换,提高数据处理效率 - 更新 XML 配置,调整查询结果映射类型
This commit is contained in:
parent
82d6ab70d9
commit
0f3582ab4c
|
|
@ -1457,7 +1457,14 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
|||
.collect(Collectors.toList());
|
||||
|
||||
// 批量查询使用数量 - 性能优化关键点
|
||||
useNumMap = typeMapper.getNumListBatch(agreementInfo.getAgreementId(), typeIds);
|
||||
List<Type> 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));
|
||||
}
|
||||
}
|
||||
|
||||
// 设置使用数量
|
||||
|
|
|
|||
|
|
@ -216,9 +216,9 @@ public interface TypeMapper {
|
|||
* 批量查询数量 - 性能优化
|
||||
* @param agreementId 协议ID
|
||||
* @param typeIds 类型ID列表
|
||||
* @return 类型ID到使用数量的映射
|
||||
* @return 类型使用数量列表
|
||||
*/
|
||||
Map<Long, BigDecimal> getNumListBatch(@Param("agreementId") Long agreementId, @Param("typeIds") List<Long> typeIds);
|
||||
List<Type> getNumListBatch(@Param("agreementId") Long agreementId, @Param("typeIds") List<Long> typeIds);
|
||||
|
||||
/**
|
||||
* 查询物资类型管理绑定的用户列表
|
||||
|
|
|
|||
|
|
@ -1089,7 +1089,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<!-- 批量查询数量 - 性能优化 -->
|
||||
<select id="getNumListBatch" resultType="java.util.HashMap">
|
||||
<select id="getNumListBatch" resultType="com.bonus.material.ma.domain.Type">
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue