123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- <?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.liang.dao.StaPayapprovalDao">
- <resultMap type="com.liang.entity.StaPayapproval" id="StaPayapprovalMap">
- <result property="id" column="ID" jdbcType="INTEGER"/>
- <result property="sqlx" column="SQLX" jdbcType="VARCHAR"/>
- <result property="fysq" column="FYSQ" jdbcType="INTEGER"/>
- <result property="ht" column="HT" jdbcType="INTEGER"/>
- <result property="htje" column="HTJE" jdbcType="NUMERIC"/>
- <result property="bcfkje" column="BCFKJE" jdbcType="NUMERIC"/>
- <result property="cjr" column="CJR" jdbcType="INTEGER"/>
- <result property="cjsj" column="CJSJ" jdbcType="TIMESTAMP"/>
- <result property="spzt" column="SPZT" jdbcType="VARCHAR"/>
- <result property="yszl" column="YSZL" jdbcType="VARCHAR"/>
- <result property="fkjh" column="FKJH" jdbcType="INTEGER"/>
- <result property="sqmc" column="SQMC" jdbcType="VARCHAR"/>
- <result property="bh" column="BH" jdbcType="VARCHAR"/>
- <result property="erpbh" column="ERPBH" jdbcType="VARCHAR"/>
- <result property="xmmc" column="XMMC" jdbcType="VARCHAR"/>
- <result property="nf" column="NF" jdbcType="VARCHAR"/>
- <result property="zfje" column="ZFJE" jdbcType="DOUBLE"/>
- <result property="xmid" column="XMID" jdbcType="INTEGER"/>
- </resultMap>
- <!--查询单个-->
- <select id="queryById" resultMap="StaPayapprovalMap">
- select b.FYSQ,b.HT,b.HTJE,b.BCFKJE,b.CJR,b.CJSJ,b.SPZT,b.FKJH,b.SQMC,b.ID,
- g.SQMC as FYSQMC,
- p.RWS,
- g.XMMC as RWSMC,
- c.HTMC,
- c.WJ as HTWJ,
- c.YSZL as YSZL,
- p.JHMC as FKJHMC,
- b.CJSJ as CJRQ,
- p.ZFJE
- from sta_PayApproval b
- left join prj_PayPlan p on p.ID = b.FKJH
- left join prj_Contract c on c.ID = b.HT
- left join sta_BudgetApproval g on g.ID = b.FYSQ
- where b.ID = #{id}
- </select>
- <!--查询指定行数据-->
- <select id="queryAllByLimit" resultMap="StaPayapprovalMap">
- select
- ID, SQLX, FYSQ, HT, HTJE, BCFKJE, CJR, CJSJ, SPZT, YSZL, FKJH, SQMC
- from sta_PayApproval
- <where>
- <if test="id != null">
- and ID = #{id}
- </if>
- <if test="sqlx != null and sqlx != ''">
- and SQLX = #{sqlx}
- </if>
- <if test="fysq != null">
- and FYSQ = #{fysq}
- </if>
- <if test="ht != null">
- and HT = #{ht}
- </if>
- <if test="htje != null">
- and HTJE = #{htje}
- </if>
- <if test="bcfkje != null">
- and BCFKJE = #{bcfkje}
- </if>
- <if test="cjr != null">
- and CJR = #{cjr}
- </if>
- <if test="cjsj != null">
- and CJSJ = #{cjsj}
- </if>
- <if test="spzt != null and spzt != ''">
- and SPZT = #{spzt}
- </if>
- <if test="yszl != null and yszl != ''">
- and YSZL = #{yszl}
- </if>
- <if test="fkjh != null">
- and FKJH = #{fkjh}
- </if>
- <if test="sqmc != null and sqmc != ''">
- and SQMC = #{sqmc}
- </if>
- </where>
- limit #{pageable.offset}, #{pageable.pageSize}
- </select>
- <!--统计总行数-->
- <select id="count" resultType="java.lang.Long">
- select count(1)
- from sta_PayApproval
- <where>
- <if test="id != null">
- and ID = #{id}
- </if>
- <if test="sqlx != null and sqlx != ''">
- and SQLX = #{sqlx}
- </if>
- <if test="fysq != null">
- and FYSQ = #{fysq}
- </if>
- <if test="ht != null">
- and HT = #{ht}
- </if>
- <if test="htje != null">
- and HTJE = #{htje}
- </if>
- <if test="bcfkje != null">
- and BCFKJE = #{bcfkje}
- </if>
- <if test="cjr != null">
- and CJR = #{cjr}
- </if>
- <if test="cjsj != null">
- and CJSJ = #{cjsj}
- </if>
- <if test="spzt != null and spzt != ''">
- and SPZT = #{spzt}
- </if>
- <if test="yszl != null and yszl != ''">
- and YSZL = #{yszl}
- </if>
- <if test="fkjh != null">
- and FKJH = #{fkjh}
- </if>
- <if test="sqmc != null and sqmc != ''">
- and SQMC = #{sqmc}
- </if>
- </where>
- </select>
- <!--新增所有列-->
- <insert id="insert" keyProperty="id" useGeneratedKeys="true">
- insert into sta_PayApproval(SQLX, FYSQ, HT, HTJE, BCFKJE, CJR, CJSJ, SPZT, YSZL, FKJH, SQMC)
- values (#{sqlx}, #{fysq}, #{ht}, #{htje}, #{bcfkje}, #{cjr}, #{cjsj}, #{spzt}, #{yszl}, #{fkjh}, #{sqmc})
- </insert>
- <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
- insert into sta_PayApproval(SQLX, FYSQ, HT, HTJE, BCFKJE, CJR, CJSJ, SPZT, YSZL, FKJH, SQMC)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.sqlx}, #{entity.fysq}, #{entity.ht}, #{entity.htje}, #{entity.bcfkje}, #{entity.cjr},
- #{entity.cjsj}, #{entity.spzt}, #{entity.yszl}, #{entity.fkjh}, #{entity.sqmc})
- </foreach>
- </insert>
- <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
- insert into sta_PayApproval(SQLX, FYSQ, HT, HTJE, BCFKJE, CJR, CJSJ, SPZT, YSZL, FKJH, SQMC)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.sqlx}, #{entity.fysq}, #{entity.ht}, #{entity.htje}, #{entity.bcfkje}, #{entity.cjr},
- #{entity.cjsj}, #{entity.spzt}, #{entity.yszl}, #{entity.fkjh}, #{entity.sqmc})
- </foreach>
- on duplicate key update
- SQLX = values(SQLX),
- FYSQ = values(FYSQ),
- HT = values(HT),
- HTJE = values(HTJE),
- BCFKJE = values(BCFKJE),
- CJR = values(CJR),
- CJSJ = values(CJSJ),
- SPZT = values(SPZT),
- YSZL = values(YSZL),
- FKJH = values(FKJH)
- SQMC = values(SQMC),
- </insert>
- <!--通过主键修改数据-->
- <update id="update">
- update sta_PayApproval
- <set>
- <if test="sqlx != null and sqlx != ''">
- SQLX = #{sqlx},
- </if>
- <if test="htje != null">
- HTJE = #{htje},
- </if>
- <if test="bcfkje != null">
- BCFKJE = #{bcfkje},
- </if>
- <if test="yszl != null and yszl != ''">
- YSZL = #{yszl},
- </if>
- <if test="fkjh != null">
- FKJH = #{fkjh},
- </if>
- <if test="sqmc != null and sqmc != ''">
- SQMC = #{sqmc},
- </if>
- <if test="spzt != null and spzt != ''">
- SPZT = #{spzt},
- </if>
- </set>
- where ID = #{id}
- </update>
- <!--撤销审核状态任务书-->
- <update id="tjrevokeApprove">
- update sta_PayApproval
- set SPZT = '未提交'
- where ID = #{id}
- </update>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete
- from sta_PayApproval
- where ID = #{id}
- </delete>
- <!--获取付款申请列表-->
- <select id="getFksqList" resultMap="StaPayapprovalMap" parameterType="map">
- SELECT
- b.*,
- g.BH,
- g.XMMC,
- g.ERPBH,
- g.NF,
- g.XMID,
- u.name AS CJRXM,
- b.CJSJ AS CJRQ,
- c.HTMC,
- c.WJ AS HTWJ,
- p.JHMC AS FKJHMC,
- g.SQMC AS FYSQMC,
- g.XMMC AS RWSMC
- FROM
- sta_PayApproval b
- LEFT JOIN prj_PayPlan p ON p.ID = b.FKJH
- LEFT JOIN prj_Contract c ON c.ID = b.HT
- LEFT JOIN sta_BudgetApproval g ON g.ID = b.FYSQ
- LEFT JOIN sys_user_info u ON u.user_id = b.CJR
- LEFT JOIN sys_dept_info d ON u.dept_id = d.dept_id
- WHERE
- 1 = 1
- <if test=" rwsmc != null and rwsmc != ''">
- and g.XMMC like '%'+#{rwsmc}+'%'
- </if>
- <if test="userId != null and userId != ''">
- and (b.CJR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
- </if>
- <if test="spzt != null and spzt != ''">
- and b.SPZT = #{spzt}
- </if>
- <if test="fysq != null and fysq != ''">
- and b.fysq=#{fysq}
- </if>
- <if test="fysqmc != null and fysqmc != ''">
- and g.SQMC like '%'+#{fysqmc}+'%'
- </if>
- <if test="cjr != null and cjr != ''">
- and u.name like '%'+#{cjr}+'%'
- </if>
- <if test="erpbh !=null and erpbh != ''">
- and g.ERPBH like '%'+#{erpbh}+'%'
- </if>
- <if test="bh != null and bh != ''">
- and g.BH like '%'+#{bh}+'%'
- </if>
- <if test="cjsj1 != null and cjsj1 != ''">
- and b.CJSJ >= #{cjsj1}
- </if>
- <if test="cjsj2 != null and cjsj2 != ''">
- and b.CJSJ <= #{cjsj2}
- </if>
- <if test="xmmc != null and xmmc != ''">
- and g.XMMC like '%'+#{xmmc}+'%'
- </if>
- <if test="nf != null and nf != ''">
- and g.nf = #{nf}
- </if>
- <if test="ssbmmc != null and ssbmmc != ''">
- and d.dept_name = #{ssbmmc}
- </if>
- <choose>
- <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
- order by ${sortName} ${sortOrder}
- </when>
- </choose>
- ORDER BY
- CASE
- WHEN b.SPZT = '部门主任审批' THEN 0
- WHEN b.SPZT = '科技项目管理专责审批' THEN 1
- WHEN b.SPZT = '科技部部门主任审批' THEN 2
- WHEN b.SPZT = '主管院领导审批' THEN 3
- WHEN b.SPZT = '院长审批' THEN 4
- WHEN b.SPZT = '科技项目管理专责确认' THEN 5
- WHEN b.SPZT = '未提交' THEN 996
- WHEN b.SPZT = '未提交(返回)' THEN 997
- WHEN b.SPZT = '审批结束' THEN 998
- WHEN b.SPZT = '作废' THEN 999
- END
- ASC,
- b.CJSJ DESC
- </select>
- <!--批量删除付款申请-->
- <delete id="batchDelete" parameterType="java.util.ArrayList">
- delete from sta_PayApproval
- where ID in
- <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </delete>
- <!--通过主键修改审批状态-->
- <update id="updateSpzt">
- update sta_PayApproval
- set SPZT = #{spzt}
- where ID = #{id}
- </update>
- <update id="updateHtje">
- update sta_PayApproval
- set HTJE = #{htje}
- where HT = #{id}
- </update>
- <select id="getFksq" resultMap="StaPayapprovalMap">
- select *
- from
- sta_PayApproval
- where
- SPZT != '作废'
- <if test="fysq != null and fysq != ''">
- and FYSQ = #{fysq}
- </if>
- </select>
- <select id="queryByHtId" resultType="com.liang.entity.StaPayapproval">
- SELECT * FROM sta_PayApproval WHERE HT = #{id}
- </select>
- <select id="getYFKJE" resultType="com.liang.entity.StaPayapproval">
- SELECT
- COALESCE(SUM(b.BCFKJE), 0) AS FKJE,
- COALESCE(a.BZJE, 0) / 10000 AS BZJE
- FROM sta_Reimbursement a
- left JOIN sta_PayApproval b ON a.FYSQ = b.FYSQ AND b.SPZT != '作废'
- WHERE a.FYSQ = #{fysq}
- and a.spzt != '作废'
- GROUP BY a.BZJE
- </select>
- <select id="getFkjh" resultType="com.liang.entity.StaPayapproval">
- select * from
- sta_PayApproval
- where
- FKJH = #{id}
- </select>
- <select id="selectPayByFkjh" resultType="java.lang.Double">
- SELECT SUM(BCFKJE) FROM sta_PayApproval WHERE FKJH = #{id} AND SPZT != '作废'
- </select>
- </mapper>
|