PurchaseItemMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. <!-- Response通用查询列 -->
  10. <sql id="Base_Column_List_Response">
  11. tppi.item_id,
  12. tppi.pur_id,
  13. tppi.item_index,
  14. tppi.sku_id,
  15. tppi.item_qty,
  16. tppi.price_std as "pricePurchase",
  17. tppi.amt_std,
  18. tppi.price_pur,
  19. tppi.item_amt,
  20. tppi.price_discount,
  21. tppi.non_std_code,
  22. tppi.into_status,
  23. tppi.intoing_qty,
  24. tppi.intoing_amt,
  25. tppi.into_qty,
  26. tppi.into_amt,
  27. tppi.return_qty,
  28. tppi.return_amt,
  29. tppi.remarks,
  30. tppi.flg_valid,
  31. tppi.cp_id,
  32. tppi.op_create_time,
  33. tppi.op_create_user_id,
  34. tppi.op_update_time,
  35. tppi.op_update_user_id,
  36. tppi.op_app_code,
  37. tppi.op_timestamp,
  38. tppi.op_db_user
  39. </sql>
  40. <!-- 通用查询映射结果 -->
  41. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.pur.PurchaseItem">
  42. <id column="item_id" property="itemId"/>
  43. <result column="pur_id" property="purId" typeHandler="UuidTypeHandler"/>
  44. <result column="item_index" property="itemIndex"/>
  45. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  46. <result column="item_qty" property="itemQty"/>
  47. <result column="price_std" property="priceStd"/>
  48. <result column="amt_std" property="amtStd"/>
  49. <result column="price_pur" property="pricePur"/>
  50. <result column="item_amt" property="itemAmt"/>
  51. <result column="price_discount" property="priceDiscount"/>
  52. <result column="non_std_code" property="nonStdCode"/>
  53. <result column="into_status" property="intoStatus"/>
  54. <result column="intoing_qty" property="intoingQty"/>
  55. <result column="intoing_amt" property="intoingAmt"/>
  56. <result column="into_qty" property="intoQty"/>
  57. <result column="into_amt" property="intoAmt"/>
  58. <result column="return_qty" property="returnQty"/>
  59. <result column="return_amt" property="returnAmt"/>
  60. <result column="remarks" property="remarks"/>
  61. <result column="flg_valid" property="flgValid"/>
  62. <result column="cp_id" property="cpId"/>
  63. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  64. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  65. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  66. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  67. <result column="op_app_code" property="opAppCode"/>
  68. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  69. <result column="op_db_user" property="opDbUser"/>
  70. </resultMap>
  71. <!-- Response通用查询映射结果 -->
  72. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.pur.PurchaseItemResponse">
  73. <id column="item_id" property="itemId"/>
  74. <result column="pur_id" property="purId" typeHandler="UuidTypeHandler"/>
  75. <result column="item_index" property="itemIndex"/>
  76. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  77. <result column="item_qty" property="itemQty"/>
  78. <result column="price_std" property="priceStd"/>
  79. <result column="amt_std" property="amtStd"/>
  80. <result column="price_pur" property="pricePur"/>
  81. <result column="item_amt" property="itemAmt"/>
  82. <result column="price_discount" property="priceDiscount"/>
  83. <result column="non_std_code" property="nonStdCode"/>
  84. <result column="into_status" property="intoStatus"/>
  85. <result column="intoing_qty" property="intoingQty"/>
  86. <result column="intoing_amt" property="intoingAmt"/>
  87. <result column="into_qty" property="intoQty"/>
  88. <result column="into_amt" property="intoAmt"/>
  89. <result column="return_qty" property="returnQty"/>
  90. <result column="return_amt" property="returnAmt"/>
  91. <result column="remarks" property="remarks"/>
  92. <result column="flg_valid" property="flgValid"/>
  93. <result column="cp_id" property="cpId"/>
  94. </resultMap>
  95. <!-- 通用条件列 -->
  96. <sql id="Condition">
  97. <where>
  98. <if test="purId != null and purId != ''">
  99. AND pur_id = #{purId}::uuid
  100. </if>
  101. <if test="itemIndex != null">
  102. AND item_index = #{itemIndex}
  103. </if>
  104. <if test="skuId != null and skuId != ''">
  105. AND sku_id = #{skuId}
  106. </if>
  107. <if test="itemQty != null">
  108. AND item_qty = #{itemQty}
  109. </if>
  110. <if test="priceStd != null">
  111. AND price_std = #{priceStd}
  112. </if>
  113. <if test="amtStd != null">
  114. AND amt_std = #{amtStd}
  115. </if>
  116. <if test="pricePur != null">
  117. AND price_pur = #{pricePur}
  118. </if>
  119. <if test="itemAmt != null">
  120. AND item_amt = #{itemAmt}
  121. </if>
  122. <if test="priceDiscount != null">
  123. AND price_discount = #{priceDiscount}
  124. </if>
  125. <if test="nonStdCode != null and nonStdCode != ''">
  126. AND non_std_code = #{nonStdCode}
  127. </if>
  128. <if test="intoStatus != null and intoStatus != ''">
  129. AND into_status = #{intoStatus}
  130. </if>
  131. <if test="intoingQty != null">
  132. AND intoing_qty = #{intoingQty}
  133. </if>
  134. <if test="intoingAmt != null">
  135. AND intoing_amt = #{intoingAmt}
  136. </if>
  137. <if test="intoQty != null">
  138. AND into_qty = #{intoQty}
  139. </if>
  140. <if test="intoAmt != null">
  141. AND into_amt = #{intoAmt}
  142. </if>
  143. <if test="returnQty != null">
  144. AND return_qty = #{returnQty}
  145. </if>
  146. <if test="returnAmt != null">
  147. AND return_amt = #{returnAmt}
  148. </if>
  149. <if test="remarks != null and remarks != ''">
  150. AND remarks = #{remarks}
  151. </if>
  152. <if test="flgValid != null">
  153. AND flg_valid = #{flgValid}
  154. </if>
  155. <if test="cpId != null">
  156. AND cp_id = #{cpId}
  157. </if>
  158. <if test="opCreateTime != null">
  159. AND op_create_time = #{opCreateTime}
  160. </if>
  161. <if test="opCreateUserId != null and opCreateUserId != ''">
  162. AND op_create_user_id = #{opCreateUserId}
  163. </if>
  164. <if test="opUpdateTime != null">
  165. AND op_update_time = #{opUpdateTime}
  166. </if>
  167. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  168. AND op_update_user_id = #{opUpdateUserId}
  169. </if>
  170. <if test="opAppCode != null and opAppCode != ''">
  171. AND op_app_code = #{opAppCode}
  172. </if>
  173. <if test="opTimestamp != null">
  174. AND op_timestamp = #{opTimestamp}
  175. </if>
  176. <if test="opDbUser != null and opDbUser != ''">
  177. AND op_db_user = #{opDbUser}
  178. </if>
  179. </where>
  180. </sql>
  181. <!-- 通用条件列 -->
  182. <sql id="Condition_1">
  183. <where>
  184. <if test="purId != null and purId != ''">
  185. AND tppi.pur_id = #{purId}::uuid
  186. </if>
  187. <if test="itemIndex != null">
  188. AND tppi.item_index = #{itemIndex}
  189. </if>
  190. <if test="skuId != null and skuId != ''">
  191. AND tppi.sku_id = #{skuId}
  192. </if>
  193. <if test="itemQty != null">
  194. AND tppi.item_qty = #{itemQty}
  195. </if>
  196. <if test="priceStd != null">
  197. AND tppi.price_std = #{priceStd}
  198. </if>
  199. <if test="amtStd != null">
  200. AND tppi.amt_std = #{amtStd}
  201. </if>
  202. <if test="pricePur != null">
  203. AND tppi.price_pur = #{pricePur}
  204. </if>
  205. <if test="itemAmt != null">
  206. AND tppi.item_amt = #{itemAmt}
  207. </if>
  208. <if test="priceDiscount != null">
  209. AND tppi.price_discount = #{priceDiscount}
  210. </if>
  211. <if test="nonStdCode != null and nonStdCode != ''">
  212. AND tppi.non_std_code = #{nonStdCode}
  213. </if>
  214. <if test="intoStatus != null and intoStatus != ''">
  215. AND tppi.into_status = #{intoStatus}
  216. </if>
  217. <if test="intoingQty != null">
  218. AND tppi.intoing_qty = #{intoingQty}
  219. </if>
  220. <if test="intoingAmt != null">
  221. AND tppi.intoing_amt = #{intoingAmt}
  222. </if>
  223. <if test="intoQty != null">
  224. AND tppi.into_qty = #{intoQty}
  225. </if>
  226. <if test="intoAmt != null">
  227. AND tppi.into_amt = #{intoAmt}
  228. </if>
  229. <if test="returnQty != null">
  230. AND tppi.return_qty = #{returnQty}
  231. </if>
  232. <if test="returnAmt != null">
  233. AND tppi.return_amt = #{returnAmt}
  234. </if>
  235. <if test="remarks != null and remarks != ''">
  236. AND tppi.remarks = #{remarks}
  237. </if>
  238. <if test="flgValid != null">
  239. AND tppi.flg_valid = #{flgValid}
  240. </if>
  241. <if test="cpId != null">
  242. AND tppi.cp_id = #{cpId}
  243. </if>
  244. <if test="opCreateTime != null">
  245. AND tppi.op_create_time = #{opCreateTime}
  246. </if>
  247. <if test="opCreateUserId != null and opCreateUserId != ''">
  248. AND tppi.op_create_user_id = #{opCreateUserId}
  249. </if>
  250. <if test="opUpdateTime != null">
  251. AND tppi.op_update_time = #{opUpdateTime}
  252. </if>
  253. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  254. AND tppi.op_update_user_id = #{opUpdateUserId}
  255. </if>
  256. <if test="opAppCode != null and opAppCode != ''">
  257. AND tppi.op_app_code = #{opAppCode}
  258. </if>
  259. <if test="opTimestamp != null">
  260. AND tppi.op_timestamp = #{opTimestamp}
  261. </if>
  262. <if test="opDbUser != null and opDbUser != ''">
  263. AND tppi.op_db_user = #{opDbUser}
  264. </if>
  265. </where>
  266. </sql>
  267. <sql id="idsForeach">
  268. <!-- 根据主键itemId批量操作 -->
  269. WHERE item_id in
  270. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  271. #{item}
  272. </foreach>
  273. </sql>
  274. <!-- 查询表dkic_b.t_psi_purchase_item,(条件查询+分页)列表 -->
  275. <select id="selectByCond" resultMap="BaseResultMapResponse">
  276. SELECT
  277. <include refid="Base_Column_List_Response"/>
  278. ,tmgs.sku_code as "skuCode"
  279. ,tmgs.sku_model as "skuModel"
  280. ,tmgs.sku_name as "skuName"
  281. FROM dkic_b.t_psi_purchase_item tppi
  282. left join dkic_b.t_mst_goods_sku tmgs on tppi.sku_id = tmgs.sku_id
  283. <include refid="Condition_1"/>
  284. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  285. limit #{end} offset #{start}
  286. </if>
  287. </select>
  288. <!-- 查询表dkic_b.t_psi_purchase_item,(条件查询)个数 -->
  289. <select id="countByCond" resultType="Long">
  290. SELECT
  291. count(1)
  292. FROM dkic_b.t_psi_purchase_item
  293. <include refid="Condition"/>
  294. </select>
  295. <!-- 根据主键查询表dkic_b.t_psi_purchase_item的一行数据 -->
  296. <select id="selectById" resultMap="BaseResultMapResponse">
  297. SELECT
  298. <include refid="Base_Column_List_Response"/>
  299. FROM dkic_b.t_psi_purchase_item tppi
  300. WHERE tppi.item_id = #{itemId}::uuid
  301. </select>
  302. <!-- 根据主键锁定表dkic_b.t_psi_purchase_item的一行数据 -->
  303. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  304. SELECT
  305. <include refid="Base_Column_List"/>
  306. FROM dkic_b.t_psi_purchase_item
  307. WHERE item_id = #{itemId}
  308. for update
  309. </select>
  310. <!-- 根据主键锁定表dkic_b.t_psi_purchase_item的多行数据 -->
  311. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  312. SELECT
  313. <include refid="Base_Column_List"/>
  314. FROM dkic_b.t_psi_purchase_item
  315. <include refid="idsForeach"/>
  316. for update
  317. </select>
  318. <delete id="deleteById">
  319. DELETE FROM dkic_b.t_psi_purchase_item
  320. WHERE item_id = #{id}::UUID;
  321. </delete>
  322. </mapper>