From a76e1d17d67641993dea6335cb8e1465a94df58d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 21 五月 2026 15:39:05 +0800
Subject: [PATCH] feat(stock): 优化库存管理和成品树结构功能 1- 为ApproveProcessMapper.xml和ProductBomMapper.xml添加排序功能 2- 在ProductionProductMainDto中新增bomInputQty字段用于产品结构投入数量 3- 修改ProductionProductMainServiceImpl中投入数量计算逻辑,使用前端传入的bomInputQty值 4- 在ProductWorkOrderDto中添加bomInputQty字段并在服务实现中计算标准投入数量 5- 更新SalesLedgerMapper.xml查询逻辑,从product_summary获取电压信息 6- 为SalesLedgerProduct添加stockId字段并修改库存扣减逻辑使用具体库存ID 7- 重构StockInventoryController中的成品库存树查询接口和导入导出功能 8- 新增成品和非成品库存导入导出的数据模型和Excel工具类 9- 优化StockInventoryServiceImpl中的库存扣减逻辑,支持按特定库存ID操作 10- 更新库存导入导出功能,区分成品和非成品类型并提供相应模板
---
src/main/resources/mapper/sales/SalesLedgerMapper.xml | 107 ++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 77 insertions(+), 30 deletions(-)
diff --git a/src/main/resources/mapper/sales/SalesLedgerMapper.xml b/src/main/resources/mapper/sales/SalesLedgerMapper.xml
index 5d83bb1..243b400 100644
--- a/src/main/resources/mapper/sales/SalesLedgerMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerMapper.xml
@@ -15,34 +15,6 @@
<select id="selectSalesLedgerList" resultType="com.ruoyi.sales.pojo.SalesLedger">
SELECT
- T1.id,
- T1.sales_contract_no,
- T1.customer_contract_no,
- T1.project_name,
- T1.entry_date,
- T1.salesman,
- T1.customer_id,
- T1.customer_name,
- T1.entry_person,
- T1.remarks,
- T1.attachment_materials,
- T1.tenant_id,
- T1.contract_amount,
- T1.execution_date,
- T2.nick_name AS entry_person_name,
- T1.payment_method
- FROM
- sales_ledger T1
- LEFT JOIN sys_user T2 ON T1.entry_person = T2.user_id
- <where>
- <if test="salesLedgerDto.customerName != null and salesLedgerDto.customerName != '' ">
- T1.customer_name LIKE CONCAT('%',#{salesLedgerDto.customerName},'%')
- </if>
- </where>
- </select>
-
- <select id="selectSalesLedgerListPage" resultType="com.ruoyi.sales.pojo.SalesLedger">
- SELECT
T1.id,
T1.sales_contract_no,
T1.customer_contract_no,
@@ -58,10 +30,72 @@
T1.contract_amount,
T1.execution_date,
T2.nick_name AS entry_person_name,
- T1.payment_method
+ T1.payment_method,
+ T1.is_produce AS produce,
+ DATEDIFF(T1.delivery_date, CURDATE()) AS delivery_days_diff
FROM
sales_ledger T1
LEFT JOIN sys_user T2 ON T1.entry_person = T2.user_id
+ <where>
+ <if test="salesLedgerDto.customerName != null and salesLedgerDto.customerName != '' ">
+ T1.customer_name LIKE CONCAT('%',#{salesLedgerDto.customerName},'%')
+ </if>
+ </where>
+ </select>
+
+ <select id="selectSalesLedgerListPage" resultType="com.ruoyi.sales.dto.SalesLedgerDto">
+ SELECT T1.id,
+ T1.sales_contract_no,
+ T1.customer_contract_no,
+ T1.project_name,
+ T1.entry_date,
+ T1.salesman,
+ T1.customer_id,
+ T1.customer_name,
+ T3.company_address,
+ T3.contact_phone,
+ T3.contact_person,
+ T3.company_phone,
+ T1.entry_person,
+ T1.remarks,
+ T1.attachment_materials,
+ T1.tenant_id,
+ T1.contract_amount,
+ T1.contract_amount as noInvoiceAmountTotal,
+ T1.execution_date,
+ T2.nick_name AS entry_person_name,
+ T1.payment_method,
+ T1.is_produce AS produce,
+ T1.delivery_date,
+ DATEDIFF(T1.delivery_date, CURDATE()) AS delivery_days_diff,
+ product_summary.model,
+ product_summary.voltage,
+ product_summary.qty,
+ CASE
+ WHEN shipping_status_counts.total_count = 0 THEN false
+ WHEN shipping_status_counts.unshipped_count = 0 THEN true
+ ELSE false
+ END AS is_fh
+ FROM sales_ledger T1
+ LEFT JOIN sys_user T2 ON T1.entry_person = T2.user_id
+ LEFT JOIN customer T3 ON T1.customer_id = T3.id
+ LEFT JOIN (
+ SELECT sales_ledger_id,
+ COUNT(*) as total_count,
+ SUM(CASE WHEN status != '宸插彂璐�' THEN 1 ELSE 0 END) as unshipped_count
+ FROM shipping_info
+ GROUP BY sales_ledger_id
+ ) shipping_status_counts ON T1.id = shipping_status_counts.sales_ledger_id
+ LEFT JOIN (
+ SELECT
+ sales_ledger_id,
+ GROUP_CONCAT(IFNULL(specification_model, '') ORDER BY id SEPARATOR ',') AS model,
+ GROUP_CONCAT(IFNULL(CAST(quantity AS CHAR), '') ORDER BY id SEPARATOR ',') AS qty,
+ GROUP_CONCAT(IFNULL(SUBSTRING_INDEX(specification_model, '-', -1), '') ORDER BY id SEPARATOR ',') AS voltage
+ FROM sales_ledger_product
+ WHERE type = 1
+ GROUP BY sales_ledger_id
+ ) product_summary ON T1.id = product_summary.sales_ledger_id
<where>
<if test="salesLedgerDto.customerName != null and salesLedgerDto.customerName != '' ">
AND T1.customer_name LIKE CONCAT('%',#{salesLedgerDto.customerName},'%')
@@ -84,4 +118,17 @@
</where>
order by T1.entry_date desc
</select>
-</mapper>
\ No newline at end of file
+
+ <select id="selectIncomeStats" resultType="com.ruoyi.home.dto.IncomeExpenseAnalysisDto">
+ SELECT DATE_FORMAT(entry_date, #{dateFormat}) as dateStr, IFNULL(SUM(contract_amount), 0) as amount
+ FROM sales_ledger
+ WHERE entry_date BETWEEN #{startDate} AND #{endDate}
+ GROUP BY dateStr
+ </select>
+
+ <select id="selectCustomerSalesComposition" resultType="com.ruoyi.dto.MapDto">
+ SELECT customer_name as name, CAST(IFNULL(SUM(contract_amount), 0) AS CHAR) as value
+ FROM sales_ledger
+ GROUP BY customer_name
+ </select>
+</mapper>
--
Gitblit v1.9.3