From b5f260b2364fad1e74a7eb1f5985268056e3a9e7 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期五, 24 四月 2026 18:24:15 +0800
Subject: [PATCH] Merge branch 'dev_New_pro' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_New_pro

---
 src/main/resources/mapper/stock/StockInventoryMapper.xml |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/main/resources/mapper/stock/StockInventoryMapper.xml b/src/main/resources/mapper/stock/StockInventoryMapper.xml
index f136a84..a7dab00 100644
--- a/src/main/resources/mapper/stock/StockInventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -34,6 +34,12 @@
             update_time = now()
         </set>
         where product_model_id = #{ew.productModelId}
+            <if test="ew.batchNo == null">
+                and batch_no is null
+            </if>
+            <if test="ew.batchNo != null">
+                and batch_no = #{ew.batchNo}
+            </if>
     </update>
     <update id="updateSubtractStockInventory">
         update stock_inventory
@@ -50,6 +56,12 @@
             update_time = now()
         </set>
         where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity}
+            <if test="ew.batchNo == null">
+                and batch_no is null
+            </if>
+            <if test="ew.batchNo != null">
+                and batch_no = #{ew.batchNo}
+            </if>
     </update>
     <select id="pagestockInventory" resultType="com.ruoyi.stock.dto.StockInventoryDto">
         select si.id,
@@ -87,6 +99,7 @@
         INNER JOIN product_tree pt ON p.parent_id = pt.id
         )
         select
+            batch_no,
             MAX(qualifiedId) as qualifiedId,
             MAX(unQualifiedId) as unQualifiedId,
             SUM(qualifiedQuantity) as qualifiedQuantity,
@@ -108,6 +121,7 @@
             'combined' as stockType
         from (
             select
+            si.batch_no,
             si.id as qualifiedId,
             null as unQualifiedId,
             si.qualitity as qualifiedQuantity,
@@ -133,6 +147,7 @@
             union all
 
             select
+            su.batch_no,
             null as qualifiedId,
             su.id as unQualifiedId,
             0 as qualifiedQuantity,
@@ -168,7 +183,7 @@
                 and combined.product_id in (select id from product_tree)
             </if>
         </where>
-        group by product_model_id, model, unit, product_name, product_id
+        group by batch_no, product_model_id, model, unit, product_name, product_id
     </select>
 
     <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData">
@@ -395,4 +410,4 @@
         ORDER BY DATE(sor.create_time) ASC
     </select>
 
-</mapper>
\ No newline at end of file
+</mapper>

--
Gitblit v1.9.3