StaPayapprovalDao.xml 9.8 KB

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