StaPayapprovalDao.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.liang.dao.StaPayapprovalDao">
  4. <resultMap type="com.liang.entity.StaPayapproval" id="StaPayapprovalMap">
  5. <result property="id" column="ID" jdbcType="INTEGER"/>
  6. <result property="sqlx" column="SQLX" jdbcType="VARCHAR"/>
  7. <result property="fysq" column="FYSQ" jdbcType="INTEGER"/>
  8. <result property="ht" column="HT" jdbcType="INTEGER"/>
  9. <result property="htje" column="HTJE" jdbcType="NUMERIC"/>
  10. <result property="bcfkje" column="BCFKJE" jdbcType="NUMERIC"/>
  11. <result property="cjr" column="CJR" jdbcType="INTEGER"/>
  12. <result property="cjsj" column="CJSJ" jdbcType="TIMESTAMP"/>
  13. <result property="spzt" column="SPZT" jdbcType="VARCHAR"/>
  14. <result property="yszl" column="YSZL" jdbcType="VARCHAR"/>
  15. <result property="fkjh" column="FKJH" jdbcType="INTEGER"/>
  16. <result property="sqmc" column="SQMC" jdbcType="VARCHAR"/>
  17. </resultMap>
  18. <!--查询单个-->
  19. <select id="queryById" resultMap="StaPayapprovalMap">
  20. select b.*, g.SQMC as FYSQMC, p.RWS, g.XMMC as RWSMC, c.HTMC, c.WJ as HTWJ, p.JHMC as FKJHMC, b.CJSJ as CJRQ
  21. from sta_PayApproval b
  22. left join prj_PayPlan p on p.ID = b.FKJH
  23. left join prj_Contract c on c.ID = b.HT
  24. left join sta_BudgetApproval g on g.ID = b.FYSQ
  25. where b.ID = #{id}
  26. </select>
  27. <!--查询指定行数据-->
  28. <select id="queryAllByLimit" resultMap="StaPayapprovalMap">
  29. select
  30. ID, SQLX, FYSQ, HT, HTJE, BCFKJE, CJR, CJSJ, SPZT, YSZL, FKJH, SQMC
  31. from sta_PayApproval
  32. <where>
  33. <if test="id != null">
  34. and ID = #{id}
  35. </if>
  36. <if test="sqlx != null and sqlx != ''">
  37. and SQLX = #{sqlx}
  38. </if>
  39. <if test="fysq != null">
  40. and FYSQ = #{fysq}
  41. </if>
  42. <if test="ht != null">
  43. and HT = #{ht}
  44. </if>
  45. <if test="htje != null">
  46. and HTJE = #{htje}
  47. </if>
  48. <if test="bcfkje != null">
  49. and BCFKJE = #{bcfkje}
  50. </if>
  51. <if test="cjr != null">
  52. and CJR = #{cjr}
  53. </if>
  54. <if test="cjsj != null">
  55. and CJSJ = #{cjsj}
  56. </if>
  57. <if test="spzt != null and spzt != ''">
  58. and SPZT = #{spzt}
  59. </if>
  60. <if test="yszl != null and yszl != ''">
  61. and YSZL = #{yszl}
  62. </if>
  63. <if test="fkjh != null">
  64. and FKJH = #{fkjh}
  65. </if>
  66. <if test="sqmc != null and sqmc != ''">
  67. and SQMC = #{sqmc}
  68. </if>
  69. </where>
  70. limit #{pageable.offset}, #{pageable.pageSize}
  71. </select>
  72. <!--统计总行数-->
  73. <select id="count" resultType="java.lang.Long">
  74. select count(1)
  75. from sta_PayApproval
  76. <where>
  77. <if test="id != null">
  78. and ID = #{id}
  79. </if>
  80. <if test="sqlx != null and sqlx != ''">
  81. and SQLX = #{sqlx}
  82. </if>
  83. <if test="fysq != null">
  84. and FYSQ = #{fysq}
  85. </if>
  86. <if test="ht != null">
  87. and HT = #{ht}
  88. </if>
  89. <if test="htje != null">
  90. and HTJE = #{htje}
  91. </if>
  92. <if test="bcfkje != null">
  93. and BCFKJE = #{bcfkje}
  94. </if>
  95. <if test="cjr != null">
  96. and CJR = #{cjr}
  97. </if>
  98. <if test="cjsj != null">
  99. and CJSJ = #{cjsj}
  100. </if>
  101. <if test="spzt != null and spzt != ''">
  102. and SPZT = #{spzt}
  103. </if>
  104. <if test="yszl != null and yszl != ''">
  105. and YSZL = #{yszl}
  106. </if>
  107. <if test="fkjh != null">
  108. and FKJH = #{fkjh}
  109. </if>
  110. <if test="sqmc != null and sqmc != ''">
  111. and SQMC = #{sqmc}
  112. </if>
  113. </where>
  114. </select>
  115. <!--新增所有列-->
  116. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  117. insert into sta_PayApproval(SQLX, FYSQ, HT, HTJE, BCFKJE, CJR, CJSJ, SPZT, YSZL, FKJH, SQMC)
  118. values (#{sqlx}, #{fysq}, #{ht}, #{htje}, #{bcfkje}, #{cjr}, #{cjsj}, #{spzt}, #{yszl}, #{fkjh}, #{sqmc})
  119. </insert>
  120. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  121. insert into sta_PayApproval(SQLX, FYSQ, HT, HTJE, BCFKJE, CJR, CJSJ, SPZT, YSZL, FKJH, SQMC)
  122. values
  123. <foreach collection="entities" item="entity" separator=",">
  124. (#{entity.sqlx}, #{entity.fysq}, #{entity.ht}, #{entity.htje}, #{entity.bcfkje}, #{entity.cjr}, #{entity.cjsj}, #{entity.spzt}, #{entity.yszl}, #{entity.fkjh}, #{entity.sqmc})
  125. </foreach>
  126. </insert>
  127. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  128. insert into sta_PayApproval(SQLX, FYSQ, HT, HTJE, BCFKJE, CJR, CJSJ, SPZT, YSZL, FKJH, SQMC)
  129. values
  130. <foreach collection="entities" item="entity" separator=",">
  131. (#{entity.sqlx}, #{entity.fysq}, #{entity.ht}, #{entity.htje}, #{entity.bcfkje}, #{entity.cjr}, #{entity.cjsj}, #{entity.spzt}, #{entity.yszl}, #{entity.fkjh}, #{entity.sqmc})
  132. </foreach>
  133. on duplicate key update
  134. SQLX = values(SQLX),
  135. FYSQ = values(FYSQ),
  136. HT = values(HT),
  137. HTJE = values(HTJE),
  138. BCFKJE = values(BCFKJE),
  139. CJR = values(CJR),
  140. CJSJ = values(CJSJ),
  141. SPZT = values(SPZT),
  142. YSZL = values(YSZL),
  143. FKJH = values(FKJH)
  144. SQMC = values(SQMC),
  145. </insert>
  146. <!--通过主键修改数据-->
  147. <update id="update">
  148. update sta_PayApproval
  149. <set>
  150. <if test="sqlx != null and sqlx != ''">
  151. SQLX = #{sqlx},
  152. </if>
  153. <if test="htje != null">
  154. HTJE = #{htje},
  155. </if>
  156. <if test="bcfkje != null">
  157. BCFKJE = #{bcfkje},
  158. </if>
  159. <if test="yszl != null and yszl != ''">
  160. YSZL = #{yszl},
  161. </if>
  162. <if test="fkjh != null">
  163. FKJH = #{fkjh},
  164. </if>
  165. <if test="sqmc != null and sqmc != ''">
  166. SQMC = #{sqmc},
  167. </if>
  168. </set>
  169. where ID = #{id}
  170. </update>
  171. <!--撤销审核状态任务书-->
  172. <update id="tjrevokeApprove">
  173. update sta_PayApproval
  174. set SPZT = '未提交'
  175. where ID = #{id}
  176. </update>
  177. <!--通过主键删除-->
  178. <delete id="deleteById">
  179. delete from sta_PayApproval where ID = #{id}
  180. </delete>
  181. <!--获取付款申请列表-->
  182. <select id="getFksqList" resultMap="StaPayapprovalMap" parameterType="map">
  183. select b.*, u.name as CJRXM, FORMAT(b.CJSJ, 'yyyy-MM-dd') as CJRQ, c.HTMC, c.WJ as HTWJ, p.JHMC as FKJHMC, g.SQMC as FYSQMC, g.XMMC as RWSMC
  184. from sta_PayApproval b
  185. left join prj_PayPlan p on p.ID = b.FKJH
  186. left join prj_Contract c on c.ID = b.HT
  187. left join sta_BudgetApproval g on g.ID = b.FYSQ
  188. left join sys_user_info u on u.user_id = b.CJR
  189. where 1 = 1
  190. <if test="userId != null and userId != ''">
  191. and (b.CJR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
  192. </if>
  193. <if test="spzt != null and spzt != ''">
  194. and b.SPZT = #{spzt}
  195. </if>
  196. <if test="fysqmc != null and fysqmc != ''">
  197. and g.SQMC like '%'+#{fysqmc}+'%'
  198. </if>
  199. <if test="erpbh !=null and erpbh != ''" >
  200. and g.ERPBH like '%'+#{erpbh}+'%'
  201. </if>
  202. <if test="bh != null and bh != ''">
  203. and g.BH like '%'+#{bh}+'%'
  204. </if>
  205. <if test="cjsj1 != null and cjsj1 != ''">
  206. and b.CJSJ &gt;= #{cjsj1}
  207. </if>
  208. <if test="cjsj2 != null and cjsj2 != ''">
  209. and b.CJSJ &lt;= #{cjsj2}
  210. </if>
  211. <choose>
  212. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  213. order by ${sortName} ${sortOrder}
  214. </when>
  215. </choose>
  216. ORDER BY
  217. CASE
  218. WHEN b.SPZT = '部门主任审批' THEN 0
  219. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  220. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  221. WHEN b.SPZT = '主管院领导审批' THEN 3
  222. WHEN b.SPZT = '院长审批' THEN 4
  223. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  224. WHEN b.SPZT = '未提交' THEN 996
  225. WHEN b.SPZT = '未提交(返回)' THEN 997
  226. WHEN b.SPZT = '审批结束' THEN 998
  227. WHEN b.SPZT = '作废' THEN 999
  228. END
  229. ASC,
  230. p.CJSJ DESC
  231. </select>
  232. <!--批量删除付款申请-->
  233. <delete id="batchDelete" parameterType="java.util.ArrayList">
  234. delete from sta_PayApproval
  235. where ID in
  236. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  237. #{item}
  238. </foreach>
  239. </delete>
  240. <!--通过主键修改审批状态-->
  241. <update id="updateSpzt">
  242. update sta_PayApproval
  243. set SPZT = #{spzt}
  244. where ID = #{id}
  245. </update>
  246. </mapper>