AuditItemsMapper.xml 20 KB

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