PurchaseItemMapper.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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.pur.PurchaseItemMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. item_id, pur_id, item_index, sku_id, item_qty, price_std, amt_std, price_pur, item_amt, price_discount, non_std_code, into_status, intoing_qty, intoing_amt, into_qty, into_amt, return_qty, return_amt, 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
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.pur.PurchaseItem">
  11. <id column="item_id" property="itemId"/>
  12. <result column="pur_id" property="purId" typeHandler="UuidTypeHandler"/>
  13. <result column="item_index" property="itemIndex"/>
  14. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  15. <result column="item_qty" property="itemQty"/>
  16. <result column="price_std" property="priceStd"/>
  17. <result column="amt_std" property="amtStd"/>
  18. <result column="price_pur" property="pricePur"/>
  19. <result column="item_amt" property="itemAmt"/>
  20. <result column="price_discount" property="priceDiscount"/>
  21. <result column="non_std_code" property="nonStdCode"/>
  22. <result column="into_status" property="intoStatus"/>
  23. <result column="intoing_qty" property="intoingQty"/>
  24. <result column="intoing_amt" property="intoingAmt"/>
  25. <result column="into_qty" property="intoQty"/>
  26. <result column="into_amt" property="intoAmt"/>
  27. <result column="return_qty" property="returnQty"/>
  28. <result column="return_amt" property="returnAmt"/>
  29. <result column="remarks" property="remarks"/>
  30. <result column="flg_valid" property="flgValid"/>
  31. <result column="cp_id" property="cpId"/>
  32. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  33. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  34. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  35. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  36. <result column="op_app_code" property="opAppCode"/>
  37. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  38. <result column="op_db_user" property="opDbUser"/>
  39. </resultMap>
  40. <!-- 通用条件列 -->
  41. <sql id="Condition">
  42. <where>
  43. <if test="purId != null and purId != ''">
  44. AND pur_id = #{purId}
  45. </if>
  46. <if test="itemIndex != null">
  47. AND item_index = #{itemIndex}
  48. </if>
  49. <if test="skuId != null and skuId != ''">
  50. AND sku_id = #{skuId}
  51. </if>
  52. <if test="itemQty != null">
  53. AND item_qty = #{itemQty}
  54. </if>
  55. <if test="priceStd != null">
  56. AND price_std = #{priceStd}
  57. </if>
  58. <if test="amtStd != null">
  59. AND amt_std = #{amtStd}
  60. </if>
  61. <if test="pricePur != null">
  62. AND price_pur = #{pricePur}
  63. </if>
  64. <if test="itemAmt != null">
  65. AND item_amt = #{itemAmt}
  66. </if>
  67. <if test="priceDiscount != null">
  68. AND price_discount = #{priceDiscount}
  69. </if>
  70. <if test="nonStdCode != null and nonStdCode != ''">
  71. AND non_std_code = #{nonStdCode}
  72. </if>
  73. <if test="intoStatus != null and intoStatus != ''">
  74. AND into_status = #{intoStatus}
  75. </if>
  76. <if test="intoingQty != null">
  77. AND intoing_qty = #{intoingQty}
  78. </if>
  79. <if test="intoingAmt != null">
  80. AND intoing_amt = #{intoingAmt}
  81. </if>
  82. <if test="intoQty != null">
  83. AND into_qty = #{intoQty}
  84. </if>
  85. <if test="intoAmt != null">
  86. AND into_amt = #{intoAmt}
  87. </if>
  88. <if test="returnQty != null">
  89. AND return_qty = #{returnQty}
  90. </if>
  91. <if test="returnAmt != null">
  92. AND return_amt = #{returnAmt}
  93. </if>
  94. <if test="remarks != null and remarks != ''">
  95. AND remarks = #{remarks}
  96. </if>
  97. <if test="flgValid != null">
  98. AND flg_valid = #{flgValid}
  99. </if>
  100. <if test="cpId != null">
  101. AND cp_id = #{cpId}
  102. </if>
  103. <if test="opCreateTime != null">
  104. AND op_create_time = #{opCreateTime}
  105. </if>
  106. <if test="opCreateUserId != null and opCreateUserId != ''">
  107. AND op_create_user_id = #{opCreateUserId}
  108. </if>
  109. <if test="opUpdateTime != null">
  110. AND op_update_time = #{opUpdateTime}
  111. </if>
  112. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  113. AND op_update_user_id = #{opUpdateUserId}
  114. </if>
  115. <if test="opAppCode != null and opAppCode != ''">
  116. AND op_app_code = #{opAppCode}
  117. </if>
  118. <if test="opTimestamp != null">
  119. AND op_timestamp = #{opTimestamp}
  120. </if>
  121. <if test="opDbUser != null and opDbUser != ''">
  122. AND op_db_user = #{opDbUser}
  123. </if>
  124. </where>
  125. </sql>
  126. <sql id="idsForeach">
  127. <!-- 根据主键itemId批量操作 -->
  128. WHERE item_id in
  129. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  130. #{item}
  131. </foreach>
  132. </sql>
  133. <!-- 查询表dkic_b.t_psi_purchase_item,(条件查询+分页)列表 -->
  134. <select id="selectByCond" resultMap="BaseResultMap">
  135. SELECT
  136. <include refid="Base_Column_List"/>
  137. FROM dkic_b.t_psi_purchase_item
  138. <include refid="Condition"/>
  139. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  140. limit #{end} offset #{start}
  141. </if>
  142. </select>
  143. <!-- 查询表dkic_b.t_psi_purchase_item,(条件查询)个数 -->
  144. <select id="countByCond" resultType="Long">
  145. SELECT
  146. count(1)
  147. FROM dkic_b.t_psi_purchase_item
  148. <include refid="Condition"/>
  149. </select>
  150. <!-- 根据主键查询表dkic_b.t_psi_purchase_item的一行数据 -->
  151. <select id="selectById" resultMap="BaseResultMap">
  152. SELECT
  153. <include refid="Base_Column_List"/>
  154. FROM dkic_b.t_psi_purchase_item
  155. WHERE item_id = #{itemId}::uuid
  156. </select>
  157. <!-- 根据主键锁定表dkic_b.t_psi_purchase_item的一行数据 -->
  158. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  159. SELECT
  160. <include refid="Base_Column_List"/>
  161. FROM dkic_b.t_psi_purchase_item
  162. WHERE item_id = #{itemId}
  163. for update
  164. </select>
  165. <!-- 根据主键锁定表dkic_b.t_psi_purchase_item的多行数据 -->
  166. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  167. SELECT
  168. <include refid="Base_Column_List"/>
  169. FROM dkic_b.t_psi_purchase_item
  170. <include refid="idsForeach"/>
  171. for update
  172. </select>
  173. <insert id="insertBatch">
  174. insert into dkic_b.t_psi_purchase_item
  175. (
  176. <trim suffixOverrides=",">
  177. pur_id,
  178. item_index,
  179. sku_id,
  180. item_qty,
  181. price_std,
  182. amt_std,
  183. price_pur,
  184. item_amt,
  185. price_discount,
  186. non_std_code,
  187. into_status,
  188. intoing_qty,
  189. intoing_amt,
  190. into_qty,
  191. into_amt,
  192. return_qty,
  193. return_amt,
  194. remarks,
  195. cp_id,
  196. op_app_code,
  197. </trim>
  198. )
  199. values
  200. <foreach collection="list" index="index" item="item" separator=",">
  201. (
  202. <trim suffixOverrides=",">
  203. #{item.purId}::uuid,
  204. #{item.itemIndex},
  205. #{item.skuId}::uuid,
  206. #{item.itemQty},
  207. #{item.priceStd},
  208. #{item.amtStd},
  209. #{item.pricePur},
  210. #{item.itemAmt},
  211. #{item.priceDiscount},
  212. #{item.nonStdCode},
  213. #{item.intoStatus},
  214. #{item.intoingQty},
  215. #{item.intoingAmt},
  216. #{item.intoQty},
  217. #{item.intoAmt},
  218. #{item.returnQty},
  219. #{item.returnAmt},
  220. #{item.remarks},
  221. #{item.cpId},
  222. #{item.opAppCode},
  223. </trim>
  224. )
  225. </foreach>
  226. </insert>
  227. </mapper>