领料出库、材料站类型树查询优化
This commit is contained in:
parent
513d96dca7
commit
2457422046
|
|
@ -237,6 +237,13 @@ public interface MaterialLeaseInfoMapper {
|
||||||
*/
|
*/
|
||||||
List<TypeTreeNode> getUseTypeTree(MaterialLeaseApplyInfo bean);
|
List<TypeTreeNode> getUseTypeTree(MaterialLeaseApplyInfo bean);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询
|
||||||
|
* @param agreementIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TypeTreeNode> getPlUseTypeTree(@Param("agreementIds") List<BmAgreementInfo> agreementIds);
|
||||||
/**
|
/**
|
||||||
* 根据id查询协议id
|
* 根据id查询协议id
|
||||||
* @param id
|
* @param id
|
||||||
|
|
|
||||||
|
|
@ -1371,7 +1371,10 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
||||||
if (!CollectionUtils.isEmpty(bean.getAgreementIdList())) {
|
if (!CollectionUtils.isEmpty(bean.getAgreementIdList())) {
|
||||||
// 优化:批量查询所有协议的类型树,避免N+1查询
|
// 优化:批量查询所有协议的类型树,避免N+1查询
|
||||||
List<TypeTreeNode> allL4Nodes = new ArrayList<>();
|
List<TypeTreeNode> allL4Nodes = new ArrayList<>();
|
||||||
for (Long agreementId : bean.getAgreementIdList()) {
|
//合并lsit4和list5
|
||||||
|
listL5 = mapper.getTeamClzTree(bean.getAgreementIdList());
|
||||||
|
|
||||||
|
/* for (Long agreementId : bean.getAgreementIdList()) {
|
||||||
backApplyInfo.setAgreementId(agreementId);
|
backApplyInfo.setAgreementId(agreementId);
|
||||||
listL4 = mapper.getUseTypeClzTree(backApplyInfo);
|
listL4 = mapper.getUseTypeClzTree(backApplyInfo);
|
||||||
if (!CollectionUtils.isEmpty(listL4)) {
|
if (!CollectionUtils.isEmpty(listL4)) {
|
||||||
|
|
@ -1391,13 +1394,18 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
||||||
typeNodeMap.put(typeId, node);
|
typeNodeMap.put(typeId, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listL5.addAll(typeNodeMap.values());
|
listL5.addAll(typeNodeMap.values());*/
|
||||||
}
|
}
|
||||||
// 优化:批量查询协议信息,减少数据库访问次数
|
// 优化:批量查询协议信息,减少数据库访问次数
|
||||||
List<BmAgreementInfo> listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean);
|
List<BmAgreementInfo> listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean);
|
||||||
if (!CollectionUtils.isEmpty(listAgreement)) {
|
if (!CollectionUtils.isEmpty(listAgreement)) {
|
||||||
|
|
||||||
|
list7= materialLeaseInfoMapper.getPlUseTypeTree(listAgreement);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 批量查询所有协议的使用类型树
|
// 批量查询所有协议的使用类型树
|
||||||
List<TypeTreeNode> allTypeNodes = new ArrayList<>();
|
/*List<TypeTreeNode> allTypeNodes = new ArrayList<>();
|
||||||
for (BmAgreementInfo agreementInfo : listAgreement) {
|
for (BmAgreementInfo agreementInfo : listAgreement) {
|
||||||
bean.setAgreementId(agreementInfo.getAgreementId());
|
bean.setAgreementId(agreementInfo.getAgreementId());
|
||||||
List<TypeTreeNode> list6 = materialLeaseInfoMapper.getUseTypeTree(bean);
|
List<TypeTreeNode> list6 = materialLeaseInfoMapper.getUseTypeTree(bean);
|
||||||
|
|
@ -1417,7 +1425,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
||||||
aggregatedMap.put(typeId, node);
|
aggregatedMap.put(typeId, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list7.addAll(aggregatedMap.values());
|
list7.addAll(aggregatedMap.values());*/
|
||||||
}
|
}
|
||||||
// 根据协议id去clz_slt_agreement_info材料站协议表中查询在用设备,进行数据筛选去除
|
// 根据协议id去clz_slt_agreement_info材料站协议表中查询在用设备,进行数据筛选去除
|
||||||
if (!CollectionUtils.isEmpty(listL5)) {
|
if (!CollectionUtils.isEmpty(listL5)) {
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,8 @@ public interface SelectMapper {
|
||||||
*/
|
*/
|
||||||
List<TypeTreeNode> getUseTypeClzTree(BackApplyInfo backApplyInfo);
|
List<TypeTreeNode> getUseTypeClzTree(BackApplyInfo backApplyInfo);
|
||||||
|
|
||||||
|
List<TypeTreeNode> getTeamClzTree(@Param("agreementId")List<Long> agreementId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取班组在用量
|
* 获取班组在用量
|
||||||
* @param bean
|
* @param bean
|
||||||
|
|
|
||||||
|
|
@ -1057,8 +1057,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
lease_publish_details lpd
|
lease_publish_details lpd
|
||||||
LEFT JOIN lease_apply_info lai ON lai.id = lpd.parent_id
|
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 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
|
LEFT JOIN (
|
||||||
GROUP BY parent_id, publish_task) lod ON lpd.parent_id = lod.parent_id
|
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
|
AND lpd.publish_task = lod.publish_task
|
||||||
LEFT JOIN bm_unit bu ON bu.unit_id = lpd.unit_id
|
LEFT JOIN bm_unit bu ON bu.unit_id = lpd.unit_id
|
||||||
LEFT JOIN bm_project bp ON bp.pro_id = lpd.project_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"
|
||||||
<if test="userId != null">
|
<if test="userId != null">
|
||||||
JOIN ma_type_keeper mtk ON mtk.type_id = lpd.type_id AND mtk.user_id = #{userId}
|
JOIN ma_type_keeper mtk ON mtk.type_id = lpd.type_id AND mtk.user_id = #{userId}
|
||||||
</if>
|
</if>
|
||||||
where 1 = 1
|
|
||||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||||
<![CDATA[ AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
<![CDATA[ AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -1277,4 +1282,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
WHERE
|
WHERE
|
||||||
lease_id = #{id}
|
lease_id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getPlUseTypeTree" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||||||
|
SELECT
|
||||||
|
mt.type_id AS typeId,
|
||||||
|
mt1.type_name AS materialName,
|
||||||
|
mt.type_name AS typeName,
|
||||||
|
mt.parent_id AS parentId,
|
||||||
|
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,
|
||||||
|
|
||||||
|
mt.LEVEL AS LEVEL
|
||||||
|
FROM
|
||||||
|
ma_type mt
|
||||||
|
LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id
|
||||||
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||||
|
AND mt1.del_flag = '0'
|
||||||
|
WHERE
|
||||||
|
sai.agreement_id in
|
||||||
|
<foreach item="agreement" collection="agreementIds" open="(" separator="," close=")">
|
||||||
|
#{agreement.agreementId}
|
||||||
|
</foreach>
|
||||||
|
and
|
||||||
|
EXISTS (
|
||||||
|
SELECT
|
||||||
|
1
|
||||||
|
FROM
|
||||||
|
clz_slt_agreement_info sai2
|
||||||
|
WHERE
|
||||||
|
sai2.type_id = mt.type_id
|
||||||
|
AND sai2.agreement_id in
|
||||||
|
<foreach item="agreement" collection="agreementIds" open="(" separator="," close=")">
|
||||||
|
#{agreement.agreementId}
|
||||||
|
</foreach>
|
||||||
|
AND sai.STATUS = '0'
|
||||||
|
AND IFNULL( sai.lease_type, 0 ) = 0
|
||||||
|
AND sai2.num > 0
|
||||||
|
)
|
||||||
|
GROUP BY
|
||||||
|
mt.type_id,
|
||||||
|
sai.agreement_id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -885,7 +885,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
HAVING
|
HAVING
|
||||||
num > 0
|
num > 0
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getTeamClzTree" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||||||
|
SELECT
|
||||||
|
mt.type_id as typeId,
|
||||||
|
sai.agreement_id,
|
||||||
|
mt1.type_name as materialName,
|
||||||
|
mt.type_name as typeName,
|
||||||
|
mt.parent_id as parentId,
|
||||||
|
mt.unit_name as unitName,
|
||||||
|
mt.unit_value as unitValue,
|
||||||
|
mt.manage_type as manageType,
|
||||||
|
SUM(sai.num) AS num,
|
||||||
|
mt.LEVEL as level,
|
||||||
|
mt.jiju_type as jijuType,
|
||||||
|
mt.is_check as isCheck
|
||||||
|
FROM
|
||||||
|
ma_type mt
|
||||||
|
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
||||||
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||||||
|
WHERE
|
||||||
|
sai.STATUS = '0' and mt1.type_name is not NULL and mt.type_name is not NULL
|
||||||
|
and sai.agreement_id in
|
||||||
|
<foreach item="id" collection="agreementId" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
|
||||||
|
|
||||||
|
GROUP BY
|
||||||
|
mt.type_id,sai.agreement_id
|
||||||
|
HAVING
|
||||||
|
num > 0
|
||||||
|
</select>
|
||||||
<select id="getBzUseTypeTreeL4" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
<select id="getBzUseTypeTreeL4" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||||||
SELECT
|
SELECT
|
||||||
mt.type_id as typeId,
|
mt.type_id as typeId,
|
||||||
|
|
|
||||||
|
|
@ -354,6 +354,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="userId != null">
|
<if test="userId != null">
|
||||||
JOIN ma_type_keeper mtk ON mtk.type_id = a.type_id AND mtk.user_id = #{userId}
|
JOIN ma_type_keeper mtk ON mtk.type_id = a.type_id AND mtk.user_id = #{userId}
|
||||||
</if>
|
</if>
|
||||||
|
WHERE a.publish_task is not null
|
||||||
GROUP BY parent_id, publish_task) lod ON lpd.parent_id = lod.parent_id
|
GROUP BY parent_id, publish_task) lod ON lpd.parent_id = lod.parent_id
|
||||||
AND lpd.publish_task = lod.publish_task
|
AND lpd.publish_task = lod.publish_task
|
||||||
LEFT JOIN bm_unit bu ON bu.unit_id = lpd.unit_id
|
LEFT JOIN bm_unit bu ON bu.unit_id = lpd.unit_id
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
LEFT JOIN repair_apply_details rad ON rad.id = rid.repair_id
|
LEFT JOIN repair_apply_details rad ON rad.id = rid.repair_id
|
||||||
LEFT JOIN tm_task tt1 on rad.task_id = tt1.task_id
|
LEFT JOIN tm_task tt1 on rad.task_id = tt1.task_id
|
||||||
WHERE
|
WHERE
|
||||||
rid.`status` = '0' and mm.ma_status = '5'
|
tt.task_status = '0' and mm.ma_status = '5'
|
||||||
<if test="qrCode != null and qrCode != ''">
|
<if test="qrCode != null and qrCode != ''">
|
||||||
and mm.qr_code = #{qrCode}
|
and mm.qr_code = #{qrCode}
|
||||||
</if>
|
</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue