From 0bc2c552b180afa16e4aae3c8c12746b15ba6fc8 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 02 四月 2026 17:35:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_长治_健齿齿科器材' into dev_长治_健齿齿科器材

---
 src/main/resources/mapper/sales/SalesLedgerProductMapper.xml |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 73026c8..711c961 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -5,15 +5,22 @@
 <mapper namespace="com.ruoyi.sales.mapper.SalesLedgerProductMapper">
 
     <select id="selectSalesLedgerProductList" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct">
+        WITH stock_summary AS (
+        SELECT
+        product_model_id,
+        SUM(qualitity) AS total_quantity,
+        SUM(locked_quantity) AS total_locked
+        FROM stock_inventory
+        GROUP BY product_model_id
+        )
         SELECT
         T1.*,
         CASE
-        WHEN (IFNULL(t2.qualitity, 0) - IFNULL(t2.locked_quantity, 0)) >= IFNULL(T1.quantity, 0) THEN 1
+        WHEN (IFNULL(s.total_quantity, 0) - IFNULL(s.total_locked, 0)) >= IFNULL(T1.quantity, 0) THEN 1
         ELSE 0
         END as has_sufficient_stock
-        FROM
-        sales_ledger_product T1
-        LEFT JOIN stock_inventory t2 ON T1.product_model_id = t2.product_model_id
+        FROM sales_ledger_product T1
+        LEFT JOIN stock_summary s ON T1.product_model_id = s.product_model_id
         <where>
             <if test="salesLedgerProduct.salesLedgerId != null">
                 AND T1.sales_ledger_id = #{salesLedgerProduct.salesLedgerId}
@@ -127,8 +134,10 @@
         <if test="req.productCategory != null and req.productCategory != ''">
             AND slp.product_category = #{req.productCategory}
         </if>
-        <!-- 鎸変骇鍝佸ぇ绫诲垎缁勮仛鍚� -->
-        GROUP BY slp.product_category
+        GROUP BY
+        slp.product_category,
+        slp.specification_model,
+        sl.supplier_name
         <!-- 鎸変骇鍝佸ぇ绫绘帓搴� -->
         ORDER BY slp.product_category
     </select>

--
Gitblit v1.9.3