From 30a4a720cfdd57248514f50d141dfd51519aa75d Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 16 一月 2026 08:58:57 +0800
Subject: [PATCH] yys 销售指标,采购报表

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

diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 395ce1b..2579a18 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -33,4 +33,97 @@
 
 
     </select>
+    <select id="listPage" resultType="com.ruoyi.sales.dto.SalesLedgerProductDto">
+        select slp.*,
+        sl.project_name,
+        sl.customer_name,
+        sl.sales_contract_no,
+        sl.customer_contract_no
+        from sales_ledger_product slp
+        left join sales_ledger sl on slp.sales_ledger_id = sl.id
+        <where>
+            slp.type = 1
+            <if test="req.salesContractNo != null and req.salesContractNo != '' ">
+                AND  sl.sales_contract_no like concat('%',#{req.salesContractNo},'%')
+            </if>
+            <if test="req.customerContractNo != null and req.customerContractNo != '' ">
+                AND  sl.customer_contract_no like concat('%',#{req.customerContractNo},'%')
+            </if>
+            <if test="req.projectName != null and req.projectName != '' ">
+                AND  sl.project_name like concat('%',#{req.projectName},'%')
+            </if>
+            <if test="req.customerName != null and req.customerName != '' ">
+                AND  sl.customer_name like concat('%',#{req.customerName},'%')
+            </if>
+            <if test="req.productCategory != null and req.productCategory != '' ">
+                AND  slp.product_category like concat('%',#{req.productCategory},'%')
+            </if>
+            <if test="req.status != null and req.status ">
+                AND  slp.pending_invoice_total &gt; 0
+            </if>
+        </where>
+        order by slp.register_date desc
+    </select>
+    <select id="listPagePurchaseLedger" resultType="com.ruoyi.sales.dto.SalesLedgerProductDto">
+        select slp.*,
+        sl.project_name,
+        sl.supplier_name,
+        sl.supplier_id,
+        sl.sales_contract_no,
+        sl.purchase_contract_number
+        from sales_ledger_product slp
+        left join purchase_ledger sl on slp.sales_ledger_id = sl.id
+        <where>
+            slp.type = 2
+            <if test="req.purchaseContractNumber != null and req.purchaseContractNumber != '' ">
+                AND  sl.purchase_contract_number like concat('%',#{req.purchaseContractNumber},'%')
+            </if>
+            <if test="req.customerContractNo != null and req.customerContractNo != '' ">
+                AND  sl.customer_contract_no like concat('%',#{req.customerContractNo},'%')
+            </if>
+            <if test="req.projectName != null and req.projectName != '' ">
+                AND  sl.project_name like concat('%',#{req.projectName},'%')
+            </if>
+            <if test="req.customerName != null and req.customerName != '' ">
+                AND  sl.customer_name like concat('%',#{req.customerName},'%')
+            </if>
+            <if test="req.productCategory != null and req.productCategory != '' ">
+                AND  slp.product_category like concat('%',#{req.productCategory},'%')
+            </if>
+            <if test="req.status != null and req.status ">
+                AND  slp.pending_invoice_total &gt; 0
+            </if>
+        </where>
+        order by slp.register_date desc
+    </select>
+    <select id="procurementBusinessSummaryListPage"
+            resultType="com.ruoyi.purchase.dto.ProcurementBusinessSummaryDto">
+        SELECT
+        slp.product_category AS productCategory,
+        slp.specification_model AS specificationModel,
+        sl.supplier_name AS supplierName,
+        SUM(slp.quantity) AS purchaseNum,
+        SUM(slp.tax_inclusive_total_price) AS purchaseAmount,
+        COUNT(DISTINCT slp.sales_ledger_id) AS purchaseTimes,
+        <!-- 骞冲潎鍗曚环 = 鎬婚噰璐噾棰�/鎬婚噰璐暟閲忥紝淇濈暀2浣嶅皬鏁帮紝閬垮厤闄�0 -->
+        ROUND(IF(SUM(slp.quantity) = 0, 0, SUM(slp.tax_inclusive_total_price) / SUM(slp.quantity)), 2) AS averagePrice,
+        <!-- 璇ヤ骇鍝佸ぇ绫讳笅鏈�鍚庝竴涓綍鍏ユ棩鏈燂紙鍙栧彴璐︿富琛ㄧ殑entry_date锛� -->
+        MAX(sl.entry_date) AS entryDate
+        FROM sales_ledger_product slp
+        <!-- 鍏宠仈鍙拌处涓昏〃锛氳幏鍙栧綍鍏ユ棩鏈焑ntry_date -->
+        LEFT JOIN purchase_ledger sl ON slp.sales_ledger_id = sl.id
+        WHERE slp.type = 2 <!-- 鍥哄畾绛涢�夛細閲囪喘鍙拌处锛坱ype=2锛� -->
+        <!-- 閲囪喘鏃ユ湡绛涢�夛細鍙�夋潯浠� -->
+        <if test="req.entryDateStart != null and req.entryDateEnd != null">
+            AND sl.entry_date BETWEEN #{req.entryDateStart} AND #{req.entryDateEnd} <!-- 鏃堕棿鑼冨洿锛氶潪绌烘湁鏁� -->
+        </if>
+        <!-- 浜у搧澶х被绛涢�夛細鍙�夋潯浠� -->
+        <if test="req.productCategory != null and req.productCategory != ''">
+            AND slp.product_category = #{req.productCategory}
+        </if>
+        <!-- 鎸変骇鍝佸ぇ绫诲垎缁勮仛鍚� -->
+        GROUP BY slp.product_category
+        <!-- 鎸変骇鍝佸ぇ绫绘帓搴� -->
+        ORDER BY slp.product_category
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3