# Conflicts:
#	bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml
#	bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml
This commit is contained in:
hongchao 2025-09-13 17:57:09 +08:00
commit 167e214bc8
11 changed files with 216 additions and 127 deletions

View File

@ -61,6 +61,9 @@ public class MaterialStorageInfo {
@ApiModelProperty(value = "关键字")
private String keyWord;
@ApiModelProperty(value = "班组id")
private String teamId;
@ApiModelProperty(value = "班组名称")
private String teamName;

View File

@ -237,6 +237,13 @@ public interface MaterialLeaseInfoMapper {
*/
List<TypeTreeNode> getUseTypeTree(MaterialLeaseApplyInfo bean);
/**
* 批量查询
* @param agreementIds
* @return
*/
List<TypeTreeNode> getPlUseTypeTree(@Param("agreementIds") List<BmAgreementInfo> agreementIds);
/**
* 根据id查询协议id
* @param id

View File

@ -214,4 +214,11 @@ public interface MaterialMachineMapper {
* @return
*/
List<MaterialRetainedEquipmentInfo> getUsInfoList(MaterialRetainedEquipmentInfo bean);
/**
* 获取材料站设备详情
* @param bean
* @return
*/
List<MaterialStorageInfo> getMaCodeDetails(MaterialStorageInfo bean);
}

View File

@ -1396,7 +1396,10 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
if (!CollectionUtils.isEmpty(bean.getAgreementIdList())) {
// 优化批量查询所有协议的类型树避免N+1查询
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);
listL4 = mapper.getUseTypeClzTree(backApplyInfo);
if (!CollectionUtils.isEmpty(listL4)) {
@ -1416,13 +1419,18 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
typeNodeMap.put(typeId, node);
}
}
listL5.addAll(typeNodeMap.values());
listL5.addAll(typeNodeMap.values());*/
}
// 优化批量查询协议信息减少数据库访问次数
List<BmAgreementInfo> listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean);
if (!CollectionUtils.isEmpty(listAgreement)) {
list7= materialLeaseInfoMapper.getPlUseTypeTree(listAgreement);
// 批量查询所有协议的使用类型树
List<TypeTreeNode> allTypeNodes = new ArrayList<>();
/*List<TypeTreeNode> allTypeNodes = new ArrayList<>();
for (BmAgreementInfo agreementInfo : listAgreement) {
bean.setAgreementId(agreementInfo.getAgreementId());
List<TypeTreeNode> list6 = materialLeaseInfoMapper.getUseTypeTree(bean);
@ -1442,7 +1450,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)) {

View File

@ -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<MaterialStorageInfo> getMaCodeList(MaterialStorageInfo bean) {
try {
// 查询库管员
List<MaterialStorageInfo> 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<MaterialUseStorageInfo> 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<MaterialStorageInfo> 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<MaterialUseStorageInfo> 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<MaterialStorageInfo> 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) {

View File

@ -294,6 +294,8 @@ public interface SelectMapper {
*/
List<TypeTreeNode> getUseTypeClzTree(BackApplyInfo backApplyInfo);
List<TypeTreeNode> getTeamClzTree(@Param("agreementId")List<Long> agreementId);
/**
* 获取班组在用量
* @param bean

View File

@ -389,22 +389,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectLeaseApplyInfoList" parameterType="com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo" resultMap="LeaseApplyInfoResult">
<include refid="selectLeaseApplyInfoVo"/>
<where>
<if test="impUnitName != null and impUnitName != ''">
and sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
</if>
<if test="departName != null and departName != ''">
and bp.pro_center LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="teamName != null and teamName != ''">
and bt.unit_name LIKE CONCAT('%', #{teamName}, '%')
</if>
<if test="keyWord != null and keyWord != ''">
and (
lai.create_by like concat('%',#{keyWord},'%') or
bp.pro_name like concat('%',#{keyWord},'%') or
lai.lease_person like concat('%',#{keyWord},'%')
)
</if>
<if test="taskStatus != null"> and tt.task_status = #{taskStatus}</if>
<if test="code != null and code != ''"> and lai.code = #{code}</if>
<if test="taskId != null "> and lai.task_id = #{taskId}</if>
@ -437,7 +421,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getTotalList" resultType="com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo">
select
sd.dept_name as impUnitName,
lai.id, lai.code as code, lai.lease_person as leasePerson,
lai.create_by, lai.create_time as leaseTime, lai.update_by, lai.update_time, lai.remark, lai.company_id,
lai.lease_sign_url as leaseSignUrl, lai.lease_sign_type as leaseSignType,
@ -467,23 +450,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userId != null">
JOIN ma_type_keeper mtk ON mtk.type_id = lad.type_id AND mtk.user_id = #{userId}
</if>
where
1=1
<if test="impUnitName != null and impUnitName != ''">
and sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
</if>
<if test="leasePerson != null and leasePerson != ''">
and lai.lease_person LIKE CONCAT('%', #{leasePerson}, '%')
</if>
<if test="code != null and code != ''">
and lai.code LIKE CONCAT('%', #{code}, '%')
</if>
<if test="leaseUnit != null and leaseUnit != ''">
and bu.unit_name LIKE CONCAT('%', #{leaseUnit}, '%')
</if>
<if test="leaseProject != null and leaseProject != ''">
and bp.pro_name LIKE CONCAT('%', #{leaseProject}, '%')
</if>
<where>
<if test="statusList != null and statusList.size() > 0">
and tt.task_status in
<foreach item="item" collection="statusList" open="(" separator="," close=")">
@ -500,7 +467,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<![CDATA[ AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
</if>
and tt.task_type = '2'
</where>
GROUP BY lai.id
ORDER BY tt.create_time desc
</select>
@ -825,8 +792,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getLeaseInfoDetails" resultType="com.bonus.material.clz.domain.vo.lease.LeaseTotalInfo">
SELECT
sd.dept_name AS impUnitName,
bp.pro_center AS departName,
lod.id AS id,
lod.parent_id AS parentId,
mt.type_id AS typeId,
@ -858,18 +823,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_unit bt on lai.team_id = bt.unit_id
LEFT JOIN bm_project bp ON lai.project_id = bp.pro_id
LEFT JOIN sys_user su on su.user_id=lod.create_by
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
WHERE
lod.is_finished = '1'
<if test="impUnitName != null and impUnitName != ''">
and sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
</if>
<if test="departName != null and departName != ''">
and bp.pro_center LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="teamName != null and teamName != ''">
and bt.unit_name LIKE CONCAT('%', #{teamName}, '%')
</if>
<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} ]]>
</if>
@ -882,9 +837,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="keyWord != null and keyWord != ''">
and (
mt2.type_name like concat('%', #{keyWord}, '%') or
mt.type_name like concat('%', #{keyWord}, '%') or
lai.`code` like concat('%', #{keyWord}, '%') or
lai.lease_person like concat('%', #{keyWord}, '%') or
su.nick_name like concat('%', #{keyWord}, '%') or
lod.create_by like concat('%', #{keyWord}, '%') or
bt.unit_name like concat('%', #{keyWord}, '%') or
bp.pro_name like concat('%', #{keyWord}, '%')
)
</if>
@ -1073,7 +1030,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectPublishList" resultType="com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo">
SELECT
sd.dept_name as impUnitName,
lai.id AS id,
lai.code AS code,
lai.create_by AS createBy,
@ -1102,8 +1058,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
@ -1133,6 +1094,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="leaseProject != null and leaseProject != ''">
and bp.pro_name LIKE CONCAT('%', #{leaseProject}, '%')
</if>
<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} ]]>
</if>
@ -1337,4 +1299,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE
lease_id = #{id}
</select>
</mapper>
<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>

View File

@ -736,9 +736,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT * FROM (
-- 原查询包含status计算
SELECT
sd.dept_name as impUnitName,
bp.pro_center AS departName,
mt3.type_name as materialName,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
sai.ma_id AS maId,
@ -762,34 +759,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
LEFT JOIN ma_machine mm ON mm.ma_id = sai.ma_id
LEFT JOIN clz_slt_agreement_info csi ON mm.ma_id = csi.ma_id
LEFT JOIN clz_bm_agreement_info cba ON csi.agreement_id = cba.agreement_id
LEFT JOIN bm_unit bu ON cba.unit_id = bu.unit_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
WHERE
sai.`status` = '0'
AND mt.jiju_type = 2
AND sai.ma_id IS NOT NULL
<if test="impUnitName != null and impUnitName != ''">
and sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
</if>
<if test="departName != null and departName != ''">
and bp.pro_center LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="proName != null and proName != ''">
and bp.pro_name LIKE CONCAT('%', #{proName}, '%')
</if>
<if test="materialName != null and materialName != ''">
and mt3.type_name LIKE CONCAT('%', #{materialName}, '%')
</if>
<if test="teamName != null and teamName != ''">
and bu.unit_name LIKE CONCAT('%', #{teamName}, '%')
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[ AND DATE_FORMAT( mm.this_check_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
</if>
<if test="agreementIdList != null and agreementIdList.size >0">
AND sai.agreement_id IN
<foreach item="item" collection="agreementIdList" open="(" separator="," close=")">
@ -827,21 +804,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getTeamNumList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedTeamTotalVo">
SELECT
sd.dept_name AS impUnitName,
bp.pro_center AS departName,
bu.unit_id as teamId,
bu.unit_name as teamName,
bu.link_man as teamLeaderIdCard,
SUM( sai.num ) as usNum,
bu.bzz_idcard as idCard,
bp.imp_unit as impUnit,
bp.pro_name as proName
bp.imp_unit as impUnit
FROM
bm_unit bu
LEFT JOIN clz_bm_agreement_info bai ON bu.unit_id = bai.unit_id
LEFT JOIN clz_slt_agreement_info sai ON bai.agreement_id = sai.agreement_id
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
WHERE
sai.`status` = 0 and bu.type_id = 1731
<if test="keyWord != null and keyWord != ''">
@ -850,18 +823,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bu.link_man like concat('%',#{keyWord},'%')
)
</if>
<if test="impUnitName != null and impUnitName != ''">
and sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
</if>
<if test="departName != null and departName != ''">
and bp.pro_center LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="proName != null and proName != ''">
and bp.pro_name LIKE CONCAT('%', #{proName}, '%')
</if>
<if test="teamName != null and teamName != ''">
and bu.unit_name LIKE CONCAT('%', #{teamName}, '%')
</if>
GROUP BY
bu.unit_id
</select>
@ -1263,7 +1224,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
@ -1344,19 +1311,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
<if test="impUnitName != null and impUnitName != ''">
AND subquery1.departName = #{impUnitName}
AND subquery1.departName like concat('%',#{impUnitName},'%')
</if>
<if test="proName != null and proName != ''">
AND subquery1.proName = #{proName}
AND subquery1.proName like concat('%',#{proName},'%')
</if>
<if test="departName != null and departName != ''">
AND subquery1.proCenter = #{departName}
AND subquery1.proCenter like concat('%',#{departName},'%')
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_name = #{typeName}
AND mt2.type_name like concat('%',#{typeName},'%')
</if>
<if test="typeModelName != null and typeModelName != ''">
AND mt.type_name = #{typeModelName}
AND mt.type_name like concat('%',#{typeModelName},'%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
and subquery1.externalId in
@ -1372,7 +1339,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getUsInfoList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
SELECT
mt.type_id,
mt.type_id as typeId,
mt4.type_name AS constructionType,
mt4.type_id AS firstTypeId,
mt3.type_name AS materialType,
@ -1381,6 +1348,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
SUM(IFNULL( sai.num, 0 )) AS allNum,
bu.unit_id as teamId,
bu.unit_name AS teamName,
bp.pro_name as proName,
bp.pro_id as proId,
@ -1389,7 +1357,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bu.bzz_idcard AS idCard,
bp.pro_center AS departName,
mt.unit_name AS unit,
sd.dept_name AS impUnitName
sd.dept_name AS impUnitName,
CASE mt.manage_type
WHEN 0 THEN
'编码'
ELSE
'数量'
END manageType
FROM
clz_slt_agreement_info sai
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
@ -1437,5 +1411,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bu.unit_name,
bp.pro_name
</select>
<select id="getMaCodeDetails" resultType="com.bonus.material.clz.domain.machine.MaterialStorageInfo">
SELECT mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mt.lease_price AS buyPrice,
sai.num AS storeNum,
mm.ma_code AS maCode,
bt.unit_name AS teamName,
sai.lease_id AS leaseId,
sai.type_id AS typeId,
lai.code AS code,
sai.ma_id AS maId
FROM clz_slt_agreement_info sai
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_machine mm ON mm.ma_id = sai.ma_id
LEFT JOIN clz_bm_agreement_info bai ON bai.agreement_id = sai.agreement_id
LEFT JOIN bm_unit bt ON bai.unit_id = bt.unit_id AND bt.del_flag = '0'
LEFT JOIN lease_apply_info lai ON lai.id = sai.lease_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
WHERE sai.status = '0'
AND sai.end_time IS NULL
AND sai.back_id IS NULL
<if test="typeId !=null ">
AND sai.type_id = #{typeId}
</if>
<if test="proId !=null ">
AND bp.pro_id = #{proId}
</if>
<if test="teamId !=null ">
AND bt.unit_id = #{teamId}
</if>
</select>
</mapper>

View File

@ -885,7 +885,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
HAVING
num > 0
</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
mt.type_id as typeId,

View File

@ -354,6 +354,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userId != null">
JOIN ma_type_keeper mtk ON mtk.type_id = a.type_id AND mtk.user_id = #{userId}
</if>
WHERE a.publish_task is not null
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

View File

@ -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 tm_task tt1 on rad.task_id = tt1.task_id
WHERE
rid.`status` = '0' and mm.ma_status = '5'
tt.task_status = '0' and mm.ma_status = '5'
<if test="qrCode != null and qrCode != ''">
and mm.qr_code = #{qrCode}
</if>