From 2457422046717b0fb279ee3d0e939eece68da232 Mon Sep 17 00:00:00 2001 From: bonus <1203338439@qq.com> Date: Sat, 13 Sep 2025 17:26:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E6=96=99=E5=87=BA=E5=BA=93=E3=80=81?= =?UTF-8?q?=E6=9D=90=E6=96=99=E7=AB=99=E7=B1=BB=E5=9E=8B=E6=A0=91=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clz/mapper/MaterialLeaseInfoMapper.java | 7 +++ .../impl/MaterialLeaseInfoServiceImpl.java | 16 ++++-- .../material/common/mapper/SelectMapper.java | 2 + .../material/clz/MaterialLeaseInfoMapper.xml | 57 +++++++++++++++++-- .../mapper/material/common/SelectMapper.xml | 30 ++++++++++ .../material/lease/LeaseApplyInfoMapper.xml | 1 + .../repair/RepairInputDetailsMapper.xml | 2 +- 7 files changed, 106 insertions(+), 9 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialLeaseInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialLeaseInfoMapper.java index fb7f20a5..999499e2 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialLeaseInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialLeaseInfoMapper.java @@ -237,6 +237,13 @@ public interface MaterialLeaseInfoMapper { */ List getUseTypeTree(MaterialLeaseApplyInfo bean); + + /** + * 批量查询 + * @param agreementIds + * @return + */ + List getPlUseTypeTree(@Param("agreementIds") List agreementIds); /** * 根据id查询协议id * @param id 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 59941d11..7cb7bfbd 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 @@ -1371,7 +1371,10 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { if (!CollectionUtils.isEmpty(bean.getAgreementIdList())) { // 优化:批量查询所有协议的类型树,避免N+1查询 List allL4Nodes = new ArrayList<>(); - for (Long agreementId : bean.getAgreementIdList()) { + //合并lsit4和list5 + listL5 = mapper.getTeamClzTree(bean.getAgreementIdList()); + + /* for (Long agreementId : bean.getAgreementIdList()) { backApplyInfo.setAgreementId(agreementId); listL4 = mapper.getUseTypeClzTree(backApplyInfo); if (!CollectionUtils.isEmpty(listL4)) { @@ -1391,13 +1394,18 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { typeNodeMap.put(typeId, node); } } - listL5.addAll(typeNodeMap.values()); + listL5.addAll(typeNodeMap.values());*/ } // 优化:批量查询协议信息,减少数据库访问次数 List listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean); if (!CollectionUtils.isEmpty(listAgreement)) { + + list7= materialLeaseInfoMapper.getPlUseTypeTree(listAgreement); + + + // 批量查询所有协议的使用类型树 - List allTypeNodes = new ArrayList<>(); + /*List allTypeNodes = new ArrayList<>(); for (BmAgreementInfo agreementInfo : listAgreement) { bean.setAgreementId(agreementInfo.getAgreementId()); List list6 = materialLeaseInfoMapper.getUseTypeTree(bean); @@ -1417,7 +1425,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { aggregatedMap.put(typeId, node); } } - list7.addAll(aggregatedMap.values()); + list7.addAll(aggregatedMap.values());*/ } // 根据协议id去clz_slt_agreement_info材料站协议表中查询在用设备,进行数据筛选去除 if (!CollectionUtils.isEmpty(listL5)) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java index 56110232..bad6af1a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java @@ -294,6 +294,8 @@ public interface SelectMapper { */ List getUseTypeClzTree(BackApplyInfo backApplyInfo); + List getTeamClzTree(@Param("agreementId")List agreementId); + /** * 获取班组在用量 * @param bean diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml index 435e38ed..8ffc1ea5 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml @@ -1057,8 +1057,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" lease_publish_details lpd LEFT JOIN lease_apply_info lai ON lai.id = lpd.parent_id LEFT JOIN tm_task tt ON lai.task_id = tt.task_id - LEFT JOIN (SELECT IFNULL( sum(out_num ), 0) AS num, parent_id, publish_task from lease_out_details - GROUP BY parent_id, publish_task) lod ON lpd.parent_id = lod.parent_id + LEFT JOIN ( + SELECT IFNULL( sum(out_num ), 0) AS num, parent_id, publish_task from lease_out_details + + + GROUP BY parent_id, publish_task + + ) lod ON lpd.parent_id = lod.parent_id AND lpd.publish_task = lod.publish_task LEFT JOIN bm_unit bu ON bu.unit_id = lpd.unit_id LEFT JOIN bm_project bp ON bp.pro_id = lpd.project_id @@ -1072,7 +1077,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" JOIN ma_type_keeper mtk ON mtk.type_id = lpd.type_id AND mtk.user_id = #{userId} - where 1 = 1 + @@ -1277,4 +1282,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE lease_id = #{id} - \ No newline at end of file + + + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml index 709b8f15..126ae7b0 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml @@ -885,7 +885,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" HAVING num > 0 +