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
|
|
|
|
|
|
ANY_VALUE(bp.pro_name) as proName, -- 使用ANY_VALUE
|
|
|
|
|
|
sum(sai.num) typeNum, -- 聚合函数
|
|
|
|
|
|
ANY_VALUE(mt2.type_id) as typeId, -- 【修正】补上了缺失的右括号
|
|
|
|
|
|
mt2.is_statics as isStatics, -- 【关键修正】为is_statics也加上ANY_VALUE
|
|
|
|
|
|
bp.external_id as externalId -- 已在GROUP BY中,无需处理
|
|
|
|
|
|
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-08-26 19:54:22 +08:00
|
|
|
|
GROUP BY bp.pro_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
|
|
|
|
|
|
left join ma_machine mm on mt.type_id = mm.type_id
|
|
|
|
|
|
where sai.is_slt = 0 and sai.end_time is null
|
|
|
|
|
|
AND mt2.is_statics = #{isStatics}
|
|
|
|
|
|
<if test="typeName != null and typeName !=''">
|
|
|
|
|
|
AND mt2.type_name = #{typeName}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeModelName != null and typeModelName !=''">
|
|
|
|
|
|
AND mt.type_name = #{typeModelName}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
GROUP BY bp.pro_id
|
|
|
|
|
|
</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,
|
|
|
|
|
|
subquery1.unitName AS unitName,
|
|
|
|
|
|
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>
|
|
|
|
|
|
<if test="proId != null">
|
|
|
|
|
|
AND bp.pro_id = #{proId}
|
|
|
|
|
|
</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>
|
|
|
|
|
|
<if test="proId != null">
|
|
|
|
|
|
AND bp.pro_id = #{proId}
|
|
|
|
|
|
</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
|
|
|
|
|
|
WHERE mt.del_flag = '0' and mt.`level` = '4'
|
|
|
|
|
|
<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">
|
|
|
|
|
|
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
|
|
|
|
|
|
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 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-08-23 19:26:12 +08:00
|
|
|
|
<if test="proId != null">
|
2025-08-23 19:24:46 +08:00
|
|
|
|
AND bp.pro_id = #{proId}
|
|
|
|
|
|
</if>
|
2025-08-23 19:18:15 +08:00
|
|
|
|
AND mm.next_check_time IS NOT NULL
|
2025-08-24 18:02:56 +08:00
|
|
|
|
<if test="proId != null">
|
|
|
|
|
|
GROUP BY bp.pro_id
|
|
|
|
|
|
</if>
|
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
|
|
|
|
|
|
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
|
2025-08-26 19:54:22 +08:00
|
|
|
|
WHERE mm.next_check_time is not null AND mt.`level`=4
|
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 !=''">
|
|
|
|
|
|
AND mt2.type_name = #{typeName}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeModelName != null and typeModelName !=''">
|
|
|
|
|
|
AND mt.type_name = #{typeModelName}
|
|
|
|
|
|
</if>
|
2025-08-24 18:02:56 +08:00
|
|
|
|
<if test="proId != null">
|
|
|
|
|
|
GROUP BY bp.pro_id
|
|
|
|
|
|
</if>
|
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
|
|
|
|
|
|
bp.pro_name as proName,
|
|
|
|
|
|
sum(sai.num) num,
|
|
|
|
|
|
mt2.type_id as typeId,
|
|
|
|
|
|
sd.dept_name as deptName,
|
2025-08-24 18:02:56 +08:00
|
|
|
|
sd.dept_id as deptId
|
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-08-26 19:54:22 +08:00
|
|
|
|
where sai.is_slt = 0 and sai.end_time is null and bp.actual_end_date is not null AND sd.dept_name in
|
|
|
|
|
|
('送电一分公司','送电二分公司','检修试验分公司','建筑分公司(消防分公司)','安徽宏源电力建设有限公司','变电分公司')
|
2025-08-24 11:27:05 +08:00
|
|
|
|
<if test="proId != null">
|
|
|
|
|
|
AND bp.pro_id = #{proId}
|
|
|
|
|
|
</if>
|
2025-08-24 18:02:56 +08:00
|
|
|
|
GROUP BY
|
|
|
|
|
|
<if test="proId != null">
|
|
|
|
|
|
bp.pro_id,
|
|
|
|
|
|
</if>
|
2025-08-26 19:54:22 +08:00
|
|
|
|
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 12:25:38 +08:00
|
|
|
|
bp.pro_center as proCenter,
|
2025-08-24 18:02:56 +08:00
|
|
|
|
bp.actual_end_date as actualEndDate,
|
|
|
|
|
|
DATEDIFF(NOW(), bp.actual_end_date) as daysDiff,
|
2025-08-24 11:27:05 +08:00
|
|
|
|
sum(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-08-24 11:27:05 +08:00
|
|
|
|
sd.dept_name as deptName
|
|
|
|
|
|
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.is_slt = 0 and sai.end_time is null and bp.actual_end_date is not null
|
|
|
|
|
|
and sd.dept_id = #{deptId}
|
|
|
|
|
|
<if test="proId != null">
|
|
|
|
|
|
AND bp.pro_id = #{proId}
|
|
|
|
|
|
</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 !=''">
|
|
|
|
|
|
AND mt2.type_name = #{typeName}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeModelName != null and typeModelName !=''">
|
|
|
|
|
|
AND mt.type_name = #{typeModelName}
|
|
|
|
|
|
</if>
|
2025-08-26 19:54:22 +08:00
|
|
|
|
|
2025-08-24 11:27:05 +08:00
|
|
|
|
</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 !=''">
|
|
|
|
|
|
AND mt2.type_name = #{typeName}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeModelName != null and typeModelName !=''">
|
|
|
|
|
|
AND mt.type_name = #{typeModelName}
|
|
|
|
|
|
</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 !=''">
|
|
|
|
|
|
AND mt2.type_name = #{typeName}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeModelName != null and typeModelName !=''">
|
|
|
|
|
|
AND mt.type_name = #{typeModelName}
|
|
|
|
|
|
</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
|
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
|
mt2.type_name AS typeName,
|
2025-08-27 18:12:27 +08:00
|
|
|
|
mt.unit_name AS unit,
|
|
|
|
|
|
mt.storage_num AS num
|
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-08-24 11:27:05 +08:00
|
|
|
|
<if test="typeName != null and typeName !=''">
|
|
|
|
|
|
AND mt2.type_name = #{typeName}
|
|
|
|
|
|
</if>
|
2025-08-26 19:54:22 +08:00
|
|
|
|
<if test="typeModelName != null and typeModelName !=''">
|
|
|
|
|
|
AND mt.type_name = #{typeModelName}
|
|
|
|
|
|
</if>
|
2025-08-24 11:27:05 +08:00
|
|
|
|
</select>
|
2025-08-26 19:54:22 +08:00
|
|
|
|
|
2025-08-23 19:18:15 +08:00
|
|
|
|
</mapper>
|