StaPayapprovalDao.xml 12 KB

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