StaReimbursementDao.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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.StaReimbursementDao">
  4. <resultMap type="com.liang.entity.StaReimbursement" id="StaReimbursementMap">
  5. <result property="id" column="ID" jdbcType="INTEGER"/>
  6. <result property="bxpz" column="BXPZ" jdbcType="VARCHAR"/>
  7. <result property="fysq" column="FYSQ" jdbcType="INTEGER"/>
  8. <result property="bzje" column="BZJE" jdbcType="NUMERIC"/>
  9. <result property="sl" column="SL" jdbcType="NUMERIC"/>
  10. <result property="bhsje" column="BHSJE" jdbcType="NUMERIC"/>
  11. <result property="sf" column="SF" jdbcType="NUMERIC"/>
  12. <result property="bzr" column="BZR" jdbcType="INTEGER"/>
  13. <result property="cjsj" column="CJSJ" jdbcType="TIMESTAMP"/>
  14. <result property="mc" column="MC" jdbcType="VARCHAR"/>
  15. <result property="spzt" column="SPZT" jdbcType="VARCHAR"/>
  16. <result property="sfbyj" column="SFBYJ" jdbcType="VARCHAR" />
  17. </resultMap>
  18. <!--id查询单个-->
  19. <select id="queryById" resultMap="StaReimbursementMap">
  20. select r.*, b.FYLB, g.FYMC as FYLBMC, b.SQJE
  21. from sta_Reimbursement r
  22. left join sta_BudgetApproval b on b.ID = r.FYSQ
  23. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  24. where r.ID = #{id}
  25. </select>
  26. <!--fysq查询单个-->
  27. <select id="queryByFYSQ" resultMap="StaReimbursementMap">
  28. select *
  29. from sta_Reimbursement
  30. where FYSQ = #{fysq}
  31. </select>
  32. <!--查询指定行数据-->
  33. <select id="queryAllByLimit" resultMap="StaReimbursementMap">
  34. select *
  35. from sta_Reimbursement
  36. <where>
  37. <if test="id != null">
  38. and ID = #{id}
  39. </if>
  40. <if test="bxpz != null and bxpz != ''">
  41. and BXPZ = #{bxpz}
  42. </if>
  43. <if test="fysq != null">
  44. and FYSQ = #{fysq}
  45. </if>
  46. <if test="bzje != null">
  47. and BZJE = #{bzje}
  48. </if>
  49. <if test="sl != null">
  50. and SL = #{sl}
  51. </if>
  52. <if test="bhsje != null">
  53. and BHSJE = #{bhsje}
  54. </if>
  55. <if test="sf != null">
  56. and SF = #{sf}
  57. </if>
  58. <if test="bzr != null">
  59. and BZR = #{bzr}
  60. </if>
  61. <if test="cjsj != null">
  62. and CJSJ = #{cjsj}
  63. </if>
  64. <if test="mc != null and mc != ''">
  65. and MC = #{mc}
  66. </if>
  67. <if test="spzt != null and spzt != ''">
  68. and SPZT = #{spzt}
  69. </if>
  70. </where>
  71. limit #{pageable.offset}, #{pageable.pageSize}
  72. </select>
  73. <!--统计总行数-->
  74. <select id="count" resultType="java.lang.Long">
  75. select count(1)
  76. from sta_Reimbursement
  77. <where>
  78. <if test="id != null">
  79. and ID = #{id}
  80. </if>
  81. <if test="bxpz != null and bxpz != ''">
  82. and BXPZ = #{bxpz}
  83. </if>
  84. <if test="fysq != null">
  85. and FYSQ = #{fysq}
  86. </if>
  87. <if test="bzje != null">
  88. and BZJE = #{bzje}
  89. </if>
  90. <if test="sl != null">
  91. and SL = #{sl}
  92. </if>
  93. <if test="bhsje != null">
  94. and BHSJE = #{bhsje}
  95. </if>
  96. <if test="sf != null">
  97. and SF = #{sf}
  98. </if>
  99. <if test="bzr != null">
  100. and BZR = #{bzr}
  101. </if>
  102. <if test="cjsj != null">
  103. and CJSJ = #{cjsj}
  104. </if>
  105. <if test="mc != null and mc != ''">
  106. and MC = #{mc}
  107. </if>
  108. <if test="spzt != null and spzt != ''">
  109. and SPZT = #{spzt}
  110. </if>
  111. </where>
  112. </select>
  113. <!--新增所有列-->
  114. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  115. insert into sta_Reimbursement(BXPZ, FYSQ, BZJE, SL, BHSJE, SF, BZR, CJSJ, MC, SPZT)
  116. values (#{bxpz}, #{fysq}, #{bzje}, #{sl}, #{bhsje}, #{sf}, #{bzr}, #{cjsj}, #{mc}, #{spzt})
  117. </insert>
  118. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  119. insert into sta_Reimbursement(BXPZ, FYSQ, BZJE, SL, BHSJE, SF, BZR, CJSJ, MC, SPZT)
  120. values
  121. <foreach collection="entities" item="entity" separator=",">
  122. (#{entity.bxpz}, #{entity.fysq}, #{entity.bzje}, #{entity.sl}, #{entity.bhsje}, #{entity.sf}, #{entity.bzr},
  123. #{entity.cjsj}, #{entity.mc}, #{entity.spzt})
  124. </foreach>
  125. </insert>
  126. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  127. insert into sta_Reimbursement(BXPZ, FYSQ, BZJE, SL, BHSJE, SF, BZR, CJSJ, MC, SPZT)
  128. values
  129. <foreach collection="entities" item="entity" separator=",">
  130. (#{entity.bxpz}, #{entity.fysq}, #{entity.bzje}, #{entity.sl}, #{entity.bhsje}, #{entity.sf}, #{entity.bzr},
  131. #{entity.cjsj}, #{entity.mc}, #{entity.spzt})
  132. </foreach>
  133. on duplicate key update
  134. BXPZ = values(BXPZ),
  135. FYSQ = values(FYSQ),
  136. BZJE = values(BZJE),
  137. SL = values(SL),
  138. BHSJE = values(BHSJE),
  139. SF = values(SF),
  140. BZR = values(BZR),
  141. CJSJ = values(CJSJ),
  142. MC = values(MC),
  143. SPZT = values(SPZT)
  144. </insert>
  145. <!--通过主键修改数据-->
  146. <update id="update">
  147. update sta_Reimbursement
  148. set MC = #{mc},
  149. BXPZ = #{bxpz},
  150. BZJE = #{bzje},
  151. SL = #{sl},
  152. BHSJE = #{bhsje},
  153. SF = #{sf}
  154. where ID = #{id}
  155. </update>
  156. <!--通过主键删除-->
  157. <delete id="deleteById">
  158. delete
  159. from sta_Reimbursement
  160. where ID = #{id}
  161. </delete>
  162. <!--获取报账列表-->
  163. <select id="getReimburseList" resultMap="StaReimbursementMap" parameterType="map">
  164. select r.*, a.BH as FYSQBH, a.SQMC as FYSQMC, u.name as BZRXM, a.XMID, a.XMMC,
  165. CASE
  166. WHEN a.SFBYJ = 1 THEN '是' ELSE '否'
  167. END AS SFBYJ
  168. from sta_Reimbursement r
  169. inner join sta_BudgetApproval a on a.ID = r.FYSQ
  170. left join sys_user_info u on u.user_id = r.BZR
  171. where 1 = 1
  172. <if test="userId != null and userId != ''">
  173. and (r.BZR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = r.ID))
  174. </if>
  175. <if test="spzt != null and spzt != ''">
  176. and r.SPZT = #{spzt}
  177. </if>
  178. <if test="fysqbh != null and fysqbh != ''">
  179. and a.BH like '%'+#{fysqbh}+'%'
  180. </if>
  181. <if test="mc != null and mc != ''">
  182. and r.MC like '%'+#{mc}+'%'
  183. </if>
  184. <if test="xmmc !=null and mc != ''">
  185. and r.XMMC like '%'+#{xmmc}+'%'
  186. </if>
  187. <choose>
  188. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  189. order by ${sortName} ${sortOrder}
  190. </when>
  191. </choose>
  192. ORDER BY
  193. CASE
  194. WHEN r.SPZT = '部门主任审批' THEN 0
  195. WHEN r.SPZT = '科技项目管理专责审批' THEN 1
  196. WHEN r.SPZT = '科技部部门主任审批' THEN 2
  197. WHEN r.SPZT = '主管院领导审批' THEN 3
  198. WHEN r.SPZT = '院长审批' THEN 4
  199. WHEN r.SPZT = '科技项目管理专责确认' THEN 5
  200. WHEN r.SPZT = '未提交' THEN 996
  201. WHEN r.SPZT = '未提交(返回)' THEN 997
  202. WHEN r.SPZT = '审批结束' THEN 998
  203. WHEN r.SPZT = '作废' THEN 999
  204. END
  205. ASC,
  206. CJSJ DESC
  207. </select>
  208. <!--批量删除报账-->
  209. <delete id="batchDelete" parameterType="java.util.ArrayList">
  210. delete from sta_Reimbursement
  211. where ID in
  212. <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
  213. #{item}
  214. </foreach>
  215. </delete>
  216. <!--撤销审核状态报账-->
  217. <update id="tjrevokeApprove">
  218. update sta_Reimbursement
  219. set SPZT = '未提交'
  220. where ID = #{id}
  221. </update>
  222. <!--通过主键修改审批状态-->
  223. <update id="updateSpzt">
  224. update sta_Reimbursement
  225. set SPZT = #{spzt}
  226. where ID = #{id}
  227. </update>
  228. <!-- 通过主键修改报账-->
  229. <update id="updateBZJE">
  230. update sta_Reimbursement
  231. set BZJE = #{bzje}
  232. where ID = #{id}
  233. </update>
  234. </mapper>