From 1729474b4c7ffacb1790bb70981e64e7744bffb2 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期一, 26 一月 2026 17:51:06 +0800
Subject: [PATCH] feat: BOM导入模板下载接口,导入导出接口添加权限
---
src/main/resources/mapper/sales/SalesLedgerProductMapper.xml | 139 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 134 insertions(+), 5 deletions(-)
diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 8982caf..71b776c 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -8,17 +8,24 @@
SELECT
T1.*,
t3.shipping_car_number,
- t3.shipping_date
+ t3.shipping_date,
+ t3.status as shippingStatus,
+ t3.shipping_date,
+ CASE
+ WHEN t2.qualitity > T1.quantity THEN 1
+ ELSE 0
+ END as has_sufficient_stock
FROM
sales_ledger_product T1
- left join shipping_info t3 on T1.id = t3.sales_ledger_id
+ LEFT JOIN stock_inventory t2 ON T1.product_model_id = t2.product_model_id
+ LEFT JOIN shipping_info t3 ON T1.id = t3.sales_ledger_product_id
<where>
1=1
<if test="salesLedgerProduct.salesLedgerId != null and salesLedgerProduct.salesLedgerId != '' ">
- AND T1.sales_ledger_id = #{salesLedgerProduct.salesLedgerId}
+ AND T1.sales_ledger_id = #{salesLedgerProduct.salesLedgerId}
</if>
<if test="salesLedgerProduct.type != null and salesLedgerProduct.type != '' ">
- AND T1.type = #{salesLedgerProduct.type}
+ AND T1.type = #{salesLedgerProduct.type}
</if>
</where>
</select>
@@ -27,10 +34,132 @@
from quality_inspect qi
left join production_product_main ppm on qi.product_main_id = ppm.id
left join product_work_order pwo on ppm.work_order_id = pwo.id
- left join product_order po on pwo.product_order_id = po.id
+ left join product_order po on pwo.product_order_id = po.id
left join sales_ledger_product slp on po.product_model_id = slp.id
where qi.product_main_id = #{productMainId}
</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 > 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 > 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>
+ <select id="selectProductBomStructure" resultType="com.ruoyi.sales.dto.LossProductModelDto">
+ select
+ a.model,
+ a.product_name,
+ a.unit,
+ sum(a.single_quantity) AS loss_num
+ from (SELECT ps.unit,
+ ps.unit_quantity,
+ pm1.model,
+ p.product_name,
+ ps.unit_quantity * slp.quantity AS single_quantity
+ FROM sales_ledger sl
+ LEFT JOIN sales_ledger_product slp ON slp.sales_ledger_id = sl.id
+ LEFT JOIN product_model pm ON pm.id = slp.product_model_id
+ LEFT JOIN product_bom pb ON pb.product_model_id = pm.id
+ LEFT JOIN product_structure ps ON pb.id = ps.bom_id
+ LEFT JOIN product_model pm1 ON pm1.id = ps.product_model_id
+ LEFT JOIN product p ON p.id = pm1.product_id
+ WHERE sl.id = #{salesLedegerId}) A
+ group by a.model, a.product_name, a.unit
+ </select>
+ <select id="selectProduct" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct">
+ select
+ p.product_name as product_category,
+ pm.model as specification_model,
+ pm.id
+ from product_model pm
+ left join product p on pm.product_id = p.id
+ </select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3