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">
|
|
|
|
|
select
|
|
|
|
|
bp.pro_name as proName,
|
|
|
|
|
sum(sai.num) typeNum,
|
|
|
|
|
mt2.type_id as typeId,
|
|
|
|
|
bp.pro_id as proId
|
|
|
|
|
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.pro_id = #{proId}
|
|
|
|
|
AND mt2.type_id in
|
|
|
|
|
<foreach collection="typeIds" item="id" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
GROUP BY bp.pro_id,mt2.is_statics
|
|
|
|
|
</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,
|
|
|
|
|
mm.keeper_name as typeKeeperName,
|
|
|
|
|
'在用' 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 bp.pro_id = #{proId}
|
|
|
|
|
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">
|
|
|
|
|
select su.nick_name from ma_type_keeper mtk
|
|
|
|
|
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">
|
|
|
|
|
select
|
|
|
|
|
</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-23 19:24:46 +08:00
|
|
|
where 1=1
|
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
|
|
|
|
|
GROUP BY bp.pro_id
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getApproachingDetails" resultType="com.bonus.material.push.domain.MachineInfoBean">
|
|
|
|
|
SELECT
|
|
|
|
|
sd.dept_name,
|
|
|
|
|
bp.pro_center,
|
|
|
|
|
bp.pro_name,
|
|
|
|
|
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-23 19:24:46 +08:00
|
|
|
WHERE mm.next_check_time IS NOT NULL
|
|
|
|
|
<if test="proId != null">
|
|
|
|
|
AND bp.pro_id = #{proId}
|
|
|
|
|
</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>
|
|
|
|
|
GROUP BY bp.pro_id
|
|
|
|
|
</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,
|
|
|
|
|
sd.dept_id
|
|
|
|
|
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
|
|
|
|
|
<if test="proId != null">
|
|
|
|
|
AND bp.pro_id = #{proId}
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY bp.pro_id,bp.imp_unit
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getCompletionNotRefundedDetails" 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
|
|
|
|
|
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>
|
|
|
|
|
GROUP BY bp.pro_id,bp.imp_unit
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getInventoryAlert" resultType="com.bonus.material.push.domain.InventoryAlertBean">
|
|
|
|
|
select
|
|
|
|
|
mt.type_name as typeModelName,
|
|
|
|
|
mt2.type_name as typeName,
|
|
|
|
|
mt.warn_num as warnNum,
|
|
|
|
|
mt.storage_num as num,
|
|
|
|
|
mt.warn_num - mt.storage_num as poorNum
|
|
|
|
|
from ma_type mt
|
|
|
|
|
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
|
|
|
|
where mt2.is_statics in (1,2,3,4,5,6,7)
|
|
|
|
|
<if test="typeName != null and typeName !=''">
|
|
|
|
|
AND mt2.type_name = #{typeName}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
2025-08-23 19:18:15 +08:00
|
|
|
</mapper>
|