From 554738e1e277a9aafda4c20d420cba252d5f528f Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期二, 31 三月 2026 15:16:50 +0800
Subject: [PATCH] 显示料号

---
 src/main/resources/mapper/sales/SalesLedgerProductMapper.xml |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 2c50787..e0f219f 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -7,24 +7,26 @@
     <select id="selectSalesLedgerProductList" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct">
         SELECT
         T1.*,
+        T3.material_code,
         CASE
-        WHEN t2.qualitity > T1.quantity THEN 1
+        WHEN (IFNULL(t2.qualitity, 0) - IFNULL(t2.locked_quantity, 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
+        LEFT JOIN product_model T3 ON T1.product_model_id = T3.id
         <where>
-            1=1
-            <if test="salesLedgerProduct.salesLedgerId != null and salesLedgerProduct.salesLedgerId != '' ">
+            <if test="salesLedgerProduct.salesLedgerId != null">
                 AND T1.sales_ledger_id = #{salesLedgerProduct.salesLedgerId}
             </if>
-            <if test="salesLedgerProduct.type != null and salesLedgerProduct.type != '' ">
+            <if test="salesLedgerProduct.type != null">
                 AND T1.type = #{salesLedgerProduct.type}
             </if>
         </where>
         ORDER BY T1.register_date DESC
     </select>
+
     <select id="selectSalesLedgerProductByMainId" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct">
         select slp.*
         from quality_inspect qi
@@ -108,6 +110,7 @@
         slp.product_category AS productCategory,
         slp.specification_model AS specificationModel,
         sl.supplier_name AS supplierName,
+        pm.material_code AS materialCode,
         SUM(slp.quantity) AS purchaseNum,
         SUM(slp.tax_inclusive_total_price) AS purchaseAmount,
         COUNT(DISTINCT slp.sales_ledger_id) AS purchaseTimes,
@@ -118,6 +121,9 @@
         FROM sales_ledger_product slp
         <!-- 鍏宠仈鍙拌处涓昏〃锛氳幏鍙栧綍鍏ユ棩鏈焑ntry_date -->
         LEFT JOIN purchase_ledger sl ON slp.sales_ledger_id = sl.id
+        <!-- 鍏宠仈浜у搧鍨嬪彿琛細鑾峰彇鏂欏彿material_code -->
+        LEFT JOIN product_model pm ON pm.id = slp.product_model_id
+        <!-- 閲囪喘鏃ユ湡绛涢�夛細鍙�夋潯浠� -->
         WHERE slp.type = 2 <!-- 鍥哄畾绛涢�夛細閲囪喘鍙拌处锛坱ype=2锛� -->
         <!-- 閲囪喘鏃ユ湡绛涢�夛細鍙�夋潯浠� -->
         <if test="req.entryDateStart != null and req.entryDateEnd != null">
@@ -196,11 +202,15 @@
     </select>
 
     <select id="selectProductCountByTypeAndDate" resultType="int">
-        SELECT COUNT(*)
+        SELECT IFNULL(COUNT(*), 0)
         FROM sales_ledger_product
         WHERE type = #{type}
-        AND register_date &gt;= #{startDate}
-        AND register_date &lt;= #{endDate}
+        <if test="startDate != null">
+            AND register_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null">
+            AND register_date &lt;= #{endDate}
+        </if>
     </select>
 
     <select id="selectRawMaterialExpense" resultType="java.math.BigDecimal">

--
Gitblit v1.9.3