PurchaseItemMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  95. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  96. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  97. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  98. <result column="op_app_code" property="opAppCode"/>
  99. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  100. <result column="op_db_user" property="opDbUser"/>
  101. </resultMap>
  102. <!-- 通用条件列 -->
  103. <sql id="Condition">
  104. <where>
  105. <if test="purId != null and purId != ''">
  106. AND pur_id = #{purId}::uuid
  107. </if>
  108. <if test="itemIndex != null">
  109. AND item_index = #{itemIndex}
  110. </if>
  111. <if test="skuId != null and skuId != ''">
  112. AND sku_id = #{skuId}
  113. </if>
  114. <if test="itemQty != null">
  115. AND item_qty = #{itemQty}
  116. </if>
  117. <if test="priceStd != null">
  118. AND price_std = #{priceStd}
  119. </if>
  120. <if test="amtStd != null">
  121. AND amt_std = #{amtStd}
  122. </if>
  123. <if test="pricePur != null">
  124. AND price_pur = #{pricePur}
  125. </if>
  126. <if test="itemAmt != null">
  127. AND item_amt = #{itemAmt}
  128. </if>
  129. <if test="priceDiscount != null">
  130. AND price_discount = #{priceDiscount}
  131. </if>
  132. <if test="nonStdCode != null and nonStdCode != ''">
  133. AND non_std_code = #{nonStdCode}
  134. </if>
  135. <if test="intoStatus != null and intoStatus != ''">
  136. AND into_status = #{intoStatus}
  137. </if>
  138. <if test="intoingQty != null">
  139. AND intoing_qty = #{intoingQty}
  140. </if>
  141. <if test="intoingAmt != null">
  142. AND intoing_amt = #{intoingAmt}
  143. </if>
  144. <if test="intoQty != null">
  145. AND into_qty = #{intoQty}
  146. </if>
  147. <if test="intoAmt != null">
  148. AND into_amt = #{intoAmt}
  149. </if>
  150. <if test="returnQty != null">
  151. AND return_qty = #{returnQty}
  152. </if>
  153. <if test="returnAmt != null">
  154. AND return_amt = #{returnAmt}
  155. </if>
  156. <if test="remarks != null and remarks != ''">
  157. AND remarks = #{remarks}
  158. </if>
  159. <if test="flgValid != null">
  160. AND flg_valid = #{flgValid}
  161. </if>
  162. <if test="cpId != null">
  163. AND cp_id = #{cpId}
  164. </if>
  165. <if test="opCreateTime != null">
  166. AND op_create_time = #{opCreateTime}
  167. </if>
  168. <if test="opCreateUserId != null and opCreateUserId != ''">
  169. AND op_create_user_id = #{opCreateUserId}
  170. </if>
  171. <if test="opUpdateTime != null">
  172. AND op_update_time = #{opUpdateTime}
  173. </if>
  174. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  175. AND op_update_user_id = #{opUpdateUserId}
  176. </if>
  177. <if test="opAppCode != null and opAppCode != ''">
  178. AND op_app_code = #{opAppCode}
  179. </if>
  180. <if test="opTimestamp != null">
  181. AND op_timestamp = #{opTimestamp}
  182. </if>
  183. <if test="opDbUser != null and opDbUser != ''">
  184. AND op_db_user = #{opDbUser}
  185. </if>
  186. </where>
  187. </sql>
  188. <!-- 通用条件列 -->
  189. <sql id="Condition_1">
  190. <where>
  191. <if test="purId != null and purId != ''">
  192. AND tppi.pur_id = #{purId}::uuid
  193. </if>
  194. <if test="itemIndex != null">
  195. AND tppi.item_index = #{itemIndex}
  196. </if>
  197. <if test="skuId != null and skuId != ''">
  198. AND tppi.sku_id = #{skuId}
  199. </if>
  200. <if test="itemQty != null">
  201. AND tppi.item_qty = #{itemQty}
  202. </if>
  203. <if test="priceStd != null">
  204. AND tppi.price_std = #{priceStd}
  205. </if>
  206. <if test="amtStd != null">
  207. AND tppi.amt_std = #{amtStd}
  208. </if>
  209. <if test="pricePur != null">
  210. AND tppi.price_pur = #{pricePur}
  211. </if>
  212. <if test="itemAmt != null">
  213. AND tppi.item_amt = #{itemAmt}
  214. </if>
  215. <if test="priceDiscount != null">
  216. AND tppi.price_discount = #{priceDiscount}
  217. </if>
  218. <if test="nonStdCode != null and nonStdCode != ''">
  219. AND tppi.non_std_code = #{nonStdCode}
  220. </if>
  221. <if test="intoStatus != null and intoStatus != ''">
  222. AND tppi.into_status = #{intoStatus}
  223. </if>
  224. <if test="intoingQty != null">
  225. AND tppi.intoing_qty = #{intoingQty}
  226. </if>
  227. <if test="intoingAmt != null">
  228. AND tppi.intoing_amt = #{intoingAmt}
  229. </if>
  230. <if test="intoQty != null">
  231. AND tppi.into_qty = #{intoQty}
  232. </if>
  233. <if test="intoAmt != null">
  234. AND tppi.into_amt = #{intoAmt}
  235. </if>
  236. <if test="returnQty != null">
  237. AND tppi.return_qty = #{returnQty}
  238. </if>
  239. <if test="returnAmt != null">
  240. AND tppi.return_amt = #{returnAmt}
  241. </if>
  242. <if test="remarks != null and remarks != ''">
  243. AND tppi.remarks = #{remarks}
  244. </if>
  245. <if test="flgValid != null">
  246. AND tppi.flg_valid = #{flgValid}
  247. </if>
  248. <if test="cpId != null">
  249. AND tppi.cp_id = #{cpId}
  250. </if>
  251. <if test="opCreateTime != null">
  252. AND tppi.op_create_time = #{opCreateTime}
  253. </if>
  254. <if test="opCreateUserId != null and opCreateUserId != ''">
  255. AND tppi.op_create_user_id = #{opCreateUserId}
  256. </if>
  257. <if test="opUpdateTime != null">
  258. AND tppi.op_update_time = #{opUpdateTime}
  259. </if>
  260. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  261. AND tppi.op_update_user_id = #{opUpdateUserId}
  262. </if>
  263. <if test="opAppCode != null and opAppCode != ''">
  264. AND tppi.op_app_code = #{opAppCode}
  265. </if>
  266. <if test="opTimestamp != null">
  267. AND tppi.op_timestamp = #{opTimestamp}
  268. </if>
  269. <if test="opDbUser != null and opDbUser != ''">
  270. AND tppi.op_db_user = #{opDbUser}
  271. </if>
  272. </where>
  273. </sql>
  274. <sql id="idsForeach">
  275. <!-- 根据主键itemId批量操作 -->
  276. WHERE item_id in
  277. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  278. #{item}
  279. </foreach>
  280. </sql>
  281. <!-- 查询表dkic_b.t_psi_purchase_item,(条件查询+分页)列表 -->
  282. <select id="selectByCond" resultMap="BaseResultMapResponse">
  283. SELECT
  284. <include refid="Base_Column_List_Response"/>
  285. ,tmgs.sku_code as "skuCode"
  286. ,tmgs.sku_model as "skuModel"
  287. ,tmgs.sku_name as "skuName"
  288. ,tmgb.brand_name as "brandName"
  289. ,tmgb.short_name as "shortName"
  290. FROM dkic_b.t_psi_purchase_item tppi
  291. left join dkic_b.t_mst_goods_sku tmgs on tppi.sku_id = tmgs.sku_id
  292. left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id = tmgs.brand_id
  293. <include refid="Condition_1"/>
  294. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  295. limit #{end} offset #{start}
  296. </if>
  297. </select>
  298. <!-- 查询表dkic_b.t_psi_purchase_item,(条件查询)个数 -->
  299. <select id="countByCond" resultType="Long">
  300. SELECT
  301. count(1)
  302. FROM dkic_b.t_psi_purchase_item
  303. <include refid="Condition"/>
  304. </select>
  305. <!-- 根据主键查询表dkic_b.t_psi_purchase_item的一行数据 -->
  306. <select id="selectById" resultMap="BaseResultMapResponse">
  307. SELECT
  308. <include refid="Base_Column_List_Response"/>
  309. FROM dkic_b.t_psi_purchase_item tppi
  310. WHERE tppi.item_id = #{itemId}::uuid
  311. </select>
  312. <!-- 根据主键锁定表dkic_b.t_psi_purchase_item的一行数据 -->
  313. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  314. SELECT
  315. <include refid="Base_Column_List"/>
  316. FROM dkic_b.t_psi_purchase_item
  317. WHERE item_id = #{itemId}::uuid
  318. for update
  319. </select>
  320. <!-- 根据主键锁定表dkic_b.t_psi_purchase_item的多行数据 -->
  321. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  322. SELECT
  323. <include refid="Base_Column_List"/>
  324. FROM dkic_b.t_psi_purchase_item
  325. <include refid="idsForeach"/>
  326. for update
  327. </select>
  328. <delete id="deleteById">
  329. DELETE FROM dkic_b.t_psi_purchase_item
  330. WHERE item_id = #{id}::UUID;
  331. </delete>
  332. <update id="updateAmount" parameterType="com.dk.mdm.model.pojo.pur.PurchaseItem">
  333. update dkic_b.t_psi_purchase_item
  334. <set>
  335. <if test="returnQty!= null">
  336. return_qty= #{returnQty},
  337. </if>
  338. <if test="returnAmt!= null">
  339. return_amt = #{returnAmt},
  340. </if>
  341. </set>
  342. where item_id = #{itemId}::uuid
  343. </update>
  344. </mapper>