CheckItemMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.dk.mdm.mapper.ivt.CheckItemMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. item_id, check_id, item_index, sku_id, inv_id, inv_qty, box, piece, check_qty, balance_qty, staff_id, loss_reason, check_date, remarks, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user, o_inv_qty
  8. </sql>
  9. <!-- 盘点一览通用查询列 -->
  10. <sql id="Base_Column_List_Response">
  11. item.item_id,item.check_id,item.inv_id
  12. ,item.inv_qty,item.o_inv_qty,item.box,item.piece
  13. ,item.check_qty,item.balance_qty,item.staff_id
  14. ,item.loss_reason,item.check_date,item.remarks,item.flg_valid,item.cp_id
  15. ,sku.sku_code,sku.sku_name,sku.sku_model,brand.short_name,wh.wh_name
  16. ,dd.data_value AS "lossReasonName",staff.staff_name AS "dutyStaff"
  17. ,item.sku_id,inv.wh_id,inv.non_std_code,item.item_id AS "fromItemId"
  18. ,item.check_id AS "fromId",item.item_index,item.balance_qty AS "intoingQty"
  19. ,abs(item.balance_qty) AS "outingQty",item.price_into,item.intoing_amt
  20. ,0 AS "priceOut"
  21. </sql>
  22. <!-- 通用查询映射结果 -->
  23. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.ivt.CheckItem">
  24. <id column="item_id" property="itemId"/>
  25. <result column="check_id" property="checkId" typeHandler="UuidTypeHandler"/>
  26. <result column="item_index" property="itemIndex"/>
  27. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  28. <result column="inv_id" property="invId" typeHandler="UuidTypeHandler"/>
  29. <result column="inv_qty" property="invQty"/>
  30. <result column="box" property="box"/>
  31. <result column="piece" property="piece"/>
  32. <result column="check_qty" property="checkQty"/>
  33. <result column="balance_qty" property="balanceQty"/>
  34. <result column="price_into" property="priceInto"/>
  35. <result column="intoing_amt" property="intoingAmt"/>
  36. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  37. <result column="loss_reason" property="lossReason" typeHandler="UuidTypeHandler"/>
  38. <result column="check_date" property="checkDate" typeHandler="TimestampTypeHandler"/>
  39. <result column="remarks" property="remarks"/>
  40. <result column="flg_valid" property="flgValid"/>
  41. <result column="cp_id" property="cpId"/>
  42. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  43. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  44. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  45. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  46. <result column="op_app_code" property="opAppCode"/>
  47. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  48. <result column="op_db_user" property="opDbUser"/>
  49. <result column="o_inv_qty" property="oInvQty"/>
  50. </resultMap>
  51. <!-- 盘点一览查询映射结果 -->
  52. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.ivt.CheckItemResponse">
  53. <id column="item_id" property="itemId"/>
  54. <result column="check_id" property="checkId" typeHandler="UuidTypeHandler"/>
  55. <result column="item_index" property="itemIndex"/>
  56. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  57. <result column="inv_id" property="invId" typeHandler="UuidTypeHandler"/>
  58. <result column="inv_qty" property="invQty"/>
  59. <result column="box" property="box"/>
  60. <result column="piece" property="piece"/>
  61. <result column="check_qty" property="checkQty"/>
  62. <result column="balance_qty" property="balanceQty"/>
  63. <result column="price_into" property="priceInto"/>
  64. <result column="intoing_amt" property="intoingAmt"/>
  65. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  66. <result column="loss_reason" property="lossReason" typeHandler="UuidTypeHandler"/>
  67. <result column="check_date" property="checkDate" typeHandler="TimestampTypeHandler"/>
  68. <result column="remarks" property="remarks"/>
  69. <result column="flg_valid" property="flgValid"/>
  70. <result column="cp_id" property="cpId"/>
  71. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  72. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  73. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  74. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  75. <result column="op_app_code" property="opAppCode"/>
  76. <result column="sku_images" property="skuImages" typeHandler="JsonTypeHandler"/>
  77. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  78. <result column="op_db_user" property="opDbUser"/>
  79. <result column="o_inv_qty" property="oInvQty"/>
  80. </resultMap>
  81. <!-- 通用条件列 -->
  82. <sql id="Condition">
  83. <where>
  84. <if test="checkId != null and checkId != ''">
  85. AND check_id = #{checkId}::uuid
  86. </if>
  87. <if test="itemIndex != null">
  88. AND item_index = #{itemIndex}
  89. </if>
  90. <if test="skuId != null and skuId != ''">
  91. AND sku_id = #{skuId}
  92. </if>
  93. <if test="invId != null and invId != ''">
  94. AND inv_id = #{invId}
  95. </if>
  96. <if test="invQty != null">
  97. AND inv_qty = #{invQty}
  98. </if>
  99. <if test="checkQty != null">
  100. AND check_qty = #{checkQty}
  101. </if>
  102. <if test="balanceQty != null">
  103. AND balance_qty = #{balanceQty}
  104. </if>
  105. <if test="staffId != null and staffId != ''">
  106. AND staff_id = #{staffId}
  107. </if>
  108. <if test="lossReason != null and lossReason != ''">
  109. AND loss_reason = #{lossReason}
  110. </if>
  111. <if test="checkDate != null">
  112. AND check_date = #{checkDate}
  113. </if>
  114. <if test="remarks != null and remarks != ''">
  115. AND remarks = #{remarks}
  116. </if>
  117. <if test="flgValid != null">
  118. AND flg_valid = #{flgValid}
  119. </if>
  120. <if test="cpId != null">
  121. AND cp_id = #{cpId}
  122. </if>
  123. <if test="opCreateTime != null">
  124. AND op_create_time = #{opCreateTime}
  125. </if>
  126. <if test="opCreateUserId != null and opCreateUserId != ''">
  127. AND op_create_user_id = #{opCreateUserId}
  128. </if>
  129. <if test="opUpdateTime != null">
  130. AND op_update_time = #{opUpdateTime}
  131. </if>
  132. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  133. AND op_update_user_id = #{opUpdateUserId}
  134. </if>
  135. <if test="opAppCode != null and opAppCode != ''">
  136. AND op_app_code = #{opAppCode}
  137. </if>
  138. <if test="opTimestamp != null">
  139. AND op_timestamp = #{opTimestamp}
  140. </if>
  141. <if test="opDbUser != null and opDbUser != ''">
  142. AND op_db_user = #{opDbUser}
  143. </if>
  144. <if test="oInvQty != null">
  145. AND o_inv_qty = #{oInvQty}
  146. </if>
  147. </where>
  148. </sql>
  149. <!-- 盘点一览条件列 -->
  150. <sql id="Condition_Response">
  151. <where>
  152. <if test="checkId != null and checkId != ''">
  153. AND item.check_id = #{checkId}::uuid
  154. </if>
  155. </where>
  156. </sql>
  157. <sql id="idsForeach">
  158. <!-- 根据主键itemId批量操作 -->
  159. WHERE item_id in
  160. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  161. #{item}
  162. </foreach>
  163. </sql>
  164. <!-- 查询表t_psi_check_item,(条件查询+分页)列表 -->
  165. <select id="selectByCond" resultMap="BaseResultMapResponse">
  166. SELECT
  167. <include refid="Base_Column_List_Response"/>
  168. ,sku.sku_images
  169. FROM dkic_b.t_psi_check_item AS item
  170. LEFT JOIN dkic_b.t_mst_goods_sku AS sku ON item.sku_id=sku.sku_id
  171. LEFT JOIN dkic_b.t_psi_inventory AS inv ON inv.inv_id=item.inv_id
  172. LEFT JOIN dkic_b.t_mst_warehouse AS wh ON wh.wh_id=inv.wh_id
  173. LEFT JOIN dkic_b.t_mst_goods_brand AS brand ON brand.brand_id=sku.brand_id
  174. LEFT JOIN dkic_b.t_mst_staff AS staff ON staff.staff_id=item.staff_id
  175. left join dkic_b.t_mst_dictionary_data AS dd ON dd.data_id=item.loss_reason
  176. <include refid="Condition_Response"/>
  177. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  178. limit #{end} offset #{start}
  179. </if>
  180. </select>
  181. <!-- 查询表t_psi_check_item,(条件查询)个数 -->
  182. <select id="countByCond" resultType="Long">
  183. SELECT
  184. count(1)
  185. FROM dkic_b.t_psi_check_item
  186. <include refid="Condition"/>
  187. </select>
  188. <!-- 根据主键查询表t_psi_check_item的一行数据 -->
  189. <select id="selectById" resultMap="BaseResultMap">
  190. SELECT
  191. <include refid="Base_Column_List"/>
  192. FROM dkic_b.t_psi_check_item
  193. WHERE item_id = #{id}::uuid
  194. </select>
  195. <!-- 根据主键锁定表t_psi_check_item的一行数据 -->
  196. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  197. SELECT
  198. <include refid="Base_Column_List"/>
  199. FROM dkic_b.t_psi_check_item
  200. WHERE item_id = #{itemId}
  201. for update
  202. </select>
  203. <!-- 根据主键锁定表t_psi_check_item的多行数据 -->
  204. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  205. SELECT
  206. <include refid="Base_Column_List"/>
  207. FROM dkic_b.t_psi_check_item
  208. <include refid="idsForeach"/>
  209. for update
  210. </select>
  211. <insert id="insertBatch">
  212. insert into t_psi_check_item
  213. (
  214. <trim suffixOverrides=",">
  215. check_id,
  216. item_index,
  217. sku_id,
  218. inv_id,
  219. inv_qty,
  220. check_qty,
  221. balance_qty,
  222. staff_id,
  223. loss_reason,
  224. check_date,
  225. remarks,
  226. cp_id,
  227. op_app_code,
  228. o_inv_qty,
  229. </trim>
  230. )
  231. values
  232. <foreach collection="list" index="index" item="item" separator=",">
  233. (
  234. <trim suffixOverrides=",">
  235. #{item.checkId}::uuid,
  236. #{item.itemIndex},
  237. #{item.skuId}::uuid,
  238. #{item.invId}::uuid,
  239. #{item.invQty},
  240. #{item.checkQty},
  241. #{item.balanceQty},
  242. #{item.staffId}::uuid,
  243. #{item.lossReason}::uuid,
  244. #{item.checkDate},
  245. #{item.remarks},
  246. #{item.cpId},
  247. #{item.opAppCode},
  248. #{item.oInvQty},
  249. </trim>
  250. )
  251. </foreach>
  252. </insert>
  253. </mapper>