From 513d96dca765e1aa1f33aceecc6dff191f8cb7a0 Mon Sep 17 00:00:00 2001 From: hayu <1604366271@qq.com> Date: Sat, 13 Sep 2025 15:29:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/machine/MaterialStorageInfo.java | 3 + .../clz/mapper/MaterialMachineMapper.java | 7 ++ .../impl/MaterialMachineServiceImpl.java | 63 ++++++++++------ .../material/clz/MaterialMachineMapper.xml | 73 +++++++++++++++---- 4 files changed, 110 insertions(+), 36 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/machine/MaterialStorageInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/machine/MaterialStorageInfo.java index 38624a74..1d19692a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/machine/MaterialStorageInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/machine/MaterialStorageInfo.java @@ -61,6 +61,9 @@ public class MaterialStorageInfo { @ApiModelProperty(value = "关键字") private String keyWord; + @ApiModelProperty(value = "班组id") + private String teamId; + @ApiModelProperty(value = "班组名称") private String teamName; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialMachineMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialMachineMapper.java index e61519b1..0289163b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialMachineMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialMachineMapper.java @@ -214,4 +214,11 @@ public interface MaterialMachineMapper { * @return */ List getUsInfoList(MaterialRetainedEquipmentInfo bean); + + /** + * 获取材料站设备详情 + * @param bean + * @return + */ + List getMaCodeDetails(MaterialStorageInfo bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java index ec7e7c69..3858c3b6 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java @@ -20,6 +20,7 @@ import com.bonus.material.clz.domain.machine.MaterialStorageInfo; import com.bonus.material.clz.mapper.MaterialMachineMapper; import com.bonus.material.clz.service.MaterialMachineService; import lombok.extern.slf4j.Slf4j; +import org.hibernate.validator.internal.util.StringHelper; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -173,16 +174,26 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { String subUnitName = iwsTeamUserMapper.getTeamName(materialRetainedEquipmentInfo.getTeamName()); materialRetainedEquipmentInfo.setSubUnitName(subUnitName); } - // 数据合并 - if (!CollectionUtils.isEmpty(recordList)) { - usList.addAll(recordList); - } - if (teamData != null) { + } + // 数据合并 + if (!CollectionUtils.isEmpty(recordList)) { + usList.addAll(recordList); + } + if (!CollectionUtils.isEmpty(usList)){ + if (teamData != null){ // 将sortedList中班组身份证号与username相同的元素过滤处理 usList = usList.stream() .filter(item -> StringUtils.isBlank(item.getIdCard()) || username.equals(item.getIdCard())) .collect(Collectors.toList()); } + String subUnitName = bean.getSubUnitName(); + + if (!CollectionUtils.isEmpty(usList)) { + usList = usList.stream() + .filter(item -> StringUtils.isBlank(subUnitName) + || (item.getSubUnitName() != null && item.getSubUnitName().contains(subUnitName))) + .collect(Collectors.toList()); + } } return usList; } @@ -226,23 +237,31 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { @Override public List getMaCodeList(MaterialStorageInfo bean) { try { - // 查询库管员 - List list = materialMachineMapper.getMaCodeList(bean); - MaterialUseStorageInfo materialUseStorageInfo = new MaterialUseStorageInfo(); - materialUseStorageInfo.setProId(StringUtils.isNotBlank(bean.getProId()) ? bean.getProId() : null); - materialUseStorageInfo.setTypeId(bean.getTypeId() != null ? bean.getTypeId() : null); - List userList = materialMachineMapper.getUserRecords(materialUseStorageInfo); - if (CollectionUtils.isNotEmpty(list)) { - if (CollectionUtils.isNotEmpty(userList)) { - list.removeIf(info -> { - for (MaterialUseStorageInfo useStorageInfo : userList) { - if (info.getMaId().equals(useStorageInfo.getMaId())) { - return true; - } - } - return false; - }); - } +// // 查询库管员 +// List list = materialMachineMapper.getMaCodeList(bean); +// MaterialUseStorageInfo materialUseStorageInfo = new MaterialUseStorageInfo(); +// materialUseStorageInfo.setProId(StringUtils.isNotBlank(bean.getProId()) ? bean.getProId() : null); +// materialUseStorageInfo.setTypeId(bean.getTypeId() != null ? bean.getTypeId() : null); +// List userList = materialMachineMapper.getUserRecords(materialUseStorageInfo); +// if (CollectionUtils.isNotEmpty(list)) { +// if (CollectionUtils.isNotEmpty(userList)) { +// list.removeIf(info -> { +// for (MaterialUseStorageInfo useStorageInfo : userList) { +// if (info.getMaId()!=null && useStorageInfo.getMaId()!=null){ +// if (info.getMaId().equals(useStorageInfo.getMaId())) { +// return true; +// } +// } +// } +// return false; +// }); +// } +// } + List list = new ArrayList<>(); + if (!StringHelper.isNullOrEmptyString(bean.getTeamId())){ + list = materialMachineMapper.getMaCodeDetails(bean); + } else { + list = materialMachineMapper.getMaCodeList(bean); } if (CollectionUtils.isNotEmpty(list)) { for (MaterialStorageInfo useStorageInfo : list) { diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml index c4f6be01..e049cfed 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml @@ -1197,7 +1197,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" IFNULL(subquery3.usNum, 0) AS usNum, IFNULL(subquery1.usNum, 0) AS allNum, subquery1.proCenter AS departName, - subquery1.departName AS impUnitName + subquery1.departName AS impUnitName, + CASE mt.manage_type + WHEN 0 THEN + '编码' + ELSE + '数量' + END manageType FROM ma_type mt LEFT JOIN ( SELECT @@ -1278,19 +1284,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE mt.`level` = 4 and mt.del_flag = '0' AND IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0) > 0 - AND subquery1.departName = #{impUnitName} + AND subquery1.departName like concat('%',#{impUnitName},'%') - AND subquery1.proName = #{proName} + AND subquery1.proName like concat('%',#{proName},'%') - AND subquery1.proCenter = #{departName} + AND subquery1.proCenter like concat('%',#{departName},'%') - AND mt2.type_name = #{typeName} + AND mt2.type_name like concat('%',#{typeName},'%') - AND mt.type_name = #{typeModelName} + AND mt.type_name like concat('%',#{typeModelName},'%') and subquery1.externalId in @@ -1306,7 +1312,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + \ No newline at end of file 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 2/2] =?UTF-8?q?=E9=A2=86=E6=96=99=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E3=80=81=E6=9D=90=E6=96=99=E7=AB=99=E7=B1=BB=E5=9E=8B=E6=A0=91?= =?UTF-8?q?=E6=9F=A5=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 +