From 7782a7e1191a0e98ffb20bca8b59248e98c556a8 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 24 四月 2026 14:38:13 +0800
Subject: [PATCH] feat(stock): 添加库存位置功能支持

---
 src/main/resources/mapper/stock/StockUninventoryMapper.xml |   39 +++++++++++++++++++++++++++++----------
 1 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/src/main/resources/mapper/stock/StockUninventoryMapper.xml b/src/main/resources/mapper/stock/StockUninventoryMapper.xml
index 39b16b3..db13390 100644
--- a/src/main/resources/mapper/stock/StockUninventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockUninventoryMapper.xml
@@ -10,6 +10,9 @@
         <result column="create_time" property="createTime" />
         <result column="update_time" property="updateTime" />
         <result column="version" property="version" />
+        <result column="remark" property="remark" />
+        <result column="locked_quantity" property="lockedQuantity" />
+        <result column="stock_location" property="stockLocation" />
     </resultMap>
     <update id="updateSubtractStockUnInventory">
         update stock_uninventory
@@ -25,7 +28,7 @@
             </if>
             update_time = now()
         </set>
-        where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity}
+        where product_model_id = #{ew.productModelId} and stock_location = #{ew.stockLocation} and qualitity >= #{ew.qualitity}
     </update>
     <update id="updateAddStockUnInventory">
         update stock_uninventory
@@ -41,22 +44,35 @@
             </if>
             update_time = now()
         </set>
-        where product_model_id = #{ew.productModelId}
+        where product_model_id = #{ew.productModelId} and stock_location = #{ew.stockLocation}
     </update>
     <select id="pageStockUninventory" resultType="com.ruoyi.stock.dto.StockUninventoryDto">
-        select su.*,
-               pm.model,
-               pm.unit,
-               p.product_name
+        select su.id,
+        su.qualitity,
+        COALESCE(su.locked_quantity, 0) as locked_quantity,
+        su.product_model_id,
+        su.create_time,
+        su.update_time,
+        su.version,
+        su.update_time,
+        (su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity,
+        su.remark,
+        su.stock_location,
+        pm.model,
+        pm.unit,
+        p.product_name
         from stock_uninventory su
-                 left join product_model pm on su.product_model_id = pm.id
-                 left join product p on pm.product_id = p.id
-        where 1 = 1
+        left join product_model pm on su.product_model_id = pm.id
+        left join product p on pm.product_id = p.id
+        where pm.product_type = #{ew.productType}
         <if test="ew.productName != null and ew.productName !=''">
             and p.product_name like concat('%',#{ew.productName},'%')
         </if>
+        <if test="ew.stockLocation != null and ew.stockLocation != ''">
+            and su.stock_location = #{ew.stockLocation}
+        </if>
     </select>
-    <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData">
+    <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockUnInventoryExportData">
         select su.*,
         pm.model,
         pm.unit,
@@ -68,6 +84,9 @@
         <if test="ew.productName != null and ew.productName !=''">
             and p.product_name like concat('%',#{ew.productName},'%')
         </if>
+        <if test="ew.stockLocation != null and ew.stockLocation != ''">
+            and su.stock_location = #{ew.stockLocation}
+        </if>
     </select>
 
 </mapper>

--
Gitblit v1.9.3