InventoryMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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.InventoryMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. inv_id, wh_id, sku_id, non_std_code, sys.f_remove_zero(inv_qty) as inv_qty, sys.f_remove_zero(outing_qty) as outing_qty,
  8. sys.f_remove_zero(usable_qty) as usable_qty, cost_price, cost_amt, remarks, flg_valid, cp_id, op_create_time,
  9. op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user, sys.f_remove_zero(freeze_qty) as freeze_qty
  10. </sql>
  11. <!-- 通用查询列Response -->
  12. <sql id="Base_Column_List_Response">
  13. tpi.inv_id, tpi.wh_id, tpi.sku_id, tpi.non_std_code, sys.f_remove_zero(tpi.inv_qty) as inv_qty,
  14. sys.f_remove_zero(tpi.outing_qty) as outing_qty,
  15. sys.f_remove_zero(tpi.usable_qty) as usable_qty, tpi.cost_price, tpi.cost_amt, tpi.remarks, tpi.flg_valid,
  16. tpi.cp_id,sys.f_remove_zero(tpi.freeze_qty) as freeze_qty
  17. </sql>
  18. <!-- 通用查询映射结果 -->
  19. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.ivt.Inventory">
  20. <id column="inv_id" property="invId"/>
  21. <result column="wh_id" property="whId" typeHandler="UuidTypeHandler"/>
  22. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  23. <result column="non_std_code" property="nonStdCode"/>
  24. <result column="inv_qty" property="invQty"/>
  25. <result column="outing_qty" property="outingQty"/>
  26. <result column="usable_qty" property="usableQty"/>
  27. <result column="cost_price" property="costPrice"/>
  28. <result column="cost_amt" property="costAmt"/>
  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. <result column="freeze_qty" property="freezeQty"/>
  40. <result column="decimalPlaces" property="decimalPlaces"/>
  41. </resultMap>
  42. <!-- 通用查询映射结果Response -->
  43. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.ivt.InventoryResponse">
  44. <id column="inv_id" property="invId"/>
  45. <result column="wh_id" property="whId" typeHandler="UuidTypeHandler"/>
  46. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  47. <result column="non_std_code" property="nonStdCode"/>
  48. <result column="inv_qty" property="invQty"/>
  49. <result column="outing_qty" property="outingQty"/>
  50. <result column="usable_qty" property="usableQty"/>
  51. <result column="cost_price" property="costPrice"/>
  52. <result column="cost_amt" property="costAmt"/>
  53. <result column="remarks" property="remarks"/>
  54. <result column="flg_valid" property="flgValid"/>
  55. <result column="cp_id" property="cpId"/>
  56. <result column="sku_code" property="skuCode"/>
  57. <result column="sku_name" property="skuName"/>
  58. <result column="sku_spec" property="skuSpec"/>
  59. <result column="sku_model" property="skuModel"/>
  60. <result column="brand_name" property="brandName"/>
  61. <result column="short_name" property="shortName"/>
  62. <result column="wh_name" property="whName"/>
  63. <result column="price_purchase" property="pricePurchase"/>
  64. <result column="price_standard" property="priceStandard"/>
  65. <result column="price_wholesale" property="priceWholesale"/>
  66. <result column="price_limited" property="priceLimited"/>
  67. <result column="unit_id" property="unitId" typeHandler="UuidTypeHandler"/>
  68. <result column="sub_unit_id" property="subUnitId" typeHandler="UuidTypeHandler"/>
  69. <result column="pack_box" property="packBox"/>
  70. <result column="subUnitName" property="subUnitName"/>
  71. <result column="unitName" property="unitName"/>
  72. <result column="flg_sub_unit" property="flgSubUnit"/>
  73. <result column="seriesName" property="seriesName"/>
  74. <result column="catName" property="catName"/>
  75. <result column="price_other" property="priceOther"/>
  76. <result column="warning_upper_limit" property="warningUpperLimit"/>
  77. <result column="warning_lower_limit" property="warningLowerLimit"/>
  78. <result column="sku_images" property="skuImages" typeHandler="JsonTypeHandler"/>
  79. <result column="decimalPlaces" property="decimalPlaces"/>
  80. </resultMap>
  81. <!-- 通用条件列 -->
  82. <sql id="Condition">
  83. <where>
  84. <if test="whId != null and whId != ''">
  85. AND tpi.wh_id = #{whId}::UUID
  86. </if>
  87. <if test="whIds != null and whIds.size()>0">
  88. AND tpi.wh_id =
  89. any(#{whIds, typeHandler=UuidListTypeHandler})
  90. </if>
  91. <if test="skuId != null and skuId != ''">
  92. AND tpi.sku_id = #{skuId}
  93. </if>
  94. <if test="nonStdCode != null and nonStdCode != ''">
  95. AND tpi.non_std_code = #{nonStdCode}
  96. </if>
  97. <if test="invQty != null">
  98. AND tpi.inv_qty = #{invQty}
  99. </if>
  100. <if test="outingQty != null">
  101. AND tpi.outing_qty = #{outingQty}
  102. </if>
  103. <if test="usableQty != null">
  104. AND tpi.usable_qty = #{usableQty}
  105. </if>
  106. <if test="costPrice != null">
  107. AND tpi.cost_price = #{costPrice}
  108. </if>
  109. <if test="costAmt != null">
  110. AND tpi.cost_amt = #{costAmt}
  111. </if>
  112. <if test="flgValid != null">
  113. AND tpi.flg_valid = #{flgValid}
  114. </if>
  115. <if test="flgZero == true">
  116. AND tpi.inv_qty != 0
  117. </if>
  118. <if test="cpId != null">
  119. AND tpi.cp_id = #{cpId}
  120. </if>
  121. <if test="freezeQty != null">
  122. AND tpi.freeze_qty = #{freezeQty}
  123. </if>
  124. <if test="categoryId != null and categoryId != ''">
  125. AND tmgs.category_id = #{categoryId}::UUID
  126. </if>
  127. <if test="brandId != null and brandId != ''">
  128. AND tmgs.brand_id = #{brandId}::UUID
  129. </if>
  130. <if test="searchText != null">
  131. AND (tmgs.sku_model like concat('%', my_ex.likequery(#{searchText}) , '%')
  132. OR tmgs.sku_name like concat('%', my_ex.likequery(#{searchText}) , '%')
  133. OR tpi.non_std_code like concat('%', my_ex.likequery(#{searchText}) , '%')
  134. )
  135. </if>
  136. <if test="invQtyFlag != null and invQtyFlag = true">
  137. and tpi.inv_qty != 0
  138. </if>
  139. </where>
  140. </sql>
  141. <sql id="idsForeach">
  142. <!-- 根据主键invId批量操作 -->
  143. WHERE inv_id in
  144. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  145. #{item}
  146. </foreach>
  147. </sql>
  148. <!-- 查询表dkic_b.t_psi_inventory,(条件查询+分页)列表 -->
  149. <select id="selectByCond" resultMap="BaseResultMapResponse">
  150. SELECT
  151. <include refid="Base_Column_List_Response"/>
  152. ,tmgs.sku_code
  153. ,tmgs.sku_model
  154. ,tmgs.sku_name
  155. ,tmgs.sku_spec
  156. ,tmgs.price_purchase
  157. ,tmgs.price_standard
  158. ,tmgs.price_wholesale
  159. ,tmgs.price_other
  160. ,tmgs.price_limited
  161. ,tmgs.sku_images
  162. ,tmgs.unit_id
  163. ,tmgs.sub_unit_id
  164. ,tmgs.warning_upper_limit
  165. ,tmgs.warning_lower_limit
  166. ,tmgs.pack_box
  167. ,tmu.unit_name AS "unitName"
  168. ,subtmu.unit_name AS "subUnitName"
  169. ,tmgs.flg_sub_unit
  170. ,tmgb.brand_name
  171. ,tmgb.short_name
  172. ,tmw.wh_name
  173. ,tmgc.cat_name as "catName"
  174. ,tmgseries.series_name as "seriesName"
  175. ,tmu.decimal_places as "decimalPlaces"
  176. FROM dkic_b.t_psi_inventory tpi
  177. <include refid="Join_Table"/>
  178. <include refid="Condition"/>
  179. <if test="desc != null and desc != ''">
  180. order by tpi.usable_qty desc
  181. </if>
  182. <if test="desc == null or desc == ''">
  183. order by tpi.usable_qty
  184. </if>
  185. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  186. limit #{end} offset #{start}
  187. </if>
  188. </select>
  189. <!-- 查询表dkic_b.t_psi_inventory,(条件查询)个数 -->
  190. <select id="countByCond" resultType="Long">
  191. SELECT
  192. count(1)
  193. FROM dkic_b.t_psi_inventory tpi
  194. <include refid="Join_Table"/>
  195. <include refid="Condition"/>
  196. </select>
  197. <sql id="Join_Table">
  198. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpi.sku_id
  199. left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
  200. LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
  201. LEFT JOIN dkic_b.t_mst_unit tmu ON tmu.unit_id = tmgs.unit_id
  202. LEFT JOIN dkic_b.t_mst_unit subtmu ON subtmu.unit_id = tmgs.sub_unit_id
  203. left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
  204. left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
  205. </sql>
  206. <!-- 根据主键查询表dkic_b.t_psi_inventory的一行数据 -->
  207. <select id="selectById" resultMap="BaseResultMapResponse">
  208. SELECT
  209. <include refid="Base_Column_List_Response"/>
  210. ,tmu.decimal_places as "decimalPlaces"
  211. FROM dkic_b.t_psi_inventory tpi
  212. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpi.sku_id
  213. LEFT JOIN dkic_b.t_mst_unit tmu ON tmu.unit_id = tmgs.unit_id
  214. WHERE tpi.inv_id = #{id}::uuid
  215. </select>
  216. <!-- 根据主键锁定表dkic_b.t_psi_inventory的一行数据 -->
  217. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  218. SELECT
  219. <include refid="Base_Column_List"/>
  220. FROM dkic_b.t_psi_inventory
  221. WHERE inv_id = #{id}::uuid
  222. for update
  223. </select>
  224. <!-- 根据主键锁定表dkic_b.t_psi_inventory的多行数据 -->
  225. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  226. SELECT
  227. <include refid="Base_Column_List"/>
  228. FROM dkic_b.t_psi_inventory
  229. <include refid="idsForeach"/>
  230. for update
  231. </select>
  232. <insert id="insertBatch">
  233. insert into dkic_b.t_psi_inventory
  234. (
  235. <trim suffixOverrides=",">
  236. wh_id,
  237. sku_id,
  238. non_std_code,
  239. inv_qty,
  240. outing_qty,
  241. usable_qty,
  242. cost_price,
  243. cost_amt,
  244. remarks,
  245. cp_id,
  246. op_app_code,
  247. freeze_qty,
  248. </trim>
  249. )
  250. values
  251. <foreach collection="list" index="index" item="item" separator=",">
  252. (
  253. <trim suffixOverrides=",">
  254. #{item.whId}::uuid,
  255. #{item.skuId}::uuid,
  256. #{item.nonStdCode},
  257. #{item.invQty},
  258. #{item.outingQty},
  259. #{item.usableQty},
  260. #{item.costPrice},
  261. #{item.costAmt},
  262. #{item.remarks},
  263. #{item.cpId},
  264. #{item.opAppCode},
  265. #{item.freezeQty},
  266. </trim>
  267. )
  268. </foreach>
  269. </insert>
  270. <!-- 查询表dkic_b.t_psi_inventory,(条件查询+分页)列表 -->
  271. <select id="selectByOther" resultMap="BaseResultMapResponse">
  272. SELECT
  273. <include refid="Base_Column_List_Response"/>
  274. ,tmu.decimal_places as "decimalPlaces"
  275. FROM dkic_b.t_psi_inventory tpi
  276. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpi.sku_id
  277. LEFT JOIN dkic_b.t_mst_unit tmu ON tmu.unit_id = tmgs.unit_id
  278. <where>
  279. <if test="whId != null and whId != ''">
  280. AND tpi.wh_id = #{whId}::uuid
  281. </if>
  282. <if test="skuId != null and skuId != ''">
  283. AND tpi.sku_id = #{skuId}::uuid
  284. </if>
  285. <if test="nonStdCode != null and nonStdCode != ''">
  286. AND tpi.non_std_code = #{nonStdCode}
  287. </if>
  288. <if test="nonStdCode == null and nonStdCode == ''">
  289. AND tpi.non_std_code = '-'
  290. </if>
  291. </where>
  292. </select>
  293. <select id="warningCountByCond" resultType="java.lang.Long">
  294. SELECT
  295. count(1)
  296. FROM dkic_b.t_psi_inventory tpi
  297. <include refid="Join_Table"/>
  298. <where>
  299. (tmgs.warning_lower_limit &lt;&gt; 0 OR tmgs.warning_upper_limit &lt;&gt; 0)
  300. AND (tpi.inv_qty > tmgs.warning_lower_limit OR tpi.inv_qty > tmgs.warning_upper_limit)
  301. <if test="whId != null and whId != ''">
  302. AND tpi.wh_id = #{whId}::UUID
  303. </if>
  304. <if test="whIds != null and whIds.size()>0">
  305. AND tpi.wh_id =
  306. any(#{whIds, typeHandler=UuidListTypeHandler})
  307. </if>
  308. <if test="skuId != null and skuId != ''">
  309. AND tpi.sku_id = #{skuId}
  310. </if>
  311. <if test="nonStdCode != null and nonStdCode != ''">
  312. AND tpi.non_std_code = #{nonStdCode}
  313. </if>
  314. <if test="invQty != null">
  315. AND tpi.inv_qty = #{invQty}
  316. </if>
  317. <if test="outingQty != null">
  318. AND tpi.outing_qty = #{outingQty}
  319. </if>
  320. <if test="usableQty != null">
  321. AND tpi.usable_qty = #{usableQty}
  322. </if>
  323. <if test="costPrice != null">
  324. AND tpi.cost_price = #{costPrice}
  325. </if>
  326. <if test="costAmt != null">
  327. AND tpi.cost_amt = #{costAmt}
  328. </if>
  329. <if test="flgValid != null">
  330. AND tpi.flg_valid = #{flgValid}
  331. </if>
  332. <if test="flgZero == true">
  333. AND tpi.inv_qty != 0
  334. </if>
  335. <if test="cpId != null">
  336. AND tpi.cp_id = #{cpId}
  337. </if>
  338. <if test="freezeQty != null">
  339. AND tpi.freeze_qty = #{freezeQty}
  340. </if>
  341. <if test="categoryId != null and categoryId != ''">
  342. AND tmgs.category_id = #{categoryId}::UUID
  343. </if>
  344. <if test="brandId != null and brandId != ''">
  345. AND tmgs.brand_id = #{brandId}::UUID
  346. </if>
  347. <if test="searchText != null">
  348. AND (tmgs.sku_model like concat('%', my_ex.likequery(#{searchText}) , '%')
  349. OR tmgs.sku_name like concat('%', my_ex.likequery(#{searchText}) , '%')
  350. OR tpi.non_std_code like concat('%', my_ex.likequery(#{searchText}) , '%')
  351. )
  352. </if>
  353. <if test="invQtyFlag != null and invQtyFlag = true">
  354. and tpi.inv_qty != 0
  355. </if>
  356. </where>
  357. </select>
  358. <select id="warningSelectByCond" resultType="com.dk.mdm.model.response.ivt.InventoryResponse">
  359. SELECT
  360. <include refid="Base_Column_List_Response"/>
  361. ,tmgs.sku_code
  362. ,tmgs.sku_model
  363. ,tmgs.sku_name
  364. ,tmgs.sku_spec
  365. ,tmgs.price_purchase
  366. ,tmgs.price_standard
  367. ,tmgs.price_wholesale
  368. ,tmgs.price_other
  369. ,tmgs.price_limited
  370. ,tmgs.sku_images
  371. ,tmgs.unit_id
  372. ,tmgs.sub_unit_id
  373. ,tmgs.warning_upper_limit
  374. ,tmgs.warning_lower_limit
  375. ,tmgs.pack_box
  376. ,tmu.unit_name AS "unitName"
  377. ,subtmu.unit_name AS "subUnitName"
  378. ,tmgs.flg_sub_unit
  379. ,tmgb.brand_name
  380. ,tmgb.short_name
  381. ,tmw.wh_name
  382. ,tmgc.cat_name as "catName"
  383. ,tmgseries.series_name as "seriesName"
  384. ,tmu.decimal_places as "decimalPlaces"
  385. FROM dkic_b.t_psi_inventory tpi
  386. <include refid="Join_Table"/>
  387. <where>
  388. (tmgs.warning_lower_limit &lt;&gt; 0 OR tmgs.warning_upper_limit &lt;&gt; 0)
  389. AND (tpi.inv_qty > tmgs.warning_lower_limit OR tpi.inv_qty > tmgs.warning_upper_limit)
  390. <if test="whId != null and whId != ''">
  391. AND tpi.wh_id = #{whId}::UUID
  392. </if>
  393. <if test="whIds != null and whIds.size()>0">
  394. AND tpi.wh_id =
  395. any(#{whIds, typeHandler=UuidListTypeHandler})
  396. </if>
  397. <if test="skuId != null and skuId != ''">
  398. AND tpi.sku_id = #{skuId}
  399. </if>
  400. <if test="nonStdCode != null and nonStdCode != ''">
  401. AND tpi.non_std_code = #{nonStdCode}
  402. </if>
  403. <if test="invQty != null">
  404. AND tpi.inv_qty = #{invQty}
  405. </if>
  406. <if test="outingQty != null">
  407. AND tpi.outing_qty = #{outingQty}
  408. </if>
  409. <if test="usableQty != null">
  410. AND tpi.usable_qty = #{usableQty}
  411. </if>
  412. <if test="costPrice != null">
  413. AND tpi.cost_price = #{costPrice}
  414. </if>
  415. <if test="costAmt != null">
  416. AND tpi.cost_amt = #{costAmt}
  417. </if>
  418. <if test="flgValid != null">
  419. AND tpi.flg_valid = #{flgValid}
  420. </if>
  421. <if test="flgZero == true">
  422. AND tpi.inv_qty != 0
  423. </if>
  424. <if test="cpId != null">
  425. AND tpi.cp_id = #{cpId}
  426. </if>
  427. <if test="freezeQty != null">
  428. AND tpi.freeze_qty = #{freezeQty}
  429. </if>
  430. <if test="categoryId != null and categoryId != ''">
  431. AND tmgs.category_id = #{categoryId}::UUID
  432. </if>
  433. <if test="brandId != null and brandId != ''">
  434. AND tmgs.brand_id = #{brandId}::UUID
  435. </if>
  436. <if test="searchText != null">
  437. AND (tmgs.sku_model like concat('%', my_ex.likequery(#{searchText}) , '%')
  438. OR tmgs.sku_name like concat('%', my_ex.likequery(#{searchText}) , '%')
  439. OR tpi.non_std_code like concat('%', my_ex.likequery(#{searchText}) , '%')
  440. )
  441. </if>
  442. <if test="invQtyFlag != null and invQtyFlag = true">
  443. and tpi.inv_qty != 0
  444. </if>
  445. </where>
  446. <if test="desc != null and desc != ''">
  447. order by tpi.usable_qty desc
  448. </if>
  449. <if test="desc == null or desc == ''">
  450. order by tpi.usable_qty
  451. </if>
  452. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  453. limit #{end} offset #{start}
  454. </if>
  455. </select>
  456. <!--修改库存数量金额-->
  457. <update id="updateAmountAndQuantity" parameterType="com.dk.mdm.model.vo.ivt.InventoryVO">
  458. update dkic_b.t_psi_inventory
  459. <set>
  460. <if test="invQty != null">
  461. inv_qty = inv_qty + #{invQty,jdbcType=NUMERIC},
  462. usable_qty = (inv_qty + #{invQty,jdbcType=NUMERIC}) - outing_qty - freeze_qty,
  463. <if test="zeroFlag">
  464. cost_amt = 0,
  465. cost_price = 0 ,
  466. </if>
  467. <if test="!zeroFlag">
  468. cost_amt = cost_amt + #{costAmt,jdbcType=NUMERIC},
  469. cost_price = (cost_amt + #{costAmt,jdbcType=NUMERIC}) / (inv_qty + #{invQty,jdbcType=NUMERIC}) ,
  470. </if>
  471. </if>
  472. </set>
  473. where inv_id =#{invId,typeHandler=UuidTypeHandler}
  474. and inv_qty + #{invQty,jdbcType=NUMERIC}>=0
  475. and cost_amt + #{costAmt,jdbcType=NUMERIC}>=0
  476. </update>
  477. <!--修改库存数量金额(删除用)-->
  478. <update id="updateAmtAndQty" parameterType="com.dk.mdm.model.pojo.ivt.Inventory">
  479. update dkic_b.t_psi_inventory
  480. <set>
  481. <if test="invQty != null">
  482. inv_qty = #{invQty,jdbcType=NUMERIC},
  483. </if>
  484. <if test="usableQty != null">
  485. usable_qty = #{usableQty,jdbcType=NUMERIC},
  486. </if>
  487. <if test="costPrice != null">
  488. cost_price = #{costPrice,jdbcType=NUMERIC},
  489. </if>
  490. <if test="costAmt != null">
  491. cost_amt = #{costAmt,jdbcType=NUMERIC},
  492. </if>
  493. </set>
  494. where inv_id =#{invId,typeHandler=UuidTypeHandler}
  495. and #{invQty,jdbcType=NUMERIC}>=0
  496. and #{costAmt,jdbcType=NUMERIC}>=0
  497. </update>
  498. <!--删除数据-->
  499. <delete id="deleteData" parameterType="com.dk.mdm.model.pojo.ivt.InOutRecord">
  500. DELETE
  501. FROM dkic_b.t_psi_inventory
  502. where inv_id = #{invId,typeHandler=UuidTypeHandler}
  503. </delete>
  504. <!--修改存货单价/存货资产-->
  505. <update id="updateCost" parameterType="com.dk.mdm.model.pojo.ivt.Inventory">
  506. update dkic_b.t_psi_inventory
  507. <set>
  508. <if test="costPrice != null">
  509. cost_price = #{costPrice,jdbcType=NUMERIC},
  510. </if>
  511. <if test="costAmt != null">
  512. cost_amt = #{costAmt,jdbcType=NUMERIC},
  513. </if>
  514. </set>
  515. where inv_id =#{invId,typeHandler=UuidTypeHandler}
  516. </update>
  517. </mapper>