cqdevicemgt/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml

111 lines
5.0 KiB
XML
Raw Normal View History

2024-08-08 14:57:05 +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.sgzb.material.mapper.CalMonthlyMapper">
<insert id="insertCalcRecord" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean" useGeneratedKeys="true" keyProperty="id">
INSERT INTO slt_project_month (month,create_time) VALUES (#{month},now())
</insert>
<insert id="insertProMonCosts" useGeneratedKeys="true" keyProperty="id">
2024-09-06 10:34:28 +08:00
insert into project_month_costs(agreement_id,task_id,unit_id,project_id,month,cost_bearing_party,create_time)
2024-08-08 14:57:05 +08:00
values
2024-09-06 10:34:28 +08:00
(#{agreementId},#{taskId},#{unitId},#{projectId},#{month},#{costBearingParty},now())
2024-08-08 14:57:05 +08:00
</insert>
<insert id="insertProjectMonthDetail">
2024-09-06 10:34:28 +08:00
insert into project_month_detail (type_id,ma_id,unit,start_time,end_time,slt_days,slt_costs,month_temporarily_costs,pro_month_cost_id,num,lease_price,create_time)
2024-08-08 14:57:05 +08:00
values
2024-09-06 10:34:28 +08:00
(#{typeId},#{maId},#{unit},#{startTime},#{endTime},#{sltDays},#{sltCosts},#{monthTemporarilyCosts},#{proMonthCostId},#{num},#{leasePrice},now())
2024-08-08 14:57:05 +08:00
</insert>
<update id="updateProMonCosts">
2024-09-06 10:34:28 +08:00
update project_month_costs set costs = #{costs},update_time = now() where id = #{id}
2024-08-08 14:57:05 +08:00
</update>
<select id="getCalcRecords" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean" resultType="com.bonus.sgzb.material.domain.CalMonthlyBean">
2024-08-14 18:25:32 +08:00
select id,month from slt_project_month
2024-08-08 14:57:05 +08:00
where month = #{month}
</select>
<select id="getMonthCosts" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
SELECT
2024-08-26 10:44:59 +08:00
GROUP_CONCAT(pmc.id) as ids,
2024-08-08 14:57:05 +08:00
bui.unit_name AS unitName,
bp.lot_name AS projectName,
spm.month as month,
2024-08-23 17:28:42 +08:00
pmc.agreement_id as agreementId,
2024-08-08 14:57:05 +08:00
pmc.cost_bearing_party as costBearingParty,
2024-08-26 10:44:59 +08:00
SUM(pmc.costs) as costs
2024-08-08 14:57:05 +08:00
FROM
project_month_costs pmc
2024-08-14 18:25:32 +08:00
LEFT JOIN slt_project_month spm ON pmc.task_id = spm.id
2024-08-08 14:57:05 +08:00
LEFT JOIN bm_agreement_info bai ON pmc.agreement_id = bai.agreement_id
LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
2024-08-09 10:59:52 +08:00
WHERE 1=1
<if test="endTime != null and endTime != ''">
2024-08-13 09:07:25 +08:00
and spm.month = #{endTime}
2024-08-09 10:59:52 +08:00
</if>
AND pmc.agreement_id = #{agreementId}
<if test="costBearingParty != null and costBearingParty != ''">
and pmc.cost_bearing_party = #{costBearingParty}
</if>
2024-08-26 10:44:59 +08:00
GROUP BY spm.month,pmc.cost_bearing_party
2024-08-08 14:57:05 +08:00
</select>
<select id="getMonthDetails" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
SELECT
mt1.type_name AS typeName,
mt.type_name AS modelName,
bui.unit_name AS unitName,
bp.lot_name AS projectName,
mt.unit_name AS nuitName,
pmd.num as num,
pmc.cost_bearing_party as costBearingParty,
pmc.`month` as month,
pmd.lease_price as leasePrice,
DATE_FORMAT( pmd.start_time, '%Y-%m-%d' ) as startTime,
DATE_FORMAT( pmd.end_time, '%Y-%m-%d' ) as endTime,
pmd.slt_days as leaseDays,
pmd.slt_costs as costs,
pmd.month_temporarily_costs as realCosts
FROM
project_month_detail pmd
LEFT JOIN project_month_costs pmc ON pmd.pro_month_cost_id = pmc.id
LEFT JOIN bm_unit_info bui ON bui.unit_id = pmc.unit_id
LEFT JOIN bm_project_lot bp ON bp.lot_id = pmc.project_id
LEFT JOIN ma_type mt ON pmd.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
LEFT JOIN ma_machine mm ON mm.ma_id = pmd.ma_id
WHERE
pmc.id = #{id}
</select>
<select id="selectIdByProjectIdAndMonth" resultType="java.lang.String">
select id from project_month_costs
where project_id = #{projectId} and month = #{month} and cost_bearing_party = #{costBearingParty}
</select>
2024-08-08 14:57:05 +08:00
<delete id="deleteCalcRecord" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean">
2024-08-14 18:25:32 +08:00
delete from slt_project_month
2024-08-08 14:57:05 +08:00
where id = #{id}
</delete>
2024-08-14 18:25:32 +08:00
<delete id="deleteMonthlyDetail" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean">
delete
from project_month_detail
where pro_month_cost_id in
(select id from project_month_costs where task_id = #{id})
</delete>
2024-08-08 14:57:05 +08:00
<delete id="deleteMonthlyCosts" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean">
delete from project_month_costs
where task_id = #{id}
</delete>
<delete id="deleteCostByProjectIdAndMonth">
delete from project_month_costs
where project_id = #{projectId} and month = #{month} and cost_bearing_party = #{costBearingParty}
</delete>
<delete id="deleteDetailsByProMonthCostId">
delete from project_month_detail
where pro_month_cost_id = #{proMonthCostId}
</delete>
2024-08-08 14:57:05 +08:00
</mapper>