From 6b623f2eab57440643a300e705cbddcd9328b84a Mon Sep 17 00:00:00 2001 From: mashuai Date: Fri, 19 Sep 2025 15:43:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MaterialLeaseInfoServiceImpl.java | 56 ------------------- .../material/clz/MaterialLeaseInfoMapper.xml | 30 +++------- .../mapper/material/common/SelectMapper.xml | 3 +- 3 files changed, 8 insertions(+), 81 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 15656d6d..6ead812e 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 @@ -1319,75 +1319,19 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { List groupList = new ArrayList<>(); List list = new ArrayList<>(); - List listL4 = new ArrayList<>(); List listL3 = new ArrayList<>(); List listL21 = new ArrayList<>(); List listL5 = new ArrayList<>(); List list7 = new ArrayList<>(); try { - // 优化:使用Map来避免重复的Stream查找操作 - Map typeNodeMap = new HashMap<>(); - - // 先查第四层类型 - BackApplyInfo backApplyInfo = new BackApplyInfo(); if (!CollectionUtils.isEmpty(bean.getAgreementIdList())) { - // 优化:批量查询所有协议的类型树,避免N+1查询 - List allL4Nodes = new ArrayList<>(); //合并lsit4和list5 listL5 = mapper.getTeamClzTree(bean.getAgreementIdList()); - - /* for (Long agreementId : bean.getAgreementIdList()) { - backApplyInfo.setAgreementId(agreementId); - listL4 = mapper.getUseTypeClzTree(backApplyInfo); - if (!CollectionUtils.isEmpty(listL4)) { - allL4Nodes.addAll(listL4.stream() - .filter(item -> StringUtils.isNotBlank(item.getMaterialName()) && StringUtils.isNotBlank(item.getTypeName())) - .collect(Collectors.toList())); - } - } - - // 优化:使用Map进行聚合,避免重复的Stream查找 - for (TypeTreeNode node : allL4Nodes) { - Long typeId = node.getTypeId(); - if (typeNodeMap.containsKey(typeId)) { - TypeTreeNode existingNode = typeNodeMap.get(typeId); - existingNode.setNum(existingNode.getNum().add(node.getNum())); - } else { - typeNodeMap.put(typeId, node); - } - } - listL5.addAll(typeNodeMap.values());*/ } // 优化:批量查询协议信息,减少数据库访问次数 List listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean); if (!CollectionUtils.isEmpty(listAgreement)) { - list7= materialLeaseInfoMapper.getPlUseTypeTree(listAgreement); - - - - // 批量查询所有协议的使用类型树 - /*List allTypeNodes = new ArrayList<>(); - for (BmAgreementInfo agreementInfo : listAgreement) { - bean.setAgreementId(agreementInfo.getAgreementId()); - List list6 = materialLeaseInfoMapper.getUseTypeTree(bean); - if (!CollectionUtils.isEmpty(list6)) { - allTypeNodes.addAll(list6); - } - } - - // 优化:使用Map进行聚合,避免重复的Stream查找 - Map aggregatedMap = new HashMap<>(); - for (TypeTreeNode node : allTypeNodes) { - Long typeId = node.getTypeId(); - if (aggregatedMap.containsKey(typeId)) { - TypeTreeNode existingNode = aggregatedMap.get(typeId); - existingNode.setNum(existingNode.getNum().add(node.getNum())); - } else { - aggregatedMap.put(typeId, node); - } - } - list7.addAll(aggregatedMap.values());*/ } // 根据协议id去clz_slt_agreement_info材料站协议表中查询在用设备,进行数据筛选去除 if (!CollectionUtils.isEmpty(listL5)) { 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 aab88ff9..a426f02c 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 @@ -1058,7 +1058,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN bm_unit bu ON ba.unit_id = bu.unit_id and bu.del_flag = '0' WHERE sai.status = '0' - AND bu.type_id = '36' + AND bu.type_id in ('32', '36') AND mt.type_id = #{typeId} AND ba.project_id = #{proId} @@ -1376,9 +1376,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt.unit_name AS unitName, mt.unit_value AS unitValue, mt.manage_type AS manageType, - sai.agreement_id, - SUM( if(sai.STATUS = '0' ,sai.num, 0) ) AS num, - + SUM(IFNULL( sai.num, 0 )) AS num, mt.LEVEL AS LEVEL FROM ma_type mt @@ -1386,29 +1384,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0' WHERE - sai.agreement_id in + sai.STATUS = '0' + AND sai.agreement_id in #{agreement.agreementId} - and - EXISTS ( - SELECT - 1 - FROM - clz_slt_agreement_info sai2 - WHERE - sai2.type_id = mt.type_id - AND sai2.agreement_id in - - #{agreement.agreementId} - - AND sai.STATUS = '0' - AND IFNULL( sai.lease_type, 0 ) = 0 - AND sai2.num > 0 - ) GROUP BY - mt.type_id, - sai.agreement_id + mt.type_id + HAVING + num > 0 SELECT mt.type_id as typeId, - sai.agreement_id, mt1.type_name as materialName, mt.type_name as typeName, mt.parent_id as parentId, @@ -916,7 +915,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" GROUP BY - mt.type_id,sai.agreement_id + mt.type_id HAVING num > 0