2025-08-23 19:18:15 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
< !DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace= "com.bonus.material.push.mapper.ProDataUseInfoMapper" >
<select id= "getProDataUseInfo" resultType= "com.bonus.material.push.domain.ProIdsBean" >
2025-08-26 19:54:22 +08:00
SELECT
2025-09-04 11:28:32 +08:00
ANY_VALUE(bp.pro_name) as proName,
sum(sai.num) typeNum,
ANY_VALUE(mt2.type_id) as typeId,
mt2.is_statics as isStatics,
bp.external_id as externalId
2025-08-26 19:54:22 +08:00
FROM slt_agreement_info sai
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
WHERE
sai.is_slt = 0
AND sai.end_time IS NULL
AND bp.external_id = #{proId}
AND mt2.type_id IN
2025-08-23 19:18:15 +08:00
<foreach collection= "typeIds" item= "id" open= "(" separator= "," close= ")" >
#{id}
</foreach>
2025-09-04 11:28:32 +08:00
GROUP BY bp.external_id, mt2.is_statics
2025-08-23 19:18:15 +08:00
</select>
<select id= "getTypeId" resultType= "java.lang.Integer" >
select type_id from ma_type where is_statics in (1,2,3,4,5,6,7)
</select>
<select id= "getMachineDetails" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
select
mt.type_id as typeId,
mt2.type_name as typeName,
mt.type_name as typeModelName,
mt.unit_name as unit,
sai.num as num,
mm.assets_code as assetsCode,
mt.rent_price as rentPrice,
'在用' as status
from slt_agreement_info sai
left join bm_agreement_info bai on sai.agreement_id = bai.agreement_id
left join bm_project bp on bai.project_id = bp.pro_id
left join ma_type mt on sai.type_id = mt.type_id
left join ma_type mt2 on mt.parent_id = mt2.type_id
2025-09-04 11:28:32 +08:00
left join ma_machine mm on sai.ma_id = mm.ma_id
2025-08-23 19:18:15 +08:00
where sai.is_slt = 0 and sai.end_time is null
2025-09-04 11:28:32 +08:00
AND bp.external_id = #{externalId}
2025-08-23 19:18:15 +08:00
AND mt2.is_statics = #{isStatics}
<if test= "typeName != null and typeName !=''" >
2025-08-28 19:18:31 +08:00
AND mt2.type_name like concat ('%', #{typeName}, '%')
2025-08-23 19:18:15 +08:00
</if>
<if test= "typeModelName != null and typeModelName !=''" >
2025-08-28 19:18:31 +08:00
AND mt.type_name like concat ('%', #{typeModelName}, '%')
2025-08-23 19:18:15 +08:00
</if>
</select>
<select id= "getTypeKeeperName" resultType= "java.lang.String" >
2025-08-24 18:02:56 +08:00
select group_concat(su.nick_name) from ma_type_keeper mtk
2025-08-23 19:18:15 +08:00
left join sys_user su on mtk.user_id = su.user_id
where mtk.type_id = #{typeId}
</select>
<select id= "getNumsByStatics" resultType= "com.bonus.material.push.domain.StaticsNumsBean" >
2025-08-24 15:03:03 +08:00
SELECT
CASE mt.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(mt.storage_num, 0)
END AS num,
IFNULL(subquery1.usNum, 0) AS useNum,
IFNULL(subquery2.repairNum, 0) AS repairNum,
CASE mt.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0) + IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0)
ELSE
IFNULL(mt.storage_num, 0) + IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0)
2025-08-26 09:25:06 +08:00
END AS inventoryNum,
mt2.is_statics AS isStatics
2025-08-24 15:03:03 +08:00
FROM ma_type mt
LEFT JOIN (
SELECT
mt.type_id,
mt4.type_name AS constructionType,
mt4.type_id AS firstTypeId,
mt3.type_name AS materialType,
mt3.type_id AS secondTypeId,
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
count(mm.ma_id) AS num
FROM ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE mm.ma_code is not null and mm.ma_status in (1)
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
LEFT JOIN (
SELECT
mt.type_id,
mt4.type_name AS constructionType,
mt4.type_id AS firstTypeId,
mt3.type_name AS materialType,
mt3.type_id AS secondTypeId,
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
2025-08-26 09:25:06 +08:00
SUM(IFNULL( sai.num, 0 )) AS usNum,
sd.dept_name AS unitName
2025-08-24 15:03:03 +08:00
FROM
slt_agreement_info sai
left join bm_agreement_info bai on sai.agreement_id = bai.agreement_id
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 mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
2025-08-26 09:25:06 +08:00
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
2025-08-24 15:03:03 +08:00
WHERE
sai.`status` = '0' and sai.`is_slt` = '0'
2025-08-26 09:25:06 +08:00
<if test= "unitName != null and unitName !=''" >
AND sd.dept_name = #{unitName}
</if>
2025-09-04 11:28:32 +08:00
<if test= "deptId != null" >
AND sd.dept_id = #{deptId}
2025-08-26 09:25:06 +08:00
</if>
<if test= "isStatics != null" >
and mt2.is_statics = #{isStatics}
</if>
2025-08-24 15:03:03 +08:00
AND sai.end_time IS NULL
AND sai.back_id IS NULL
GROUP BY mt.type_id
) AS subquery1
ON mt.type_id = subquery1.type_id
LEFT JOIN (
SELECT
mt.type_id,
mt4.type_name AS constructionType,
mt4.type_id AS firstTypeId,
mt3.type_name AS materialType,
mt3.type_id AS secondTypeId,
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
SUM(
IFNULL(rad.repair_num, 0) - IFNULL(rad.repaired_num, 0) -
2025-08-26 09:25:06 +08:00
IFNULL(rad.scrap_num, 0)) AS repairNum,
sd.dept_name AS unitName
2025-08-24 15:03:03 +08:00
FROM repair_apply_details rad
LEFT JOIN tm_task tt ON rad.task_id = tt.task_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN ma_type mt ON mt.type_id = rad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
2025-08-26 09:25:06 +08:00
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
2025-08-24 15:03:03 +08:00
WHERE
rad.status = '0'
2025-08-26 09:25:06 +08:00
<if test= "unitName != null and unitName !=''" >
AND sd.dept_name = #{unitName}
</if>
2025-09-04 11:28:32 +08:00
<if test= "deptId != null" >
AND sd.dept_id = #{deptId}
2025-08-26 09:25:06 +08:00
</if>
<if test= "isStatics != null" >
and mt2.is_statics = #{isStatics}
</if>
2025-08-24 15:03:03 +08:00
GROUP BY
mt.type_id) AS subquery2 ON subquery2.type_id = mt.type_id
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
2025-09-04 19:54:59 +08:00
WHERE mt.del_flag = '0' and mt.`level` = '4' and mt2.is_statics is not null
2025-08-24 15:03:03 +08:00
<if test= "isStatics != null" >
and mt2.is_statics = #{isStatics}
</if>
2025-08-23 19:18:15 +08:00
</select>
<select id= "getApproachingAndTimeout" resultType= "com.bonus.material.push.domain.StaticsNumsBean" >
2025-09-08 18:47:39 +08:00
2025-08-23 19:18:15 +08:00
SELECT
COUNT(CASE
WHEN mm.next_check_time BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 30 DAY)
THEN 1
ELSE NULL
END) AS ApproachingNum,
COUNT(CASE
WHEN mm.next_check_time < NOW()
THEN 1
ELSE NULL
END) AS TimeoutNum
FROM ma_machine mm
2025-09-04 18:26:28 +08:00
LEFT JOIN slt_agreement_info sai on sai.ma_id = mm.ma_id and mm.type_id = sai.type_id
2025-08-23 19:18:15 +08:00
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
2025-09-04 11:28:32 +08:00
left join sys_dept sd ON sd.dept_id = bp.imp_unit
2025-08-26 19:54:22 +08:00
where mm.next_check_time is not null and mt.`level` = '4'
2025-09-04 18:26:28 +08:00
and sai.`status`='0' and sai.end_time is null
and bp.external_id is not null
and mm.ma_status = 2
2025-09-08 18:47:39 +08:00
and mt2.type_id not in (6032,6008,6270)
2025-09-04 11:28:32 +08:00
<if test= "deptId != null" >
AND sd.dept_id = #{deptId}
2025-08-23 19:24:46 +08:00
</if>
2025-08-23 19:18:15 +08:00
AND mm.next_check_time IS NOT NULL
2025-09-08 18:47:39 +08:00
2025-08-23 19:18:15 +08:00
</select>
<select id= "getApproachingDetails" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
SELECT
2025-08-24 18:02:56 +08:00
sd.dept_name as deptName,
bp.pro_center as proCenter,
bp.pro_name as proName,
2025-08-23 19:18:15 +08:00
mt2.type_name as typeName,
mt.type_name as typeModelName,
mt.unit_name as unit,
mm.ma_code as maCode,
sai.start_time as leaseTime,
mm.next_check_time as expireTime,
CASE
WHEN #{type} = 0 THEN DATEDIFF(mm.next_check_time, NOW())
WHEN #{type} = 1 THEN DATEDIFF(NOW(), mm.next_check_time)
ELSE NULL
END AS daysDiff
FROM ma_machine mm
2025-09-04 18:26:28 +08:00
LEFT JOIN slt_agreement_info sai on sai.ma_id = mm.ma_id and mm.type_id = sai.type_id
2025-08-23 19:18:15 +08:00
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN sys_dept sd on bp.imp_unit = sd.dept_id
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
2025-08-26 19:54:22 +08:00
WHERE mm.next_check_time is not null AND mt.`level`=4
2025-09-04 18:26:28 +08:00
and bp.external_id is not null
and sai.`status`='0' and sai.end_time is null
and mm.ma_status = 2
2025-09-08 18:47:39 +08:00
and mt2.type_id not in (6032,6008,6270)
2025-08-23 19:24:46 +08:00
<if test= "proId != null" >
2025-08-24 18:02:56 +08:00
AND bp.pro_id = #{proId}
2025-08-23 19:24:46 +08:00
</if>
2025-08-23 19:18:15 +08:00
<if test= "type != null and type == 0" >
AND mm.next_check_time BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 30 DAY)
</if>
<if test= "type != null and type == 1" >
AND mm.next_check_time < NOW()
</if>
<if test= "deptName != null and deptName !=''" >
AND sd.dept_name like concat ('%', #{deptName}, '%')
</if>
<if test= "proCenter != null and proCenter !=''" >
AND bp.pro_center like concat ('%', #{proCenter}, '%')
</if>
<if test= "proName != null and proName !=''" >
AND bp.pro_name like concat ('%', #{proName}, '%')
</if>
<if test= "typeName != null and typeName !=''" >
2025-08-28 19:18:31 +08:00
AND mt2.type_name like concat ('%', #{typeName}, '%')
2025-08-23 19:18:15 +08:00
</if>
<if test= "typeModelName != null and typeModelName !=''" >
2025-08-28 19:18:31 +08:00
AND mt.type_name like concat ('%', #{typeModelName}, '%')
2025-08-23 19:18:15 +08:00
</if>
2025-08-24 18:02:56 +08:00
<if test= "proId != null" >
GROUP BY bp.pro_id
</if>
2025-09-04 18:26:28 +08:00
order by mt.jiju_type desc
2025-08-23 19:18:15 +08:00
</select>
2025-08-24 11:27:05 +08:00
<select id= "getCompletionNotRefunded" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
select
2025-09-05 12:08:02 +08:00
count(distinct bp.external_id) num,
2025-09-04 18:52:02 +08:00
sd.dept_name as deptName,
sd.dept_id as deptId
2025-09-05 09:55:19 +08:00
from slt_agreement_info sai
left join bm_agreement_info bai on sai.agreement_id = bai.agreement_id
left join bm_project bp on bai.project_id = bp.pro_id
2025-09-04 18:52:02 +08:00
left join sys_dept sd on bp.imp_unit = sd.dept_id
2025-09-05 12:08:02 +08:00
where sai.is_slt = 0 and sai.end_time is null and bp.actual_end_date is not null and bp.pro_center is not null and bp.external_id is not null
<if test= "deptName != null and deptName != ''" >
AND sd.dept_name = #{deptName}
</if>
GROUP BY bp.imp_unit
2025-08-24 11:27:05 +08:00
</select>
<select id= "getCompletionNotRefundedDetails" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
select
bp.pro_name as proName,
2025-08-24 18:02:56 +08:00
bp.actual_end_date as actualEndDate,
DATEDIFF(NOW(), bp.actual_end_date) as daysDiff,
2025-09-04 12:51:07 +08:00
sai.num num,
2025-08-24 12:25:38 +08:00
mt.type_name as typeModelName,
2025-08-24 18:02:56 +08:00
mt.unit_name as unit,
2025-08-24 12:25:38 +08:00
mt2.type_name as typeName,
2025-09-04 19:54:59 +08:00
sd.dept_name as deptName,
2025-09-04 21:18:44 +08:00
bp.pro_center as proCenter
2025-08-24 11:27:05 +08:00
from slt_agreement_info sai
left join bm_agreement_info bai on sai.agreement_id = bai.agreement_id
left join bm_project bp on bai.project_id = bp.pro_id
left join sys_dept sd on bp.imp_unit = sd.dept_id
left join ma_type mt on sai.type_id = mt.type_id
left join ma_type mt2 on mt.parent_id = mt2.type_id
2025-09-05 12:08:02 +08:00
where sai.status = 0 and bp.actual_end_date is not null and bp.actual_end_date is not null and bp.pro_center is not null
2025-09-04 21:18:44 +08:00
<if test= "deptId != null" >
and sd.dept_id = #{deptId}
</if>
2025-08-24 11:27:05 +08:00
<if test= "typeName != null and typeName !=''" >
2025-08-28 19:18:31 +08:00
AND mt2.type_name like concat ('%', #{typeName}, '%')
2025-08-24 11:27:05 +08:00
</if>
<if test= "typeModelName != null and typeModelName !=''" >
2025-08-28 19:18:31 +08:00
AND mt.type_name like concat ('%', #{typeModelName}, '%')
2025-08-24 11:27:05 +08:00
</if>
</select>
<select id= "getInventoryAlert" resultType= "com.bonus.material.push.domain.InventoryAlertBean" >
select
mt.type_name as typeModelName,
mt2.type_name as typeName,
2025-08-26 19:54:22 +08:00
mt.storage_num as num
2025-08-24 11:27:05 +08:00
from ma_type mt
left join ma_type mt2 on mt.parent_id = mt2.type_id
2025-08-26 19:54:22 +08:00
where mt.del_flag = 0 and mt.`level`=4
<if test= "typeName != null and typeName !=''" >
2025-08-28 19:18:31 +08:00
AND mt2.type_name like concat ('%', #{typeName}, '%')
2025-08-26 19:54:22 +08:00
</if>
<if test= "typeModelName != null and typeModelName !=''" >
2025-08-28 19:18:31 +08:00
AND mt.type_name like concat ('%', #{typeModelName}, '%')
2025-08-26 19:54:22 +08:00
</if>
</select>
<select id= "getInventoryAlertName" resultType= "com.bonus.material.push.domain.InventoryAlertBean" >
select
mt.type_name as typeModelName,
mt2.type_name as typeName
from ma_type mt
left join ma_type mt2 on mt.parent_id = mt2.type_id
where mt.del_flag = 0 and mt.`level`=4
<if test= "typeName != null and typeName !=''" >
2025-08-28 19:18:31 +08:00
AND mt2.type_name like concat ('%', #{typeName}, '%')
2025-08-26 19:54:22 +08:00
</if>
<if test= "typeModelName != null and typeModelName !=''" >
2025-08-28 19:18:31 +08:00
AND mt.type_name like concat ('%', #{typeModelName}, '%')
2025-08-26 19:54:22 +08:00
</if>
</select>
<select id= "getApproachingDetailsByUnit" resultType= "java.util.Map" >
SELECT COUNT(CASE
WHEN mm.next_check_time BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 30 DAY) THEN 1
ELSE NULL END)
2025-08-27 16:05:42 +08:00
AS approachingNum,
COUNT(CASE WHEN mm.next_check_time < NOW() THEN 1 ELSE NULL END) AS timeoutNum,
2025-08-26 19:54:22 +08:00
sd.dept_name as deptName
FROM ma_machine mm
LEFT JOIN slt_agreement_info sai ON sai.ma_id = mm.ma_id
AND mm.type_id = sai.type_id
AND sai.`status` = '0'
AND sai.end_time IS NULL
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN sys_dept sd on bp.imp_unit = sd.dept_id
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
WHERE mm.next_check_time IS NOT NULL
AND mt.`level` = '4'
AND sd.dept_name in
('送电一分公司', '送电二分公司', '检修试验分公司', '建筑分公司(消防分公司)', '安徽宏源电力建设有限公司',
'变电分公司')
GROUP BY bp.imp_unit
</select>
<select id= "getMaTypeList" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
SELECT
2025-09-04 11:28:32 +08:00
mt.type_id AS typeId,
2025-09-04 19:54:59 +08:00
mt.type_name AS specification,
mt2.type_name AS materialName,
mt.unit_name AS materialDw,
mt.storage_num AS subKcNum
2025-08-26 19:54:22 +08:00
FROM
ma_type mt
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
WHERE
mt.del_flag = 0
AND mt.`level` =4
2025-09-04 19:54:59 +08:00
<if test= "materialName != null and materialName !=''" >
AND mt2.type_name like concat ('%', #{materialName}, '%')
2025-08-24 11:27:05 +08:00
</if>
2025-09-04 19:54:59 +08:00
<if test= "specification != null and specification !=''" >
AND mt.type_name like concat ('%', #{specification}, '%')
2025-08-26 19:54:22 +08:00
</if>
2025-08-24 11:27:05 +08:00
</select>
2025-09-04 11:28:32 +08:00
<select id= "getUseNumsDetails" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
select
mt.type_id as typeId,
mt2.type_name as typeName,
mt.type_name as typeModelName,
mt.unit_name as unit,
mm.assets_code as assetsCode,
ifnull(mt.lease_price,0) as rentPrice,
SUM(IFNULL( sai.num, 0 )) AS num,
'在用' AS status
FROM
slt_agreement_info sai
left join bm_agreement_info bai on sai.agreement_id = bai.agreement_id
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_machine mm ON mm.ma_id = sai.ma_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
WHERE
sai.`status` = '0' and sai.`is_slt` = '0'
<if test= "unitName != null and unitName !=''" >
AND sd.dept_name = #{unitName}
</if>
<if test= "deptId != null" >
AND sd.dept_id = #{deptId}
</if>
<if test= "isStatics != null" >
and mt2.is_statics = #{isStatics}
</if>
<if test= "typeName != null and typeName !=''" >
AND mt2.type_name like concat ('%', #{typeName}, '%')
</if>
<if test= "typeModelName != null and typeModelName !=''" >
AND mt.type_name like concat ('%', #{typeModelName}, '%')
</if>
AND sai.end_time IS NULL
AND sai.back_id IS NULL
GROUP BY mt.type_id
</select>
<select id= "getRepairNumsDetails" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
SELECT
mt.type_id as typeId,
mt2.type_name as typeName,
mt.type_name as typeModelName,
mt.unit_name as unit,
mm.assets_code as assetsCode,
ifnull(mt.lease_price,0) as rentPrice,
SUM(
IFNULL(rad.repair_num, 0) - IFNULL(rad.repaired_num, 0) -
IFNULL(rad.scrap_num, 0)) AS num,
'在修' AS status
FROM repair_apply_details rad
LEFT JOIN tm_task tt ON rad.task_id = tt.task_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN ma_type mt ON mt.type_id = rad.type_id
left join ma_machine mm ON mm.ma_id = rad.ma_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
WHERE
rad.status = '0'
<if test= "unitName != null and unitName !=''" >
AND sd.dept_name = #{unitName}
</if>
<if test= "deptId != null" >
AND sd.dept_id = #{deptId}
</if>
<if test= "isStatics != null" >
and mt2.is_statics = #{isStatics}
</if>
<if test= "typeName != null and typeName !=''" >
AND mt2.type_name like concat ('%', #{typeName}, '%')
</if>
<if test= "typeModelName != null and typeModelName !=''" >
AND mt.type_name like concat ('%', #{typeModelName}, '%')
</if>
GROUP BY
mt.type_id
</select>
<select id= "getNumsDetails" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
SELECT
2025-09-04 21:00:15 +08:00
mt.type_id as typeId,
mt2.type_name as typeName,
mt.type_name as typeModelName,
mt.unit_name as unit,
mm.assets_code as assetsCode,
ifnull(mt.lease_price,0) as rentPrice,
2025-09-04 21:01:32 +08:00
CASE
mt.manage_type
2025-09-04 21:00:15 +08:00
WHEN 0 THEN
2025-09-04 21:01:32 +08:00
IFNULL( COUNT( mm.ma_id ), 0 )
2025-09-04 21:00:15 +08:00
ELSE
2025-09-04 21:01:32 +08:00
IFNULL( mt.storage_num, 0 )
2025-09-04 21:00:15 +08:00
END AS num,
2025-09-04 21:01:32 +08:00
'在库' AS STATUS
2025-09-04 21:00:15 +08:00
FROM
ma_type mt
LEFT JOIN ma_machine mm ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE
mt.LEVEL = 4
2025-09-04 11:28:32 +08:00
<if test= "typeName != null and typeName !=''" >
AND mt2.type_name like concat ('%', #{typeName}, '%')
</if>
<if test= "typeModelName != null and typeModelName !=''" >
AND mt.type_name like concat ('%', #{typeModelName}, '%')
</if>
2025-09-04 21:01:32 +08:00
<if test= "isStatics != null" >
and mt2.is_statics = #{isStatics}
</if>
2025-09-04 21:00:15 +08:00
AND (
mt.manage_type != 0
OR (
mt.manage_type = 0
AND mm.ma_code IS NOT NULL
AND mm.ma_status IN (1)
))
GROUP BY
mt.type_id
2025-09-04 11:28:32 +08:00
</select>
<select id= "getAllMacheDetails" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
( SELECT
mt.type_id as typeId,
mt2.type_name as typeName,
mt.type_name as typeModelName,
mt.unit_name as unit,
mm.assets_code as assetsCode,
ifnull(mt.lease_price,0) as rentPrice,
SUM(
IFNULL( sai.num, 0 )) AS num,
'在用' AS STATUS
FROM
slt_agreement_info sai
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
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_machine mm ON mm.ma_id = sai.ma_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
WHERE
sai.STATUS = '0' AND mt.LEVEL = 4
<if test= "unitName != null and unitName !=''" >
AND sd.dept_name = #{unitName}
</if>
<if test= "deptId != null" >
AND sd.dept_id = #{deptId}
</if>
<if test= "isStatics != null" >
and mt2.is_statics = #{isStatics}
</if>
<if test= "typeName != null and typeName !=''" >
AND mt2.type_name like concat ('%', #{typeName}, '%')
</if>
<if test= "typeModelName != null and typeModelName !=''" >
AND mt.type_name like concat ('%', #{typeModelName}, '%')
</if>
AND sai.is_slt = '0'
AND sai.end_time IS NULL
AND sai.back_id IS NULL
GROUP BY
mt.type_id
) UNION ALL
(
SELECT
mt.type_id as typeId,
mt2.type_name as typeName,
mt.type_name as typeModelName,
mt.unit_name as unit,
mm.assets_code as assetsCode,
ifnull(mt.lease_price,0) as rentPrice,
SUM(
IFNULL( rad.repair_num, 0 ) - IFNULL( rad.repaired_num, 0 ) - IFNULL( rad.scrap_num, 0 )) AS num,
'在修' AS STATUS
FROM
repair_apply_details rad
LEFT JOIN tm_task tt ON rad.task_id = tt.task_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN ma_type mt ON mt.type_id = rad.type_id
left join ma_machine mm ON mm.ma_id = rad.ma_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
WHERE
rad.STATUS = '0' AND mt.LEVEL = 4
<if test= "unitName != null and unitName !=''" >
AND sd.dept_name = #{unitName}
</if>
<if test= "deptId != null" >
AND sd.dept_id = #{deptId}
</if>
<if test= "isStatics != null" >
and mt2.is_statics = #{isStatics}
</if>
<if test= "typeName != null and typeName !=''" >
AND mt2.type_name like concat ('%', #{typeName}, '%')
</if>
<if test= "typeModelName != null and typeModelName !=''" >
AND mt.type_name like concat ('%', #{typeModelName}, '%')
</if>
GROUP BY
mt.type_id
) UNION ALL
(
2025-09-04 20:57:07 +08:00
SELECT
mt.type_id as typeId,
mt2.type_name as typeName,
mt.type_name as typeModelName,
mt.unit_name as unit,
mm.assets_code as assetsCode,
ifnull(mt.lease_price,0) as rentPrice,
CASE
mt.manage_type
WHEN 0 THEN
IFNULL( COUNT( mm.ma_id ), 0 )
ELSE
IFNULL( mt.storage_num, 0 )
END AS num,
'在库' AS STATUS
FROM
ma_type mt
LEFT JOIN ma_machine mm ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE
mt.LEVEL = 4
<if test= "typeName != null and typeName !=''" >
AND mt2.type_name like concat ('%', #{typeName}, '%')
</if>
<if test= "typeModelName != null and typeModelName !=''" >
AND mt.type_name like concat ('%', #{typeModelName}, '%')
</if>
<if test= "isStatics != null" >
and mt2.is_statics = #{isStatics}
</if>
AND (
mt.manage_type != 0
OR (
mt.manage_type = 0
AND mm.ma_code IS NOT NULL
AND mm.ma_status IN (1)
))
GROUP BY
mt.type_id)
2025-09-04 11:28:32 +08:00
</select>
<select id= "getPersonNameAndPhone" resultType= "com.bonus.system.api.domain.SysUser" >
SELECT
su.nick_name AS nickName,
su.phonenumber
FROM ma_type_keeper mtk
LEFT JOIN sys_user su ON mtk.user_id = su.user_id
WHERE mtk.type_id = #{typeId}
AND su.phonenumber IS NOT NULL
ORDER BY mtk.user_id DESC
LIMIT 1
</select>
<select id= "getCompletionNotRefundedSub" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
select
2025-09-05 12:08:02 +08:00
bp.pro_center as proCenter,
count(distinct bp.external_id) num,
sd.dept_name as deptName,
sd.dept_id as deptId
2025-09-04 11:28:32 +08:00
from slt_agreement_info sai
2025-09-05 12:08:02 +08:00
left join bm_agreement_info bai on sai.agreement_id = bai.agreement_id
left join bm_project bp on bai.project_id = bp.pro_id
left join sys_dept sd on bp.imp_unit = sd.dept_id
where sai.is_slt = 0 and sai.end_time is null and bp.actual_end_date is not null and sd.dept_name = #{deptName} and bp.pro_center is not null and bp.external_id is not null
2025-09-04 11:28:32 +08:00
GROUP BY bp.pro_center
</select>
2025-09-04 15:46:32 +08:00
<select id= "getCompletionNotRefundedDetailsSub" resultType= "com.bonus.material.push.domain.MachineInfoBean" >
select
bp.pro_name as proName,
bp.pro_center as proCenter,
bp.actual_end_date as actualEndDate,
DATEDIFF(NOW(), bp.actual_end_date) as daysDiff,
sai.num num,
mt.type_name as typeModelName,
mt.unit_name as unit,
2025-09-04 21:26:17 +08:00
sd.dept_name as deptName,
2025-09-04 15:46:32 +08:00
mt2.type_name as typeName
from slt_agreement_info sai
left join bm_agreement_info bai on sai.agreement_id = bai.agreement_id
left join bm_project bp on bai.project_id = bp.pro_id
left join sys_dept sd on bp.imp_unit = sd.dept_id
left join ma_type mt on sai.type_id = mt.type_id
left join ma_type mt2 on mt.parent_id = mt2.type_id
where sai.status = 0 and bp.actual_end_date is not null
2025-09-04 21:18:44 +08:00
and bp.pro_center is not null
<if test= "proCenter != null and proCenter !=''" >
and bp.pro_center= #{proCenter}
</if>
2025-09-04 15:46:32 +08:00
<if test= "typeName != null and typeName !=''" >
AND mt2.type_name like concat ('%', #{typeName}, '%')
</if>
<if test= "typeModelName != null and typeModelName !=''" >
AND mt.type_name like concat ('%', #{typeModelName}, '%')
</if>
</select>
2025-08-26 19:54:22 +08:00
2025-08-23 19:18:15 +08:00
</mapper>