AuditItemsMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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,
  31. bill_no,
  32. bill_id,
  33. act_id,
  34. path_id,
  35. level_id,
  36. refno1,
  37. iffinal_item,
  38. refno2,
  39. refno3,
  40. branch_id,
  41. send_user_id,
  42. send_name,
  43. send_time,
  44. send_msg,
  45. audit_user_id,
  46. audit_item,
  47. audit_op_time,
  48. audit_msg,
  49. audit_status,
  50. bill_time
  51. from audit_items
  52. </sql>
  53. <select id="selectAuditItemsList" parameterType="AuditItems" resultMap="AuditItemsResult">
  54. <include refid="selectAuditItemsVo"/>
  55. <where>
  56. <if test="billNo != null and billNo != ''">and bill_no = #{billNo}</if>
  57. <if test="billId != null ">and bill_id = #{billId}</if>
  58. <if test="actId != null ">and act_id = #{actId}</if>
  59. <if test="pathId != null ">and path_id = #{pathId}</if>
  60. <if test="levelId != null ">and level_id = #{levelId}</if>
  61. <if test="refno1 != null and refno1 != ''">and refno1 = #{refno1}</if>
  62. <if test="iffinalItem != null and iffinalItem != ''">and iffinal_item = #{iffinalItem}</if>
  63. <if test="refno2 != null and refno2 != ''">and refno2 = #{refno2}</if>
  64. <if test="refno3 != null and refno3 != ''">and refno3 = #{refno3}</if>
  65. <if test="branchId != null ">and branch_id = #{branchId}</if>
  66. <if test="sendUserId != null ">and send_user_id = #{sendUserId}</if>
  67. <if test="sendName != null and sendName != ''">and send_name like concat('%', #{sendName}, '%')</if>
  68. <if test="sendTime != null ">and send_time = #{sendTime}</if>
  69. <if test="sendMsg != null and sendMsg != ''">and send_msg = #{sendMsg}</if>
  70. <if test="auditUserId != null ">and audit_user_id = #{auditUserId}</if>
  71. <if test="auditItem != null ">and audit_item = #{auditItem}</if>
  72. <if test="auditOpTime != null ">and audit_op_time = #{auditOpTime}</if>
  73. <if test="auditMsg != null and auditMsg != ''">and audit_msg = #{auditMsg}</if>
  74. <if test="auditStatus != null and auditStatus != ''">and audit_status = #{auditStatus}</if>
  75. <if test="billTime != null ">and bill_time = #{billTime},</if>
  76. </where>
  77. </select>
  78. <select id="selectAuditItemsById" parameterType="Long" resultMap="AuditItemsResult">
  79. <include refid="selectAuditItemsVo"/>
  80. where id = #{id}
  81. </select>
  82. <insert id="insertAuditItems" parameterType="AuditItems" useGeneratedKeys="true" keyProperty="id">
  83. insert into audit_items
  84. <trim prefix="(" suffix=")" suffixOverrides=",">
  85. <if test="billNo != null">bill_no,</if>
  86. <if test="billId != null">bill_id,</if>
  87. <if test="actId != null">act_id,</if>
  88. <if test="pathId != null">path_id,</if>
  89. <if test="levelId != null">level_id,</if>
  90. <if test="refno1 != null">refno1,</if>
  91. <if test="iffinalItem != null">iffinal_item,</if>
  92. <if test="refno2 != null">refno2,</if>
  93. <if test="refno3 != null">refno3,</if>
  94. <if test="branchId != null">branch_id,</if>
  95. <if test="sendUserId != null">send_user_id,</if>
  96. <if test="sendName != null">send_name,</if>
  97. <if test="sendTime != null">send_time,</if>
  98. <if test="sendMsg != null">send_msg,</if>
  99. <if test="auditUserId != null">audit_user_id,</if>
  100. <if test="auditItem != null">audit_item,</if>
  101. <if test="auditOpTime != null ">audit_op_time,</if>
  102. <if test="auditMsg != null">audit_msg,</if>
  103. <if test="auditStatus != null">audit_status,</if>
  104. <if test="billTime != null ">bill_time,</if>
  105. </trim>
  106. <trim prefix="values (" suffix=")" suffixOverrides=",">
  107. <if test="billNo != null">#{billNo},</if>
  108. <if test="billId != null">#{billId},</if>
  109. <if test="actId != null">#{actId},</if>
  110. <if test="pathId != null">#{pathId},</if>
  111. <if test="levelId != null">#{levelId},</if>
  112. <if test="refno1 != null">#{refno1},</if>
  113. <if test="iffinalItem != null">#{iffinalItem},</if>
  114. <if test="refno2 != null">#{refno2},</if>
  115. <if test="refno3 != null">#{refno3},</if>
  116. <if test="branchId != null">#{branchId},</if>
  117. <if test="sendUserId != null">#{sendUserId},</if>
  118. <if test="sendName != null">#{sendName},</if>
  119. <if test="sendTime != null">#{sendTime},</if>
  120. <if test="sendMsg != null">#{sendMsg},</if>
  121. <if test="auditUserId != null">#{auditUserId},</if>
  122. <if test="auditItem != null">#{auditItem},</if>
  123. <if test="auditOpTime != null ">#{auditOpTime},</if>
  124. <if test="auditMsg != null">#{auditMsg},</if>
  125. <if test="auditStatus != null">#{auditStatus},</if>
  126. <if test="billTime != null ">#{billTime},</if>
  127. </trim>
  128. </insert>
  129. <update id="updateAuditItems" parameterType="AuditItems">
  130. update audit_items
  131. <trim prefix="SET" suffixOverrides=",">
  132. <if test="billNo != null">bill_no = #{billNo},</if>
  133. <if test="billId != null">bill_id = #{billId},</if>
  134. <if test="actId != null">act_id = #{actId},</if>
  135. <if test="pathId != null">path_id = #{pathId},</if>
  136. <if test="levelId != null">level_id = #{levelId},</if>
  137. <if test="refno1 != null">refno1 = #{refno1},</if>
  138. <if test="iffinalItem != null">iffinal_item = #{iffinalItem},</if>
  139. <if test="refno2 != null">refno2 = #{refno2},</if>
  140. <if test="refno3 != null">refno3 = #{refno3},</if>
  141. <if test="branchId != null">branch_id = #{branchId},</if>
  142. <if test="sendUserId != null">send_user_id = #{sendUserId},</if>
  143. <if test="sendName != null">send_name = #{sendName},</if>
  144. <if test="sendTime != null">send_time = #{sendTime},</if>
  145. <if test="sendMsg != null">send_msg = #{sendMsg},</if>
  146. <if test="auditUserId != null">audit_user_id = #{auditUserId},</if>
  147. <if test="auditItem != null">audit_item = #{auditItem},</if>
  148. <if test="auditOpTime != null ">audit_op_time = #{auditOpTime},</if>
  149. <if test="auditMsg != null">audit_msg = #{auditMsg},</if>
  150. <if test="auditStatus != null">audit_status = #{auditStatus},</if>
  151. <if test="billTime != null ">bill_time = #{billTime},</if>
  152. </trim>
  153. where id = #{id}
  154. </update>
  155. <delete id="deleteAuditItemsById" parameterType="Long">
  156. delete
  157. from audit_items
  158. where id = #{id}
  159. </delete>
  160. <delete id="deleteAuditItemsByIds" parameterType="String">
  161. delete from audit_items where id in
  162. <foreach item="id" collection="array" open="(" separator="," close=")">
  163. #{id}
  164. </foreach>
  165. </delete>
  166. <select id="selectCountAuditItems" resultType="java.lang.Integer">
  167. SELECT count(*)
  168. FROM
  169. audit_items item
  170. LEFT JOIN t_corps corp ON corp.f_id = item.refno1
  171. LEFT JOIN audit_items_users us ON us.pid = item.id
  172. LEFT JOIN sys_user usr ON usr.user_id = item.audit_user_id
  173. where
  174. us.audit_status = 'S'
  175. AND item.audit_status = 'S'
  176. <if test="billNo != null and billNo != ''">and item.bill_no = #{billNo}</if>
  177. <if test="actId != null and actId != ''">and item.act_id = #{actId}</if>
  178. <if test="refno2 != null and refno2 != ''">and item.refno2 = #{refno2}</if>
  179. <if test="billId != null and billId != ''">and item.bill_id like concat('%', #{billId}, '%')</if>
  180. <if test="refno1 != null and refno1 != ''">and corp.f_name like concat('%', #{refno1}, '%')</if>
  181. <if test="sendUserId != null and sendUserId != ''">and item.send_user_id like concat('%', #{sendUserId}, '%')
  182. </if>
  183. <if test="billTime != null and billTime != ''">and item.bill_time = #{billTime}</if>
  184. <if test="auditUserId != null and auditUserId != ''">AND us.user_id = #{auditUserId}</if>
  185. <if test='sendTime != null and sendTime[0] != null and sendTime[0]!= ""'>
  186. and item.send_time &gt;= #{sendTime[0]}
  187. </if>
  188. <if test='sendTime != null and sendTime[1] != null and sendTime[1]!= ""'>
  189. and item.send_time &lt;= #{sendTime[1]}
  190. </if>
  191. <if test='auditOpTime != null and auditOpTime[0] != null and auditOpTime[0]!= ""'>
  192. and item.audit_op_time &gt;= #{auditOpTime[0]}
  193. </if>
  194. <if test='auditOpTime != null and auditOpTime[1] != null and auditOpTime[1]!= ""'>
  195. and item.audit_op_time &lt;= #{auditOpTime[1]}
  196. </if>
  197. ORDER BY
  198. item.send_time DESC
  199. </select>
  200. <select id="selectAuditItems" parameterType="AuditItems" resultType="Map">
  201. SELECT
  202. item.id,
  203. CASE
  204. item.act_id
  205. WHEN 410 THEN
  206. '下单审批'
  207. WHEN 420 THEN
  208. '配船审批'
  209. END actId,
  210. item.bill_id AS billId,
  211. corp.f_name AS refno1,
  212. item.refno2,
  213. item.refno3,
  214. item.refno2 AS refno4,
  215. item.bill_no AS billNo,
  216. us.user_id AS userId,
  217. item.audit_item,
  218. item.audit_user_id AS auditUserId,
  219. CASE
  220. item.audit_status
  221. WHEN 'O' THEN
  222. '提交'
  223. WHEN 'N' THEN
  224. '未知状态'
  225. WHEN 'S' THEN
  226. '待审'
  227. WHEN 'B' THEN
  228. '审核退回'
  229. WHEN 'A' THEN
  230. '审核通过'
  231. END audit,
  232. item.send_user_id AS sendUserId,
  233. item.send_name AS sendName,
  234. usr.user_name AS auditUserName,
  235. usr.nick_name AS nickName,
  236. item.send_time AS sendTime,
  237. item.audit_op_time AS auditOpTime,
  238. item.bill_time AS billTime,
  239. <if test="refno2 == 'SQ' or refno2 == 'CK' or refno2 == 'RK' or refno2 == 'XS' ">
  240. tw.f_money As monry,
  241. </if>
  242. item.audit_msg AS auditMsg
  243. FROM
  244. audit_items item
  245. LEFT JOIN t_corps corp ON corp.f_id = item.refno1
  246. LEFT JOIN audit_items_users us ON us.pid = item.id
  247. LEFT JOIN sys_user usr ON usr.user_id = item.audit_user_id
  248. <if test="refno2 == 'SQ' or refno2 == 'CK' or refno2 == 'RK' or refno2 == 'XS' ">
  249. LEFT JOIN t_warehousebills tw ON item.bill_id = tw.f_id
  250. </if>
  251. where
  252. 1=1
  253. <if test="billNo != null and billNo != ''">and item.bill_no = #{billNo}</if>
  254. <if test="actId != null and actId != ''">and item.act_id = #{actId}</if>
  255. <if test="refno3 != null and refno3 != ''">and item.refno3 = #{refno3}</if>
  256. <if test="auditStatus != null and auditStatus != ''">and item.audit_status = #{auditStatus} and us.audit_status = #{auditStatus} </if>
  257. <if test="refno2 != null and refno2 != ''">and item.refno2 = #{refno2}</if>
  258. <if test="billId != null and billId != ''">and item.bill_id like concat('%', #{billId}, '%')</if>
  259. <if test="refno1 != null and refno1 != ''">and corp.f_name like concat('%', #{refno1}, '%')</if>
  260. <if test="sendUserId != null">and item.send_user_id = #{sendUserId}
  261. </if>
  262. <if test="auditUserId != null">and item.audit_user_id = #{auditUserId}</if>
  263. <if test="billTime != null and billTime != ''">and item.bill_time = #{billTime}</if>
  264. <if test="auditUserId != null">AND us.user_id = #{auditUserId}</if>
  265. <if test='sendTimeList != null and sendTimeList[0] != null and sendTimeList[0]!= ""'>
  266. and item.send_time &gt;= #{sendTimeList[0]}
  267. </if>
  268. <if test='sendTimeList != null and sendTimeList[1] != null and sendTimeList[1]!= ""'>
  269. and item.send_time &lt;= #{sendTimeList[1]}
  270. </if>
  271. <if test='auditOpTimeList != null and auditOpTimeList[0] != null and auditOpTimeList[0]!= ""'>
  272. and item.audit_op_time &gt;= #{auditOpTimeList[0]}
  273. </if>
  274. <if test='auditOpTimeList != null and auditOpTimeList[1] != null and auditOpTimeList[1]!= ""'>
  275. and item.audit_op_time &lt;= #{auditOpTimeList[1]}
  276. </if>
  277. ORDER BY
  278. CONVERT(item.audit_status USING GBK) DESC,item.send_time DESC
  279. </select>
  280. <delete id="deleteUpLevelId" parameterType="com.ruoyi.approvalFlow.domain.AuditItems">
  281. DELETE
  282. item.*,
  283. userItem.*
  284. FROM audit_items item
  285. LEFT JOIN audit_items_users userItem ON userItem.pid = item.id
  286. WHERE item.id &gt; #{id}
  287. AND item.bill_id = #{billId}
  288. AND item.level_id &gt; #{levelId}
  289. </delete>
  290. <select id="selectWarehouseApprover" parameterType="com.ruoyi.approvalFlow.domain.AuditItems" resultType="Map">
  291. SELECT aud.id,
  292. us.user_name AS userName,
  293. us.nick_name AS nickName,
  294. aud.audit_status AS auditStatus,
  295. aud.audit_msg AS auditMsg,
  296. aud.audit_item AS auditItem,
  297. aud.audit_op_time AS auditOpTime,
  298. aud.bill_time AS billTime
  299. FROM audit_items aud
  300. LEFT JOIN sys_user us ON us.user_id = aud.audit_user_id
  301. WHERE aud.act_id = #{actId}
  302. AND aud.bill_id = #{id}
  303. </select>
  304. <delete id="deletePurchaseApproval" parameterType="com.ruoyi.approvalFlow.domain.AuditItems">
  305. DELETE item, userItem
  306. FROM audit_items item
  307. LEFT JOIN audit_items_users userItem ON userItem.pid = item.id
  308. WHERE item.act_id = #{actId}
  309. AND item.level_id &gt;= 0
  310. AND item.bill_id = #{billId}
  311. </delete>
  312. <update id="updateAuditStatus" parameterType="com.ruoyi.approvalFlow.domain.AuditItems">
  313. UPDATE audit_items it
  314. LEFT JOIN audit_items_users us ON us.pid = it.id
  315. SET it.audit_status = 'S',
  316. us.audit_status = 'S'
  317. WHERE it.level_id = #{levelId}
  318. AND it.bill_no = #{billNo}
  319. AND it.bill_id = #{billId}
  320. AND it.act_id = #{actId}
  321. AND it.audit_status = "N"
  322. </update>
  323. <select id="selectOrderAuditItems" parameterType="AuditItems" resultType="Map">
  324. SELECT
  325. item.id,
  326. CASE
  327. item.act_id
  328. WHEN 410 THEN
  329. '下单审批'
  330. WHEN 420 THEN
  331. '配船审批'
  332. END actId,
  333. item.bill_id AS billId,
  334. corp.f_name AS refno1,
  335. item.refno2,
  336. item.refno3,
  337. item.refno2 AS refno4,
  338. item.bill_no AS billNo,
  339. us.user_id AS userId,
  340. item.audit_item,
  341. item.audit_user_id AS auditUserId,
  342. CASE
  343. item.audit_status
  344. WHEN 'O' THEN
  345. '提交'
  346. WHEN 'N' THEN
  347. '未知状态'
  348. WHEN 'S' THEN
  349. '待审'
  350. WHEN 'B' THEN
  351. '审核退回'
  352. WHEN 'A' THEN
  353. '审核通过'
  354. END audit,
  355. item.send_user_id AS sendUserId,
  356. item.send_name AS sendName,
  357. usr.user_name AS auditUserName,
  358. usr.nick_name AS nickName,
  359. item.send_time AS sendTime,
  360. item.audit_op_time AS auditOpTime,
  361. item.bill_time AS billTime,
  362. <if test="refno2 == 'SQ' or refno2 == 'CK' or refno2 == 'RK' or refno2 == 'XS' ">
  363. tw.f_money As monry,
  364. tw.f_bsdate fBsdate,
  365. tp.f_name projectName,
  366. </if>
  367. item.audit_msg AS auditMsg
  368. FROM
  369. audit_items item
  370. LEFT JOIN t_corps corp ON corp.f_id = item.refno1
  371. LEFT JOIN audit_items_users us ON us.pid = item.id
  372. LEFT JOIN sys_user usr ON usr.user_id = item.audit_user_id
  373. <if test="refno2 == 'SQ' or refno2 == 'CK' or refno2 == 'RK' or refno2 == 'XS' ">
  374. LEFT JOIN t_warehousebills tw ON item.bill_id = tw.f_id
  375. LEFT JOIN t_project tp ON tp.f_id = tw.f_goodsid
  376. </if>
  377. where
  378. 1=1
  379. <if test="billNo != null and billNo != ''">and item.bill_no = #{billNo}</if>
  380. <if test="actId != null and actId != ''">and item.act_id = #{actId}</if>
  381. <if test="refno3 != null and refno3 != ''">and item.refno3 = #{refno3}</if>
  382. <if test="auditStatus != null and auditStatus != ''">and item.audit_status = #{auditStatus} and us.audit_status = #{auditStatus} </if>
  383. <if test="refno2 != null and refno2 != ''">and item.refno2 = #{refno2}</if>
  384. <if test="billId != null and billId != ''">and item.bill_id like concat('%', #{billId}, '%')</if>
  385. <if test="refno1 != null and refno1 != ''">and corp.f_name like concat('%', #{refno1}, '%')</if>
  386. <if test="sendUserId != null">and item.send_user_id = #{sendUserId}
  387. </if>
  388. <if test="auditUserId != null">and item.audit_user_id = #{auditUserId}</if>
  389. <if test="billTime != null">and item.bill_time = #{billTime}</if>
  390. <if test="auditUserId != null">AND us.user_id = #{auditUserId}</if>
  391. <if test="sendTimeList != null and (refno2 == 'SQ' or refno2 == 'CK' or refno2 == 'RK' or refno2 == 'XS') and sendTimeList[0] != null and sendTimeList[0]!= ''">
  392. and tw.f_bsdate &gt;= #{sendTimeList[0]}
  393. </if>
  394. <if test="sendTimeList != null and sendTimeList[1] != null and sendTimeList[1]!= '' and (refno2 == 'SQ' or refno2 == 'CK' or refno2 == 'RK' or refno2 == 'XS')">
  395. and tw.f_bsdate &lt;= #{sendTimeList[1]}
  396. </if>
  397. <if test='auditOpTimeList != null and auditOpTimeList[0] != null and auditOpTimeList[0]!= ""'>
  398. and item.audit_op_time &gt;= #{auditOpTimeList[0]}
  399. </if>
  400. <if test='auditOpTimeList != null and auditOpTimeList[1] != null and auditOpTimeList[1]!= ""'>
  401. and item.audit_op_time &lt;= #{auditOpTimeList[1]}
  402. </if>
  403. ORDER BY
  404. CONVERT(item.audit_status USING GBK) DESC,item.send_time DESC
  405. </select>
  406. <select id="selectAuditItemsUser" parameterType="AuditItems" resultMap="AuditItemsResult">
  407. <include refid="selectAuditItemsVo"/>
  408. <where>
  409. <if test="billNo != null and billNo != ''">and bill_no = #{billNo}</if>
  410. <if test="billId != null ">and bill_id = #{billId}</if>
  411. <if test="actId != null ">and act_id = #{actId}</if>
  412. <if test="pathId != null ">and path_id = #{pathId}</if>
  413. <if test="levelId != null ">and level_id = #{levelId}</if>
  414. <if test="refno1 != null and refno1 != ''">and refno1 = #{refno1}</if>
  415. <if test="iffinalItem != null and iffinalItem != ''">and iffinal_item = #{iffinalItem}</if>
  416. <if test="refno2 != null and refno2 != ''">and refno2 = #{refno2}</if>
  417. <if test="refno3 != null and refno3 != ''">and refno3 = #{refno3}</if>
  418. <if test="branchId != null ">and branch_id = #{branchId}</if>
  419. <if test="sendUserId != null ">and send_user_id = #{sendUserId}</if>
  420. <if test="sendName != null and sendName != ''">and send_name like concat('%', #{sendName}, '%')</if>
  421. <if test="sendTime != null ">and send_time = #{sendTime}</if>
  422. <if test="sendMsg != null and sendMsg != ''">and send_msg = #{sendMsg}</if>
  423. <if test="auditUserId != null ">and audit_user_id = #{auditUserId}</if>
  424. <if test="auditItem != null ">and audit_item = #{auditItem}</if>
  425. <if test="auditOpTime != null ">and audit_op_time = #{auditOpTime}</if>
  426. <if test="auditMsg != null and auditMsg != ''">and audit_msg = #{auditMsg}</if>
  427. <if test="auditStatus != null and auditStatus != ''">and audit_status = #{auditStatus}</if>
  428. <if test="billTime != null ">and bill_time = #{billTime},</if>
  429. </where>
  430. ORDER BY level_id ASC
  431. </select>
  432. </mapper>