1323 lines
60 KiB
XML
1323 lines
60 KiB
XML
<?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
|
|
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
|
|
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
|
|
<foreach collection="typeIds" item="id" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
GROUP BY bp.external_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,
|
|
'在用' 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 sai.ma_id = mm.ma_id
|
|
where sai.is_slt = 0 and sai.end_time is null
|
|
AND bp.external_id = #{externalId}
|
|
AND mt2.is_statics = #{isStatics}
|
|
<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>
|
|
<select id="getTypeKeeperName" resultType="java.lang.String">
|
|
select group_concat(DISTINCT su.nick_name) from ma_type_keeper mtk
|
|
left join sys_user su on mtk.user_id = su.user_id
|
|
left join sys_user_post sp on su.user_id = sp.user_id
|
|
where mtk.type_id = #{typeId} and sp.post_id = 5
|
|
</select>
|
|
<select id="getNumsByStatics" resultType="com.bonus.material.push.domain.StaticsNumsBean">
|
|
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)
|
|
+ IFNULL(subquery2.dsNum, 0) + IFNULL(subquery3.repairAuditNum, 0)
|
|
ELSE
|
|
IFNULL(mt.storage_num, 0) + IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0)
|
|
+ IFNULL(subquery2.dsNum, 0) + IFNULL(subquery3.repairAuditNum, 0)
|
|
END AS inventoryNum,
|
|
mt2.is_statics AS isStatics
|
|
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,
|
|
SUM(IFNULL( sai.num, 0 )) AS usNum,
|
|
sd.dept_name AS unitName
|
|
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
|
|
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>
|
|
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(CASE WHEN tt.task_status = 0 and rad.is_ds = 1 THEN IFNULL(rad.repair_num, 0) ELSE 0 END) AS dsNum,
|
|
SUM(CASE WHEN tt.task_status = 4 and rad.is_ds = 0 THEN (IFNULL(rad.repair_num, 0) - IFNULL(rad.repaired_num, 0) - IFNULL(rad.scrap_num, 0)) ELSE 0 END) AS repairNum
|
|
FROM repair_apply_details rad
|
|
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
|
|
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 sys_dept sd ON sd.dept_id = bp.imp_unit
|
|
WHERE
|
|
tt.task_status IN (0, 4)
|
|
AND tt.code is not null
|
|
<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>
|
|
GROUP BY
|
|
mt.type_id) AS subquery2 ON subquery2.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,
|
|
SUM(IFNULL(rad.repair_num, 0) ) AS repairAuditNum
|
|
FROM repair_audit_details rad
|
|
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
|
|
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 sys_dept sd ON sd.dept_id = bp.imp_unit
|
|
WHERE
|
|
tt.code is not null
|
|
and 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>
|
|
GROUP BY
|
|
mt.type_id) AS subquery3 ON subquery3.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' and mt2.is_statics is not null
|
|
<if test="isStatics != null">
|
|
and mt2.is_statics = #{isStatics}
|
|
</if>
|
|
</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
|
|
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 sys_dept sd ON sd.dept_id = bp.imp_unit
|
|
where mm.next_check_time is not null and mt.`level` = '4'
|
|
and sai.`status`='0' and sai.end_time is null
|
|
|
|
and mm.ma_status = 2
|
|
and mt2.type_id not in (6032,6008,6270)
|
|
and mt.jiju_type =2
|
|
<if test="deptId != null">
|
|
AND sd.dept_id = #{deptId}
|
|
</if>
|
|
|
|
</select>
|
|
<select id="getApproachingDetails" resultType="com.bonus.material.push.domain.MachineInfoBean">
|
|
SELECT
|
|
sd.dept_name as deptName,
|
|
bp.pro_center as proCenter,
|
|
bp.pro_name as proName,
|
|
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
|
|
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 sai.`status`='0' and sai.end_time is null
|
|
and mm.ma_status = 2
|
|
and mt2.type_id not in (6032,6008,6270)
|
|
and mt.jiju_type =2
|
|
<if test="proId != null">
|
|
AND bp.pro_id = #{proId}
|
|
</if>
|
|
<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 like concat ('%', #{typeName}, '%')
|
|
</if>
|
|
<if test="typeModelName != null and typeModelName !=''">
|
|
AND mt.type_name like concat ('%', #{typeModelName}, '%')
|
|
</if>
|
|
<if test="proId != null">
|
|
GROUP BY bp.pro_id
|
|
</if>
|
|
order by mt.jiju_type desc
|
|
</select>
|
|
<select id="getCompletionNotRefunded" resultType="com.bonus.material.push.domain.MachineInfoBean">
|
|
select
|
|
count(distinct bp.external_id) num,
|
|
sd.dept_name as deptName,
|
|
sd.dept_id as deptId
|
|
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 bp.actual_end_date is not null and bp.pro_center is not null and bp.external_id is not null
|
|
and dept_id not in (339,340,342,346)
|
|
and bai.is_show = 1
|
|
and mt.jiju_type = 1
|
|
and mt2.is_statics != 1
|
|
<if test="deptName != null and deptName != ''">
|
|
AND sd.dept_name = #{deptName}
|
|
</if>
|
|
GROUP BY bp.imp_unit
|
|
</select>
|
|
<select id="getCompletionNotRefundedDetails" resultType="com.bonus.material.push.domain.MachineInfoBean">
|
|
select
|
|
bp.pro_name as proName,
|
|
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,
|
|
mt2.type_name as typeName,
|
|
sd.dept_name as deptName,
|
|
bp.pro_center as proCenter
|
|
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 bp.actual_end_date is not null and bp.pro_center is not null and bp.external_id is not null
|
|
and sai.status = 0
|
|
and mt.jiju_type = 1
|
|
and mt2.is_statics != 1
|
|
and dept_id not in (339,340,342,346)
|
|
and bai.is_show = 1
|
|
<if test="deptId != null">
|
|
and sd.dept_id = #{deptId}
|
|
</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>
|
|
</select>
|
|
<select id="getInventoryAlert" resultType="com.bonus.material.push.domain.InventoryAlertBean">
|
|
select
|
|
mt.type_name as typeModelName,
|
|
mt2.type_name as typeName,
|
|
mt.storage_num as num
|
|
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 like concat ('%', #{typeName}, '%')
|
|
</if>
|
|
<if test="typeModelName != null and typeModelName !=''">
|
|
AND mt.type_name like concat ('%', #{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 like concat ('%', #{typeName}, '%')
|
|
</if>
|
|
<if test="typeModelName != null and typeModelName !=''">
|
|
AND mt.type_name like concat ('%', #{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)
|
|
AS approachingNum,
|
|
COUNT(CASE WHEN mm.next_check_time < NOW() THEN 1 ELSE NULL END) AS timeoutNum,
|
|
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_id AS typeId,
|
|
mt.type_name AS specification,
|
|
mt2.type_name AS materialName,
|
|
mt.unit_name AS materialDw,
|
|
mt.storage_num AS subKcNum
|
|
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="materialName != null and materialName !=''">
|
|
AND mt2.type_name like concat ('%', #{materialName}, '%')
|
|
</if>
|
|
<if test="specification != null and specification !=''">
|
|
AND mt.type_name like concat ('%', #{specification}, '%')
|
|
</if>
|
|
</select>
|
|
<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
|
|
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
|
|
</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
|
|
(
|
|
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)
|
|
</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
|
|
bp.pro_center as proCenter,
|
|
count(distinct bp.external_id) num,
|
|
sd.dept_name as deptName,
|
|
sd.dept_id as deptId
|
|
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
|
|
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
|
|
and bai.is_show = 1
|
|
GROUP BY bp.pro_center
|
|
</select>
|
|
<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,
|
|
sd.dept_name as deptName,
|
|
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 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 bai.is_show = 1
|
|
and mt.jiju_type = 1
|
|
and mt2.is_statics != 1
|
|
and dept_id not in (339,340,342,346)
|
|
<if test="proCenter != null and proCenter !=''">
|
|
and bp.pro_center= #{proCenter}
|
|
</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>
|
|
</select>
|
|
|
|
<select id="getDeviceNumByType" resultType="com.bonus.material.push.domain.TotalNumsBean">
|
|
SELECT
|
|
res.typeName as deviceName,
|
|
SUM( res.storeNum ) + SUM( dsNum )+ SUM( repairNum )+ SUM( repairAuditNum )+ SUM( repairInputNum )+ SUM( inputNum ) AS stNum,
|
|
SUM( res.usNum ) AS leaseNum
|
|
FROM
|
|
(
|
|
SELECT
|
|
mt.type_id AS typeId,
|
|
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,
|
|
mt.unit_name AS unit,
|
|
IFNULL( mt.buy_price, 0 ) AS buyPrice,
|
|
CASE
|
|
mt.manage_type
|
|
WHEN 0 THEN
|
|
IFNULL( subquery0.num, 0 ) ELSE IFNULL( mt.storage_num, 0 )
|
|
END AS storeNum,
|
|
IFNULL( subquery1.usNum, 0 ) AS usNum,
|
|
IFNULL( subquery2.dsNum, 0 ) AS dsNum,
|
|
IFNULL( subquery2.repairNum, 0 ) AS repairNum,
|
|
IFNULL( subquery12.repairAuditNum, 0 ) AS repairAuditNum,
|
|
IFNULL( subquery3.repairInputNum, 0 ) AS repairInputNum,
|
|
IFNULL( subquery4.inputNum, 0 ) AS inputNum,
|
|
CASE
|
|
mt.manage_type
|
|
WHEN 0 THEN
|
|
IFNULL( subquery0.num, 0 )+ IFNULL( subquery1.usNum, 0 ) + IFNULL( subquery2.dsNum, 0 ) + IFNULL( subquery2.repairNum, 0 ) + IFNULL( subquery3.repairInputNum, 0 ) + IFNULL( subquery12.repairAuditNum, 0 ) + IFNULL( subquery4.inputNum, 0 ) ELSE IFNULL( mt.storage_num, 0 )+ IFNULL( subquery1.usNum, 0 ) + IFNULL( subquery2.dsNum, 0 ) + IFNULL( subquery2.repairNum, 0 ) + IFNULL( subquery3.repairInputNum, 0 ) + IFNULL( subquery12.repairAuditNum, 0 ) + IFNULL( subquery4.inputNum, 0 )
|
|
END AS allNum,
|
|
CASE
|
|
mt.manage_type
|
|
WHEN 0 THEN
|
|
'编码' ELSE '数量'
|
|
END manageType
|
|
|
|
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,
|
|
SUM(
|
|
IFNULL( sai.num, 0 )) AS usNum
|
|
FROM
|
|
slt_agreement_info sai
|
|
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = sai.agreement_id
|
|
LEFT JOIN bm_project_info bp ON bp.project_id = bai.project_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
|
|
WHERE
|
|
sai.`status` = '0'
|
|
AND sai.`is_slt` = '0'
|
|
AND ( sai.source = 1 OR sai.source IS NULL )
|
|
AND sai.end_time IS NULL
|
|
AND sai.back_id IS NULL
|
|
AND mt.type_id IN (
|
|
2598,
|
|
2599,
|
|
2600,
|
|
2601,
|
|
2602,
|
|
2603,
|
|
2604,
|
|
2605,
|
|
2606,
|
|
2608,
|
|
2609,
|
|
2610,
|
|
2611,
|
|
2612,
|
|
2613,
|
|
2614,
|
|
2615,
|
|
2616,
|
|
2617,
|
|
2618,
|
|
2619,
|
|
2620,
|
|
2621,
|
|
4341,
|
|
4374,
|
|
4678,
|
|
2624,
|
|
2625,
|
|
2626,
|
|
2627,
|
|
2628,
|
|
2629,
|
|
2630,
|
|
2631,
|
|
2632,
|
|
2633,
|
|
2634,
|
|
2635,
|
|
2636,
|
|
2637,
|
|
2638,
|
|
2639,
|
|
2640,
|
|
2641,
|
|
2623,
|
|
2164,
|
|
2165,
|
|
2166,
|
|
4359,
|
|
4360,
|
|
4519,
|
|
2411,
|
|
4353,
|
|
2404,
|
|
2405,
|
|
2406,
|
|
2407,
|
|
2408,
|
|
2409,
|
|
2410,
|
|
2525,
|
|
3281
|
|
)
|
|
|
|
<if test="projectIds != null and projectIds.size() > 0">
|
|
AND bp.external_id in
|
|
<foreach item="item" index="index" collection="projectIds" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
|
|
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( CASE WHEN tt.task_status = 0 AND rad.is_ds = 1 THEN IFNULL( rad.repair_num, 0 ) ELSE 0 END ) AS dsNum,
|
|
SUM(
|
|
CASE
|
|
|
|
WHEN tt.task_status = 4
|
|
AND rad.is_ds = 0 THEN
|
|
(
|
|
IFNULL( rad.repair_num, 0 ) - IFNULL( rad.repaired_num, 0 ) - IFNULL( rad.scrap_num, 0 )) ELSE 0
|
|
END
|
|
) AS repairNum
|
|
FROM
|
|
repair_apply_details rad
|
|
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
|
|
INNER JOIN tm_task tt ON rad.task_id = tt.task_id
|
|
WHERE
|
|
tt.task_status IN ( 0, 4 )
|
|
AND tt.CODE IS NOT NULL
|
|
AND mt.type_id IN (
|
|
2598,
|
|
2599,
|
|
2600,
|
|
2601,
|
|
2602,
|
|
2603,
|
|
2604,
|
|
2605,
|
|
2606,
|
|
2608,
|
|
2609,
|
|
2610,
|
|
2611,
|
|
2612,
|
|
2613,
|
|
2614,
|
|
2615,
|
|
2616,
|
|
2617,
|
|
2618,
|
|
2619,
|
|
2620,
|
|
2621,
|
|
4341,
|
|
4374,
|
|
4678,
|
|
2624,
|
|
2625,
|
|
2626,
|
|
2627,
|
|
2628,
|
|
2629,
|
|
2630,
|
|
2631,
|
|
2632,
|
|
2633,
|
|
2634,
|
|
2635,
|
|
2636,
|
|
2637,
|
|
2638,
|
|
2639,
|
|
2640,
|
|
2641,
|
|
2623,
|
|
2164,
|
|
2165,
|
|
2166,
|
|
4359,
|
|
4360,
|
|
4519,
|
|
2411,
|
|
4353,
|
|
2404,
|
|
2405,
|
|
2406,
|
|
2407,
|
|
2408,
|
|
2409,
|
|
2410,
|
|
2525,
|
|
3281
|
|
)
|
|
GROUP BY
|
|
mt.type_id
|
|
) AS subquery2 ON subquery2.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,
|
|
SUM( IFNULL( rad.repair_num, 0 ) ) AS repairAuditNum
|
|
FROM
|
|
repair_audit_details rad
|
|
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
|
|
LEFT JOIN tm_task tt ON rad.task_id = tt.task_id
|
|
WHERE
|
|
tt.CODE IS NOT NULL
|
|
AND rad.`status` = '0'
|
|
GROUP BY
|
|
mt.type_id
|
|
) AS subquery12 ON subquery12.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,
|
|
SUM(
|
|
IFNULL( rid.repair_num, 0 ) - IFNULL( rid.input_num, 0 ) - IFNULL( rid.reject_num, 0 )) AS repairInputNum
|
|
FROM
|
|
repair_input_details rid
|
|
LEFT JOIN ma_type mt ON mt.type_id = rid.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
|
|
LEFT JOIN tm_task tt ON rid.task_id = tt.task_id
|
|
WHERE
|
|
IFNULL( rid.repair_num, 0 ) - IFNULL( rid.input_num, 0 ) - IFNULL( rid.reject_num, 0 ) > 0
|
|
AND tt.task_status = 0
|
|
AND mt.type_id IN (
|
|
2598,
|
|
2599,
|
|
2600,
|
|
2601,
|
|
2602,
|
|
2603,
|
|
2604,
|
|
2605,
|
|
2606,
|
|
2608,
|
|
2609,
|
|
2610,
|
|
2611,
|
|
2612,
|
|
2613,
|
|
2614,
|
|
2615,
|
|
2616,
|
|
2617,
|
|
2618,
|
|
2619,
|
|
2620,
|
|
2621,
|
|
4341,
|
|
4374,
|
|
4678,
|
|
2624,
|
|
2625,
|
|
2626,
|
|
2627,
|
|
2628,
|
|
2629,
|
|
2630,
|
|
2631,
|
|
2632,
|
|
2633,
|
|
2634,
|
|
2635,
|
|
2636,
|
|
2637,
|
|
2638,
|
|
2639,
|
|
2640,
|
|
2641,
|
|
2623,
|
|
2164,
|
|
2165,
|
|
2166,
|
|
4359,
|
|
4360,
|
|
4519,
|
|
2411,
|
|
4353,
|
|
2404,
|
|
2405,
|
|
2406,
|
|
2407,
|
|
2408,
|
|
2409,
|
|
2410,
|
|
2525,
|
|
3281
|
|
)
|
|
GROUP BY
|
|
mt.type_id
|
|
) AS subquery3 ON subquery3.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,
|
|
SUM(
|
|
IFNULL( pcd.check_num, 0 ) - IFNULL( pcd.input_num, 0 )) AS inputNum
|
|
FROM
|
|
purchase_check_details pcd
|
|
LEFT JOIN ma_type mt ON mt.type_id = pcd.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
|
|
IFNULL( pcd.check_num, 0 ) - IFNULL( pcd.input_num, 0 ) > 0
|
|
AND pcd.STATUS IN ( 3, 4, 13, 14 )
|
|
AND mt.type_id IN (
|
|
2598,
|
|
2599,
|
|
2600,
|
|
2601,
|
|
2602,
|
|
2603,
|
|
2604,
|
|
2605,
|
|
2606,
|
|
2608,
|
|
2609,
|
|
2610,
|
|
2611,
|
|
2612,
|
|
2613,
|
|
2614,
|
|
2615,
|
|
2616,
|
|
2617,
|
|
2618,
|
|
2619,
|
|
2620,
|
|
2621,
|
|
4341,
|
|
4374,
|
|
4678,
|
|
2624,
|
|
2625,
|
|
2626,
|
|
2627,
|
|
2628,
|
|
2629,
|
|
2630,
|
|
2631,
|
|
2632,
|
|
2633,
|
|
2634,
|
|
2635,
|
|
2636,
|
|
2637,
|
|
2638,
|
|
2639,
|
|
2640,
|
|
2641,
|
|
2623,
|
|
2164,
|
|
2165,
|
|
2166,
|
|
4359,
|
|
4360,
|
|
4519,
|
|
2411,
|
|
4353,
|
|
2404,
|
|
2405,
|
|
2406,
|
|
2407,
|
|
2408,
|
|
2409,
|
|
2410,
|
|
2525,
|
|
3281
|
|
)
|
|
GROUP BY
|
|
mt.type_id
|
|
) AS subquery4 ON subquery4.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.type_id IN (
|
|
2598,
|
|
2599,
|
|
2600,
|
|
2601,
|
|
2602,
|
|
2603,
|
|
2604,
|
|
2605,
|
|
2606,
|
|
2608,
|
|
2609,
|
|
2610,
|
|
2611,
|
|
2612,
|
|
2613,
|
|
2614,
|
|
2615,
|
|
2616,
|
|
2617,
|
|
2618,
|
|
2619,
|
|
2620,
|
|
2621,
|
|
4341,
|
|
4374,
|
|
4678,
|
|
2624,
|
|
2625,
|
|
2626,
|
|
2627,
|
|
2628,
|
|
2629,
|
|
2630,
|
|
2631,
|
|
2632,
|
|
2633,
|
|
2634,
|
|
2635,
|
|
2636,
|
|
2637,
|
|
2638,
|
|
2639,
|
|
2640,
|
|
2641,
|
|
2623,
|
|
2164,
|
|
2165,
|
|
2166,
|
|
4359,
|
|
4360,
|
|
4519,
|
|
2411,
|
|
4353,
|
|
2404,
|
|
2405,
|
|
2406,
|
|
2407,
|
|
2408,
|
|
2409,
|
|
2410,
|
|
2525,
|
|
3281
|
|
)
|
|
) res
|
|
GROUP BY
|
|
res.typeName
|
|
</select>
|
|
<select id="getProDataDetails" resultType="com.bonus.material.push.domain.MachineInfoBean">
|
|
SELECT
|
|
ANY_VALUE(bp.pro_name) as proName,
|
|
mt2.type_name as typeName,
|
|
mt.type_name as typeModelName,
|
|
mt.unit_name as unit,
|
|
sum(sai.num) num,
|
|
mt.lease_price as leasePrice,
|
|
ANY_VALUE(mt.type_id) as typeId,
|
|
mt2.is_statics as isStatics
|
|
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
|
|
<if test="proIds != null and proIds.size() > 0">
|
|
AND bp.external_id IN
|
|
<foreach collection="proIds" item="item" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</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 bp.pro_name,mt.type_id
|
|
</select>
|
|
</mapper>
|