AuditItemsMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.approvalFlow.mapper.AuditItemsMapper">
  6. <resultMap type="AuditItems" id="AuditItemsResult">
  7. <result property="id" column="id"/>
  8. <result property="billNo" column="bill_no"/>
  9. <result property="billId" column="bill_id"/>
  10. <result property="actId" column="act_id"/>
  11. <result property="pathId" column="path_id"/>
  12. <result property="levelId" column="level_id"/>
  13. <result property="refno1" column="refno1"/>
  14. <result property="iffinalItem" column="iffinal_item"/>
  15. <result property="refno2" column="refno2"/>
  16. <result property="refno3" column="refno3"/>
  17. <result property="branchId" column="branch_id"/>
  18. <result property="sendUserId" column="send_user_id"/>
  19. <result property="sendName" column="send_name"/>
  20. <result property="sendTime" column="send_time"/>
  21. <result property="sendMsg" column="send_msg"/>
  22. <result property="auditUserId" column="audit_user_id"/>
  23. <result property="auditItem" column="audit_item"/>
  24. <result property="auditOpTime" column="audit_op_time"/>
  25. <result property="auditMsg" column="audit_msg"/>
  26. <result property="auditStatus" column="audit_status"/>
  27. <result property="billTime" column="bill_time"/>
  28. </resultMap>
  29. <sql id="selectAuditItemsVo">
  30. select id, bill_no, bill_id, act_id, path_id, level_id, refno1, iffinal_item, refno2, refno3, branch_id, send_user_id, send_name, send_time, send_msg, audit_user_id, audit_item,audit_op_time, audit_msg, audit_status,bill_time from audit_items
  31. </sql>
  32. <select id="selectAuditItemsList" parameterType="AuditItems" resultMap="AuditItemsResult">
  33. <include refid="selectAuditItemsVo"/>
  34. <where>
  35. <if test="billNo != null and billNo != ''">and bill_no = #{billNo}</if>
  36. <if test="billId != null ">and bill_id = #{billId}</if>
  37. <if test="actId != null ">and act_id = #{actId}</if>
  38. <if test="pathId != null ">and path_id = #{pathId}</if>
  39. <if test="levelId != null ">and level_id = #{levelId}</if>
  40. <if test="refno1 != null and refno1 != ''">and refno1 = #{refno1}</if>
  41. <if test="iffinalItem != null and iffinalItem != ''">and iffinal_item = #{iffinalItem}</if>
  42. <if test="refno2 != null and refno2 != ''">and refno2 = #{refno2}</if>
  43. <if test="refno3 != null and refno3 != ''">and refno3 = #{refno3}</if>
  44. <if test="branchId != null ">and branch_id = #{branchId}</if>
  45. <if test="sendUserId != null ">and send_user_id = #{sendUserId}</if>
  46. <if test="sendName != null and sendName != ''">and send_name like concat('%', #{sendName}, '%')</if>
  47. <if test="sendTime != null ">and send_time = #{sendTime}</if>
  48. <if test="sendMsg != null and sendMsg != ''">and send_msg = #{sendMsg}</if>
  49. <if test="auditUserId != null ">and audit_user_id = #{auditUserId}</if>
  50. <if test="auditItem != null ">and audit_item = #{auditItem}</if>
  51. <if test="auditOpTime != null ">and audit_op_time = #{auditOpTime}</if>
  52. <if test="auditMsg != null and auditMsg != ''">and audit_msg = #{auditMsg}</if>
  53. <if test="auditStatus != null and auditStatus != ''">and audit_status = #{auditStatus}</if>
  54. <if test="billTime != null "> and bill_time = #{billTime},</if>
  55. </where>
  56. </select>
  57. <select id="selectAuditItemsById" parameterType="Long" resultMap="AuditItemsResult">
  58. <include refid="selectAuditItemsVo"/>
  59. where id = #{id}
  60. </select>
  61. <insert id="insertAuditItems" parameterType="AuditItems" useGeneratedKeys="true" keyProperty="id">
  62. insert into audit_items
  63. <trim prefix="(" suffix=")" suffixOverrides=",">
  64. <if test="billNo != null">bill_no,</if>
  65. <if test="billId != null">bill_id,</if>
  66. <if test="actId != null">act_id,</if>
  67. <if test="pathId != null">path_id,</if>
  68. <if test="levelId != null">level_id,</if>
  69. <if test="refno1 != null">refno1,</if>
  70. <if test="iffinalItem != null">iffinal_item,</if>
  71. <if test="refno2 != null">refno2,</if>
  72. <if test="refno3 != null">refno3,</if>
  73. <if test="branchId != null">branch_id,</if>
  74. <if test="sendUserId != null">send_user_id,</if>
  75. <if test="sendName != null">send_name,</if>
  76. <if test="sendTime != null">send_time,</if>
  77. <if test="sendMsg != null">send_msg,</if>
  78. <if test="auditUserId != null">audit_user_id,</if>
  79. <if test="auditItem != null">audit_item,</if>
  80. <if test="auditOpTime != null ">audit_op_time,</if>
  81. <if test="auditMsg != null">audit_msg,</if>
  82. <if test="auditStatus != null">audit_status,</if>
  83. <if test="billTime != null ">bill_time,</if>
  84. </trim>
  85. <trim prefix="values (" suffix=")" suffixOverrides=",">
  86. <if test="billNo != null">#{billNo},</if>
  87. <if test="billId != null">#{billId},</if>
  88. <if test="actId != null">#{actId},</if>
  89. <if test="pathId != null">#{pathId},</if>
  90. <if test="levelId != null">#{levelId},</if>
  91. <if test="refno1 != null">#{refno1},</if>
  92. <if test="iffinalItem != null">#{iffinalItem},</if>
  93. <if test="refno2 != null">#{refno2},</if>
  94. <if test="refno3 != null">#{refno3},</if>
  95. <if test="branchId != null">#{branchId},</if>
  96. <if test="sendUserId != null">#{sendUserId},</if>
  97. <if test="sendName != null">#{sendName},</if>
  98. <if test="sendTime != null">#{sendTime},</if>
  99. <if test="sendMsg != null">#{sendMsg},</if>
  100. <if test="auditUserId != null">#{auditUserId},</if>
  101. <if test="auditItem != null">#{auditItem},</if>
  102. <if test="auditOpTime != null ">#{auditOpTime},</if>
  103. <if test="auditMsg != null">#{auditMsg},</if>
  104. <if test="auditStatus != null">#{auditStatus},</if>
  105. <if test="billTime != null ">#{billTime},</if>
  106. </trim>
  107. </insert>
  108. <update id="updateAuditItems" parameterType="AuditItems">
  109. update audit_items
  110. <trim prefix="SET" suffixOverrides=",">
  111. <if test="billNo != null">bill_no = #{billNo},</if>
  112. <if test="billId != null">bill_id = #{billId},</if>
  113. <if test="actId != null">act_id = #{actId},</if>
  114. <if test="pathId != null">path_id = #{pathId},</if>
  115. <if test="levelId != null">level_id = #{levelId},</if>
  116. <if test="refno1 != null">refno1 = #{refno1},</if>
  117. <if test="iffinalItem != null">iffinal_item = #{iffinalItem},</if>
  118. <if test="refno2 != null">refno2 = #{refno2},</if>
  119. <if test="refno3 != null">refno3 = #{refno3},</if>
  120. <if test="branchId != null">branch_id = #{branchId},</if>
  121. <if test="sendUserId != null">send_user_id = #{sendUserId},</if>
  122. <if test="sendName != null">send_name = #{sendName},</if>
  123. <if test="sendTime != null">send_time = #{sendTime},</if>
  124. <if test="sendMsg != null">send_msg = #{sendMsg},</if>
  125. <if test="auditUserId != null">audit_user_id = #{auditUserId},</if>
  126. <if test="auditItem != null">audit_item = #{auditItem},</if>
  127. <if test="auditOpTime != null ">audit_op_time = #{auditOpTime},</if>
  128. <if test="auditMsg != null">audit_msg = #{auditMsg},</if>
  129. <if test="auditStatus != null">audit_status = #{auditStatus},</if>
  130. <if test="billTime != null ">bill_time = #{billTime},</if>
  131. </trim>
  132. where id = #{id}
  133. </update>
  134. <delete id="deleteAuditItemsById" parameterType="Long">
  135. delete from audit_items where id = #{id}
  136. </delete>
  137. <delete id="deleteAuditItemsByIds" parameterType="String">
  138. delete from audit_items where id in
  139. <foreach item="id" collection="array" open="(" separator="," close=")">
  140. #{id}
  141. </foreach>
  142. </delete>
  143. <select id="selectCountAuditItems" resultType="java.lang.Integer">
  144. SELECT count(*)
  145. FROM
  146. audit_items item
  147. LEFT JOIN t_corps corp ON corp.f_id = item.refno1
  148. LEFT JOIN audit_items_users us ON us.pid = item.id
  149. LEFT JOIN sys_user usr ON usr.user_id = item.audit_user_id
  150. where
  151. us.audit_status = 'S'
  152. AND item.audit_status = 'S'
  153. <if test="billNo != null and billNo != ''"> and item.bill_no = #{billNo}</if>
  154. <if test="actId != null and actId != ''"> and item.act_id = #{actId}</if>
  155. <if test="refno2 != null and refno2 != ''"> and item.refno2 = #{refno2}</if>
  156. <if test="billId != null and billId != ''"> and item.bill_id like concat('%', #{billId}, '%')</if>
  157. <if test="refno1 != null and refno1 != ''"> and corp.f_name like concat('%', #{refno1}, '%')</if>
  158. <if test="sendUserId != null and sendUserId != ''"> and item.send_user_id like concat('%', #{sendUserId}, '%')</if>
  159. <if test="billTime != null and billTime != ''"> and item.bill_time = #{billTime}</if>
  160. <if test="auditUserId != null and auditUserId != ''"> AND us.user_id = #{auditUserId}</if>
  161. <if test='sendTime != null and sendTime[0] != null and sendTime[0]!= ""'>
  162. and item.send_time &gt;= #{sendTime[0]}
  163. </if>
  164. <if test='sendTime != null and sendTime[1] != null and sendTime[1]!= ""'>
  165. and item.send_time &lt;= #{sendTime[1]}
  166. </if>
  167. <if test='auditOpTime != null and auditOpTime[0] != null and auditOpTime[0]!= ""'>
  168. and item.audit_op_time &gt;= #{auditOpTime[0]}
  169. </if>
  170. <if test='auditOpTime != null and auditOpTime[1] != null and auditOpTime[1]!= ""'>
  171. and item.audit_op_time &lt;= #{auditOpTime[1]}
  172. </if>
  173. ORDER BY
  174. item.send_time DESC
  175. </select>
  176. <select id="selectAuditItems" parameterType="AuditItems" resultType="Map">
  177. SELECT
  178. item.id,
  179. CASE
  180. item.act_id
  181. WHEN 410 THEN
  182. '下单审批'
  183. WHEN 420 THEN
  184. '配船审批'
  185. END actId,
  186. item.bill_id AS billId,
  187. corp.f_name AS refno1,
  188. item.refno2,
  189. item.refno3,
  190. item.bill_no AS billNo,
  191. us.user_id AS userId,
  192. item.audit_item,
  193. item.audit_user_id AS auditUserId,
  194. CASE
  195. item.audit_status
  196. WHEN 'O' THEN
  197. '提交'
  198. WHEN 'N' THEN
  199. '未知状态'
  200. WHEN 'S' THEN
  201. '待审'
  202. WHEN 'B' THEN
  203. '审核退回'
  204. WHEN 'A' THEN
  205. '审核通过'
  206. END audit,
  207. item.send_user_id AS sendUserId,
  208. usr.user_name AS auditUserName,
  209. usr.nick_name AS nickName,
  210. item.send_time AS sendTime,
  211. item.audit_op_time AS auditOpTime,
  212. item.bill_time AS billTime,
  213. item.audit_msg AS auditMsg
  214. FROM
  215. audit_items item
  216. LEFT JOIN t_corps corp ON corp.f_id = item.refno1
  217. LEFT JOIN audit_items_users us ON us.pid = item.id
  218. LEFT JOIN sys_user usr ON usr.user_id = item.audit_user_id
  219. where
  220. us.audit_status = 'S'
  221. <if test="billNo != null and billNo != ''"> and item.bill_no = #{billNo}</if>
  222. <if test="actId != null and actId != ''"> and item.act_id = #{actId}</if>
  223. <if test="refno2 != null and refno2 != ''"> and item.refno2 = #{refno2}</if>
  224. <if test="billId != null and billId != ''"> and item.bill_id like concat('%', #{billId}, '%')</if>
  225. <if test="refno1 != null and refno1 != ''"> and corp.f_name like concat('%', #{refno1}, '%')</if>
  226. <if test="sendUserId != null and sendUserId != ''"> and item.send_user_id like concat('%', #{sendUserId}, '%')</if>
  227. <if test="billTime != null and billTime != ''"> and item.bill_time = #{billTime}</if>
  228. <if test="auditUserId != null and auditUserId != ''"> AND us.user_id = #{auditUserId}</if>
  229. <if test='sendTime != null and sendTime[0] != null and sendTime[0]!= ""'>
  230. and item.send_time &gt;= #{sendTime[0]}
  231. </if>
  232. <if test='sendTime != null and sendTime[1] != null and sendTime[1]!= ""'>
  233. and item.send_time &lt;= #{sendTime[1]}
  234. </if>
  235. <if test='auditOpTime != null and auditOpTime[0] != null and auditOpTime[0]!= ""'>
  236. and item.audit_op_time &gt;= #{auditOpTime[0]}
  237. </if>
  238. <if test='auditOpTime != null and auditOpTime[1] != null and auditOpTime[1]!= ""'>
  239. and item.audit_op_time &lt;= #{auditOpTime[1]}
  240. </if>
  241. AND item.audit_status = 'S'
  242. ORDER BY
  243. item.send_time DESC
  244. </select>
  245. <delete id="deleteUpLevelId" parameterType="com.ruoyi.approvalFlow.domain.AuditItems">
  246. DELETE
  247. item.*,
  248. userItem.*
  249. FROM
  250. audit_items item
  251. LEFT JOIN audit_items_users userItem ON userItem.pid = item.id
  252. WHERE
  253. item.id &gt; #{id}
  254. AND item.bill_id = #{billId}
  255. AND item.level_id &gt; #{levelId}
  256. </delete>
  257. <select id="selectWarehouseApprover" parameterType="com.ruoyi.approvalFlow.domain.AuditItems" resultType="Map">
  258. SELECT
  259. aud.id,
  260. us.user_name AS userName,
  261. us.nick_name AS nickName,
  262. aud.audit_status AS auditStatus,
  263. aud.audit_msg AS auditMsg,
  264. aud.audit_item AS auditItem,
  265. aud.audit_op_time AS auditOpTime,
  266. aud.bill_time AS billTime
  267. FROM
  268. audit_items aud
  269. LEFT JOIN sys_user us ON us.user_id = aud.audit_user_id
  270. WHERE
  271. aud.act_id = #{actId}
  272. AND aud.bill_id = #{id}
  273. </select>
  274. <delete id="deletePurchaseApproval" parameterType="com.ruoyi.approvalFlow.domain.AuditItems">
  275. DELETE item, userItem
  276. FROM
  277. audit_items item
  278. LEFT JOIN audit_items_users userItem ON userItem.pid = item.id
  279. WHERE
  280. item.act_id = #{actId}
  281. AND item.level_id &gt;= 0
  282. AND item.bill_id = #{billId}
  283. </delete>
  284. <update id="updateAuditStatus" parameterType="com.ruoyi.approvalFlow.domain.AuditItems">
  285. UPDATE audit_items it
  286. LEFT JOIN audit_items_users us ON us.pid = it.id
  287. SET it.audit_status = 'S', us.audit_status = 'S'
  288. WHERE
  289. it.level_id = #{levelId}
  290. AND it.bill_no = #{billNo}
  291. AND it.bill_id = #{billId}
  292. AND it.act_id = #{actId}
  293. AND it.audit_status = "N"
  294. </update>
  295. </mapper>