PurchaseItemMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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, sys.f_remove_zero(item_qty) as item_qty, price_std, amt_std, price_pur,
  8. item_amt, price_discount, non_std_code, into_status, sys.f_remove_zero(intoing_qty) as intoing_qty, intoing_amt,
  9. sys.f_remove_zero(into_qty) as into_qty, into_amt, sys.f_remove_zero(return_qty) as return_qty, return_amt,
  10. remarks, flg_valid, cp_id, op_create_time,
  11. op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
  12. </sql>
  13. <!-- Response通用查询列 -->
  14. <sql id="Base_Column_List_Response">
  15. tppi.item_id,
  16. tppi.pur_id,
  17. tppi.item_index,
  18. tppi.sku_id,
  19. sys.f_remove_zero(tppi.item_qty) as item_qty,
  20. tppi.price_std as "pricePurchase",
  21. tppi.price_std,
  22. tppi.amt_std,
  23. tppi.price_pur,
  24. tppi.item_amt,
  25. tppi.price_discount,
  26. tppi.non_std_code,
  27. tppi.into_status,
  28. sys.f_remove_zero(tppi.intoing_qty) as intoing_qty,
  29. tppi.intoing_amt,
  30. sys.f_remove_zero(tppi.into_qty) as into_qty,
  31. tppi.into_amt,
  32. sys.f_remove_zero(tppi.return_qty) as return_qty,
  33. tppi.return_amt,
  34. tppi.remarks,
  35. tppi.flg_valid,
  36. tppi.cp_id,
  37. tppi.op_create_time,
  38. tppi.op_create_user_id,
  39. tppi.op_update_time,
  40. tppi.op_update_user_id,
  41. tppi.op_app_code,
  42. tppi.op_timestamp,
  43. tppi.op_db_user,
  44. tppi.from_id,
  45. tppi.from_item_id
  46. ,tppi.box
  47. ,tppi.piece
  48. ,tppi.unit_id
  49. ,tppi.sub_unit_id
  50. ,tppi.pack_box
  51. </sql>
  52. <!-- 通用查询映射结果 -->
  53. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.pur.PurchaseItem">
  54. <id column="item_id" property="itemId"/>
  55. <result column="pur_id" property="purId" typeHandler="UuidTypeHandler"/>
  56. <result column="item_index" property="itemIndex"/>
  57. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  58. <result column="item_qty" property="itemQty"/>
  59. <result column="price_std" property="priceStd"/>
  60. <result column="amt_std" property="amtStd"/>
  61. <result column="price_pur" property="pricePur"/>
  62. <result column="item_amt" property="itemAmt"/>
  63. <result column="price_discount" property="priceDiscount"/>
  64. <result column="non_std_code" property="nonStdCode"/>
  65. <result column="into_status" property="intoStatus"/>
  66. <result column="intoing_qty" property="intoingQty"/>
  67. <result column="intoing_amt" property="intoingAmt"/>
  68. <result column="into_qty" property="intoQty"/>
  69. <result column="into_amt" property="intoAmt"/>
  70. <result column="return_qty" property="returnQty"/>
  71. <result column="return_amt" property="returnAmt"/>
  72. <result column="remarks" property="remarks"/>
  73. <result column="flg_valid" property="flgValid"/>
  74. <result column="cp_id" property="cpId"/>
  75. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  76. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  77. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  78. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  79. <result column="op_app_code" property="opAppCode"/>
  80. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  81. <result column="op_db_user" property="opDbUser"/>
  82. <result column="decimalPlaces" property="decimalPlaces"/>
  83. </resultMap>
  84. <!-- Response通用查询映射结果 -->
  85. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.pur.PurchaseItemResponse">
  86. <id column="item_id" property="itemId"/>
  87. <result column="pur_id" property="purId" typeHandler="UuidTypeHandler"/>
  88. <result column="item_index" property="itemIndex"/>
  89. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  90. <result column="item_qty" property="itemQty"/>
  91. <result column="price_std" property="priceStd"/>
  92. <result column="amt_std" property="amtStd"/>
  93. <result column="price_pur" property="pricePur"/>
  94. <result column="item_amt" property="itemAmt"/>
  95. <result column="price_discount" property="priceDiscount"/>
  96. <result column="non_std_code" property="nonStdCode"/>
  97. <result column="into_status" property="intoStatus"/>
  98. <result column="intoing_qty" property="intoingQty"/>
  99. <result column="intoing_amt" property="intoingAmt"/>
  100. <result column="into_qty" property="intoQty"/>
  101. <result column="into_amt" property="intoAmt"/>
  102. <result column="return_qty" property="returnQty"/>
  103. <result column="return_amt" property="returnAmt"/>
  104. <result column="remarks" property="remarks"/>
  105. <result column="flg_valid" property="flgValid"/>
  106. <result column="cp_id" property="cpId"/>
  107. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  108. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  109. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  110. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  111. <result column="op_app_code" property="opAppCode"/>
  112. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  113. <result column="op_db_user" property="opDbUser"/>
  114. <result column="inv_id" property="invId"/>
  115. <result column="inv_qty" property="invQty"/>
  116. <result column="usable_qty" property="usableQty"/>
  117. <result column="box" property="box"/>
  118. <result column="piece" property="piece"/>
  119. <result column="pack_box" property="packBox"/>
  120. <result column="unit_id" property="unitId"/>
  121. <result column="sub_unit_id" property="subUnitId"/>
  122. <result column="subUnitName" property="subUnitName"/>
  123. <result column="unitName" property="unitName"/>
  124. <result column="flg_sub_unit" property="flgSubUnit"/>
  125. <result column="skuImages" property="skuImages" typeHandler="JsonTypeHandler"/>
  126. <result column="specsName" property="specsName"/>
  127. <result column="decimalPlaces" property="decimalPlaces"/>
  128. </resultMap>
  129. <!-- 通用条件列 -->
  130. <sql id="Condition">
  131. <where>
  132. <if test="purId != null and purId != ''">
  133. AND pur_id = #{purId}::uuid
  134. </if>
  135. <if test="itemIndex != null">
  136. AND item_index = #{itemIndex}
  137. </if>
  138. <if test="skuId != null and skuId != ''">
  139. AND sku_id = #{skuId}
  140. </if>
  141. <if test="itemQty != null">
  142. AND item_qty = #{itemQty}
  143. </if>
  144. <if test="priceStd != null">
  145. AND price_std = #{priceStd}
  146. </if>
  147. <if test="amtStd != null">
  148. AND amt_std = #{amtStd}
  149. </if>
  150. <if test="pricePur != null">
  151. AND price_pur = #{pricePur}
  152. </if>
  153. <if test="itemAmt != null">
  154. AND item_amt = #{itemAmt}
  155. </if>
  156. <if test="priceDiscount != null">
  157. AND price_discount = #{priceDiscount}
  158. </if>
  159. <if test="nonStdCode != null and nonStdCode != ''">
  160. AND non_std_code = #{nonStdCode}
  161. </if>
  162. <if test="intoStatus != null and intoStatus != ''">
  163. AND into_status = #{intoStatus}
  164. </if>
  165. <if test="intoingQty != null">
  166. AND intoing_qty = #{intoingQty}
  167. </if>
  168. <if test="intoingAmt != null">
  169. AND intoing_amt = #{intoingAmt}
  170. </if>
  171. <if test="intoQty != null">
  172. AND into_qty = #{intoQty}
  173. </if>
  174. <if test="intoAmt != null">
  175. AND into_amt = #{intoAmt}
  176. </if>
  177. <if test="returnQty != null">
  178. AND return_qty = #{returnQty}
  179. </if>
  180. <if test="returnAmt != null">
  181. AND return_amt = #{returnAmt}
  182. </if>
  183. <if test="remarks != null and remarks != ''">
  184. AND remarks = #{remarks}
  185. </if>
  186. <if test="flgValid != null">
  187. AND flg_valid = #{flgValid}
  188. </if>
  189. <if test="cpId != null">
  190. AND cp_id = #{cpId}
  191. </if>
  192. <if test="opCreateTime != null">
  193. AND op_create_time = #{opCreateTime}
  194. </if>
  195. <if test="opCreateUserId != null and opCreateUserId != ''">
  196. AND op_create_user_id = #{opCreateUserId}
  197. </if>
  198. <if test="opUpdateTime != null">
  199. AND op_update_time = #{opUpdateTime}
  200. </if>
  201. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  202. AND op_update_user_id = #{opUpdateUserId}
  203. </if>
  204. <if test="opAppCode != null and opAppCode != ''">
  205. AND op_app_code = #{opAppCode}
  206. </if>
  207. <if test="opTimestamp != null">
  208. AND op_timestamp = #{opTimestamp}
  209. </if>
  210. <if test="opDbUser != null and opDbUser != ''">
  211. AND op_db_user = #{opDbUser}
  212. </if>
  213. </where>
  214. </sql>
  215. <!-- 通用条件列 -->
  216. <sql id="Condition_1">
  217. <where>
  218. <if test="purId != null and purId != ''">
  219. AND tppi.pur_id = #{purId}::uuid
  220. </if>
  221. <if test="itemIndex != null">
  222. AND tppi.item_index = #{itemIndex}
  223. </if>
  224. <if test="skuId != null and skuId != ''">
  225. AND tppi.sku_id = #{skuId}
  226. </if>
  227. <if test="itemQty != null">
  228. AND tppi.item_qty = #{itemQty}
  229. </if>
  230. <if test="priceStd != null">
  231. AND tppi.price_std = #{priceStd}
  232. </if>
  233. <if test="amtStd != null">
  234. AND tppi.amt_std = #{amtStd}
  235. </if>
  236. <if test="pricePur != null">
  237. AND tppi.price_pur = #{pricePur}
  238. </if>
  239. <if test="itemAmt != null">
  240. AND tppi.item_amt = #{itemAmt}
  241. </if>
  242. <if test="priceDiscount != null">
  243. AND tppi.price_discount = #{priceDiscount}
  244. </if>
  245. <if test="nonStdCode != null and nonStdCode != ''">
  246. AND tppi.non_std_code = #{nonStdCode}
  247. </if>
  248. <if test="intoStatus != null and intoStatus != ''">
  249. AND tppi.into_status = #{intoStatus}
  250. </if>
  251. <if test="intoingQty != null">
  252. AND tppi.intoing_qty = #{intoingQty}
  253. </if>
  254. <if test="intoingAmt != null">
  255. AND tppi.intoing_amt = #{intoingAmt}
  256. </if>
  257. <if test="intoQty != null">
  258. AND tppi.into_qty = #{intoQty}
  259. </if>
  260. <if test="intoAmt != null">
  261. AND tppi.into_amt = #{intoAmt}
  262. </if>
  263. <if test="returnQty != null">
  264. AND tppi.return_qty = #{returnQty}
  265. </if>
  266. <if test="returnAmt != null">
  267. AND tppi.return_amt = #{returnAmt}
  268. </if>
  269. <if test="remarks != null and remarks != ''">
  270. AND tppi.remarks = #{remarks}
  271. </if>
  272. <if test="flgValid != null">
  273. AND tppi.flg_valid = #{flgValid}
  274. </if>
  275. <if test="cpId != null">
  276. AND tppi.cp_id = #{cpId}
  277. </if>
  278. <if test="opCreateTime != null">
  279. AND tppi.op_create_time = #{opCreateTime}
  280. </if>
  281. <if test="opCreateUserId != null and opCreateUserId != ''">
  282. AND tppi.op_create_user_id = #{opCreateUserId}
  283. </if>
  284. <if test="opUpdateTime != null">
  285. AND tppi.op_update_time = #{opUpdateTime}
  286. </if>
  287. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  288. AND tppi.op_update_user_id = #{opUpdateUserId}
  289. </if>
  290. <if test="opAppCode != null and opAppCode != ''">
  291. AND tppi.op_app_code = #{opAppCode}
  292. </if>
  293. <if test="opTimestamp != null">
  294. AND tppi.op_timestamp = #{opTimestamp}
  295. </if>
  296. <if test="opDbUser != null and opDbUser != ''">
  297. AND tppi.op_db_user = #{opDbUser}
  298. </if>
  299. </where>
  300. </sql>
  301. <sql id="idsForeach">
  302. <!-- 根据主键itemId批量操作 -->
  303. WHERE item_id in
  304. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  305. #{item}
  306. </foreach>
  307. </sql>
  308. <!-- 查询表dkic_b.t_psi_purchase_item,(条件查询+分页)列表 -->
  309. <select id="selectByCond" resultMap="BaseResultMapResponse">
  310. SELECT
  311. <include refid="Base_Column_List_Response"/>
  312. ,tppi.from_id as "fromId"
  313. ,tppi.from_item_id as "fromItemId"
  314. ,tpo.order_no as "orderNo"
  315. ,tmgs.sku_code as "skuCode"
  316. ,tmgs.sku_model as "skuModel"
  317. ,tmgs.sku_name as "skuName"
  318. ,tmgs.sku_images as "skuImages"
  319. ,tmgb.brand_name as "brandName"
  320. ,tmgb.short_name as "shortName"
  321. ,tmgs.sku_spec as "skuSpec"
  322. ,tmgs.price_purchase as "pricePurchase"
  323. ,tmgs.price_standard as "priceStandard"
  324. ,sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "intoStatusName"
  325. ,dkic_b.f_box_piece(tmgus.unit_name,tmgu.unit_name,tppi.box,tppi.piece) as "specsName"
  326. ,i.inv_id
  327. ,sys.f_remove_zero(i.inv_qty) as inv_qty
  328. ,sys.f_remove_zero(i.usable_qty) as usable_qty
  329. ,tpp.pur_no as "purNo"
  330. ,tmgus.unit_name as "subUnitName"
  331. ,tmgu.unit_name as "unitName"
  332. ,tmgs.flg_sub_unit
  333. ,tppi.intoing_qty/tppi.pack_box as "intoingBox"
  334. ,tppi.intoing_qty%tppi.pack_box as "intoingPiece"
  335. ,tppi.into_qty/tppi.pack_box as "intoBox"
  336. ,tppi.into_qty%tppi.pack_box as "intoPiece"
  337. ,tmgu.decimal_places as "decimalPlaces"
  338. FROM dkic_b.t_psi_purchase_item tppi
  339. left join(SELECT T.*
  340. FROM (select tpi.inv_id,
  341. tpi.wh_id,
  342. tpi.inv_qty,
  343. tpi.usable_qty,
  344. tpi.sku_id,
  345. tpi.non_std_code,
  346. tpi.cp_id,
  347. tmw.wh_name,
  348. rank()
  349. over (partition by tpi.cp_id,tpi.sku_id,tpi.non_std_code order by tpi.inv_id) as RK
  350. from dkic_b.t_psi_inventory as tpi
  351. left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id) T
  352. WHERE T.RK = 1) as i on i.sku_id = tppi.sku_id and i.non_std_code = tppi.non_std_code and i.cp_id = tppi.cp_id
  353. left join dkic_b.t_psi_order tpo on tpo.order_id = tppi.from_id
  354. left join dkic_b.t_mst_goods_sku tmgs on tppi.sku_id = tmgs.sku_id
  355. left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id = tmgs.brand_id
  356. left join sys.t_data_kind tdk1 on tdk1.kind_code = tppi.into_status
  357. left join dkic_b.t_psi_purchase tpp on tpp.pur_id = tppi.pur_id
  358. left join dkic_b.t_mst_unit as tmgu on tppi.unit_id = tmgu.unit_id
  359. left join dkic_b.t_mst_unit as tmgus on tppi.sub_unit_id = tmgus.unit_id
  360. <include refid="Condition_1"/>
  361. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  362. limit #{end} offset #{start}
  363. </if>
  364. </select>
  365. <!-- 查询表dkic_b.t_psi_purchase_item,(条件查询+分页)列表 -->
  366. <select id="purSelectByCond" resultMap="BaseResultMapResponse">
  367. SELECT
  368. <include refid="Base_Column_List_Response"/>
  369. ,tppi.from_id as "fromId"
  370. ,tppi.from_item_id as "fromItemId"
  371. ,tpo.order_no as "orderNo"
  372. ,tmgs.sku_code as "skuCode"
  373. ,tmgs.sku_model as "skuModel"
  374. ,tmgs.sku_name as "skuName"
  375. ,tmgs.sku_images as "skuImages"
  376. ,tmgb.brand_name as "brandName"
  377. ,tmgb.short_name as "shortName"
  378. ,tmgs.sku_spec as "skuSpec"
  379. ,tmgs.price_purchase as "pricePurchase"
  380. ,tmgs.price_standard as "priceStandard"
  381. ,sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "intoStatusName"
  382. ,
  383. i.inv_id,
  384. sys.f_remove_zero(i.inv_qty) as inv_qty,
  385. sys.f_remove_zero(i.usable_qty) as usable_qty
  386. ,tpp.pur_no as "purNo"
  387. ,tmgus.unit_name as "subUnitName"
  388. ,tmgu.unit_name as "unitName"
  389. ,tmgs.flg_sub_unit
  390. ,tmgu.decimal_places as "decimalPlaces"
  391. FROM dkic_b.t_psi_purchase_item tppi
  392. left join dkic_b.t_mst_unit as tmgu on tppi.unit_id = tmgu.unit_id
  393. left join dkic_b.t_mst_unit as tmgus on tppi.sub_unit_id = tmgus.unit_id
  394. left join(SELECT T.*
  395. FROM (select tpi.inv_id,
  396. tpi.wh_id,
  397. tpi.inv_qty,
  398. tpi.usable_qty,
  399. tpi.sku_id,
  400. tpi.non_std_code,
  401. tpi.cp_id,
  402. tmw.wh_name,
  403. rank()
  404. over (partition by tpi.cp_id,tpi.sku_id,tpi.non_std_code order by tpi.inv_id) as RK
  405. from dkic_b.t_psi_inventory as tpi
  406. left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id) T
  407. WHERE T.RK = 1) as i on i.sku_id = tppi.sku_id and i.non_std_code = tppi.non_std_code and i.cp_id = tppi.cp_id
  408. left join dkic_b.t_psi_order tpo on tpo.order_id = tppi.from_id
  409. left join dkic_b.t_mst_goods_sku tmgs on tppi.sku_id = tmgs.sku_id
  410. left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id = tmgs.brand_id
  411. left join sys.t_data_kind tdk1 on tdk1.kind_code = tppi.into_status
  412. left join dkic_b.t_psi_purchase tpp on tpp.pur_id = tppi.pur_id
  413. where
  414. tppi.into_status != '入库状态-已入库'
  415. AND tppi.flg_valid = true
  416. <if test="cpId != null">
  417. AND tppi.cp_id = #{cpId}
  418. </if>
  419. <if test="purId != null and purId != ''">
  420. AND tppi.pur_id = #{purId}::uuid
  421. </if>
  422. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  423. limit #{end} offset #{start}
  424. </if>
  425. </select>
  426. <!-- 查询表dkic_b.t_psi_purchase_item,(条件查询)个数 -->
  427. <select id="countByCond" resultType="Long">
  428. SELECT
  429. count(1)
  430. FROM dkic_b.t_psi_purchase_item
  431. <include refid="Condition"/>
  432. </select>
  433. <!-- 根据主键查询表dkic_b.t_psi_purchase_item的一行数据 -->
  434. <select id="selectById" resultMap="BaseResultMapResponse">
  435. SELECT
  436. <include refid="Base_Column_List_Response"/>
  437. ,tppi.from_id as "fromId"
  438. ,tppi.from_item_id as "fromItemId"
  439. ,tpo.order_no as "orderNo"
  440. ,tpp.pur_no as "purNo"
  441. ,(select ul.decimal_places from dkic_b.t_mst_unit ul where dkic_b.t_psi_purchase_item.unit_id = ul.unit_id) as "decimalPlaces"
  442. FROM dkic_b.t_psi_purchase_item tppi
  443. left join dkic_b.t_psi_order tpo on tpo.order_id = tppi.from_id
  444. left join dkic_b.t_psi_purchase tpp on tpp.pur_id = tppi.pur_id
  445. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tppi.sku_id
  446. left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id = tmgs.brand_id
  447. WHERE tppi.item_id = #{id}::uuid
  448. </select>
  449. <!-- 根据主键锁定表dkic_b.t_psi_purchase_item的一行数据 -->
  450. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  451. SELECT
  452. <include refid="Base_Column_List"/>
  453. ,(select ul.decimal_places from dkic_b.t_mst_unit ul where dkic_b.t_psi_purchase_item.unit_id = ul.unit_id) as "decimalPlaces"
  454. FROM dkic_b.t_psi_purchase_item
  455. WHERE item_id = #{itemId}::uuid
  456. for update
  457. </select>
  458. <!-- 根据主键锁定表dkic_b.t_psi_purchase_item的多行数据 -->
  459. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  460. SELECT
  461. <include refid="Base_Column_List"/>
  462. FROM dkic_b.t_psi_purchase_item
  463. <include refid="idsForeach"/>
  464. for update
  465. </select>
  466. <delete id="deleteById">
  467. DELETE FROM dkic_b.t_psi_purchase_item
  468. WHERE item_id = #{id}::UUID;
  469. </delete>
  470. <update id="updateAmount" parameterType="com.dk.mdm.model.pojo.pur.PurchaseItem">
  471. update dkic_b.t_psi_purchase_item
  472. <set>
  473. <if test="returnQty!= null">
  474. return_qty= #{returnQty},
  475. </if>
  476. <if test="returnAmt!= null">
  477. return_amt = #{returnAmt},
  478. </if>
  479. </set>
  480. where item_id = #{itemId}::uuid
  481. </update>
  482. <!-- 根据id修改-->
  483. <update id="updateById" parameterType="com.dk.mdm.model.pojo.pur.PurchaseItem">
  484. update dkic_b.t_psi_purchase_item
  485. <set>
  486. <if test=" et!=null and et.purId != null">
  487. pur_id = #{et.purId,typeHandler=UuidTypeHandler},
  488. </if>
  489. <if test=" et!=null and et.itemIndex != null">
  490. item_index = #{et.itemIndex,jdbcType=INTEGER},
  491. </if>
  492. <if test=" et!=null and et.skuId != null">
  493. sku_id = #{et.skuId,typeHandler=UuidTypeHandler},
  494. </if>
  495. <if test=" et!=null and et.itemQty != null">
  496. item_qty = #{et.itemQty,jdbcType=NUMERIC},
  497. </if>
  498. <if test=" et!=null and et.priceStd != null">
  499. price_std = #{et.priceStd,jdbcType=NUMERIC},
  500. </if>
  501. <if test=" et!=null and et.amtStd != null">
  502. amt_std = #{et.amtStd,jdbcType=NUMERIC},
  503. </if>
  504. <if test=" et!=null and et.pricePur != null">
  505. price_pur = #{et.pricePur,jdbcType=NUMERIC},
  506. </if>
  507. <if test=" et!=null and et.itemAmt != null">
  508. item_amt = #{et.itemAmt,jdbcType=NUMERIC},
  509. </if>
  510. <if test=" et!=null and et.priceDiscount != null">
  511. price_discount = #{et.priceDiscount,jdbcType=NUMERIC},
  512. </if>
  513. <if test=" et!=null and et.nonStdCode != null">
  514. non_std_code = #{et.nonStdCode,jdbcType=VARCHAR},
  515. </if>
  516. <if test=" et!=null and et.intoStatus != null">
  517. into_status = #{et.intoStatus,jdbcType=VARCHAR},
  518. </if>
  519. <if test=" et!=null and et.intoingQty != null">
  520. intoing_qty = intoing_qty + #{et.intoingQty,jdbcType=NUMERIC},
  521. </if>
  522. <if test=" et!=null and et.intoingAmt != null">
  523. intoing_amt = intoing_amt + #{et.intoingAmt,jdbcType=NUMERIC},
  524. </if>
  525. <if test=" et!=null and et.intoQty != null">
  526. into_qty = into_qty + #{et.intoQty,jdbcType=NUMERIC},
  527. </if>
  528. <if test=" et!=null and et.intoAmt != null">
  529. into_amt = into_amt + #{et.intoAmt,jdbcType=NUMERIC},
  530. </if>
  531. <if test=" et!=null and et.returnQty != null">
  532. return_qty = #{et.returnQty,jdbcType=NUMERIC},
  533. </if>
  534. <if test=" et!=null and et.returnAmt != null">
  535. return_amt = #{et.returnAmt,jdbcType=NUMERIC},
  536. </if>
  537. <if test=" et!=null and et.remarks != null">
  538. remarks = #{et.remarks,jdbcType=VARCHAR},
  539. </if>
  540. <if test=" et!=null and et.flgValid != null">
  541. flg_valid = #{et.flgValid,jdbcType=BOOLEAN},
  542. </if>
  543. <if test=" et!=null and et.cpId != null">
  544. cp_id = #{et.cpId,jdbcType=INTEGER},
  545. </if>
  546. </set>
  547. where item_id = #{et.itemId,typeHandler=UuidTypeHandler}
  548. and item_qty >= (into_qty + intoing_qty)
  549. </update>
  550. </mapper>