jhprjv2/yanzhu-jh/src/main/resources/mapper/project/SurProjectCostOutputMapper.xml

339 lines
17 KiB
XML
Raw Normal View History

2023-08-27 13:50: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.yanzhu.jh.project.mapper.SurProjectCostOutputMapper">
<resultMap type="SurProjectCostOutput" id="SurProjectCostOutputResult">
<result property="id" column="id" />
<result property="projectId" column="project_id" />
<result property="money" column="money" />
<result property="year" column="year" />
<result property="month" column="month" />
<result property="costType" column="cost_type" />
<result property="remark" column="remark" />
<result property="isDel" column="is_del" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
2024-04-18 23:28:34 +08:00
<result property="money2" column="money2" />
<result property="date1" column="date1" />
<result property="date2" column="date2" />
2024-04-24 00:26:19 +08:00
<result property="deptId" column="deptId"/>
2023-08-27 13:50:15 +08:00
</resultMap>
<sql id="selectSurProjectCostOutputVo">
2024-04-24 00:26:19 +08:00
select id, project_id, money, year, month, cost_type, remark, is_del, create_by, create_time, update_by, update_time,money2,date1,date2,deptId from sur_project_cost_output
2023-08-27 13:50:15 +08:00
</sql>
<select id="selectSurProjectCostOutputList" parameterType="SurProjectCostOutput" resultMap="SurProjectCostOutputResult">
<include refid="selectSurProjectCostOutputVo"/>
<where>
<if test="projectId != null "> and project_id = #{projectId}</if>
2024-04-24 00:26:19 +08:00
<if test="deptId != null "> and deptId = #{deptId}</if>
2023-08-27 13:50:15 +08:00
<if test="money != null "> and money = #{money}</if>
<if test="year != null "> and year = #{year}</if>
<if test="month != null "> and month = #{month}</if>
<if test="costType != null "> and cost_type = #{costType}</if>
<if test="isDel != null "> and is_del = #{isDel}</if>
2024-04-18 23:28:34 +08:00
<if test="money2 != null "> and money2 = #{money2}</if>
<if test="date1 != null "> and date1 = #{date1}</if>
<if test="date2 != null "> and date2 = #{date2}</if>
2023-08-27 13:50:15 +08:00
</where>
</select>
<select id="selectSurProjectCostOutputById" parameterType="Long" resultMap="SurProjectCostOutputResult">
<include refid="selectSurProjectCostOutputVo"/>
where id = #{id}
</select>
<insert id="insertSurProjectCostOutput" parameterType="SurProjectCostOutput" useGeneratedKeys="true" keyProperty="id">
insert into sur_project_cost_output
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="projectId != null">project_id,</if>
<if test="money != null">money,</if>
<if test="year != null">year,</if>
<if test="month != null">month,</if>
<if test="costType != null">cost_type,</if>
<if test="remark != null">remark,</if>
<if test="isDel != null">is_del,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
2024-04-18 23:28:34 +08:00
<if test="money2 != null">money2,</if>
<if test="date1 != null">date1,</if>
<if test="date2 != null">date2,</if>
2024-04-24 00:26:19 +08:00
<if test="deptId != null">deptId,</if>
2023-08-27 13:50:15 +08:00
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="projectId != null">#{projectId},</if>
<if test="money != null">#{money},</if>
<if test="year != null">#{year},</if>
<if test="month != null">#{month},</if>
<if test="costType != null">#{costType},</if>
<if test="remark != null">#{remark},</if>
<if test="isDel != null">#{isDel},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
2024-04-18 23:28:34 +08:00
<if test="money2 != null">#{money2},</if>
<if test="date1 != null">#{date1},</if>
<if test="date2 != null">#{date2},</if>
2024-04-24 00:26:19 +08:00
<if test="deptId != null">#{deptId},</if>
2023-08-27 13:50:15 +08:00
</trim>
</insert>
<update id="updateSurProjectCostOutput" parameterType="SurProjectCostOutput">
update sur_project_cost_output
<trim prefix="SET" suffixOverrides=",">
<if test="projectId != null">project_id = #{projectId},</if>
<if test="money != null">money = #{money},</if>
<if test="year != null">year = #{year},</if>
<if test="month != null">month = #{month},</if>
<if test="costType != null">cost_type = #{costType},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
2024-04-18 23:28:34 +08:00
<if test="money2 != null">money2 = #{money2},</if>
<if test="date1 != null">date1 = #{date1},</if>
<if test="date2 != null">date2 = #{date2},</if>
2024-04-24 00:26:19 +08:00
<if test="deptId != null">deptId = #{deptId},</if>
2023-08-27 13:50:15 +08:00
</trim>
where id = #{id}
</update>
<delete id="deleteSurProjectCostOutputById" parameterType="Long">
delete from sur_project_cost_output where id = #{id}
</delete>
<delete id="deleteSurProjectCostOutputByIds" parameterType="String">
delete from sur_project_cost_output where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
2023-08-31 23:57:18 +08:00
<select id="selectYearAndMonth" parameterType="SurProjectCostOutput" resultMap="SurProjectCostOutputResult">
SELECT *
FROM sur_project_cost_output
WHERE project_id = #{projectId}
and (
(YEAR=#{year} AND cost_type=2) OR cost_type NOT IN (2, 9)
OR (cost_type = 9 AND YEAR = #{year} AND MONTH &lt;= #{month})
OR (cost_type = 9 AND YEAR &lt; #{year})
)
</select>
2023-09-04 01:00:54 +08:00
2023-12-13 22:14:10 +08:00
<select id="sumByDeptId" parameterType="SurProjectCostOutput" resultMap="SurProjectCostOutputResult">
2024-04-06 01:31:05 +08:00
SELECT 10 cost_type , SUM(spco.money) money FROM sur_project_cost_output spco
left join sur_project sp on sp.id = spco.project_id
2024-04-08 01:54:00 +08:00
WHERE spco.cost_type=9 AND (spco.YEAR &lt;#{year} or ( spco.Year =#{year} and spco.MONTH &lt;= #{month})) and sp.isDel=0 and sp.progressVisible=0
2024-04-06 01:31:05 +08:00
<if test="id!=null and id>0"> and sp.deptId = #{id}</if>
<if test="proType != null and proType != ''"> and sp.projectType = #{proType}</if>
2023-09-04 01:00:54 +08:00
<if test="projectId!=null and projectId>0">
2024-04-06 01:31:05 +08:00
and spco.project_id=#{projectId}
2023-09-04 01:00:54 +08:00
</if>
2024-04-20 22:29:34 +08:00
2023-09-04 01:00:54 +08:00
UNION
2024-04-06 01:31:05 +08:00
SELECT 2 cost_type , SUM(spco.money) money FROM sur_project_cost_output spco
left join sur_project sp on sp.id = spco.project_id
WHERE (spco.cost_type=9 AND spco.YEAR=#{year} AND spco.MONTH &lt;= #{month} )
2024-04-06 21:21:55 +08:00
and sp.isDel=0 and sp.progressVisible=0
2024-04-06 01:31:05 +08:00
<if test="id!=null and id>0"> and sp.deptId = #{id}</if>
<if test="proType != null and proType != ''"> and sp.projectType = #{proType}</if>
2023-09-04 01:00:54 +08:00
<if test="projectId!=null and projectId>0">
2024-04-06 01:31:05 +08:00
and spco.project_id=#{projectId}
2023-09-04 01:00:54 +08:00
</if>
UNION
2024-04-06 01:31:05 +08:00
SELECT 9 cost_type , SUM(spco.money) money FROM sur_project_cost_output spco
left join sur_project sp on sp.id = spco.project_id
WHERE (spco.cost_type=9 AND spco.YEAR=#{year} AND spco.MONTH= #{month} )
2024-04-06 21:21:55 +08:00
and sp.isDel=0 and sp.progressVisible=0
2024-04-06 01:31:05 +08:00
<if test="id!=null and id>0"> and sp.deptId = #{id}</if>
<if test="proType != null and proType != ''"> and sp.projectType = #{proType}</if>
2023-09-04 01:00:54 +08:00
<if test="projectId!=null and projectId>0">
2024-04-06 01:31:05 +08:00
and spco.project_id=#{projectId}
2023-09-04 01:00:54 +08:00
</if>
</select>
2024-04-20 22:29:34 +08:00
<select id="sumForBsEnginAuditing" parameterType="SurProjectCostOutput" resultMap="SurProjectCostOutputResult">
select 1 cost_type,sum(money) money,'合同总金额' remark
from sur_project_cost_output a,sur_project sp
where a.project_id=sp.id and a.cost_type=3
and sp.isDel=0 and sp.progressVisible=0
<if test="id!=null and id>0"> and sp.deptId = #{id}</if>
<if test="proType != null and proType != ''"> and sp.projectType = #{proType}</if>
<if test="projectId!=null and projectId>0">
and a.project_id=#{projectId}
</if>
<if test="prjIds !=null and prjIds.size()>0">
and a.project_id in
<foreach collection="prjIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
SELECT 2 cost_type,SUM(money) money,'建安费总金额' remark
FROM sur_project_cost_output a,sur_project sp
WHERE a.project_id=sp.id AND a.cost_type=10
and sp.isDel=0 and sp.progressVisible=0
<if test="id!=null and id>0"> and sp.deptId = #{id}</if>
<if test="proType != null and proType != ''"> and sp.projectType = #{proType}</if>
<if test="projectId!=null and projectId>0">
and a.project_id=#{projectId}
</if>
<if test="prjIds !=null and prjIds.size()>0">
and a.project_id in
<foreach collection="prjIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
SELECT 3 cost_type,SUM(money2) money,'总计付款' remark
FROM sur_project_cost_output a,sur_project sp
WHERE a.project_id=sp.id AND a.cost_type in (11,12)
and sp.isDel=0 and sp.progressVisible=0
2024-07-05 23:33:45 +08:00
<if test="createTime!=null "> and a.date1 &gt;= #{createTime}</if>
<if test="updateTime!=null "> and a.date1 &lt;= #{updateTime}</if>
2024-04-20 22:29:34 +08:00
<if test="id!=null and id>0"> and sp.deptId = #{id}</if>
<if test="proType != null and proType != ''"> and sp.projectType = #{proType}</if>
<if test="projectId!=null and projectId>0">
and a.project_id=#{projectId}
</if>
<if test="prjIds !=null and prjIds.size()>0">
and a.project_id in
<foreach collection="prjIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
SELECT 4 cost_type,SUM(money2) money,'进度款已支付' remark
FROM sur_project_cost_output a,sur_project sp
WHERE a.project_id=sp.id AND a.cost_type in (11)
and sp.isDel=0 and sp.progressVisible=0
2024-07-05 23:33:45 +08:00
<if test="createTime!=null "> and a.date1 &gt;= #{createTime}</if>
<if test="updateTime!=null "> and a.date1 &lt;= #{updateTime}</if>
2024-04-20 22:29:34 +08:00
<if test="id!=null and id>0"> and sp.deptId = #{id}</if>
<if test="proType != null and proType != ''"> and sp.projectType = #{proType}</if>
<if test="projectId!=null and projectId>0">
and a.project_id=#{projectId}
</if>
<if test="prjIds !=null and prjIds.size()>0">
and a.project_id in
<foreach collection="prjIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
SELECT 5 cost_type,SUM(money2) money,'安措费已支付' remark
FROM sur_project_cost_output a,sur_project sp
WHERE a.project_id=sp.id AND a.cost_type IN (12)
and sp.isDel=0 and sp.progressVisible=0
2024-07-05 23:33:45 +08:00
<if test="createTime!=null "> and a.date1 &gt;= #{createTime}</if>
<if test="updateTime!=null "> and a.date1 &lt;= #{updateTime}</if>
2024-04-20 22:29:34 +08:00
<if test="id!=null and id>0"> and sp.deptId = #{id}</if>
<if test="proType != null and proType != ''"> and sp.projectType = #{proType}</if>
<if test="projectId!=null and projectId>0">
and a.project_id=#{projectId}
</if>
<if test="prjIds !=null and prjIds.size()>0">
and a.project_id in
<foreach collection="prjIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
SELECT 6 cost_type,SUM(money-money2) money,'挂账总金额' remark
FROM sur_project_cost_output a,sur_project sp
WHERE a.project_id=sp.id AND a.cost_type IN (11,12)
and sp.isDel=0 and sp.progressVisible=0
2024-07-05 23:33:45 +08:00
<if test="createTime!=null "> and a.date1 &gt;= #{createTime}</if>
<if test="updateTime!=null "> and a.date1 &lt;= #{updateTime}</if>
2024-04-20 22:29:34 +08:00
<if test="id!=null and id>0"> and sp.deptId = #{id}</if>
<if test="proType != null and proType != ''"> and sp.projectType = #{proType}</if>
<if test="projectId!=null and projectId>0">
and a.project_id=#{projectId}
</if>
<if test="prjIds !=null and prjIds.size()>0">
and a.project_id in
<foreach collection="prjIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="selectForBigEnginList" parameterType="SurProjectCostOutput" resultMap="SurProjectCostOutputResult">
2024-04-24 23:03:59 +08:00
SELECT a.id, a.project_id, a.money, a.year, a.month, a.cost_type, CONCAT(sp.projectName,'(',sd.dept_name,')') remark, a.is_del, a.create_by, a.create_time, a.update_by, a.update_time,a.money2,a.date1,a.date2
FROM sur_project_cost_output a,sur_project sp,sys_dept sd
WHERE a.project_id=sp.id AND a.cost_type IN (11,12) AND sd.dept_id=a.deptid
2024-04-20 22:29:34 +08:00
and sp.isDel=0 and sp.progressVisible=0
<if test="id!=null and id>0"> and sp.deptId = #{id}</if>
<if test="proType != null and proType != ''"> and sp.projectType = #{proType}</if>
<if test="projectId!=null and projectId>0">
and a.project_id=#{projectId}
</if>
<if test="prjIds !=null and prjIds.size()>0">
and a.project_id in
<foreach collection="prjIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
2024-07-02 23:42:34 +08:00
<if test="createTime!=null "> and a.date1 &gt;= #{createTime}</if>
<if test="updateTime!=null "> and a.date1 &lt;= #{updateTime}</if>
2024-04-20 22:29:34 +08:00
ORDER BY a.create_time
</select>
2024-04-26 00:08:04 +08:00
<select id="groupBYProject" parameterType="SurProjectCostOutput" resultMap="SurProjectCostOutputResult">
select x.id,x.remark,x.money,y.money money2,x.month from (
select a.dict_value id, a.dict_label remark,sum(b.money) money,count(a.id) month ,'总投资' cost_type from ( SELECT a.id,c.dict_label,c.dict_value
FROM sur_project a,sys_dict_data c
where a.isDel=0
<if test="costType==1">
and a.projectType=c.dict_value and c.dict_type='project_category'
</if>
<if test="costType==2">
and a.projiectLevel=c.dict_value and c.dict_type='project_level'
</if>
<if test="id!=null and id>0"> and a.deptId = #{id}</if>
) a
left join (select project_id,money from sur_project_cost_output where cost_type=1) b on a.id=b.project_id
group by a.dict_value,a.dict_label ) x,
(
select a.dict_value id, a.dict_label remark,sum(b.money) money,count(a.id) month ,'年度' cost_type from (
SELECT a.id,c.dict_label,c.dict_value
FROM sur_project a,sys_dict_data c
where a.isDel=0
<if test="costType==1">
and a.projectType=c.dict_value and c.dict_type='project_category'
</if>
<if test="costType==2">
and a.projiectLevel=c.dict_value and c.dict_type='project_level'
</if>
<if test="id!=null and id>0"> and a.deptId = #{id}</if>
) a
left join (select project_id,money from sur_project_cost_output where cost_type=2 and year=#{year}) b on a.id=b.project_id
group by a.dict_value,a.dict_label
)y where x.id=y.id
</select>
2023-08-27 13:50:15 +08:00
</mapper>