From f93a8f3d091f1e9d1b9c2df246ad39df0e14cfdd Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 12 五月 2026 15:22:36 +0800
Subject: [PATCH] feat(account): 实现总账科目树形结构及关联功能
---
src/main/resources/mapper/stock/StockInRecordMapper.xml | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/src/main/resources/mapper/stock/StockInRecordMapper.xml b/src/main/resources/mapper/stock/StockInRecordMapper.xml
index d5c3f38..ec25d21 100644
--- a/src/main/resources/mapper/stock/StockInRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -3,6 +3,17 @@
<mapper namespace="com.ruoyi.stock.mapper.StockInRecordMapper">
<select id="listPage" resultType="com.ruoyi.stock.dto.StockInRecordDto">
+ WITH RECURSIVE product_tree AS (
+ SELECT id
+ FROM product
+ WHERE id = #{params.topParentProductId}
+
+ UNION ALL
+
+ SELECT p.id
+ FROM product p
+ INNER JOIN product_tree pt ON p.parent_id = pt.id
+ )
SELECT
sir.*,
p.product_name as product_name,
@@ -25,6 +36,9 @@
</if>
<if test="params.recordType != null and params.recordType != ''">
and sir.record_type = #{params.recordType}
+ </if>
+ <if test="params.topParentProductId != null and params.topParentProductId > 0">
+ and p.id in (select id from product_tree)
</if>
</where>
order by sir.id desc
@@ -56,4 +70,38 @@
</where>
order by sir.id desc
</select>
-</mapper>
\ No newline at end of file
+ <select id="listPageAccountPurchase" resultType="com.ruoyi.account.bean.vo.PurchaseInboundVo">
+ SELECT
+ sir.id,
+ sir.inbound_batches,
+ pl.supplier_name,
+ DATE(sir.create_time) AS inboundDate,
+ p.product_name,
+ slp.specification_model,
+ sor.stock_in_num * slp.tax_inclusive_unit_price AS InboundAmount,
+ pl.purchase_contract_number
+ FROM stock_in_record sir
+ -- 10 绫诲瀷鎵嶅叧鑱旇川妫�琛�
+ LEFT JOIN quality_inspect qi ON sir.record_type = 10 AND sir.record_id = qi.id
+ -- 鍔ㄦ�佸叧鑱旈噰璐紙鑷姩閫傞厤 7 鍜� 10锛�
+ LEFT JOIN purchase_ledger pl
+ ON pl.id = IF(sir.record_type = 7, sir.record_id, qi.purchase_ledger_id)
+ -- 浜у搧鍏宠仈涓嶅姩
+ LEFT JOIN sales_ledger_product slp ON slp.type = 2 AND pl.id = slp.product_id
+ LEFT JOIN product_model pm ON slp.product_model_id = pm.id
+ LEFT JOIN product p ON pm.product_id = p.id
+ -- 鏉′欢
+ WHERE sir.approval_status = 1
+ AND sir.record_type IN ('7','10')
+ <if test="req.inboundBatches != null and req.inboundBatches != ''">
+ AND sir.inbound_batches LIKE CONCAT('%',#{req.inboundBatches},'%')
+ </if>
+ <if test="req.supplierName != null and req.supplierName != ''">
+ AND pl.supplier_name LIKE CONCAT('%',#{req.supplierName},'%')
+ </if>
+ <if test="req.startDate != null and req.endDate != null">
+ AND DATE(sir.create_time) BETWEEN #{startDate} AND #{endDate}
+ </if>
+ order by sir.id DESC
+ </select>
+</mapper>
--
Gitblit v1.9.3