2025-06-29 14:43:51 +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.ConsProjectLeaseMoneyMapper" >
<select id= "getRealtionList" resultType= "com.bonus.material.push.domain.ConsProjectLeaseMoneyBean" >
select
bai.agreement_id as agreementId
from bm_agreement_info bai
left join bm_unit bu on bai.unit_id = bu.unit_id
left join bm_project bp on bai.project_id = bp.pro_id
</select>
<select id= "getConsMonthMoney" resultType= "com.bonus.material.push.domain.ConsProjectLeaseMoneyBean" >
SELECT
res.id,
res.deviceName,
res.deviceModel,
2025-07-03 09:00:09 +08:00
res.typeId,
2025-06-29 14:43:51 +08:00
sum(res.leaseNum) as leaseNum,
res.startTime,
2025-07-03 09:00:09 +08:00
res.buyPrice as leasePrice,
2025-06-29 14:43:51 +08:00
res.code,
sum(ROUND(res.leaseNum*res.buyPrice*res.type,2)) as leaseMoney,
res.time
FROM
(
SELECT
sai.id,
2025-07-03 09:00:09 +08:00
sai.type_id as typeId,
mt2.type_name as deviceName,
mt1.type_name as deviceModel,
2025-06-29 14:43:51 +08:00
sai.num AS leaseNum,
sai.start_time as startTime,
tt.CODE as code,
ROUND(IFNULL(mt1.NOTAX_PRICE,0) ,2) as buyPrice,
1 as type,
tt.CREATE_TIME as time
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt1 ON sai.type_id = mt1.type_id
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
2025-07-03 09:00:09 +08:00
LEFT JOIN tm_task tt on sai.back_id = tt.task_id
2025-06-29 14:43:51 +08:00
WHERE sai.agreement_id = #{agreementId} AND sai.start_time BETWEEN #{startTime} AND #{endTime} AND mt1.CONSUMABLE = 1 AND (ISNULL(sai.end_time) OR LEFT(sai.start_time,7) != LEFT(sai.end_time,7))
UNION
SELECT
sai.ID,
2025-07-03 09:00:09 +08:00
sai.type_id as typeId,
mt2.type_name as deviceName,
mt1.type_name as deviceModel,
2025-06-29 14:43:51 +08:00
sai.NUM AS leaseNum,
sai.start_time as startTime,
tt.CODE as code,
ROUND(IFNULL(mt1.NOTAX_PRICE,0) ,2) as buyPrice,
-1 as type,tt.CREATE_TIME as time
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt1 ON sai.type_id = mt1.type_id
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
2025-07-03 09:00:09 +08:00
LEFT JOIN tm_task tt on sai.back_id = tt.task_id
2025-06-29 14:43:51 +08:00
WHERE
sai.agreement_id = #{agreementId} AND sai.status = 1
AND sai.end_time BETWEEN #{startTime} AND #{endTime} AND mt1.CONSUMABLE = 1 AND LEFT(sai.start_time,7) != LEFT(sai.end_time,7) AND sai.start_time > '2024-01-01'
) res
2025-07-03 09:00:09 +08:00
group by res.typeId,
2025-06-29 14:43:51 +08:00
res.startTime,
res.code
</select>
<insert id= "insertProjectConsMonthInfo" parameterType= "java.util.List" >
insert into project_month_info (agreementId,typeId,leaseNum,leaseDate,returnDate,leasePrice,leaseMoney,
2025-07-03 09:00:09 +08:00
taskId,push_status,push_time,push_remark,is_flag,type,jiju_type,buy_price,money)
2025-06-29 14:43:51 +08:00
VALUES
<foreach collection= "list" item= "item" separator= "," >
(
#{item.leaseName},
#{item.typeId},
#{item.leaseNum},
2025-07-03 09:00:09 +08:00
#{item.startTime},
2025-06-29 14:43:51 +08:00
#{item.returnDate},
#{item.leasePrice},
#{item.leaseMoney},
#{item.taskId},
#{item.pushStatus},
#{item.pushTime},
#{item.pushRemark},
0,
2,
2025-07-03 09:00:09 +08:00
1,
2025-06-29 14:43:51 +08:00
#{item.buyPrice},
#{item.money}
)
</foreach>
</insert>
<select id= "getScrapMoney" resultType= "com.bonus.material.push.domain.ConsProjectLeaseMoneyBean" >
select
sad.id as id,
sad.apply_id as applyId,
sad.type_id as typeId,
sad.ma_id as maId,
sad.num as leaseNum,
sad.start_time as startTime,
sad.end_time as endTime,
sad.price as leasePrice,
sad.money as leaseMoney
from slt_agreement_details sad
left join slt_agreement_apply saa on sad.apply_id = saa.id
where
saa.agreement_id = #{agreementId}
and sad.slt_type=4 and sad.is_charge = 1
</select>
<insert id= "insertProjectOthersMonthInfo" parameterType= "java.util.List" >
insert into project_month_info (agreementId,typeId,leaseNum,leaseDate,returnDate,leasePrice,leaseMoney,
2025-07-03 09:00:09 +08:00
taskId,push_status,push_time,push_remark,is_flag,type,jiju_type,buy_price,money)
2025-06-29 14:43:51 +08:00
VALUES
<foreach collection= "list" item= "item" separator= "," >
(
#{item.leaseName},
#{item.typeId},
#{item.leaseNum},
2025-07-03 09:00:09 +08:00
#{item.startTime},
#{item.endTime},
2025-06-29 14:43:51 +08:00
#{item.leasePrice},
#{item.leaseMoney},
#{item.taskId},
#{item.pushStatus},
#{item.pushTime},
#{item.pushRemark},
0,
#{item.type},
2025-07-03 09:00:09 +08:00
1,
2025-06-29 14:43:51 +08:00
#{item.buyPrice},
#{item.money}
)
</foreach>
</insert>
<select id= "getLostMoney" resultType= "com.bonus.material.push.domain.ConsProjectLeaseMoneyBean" >
select
sad.id as id,
sad.apply_id as applyId,
sad.type_id as typeId,
sad.ma_id as maId,
sad.num as leaseNum,
sad.start_time as startTime,
sad.end_time as endTime,
sad.price as leasePrice,
sad.money as leaseMoney
from slt_agreement_details sad
left join slt_agreement_apply saa on sad.apply_id = saa.id
where
saa.agreement_id = #{agreementId}
and sad.slt_type=2 and sad.is_charge = 1
</select>
<select id= "getRepairMoney" resultType= "com.bonus.material.push.domain.ConsProjectLeaseMoneyBean" >
select
sad.id as id,
sad.apply_id as applyId,
sad.type_id as typeId,
sad.ma_id as maId,
sad.num as leaseNum,
sad.start_time as startTime,
sad.end_time as endTime,
sad.price as leasePrice,
sad.money as leaseMoney
from slt_agreement_details sad
left join slt_agreement_apply saa on sad.apply_id = saa.id
where
saa.agreement_id = #{agreementId}
and sad.slt_type=3 and sad.is_charge = 1
</select>
<insert id= "insertProjectMonthCosts" parameterType= "java.util.List" >
insert into project_month_costs (agreement_id,lease_money,cons_money,scrap_money,
2025-07-03 09:00:09 +08:00
lost_money,repair_money,task_id,is_flag,month,jiju_type)
2025-06-29 14:43:51 +08:00
VALUES
<foreach collection= "list" item= "item" separator= "," >
(
#{item.agreementId},
#{item.leaseTotal},
#{item.consTotal},
#{item.scrapTotal},
#{item.lostTotal},
#{item.repairTotal},
#{item.taskId},
0,
2025-07-03 09:00:09 +08:00
#{item.month},
1
2025-06-29 14:43:51 +08:00
)
</foreach>
</insert>
2025-07-05 13:48:29 +08:00
<select id= "getIwsProjectList" resultType= "com.bonus.material.basic.domain.BmProject" >
select
dfs.id as externalId,
2025-07-07 09:20:56 +08:00
case dfs.project_status
2025-07-07 09:24:00 +08:00
when '开工准备' then 0
when '在建' then 1
when '停工' then 2
when '完工未竣工' then 3
when '竣工' then 4
2025-07-07 09:20:56 +08:00
else dfs.project_status
end as proStatus,
2025-07-05 13:48:29 +08:00
dfs.real_end_date as actualEndDate
from data_center.dx_fb_son dfs
</select>
<update id= "updateIwsProject" >
<foreach collection= "list" item= "item" separator= ";" >
UPDATE bm_project
SET
pro_status = #{item.proStatus},
actual_end_date = #{item.actualEndDate}
WHERE external_id = #{item.externalId}
</foreach>
</update>
2025-06-29 14:43:51 +08:00
</mapper>