AuditItemsMapper.xml 19 KB

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