AuditItemsMapper.xml 16 KB

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