From ae76dfe2d6f00c13419fea9c7f8d2bd150860b9b Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期一, 11 五月 2026 16:08:54 +0800
Subject: [PATCH] fix(Stock): 入库出库枚举调整

---
 src/main/resources/mapper/stock/StockInRecordMapper.xml |   87 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 83 insertions(+), 4 deletions(-)

diff --git a/src/main/resources/mapper/stock/StockInRecordMapper.xml b/src/main/resources/mapper/stock/StockInRecordMapper.xml
index 8064b7b..c0e08af 100644
--- a/src/main/resources/mapper/stock/StockInRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -3,19 +3,98 @@
 <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 productName,
+        p.product_name as product_name,
         pm.model,
-        pm.unit
+        pm.unit,
+        u.nick_name as createBy
         FROM stock_in_record as sir
         LEFT JOIN product_model as pm on sir.product_model_id = pm.id
         LEFT JOIN product as p on pm.product_id = p.id
+        LEFT JOIN sys_user as u on sir.create_user = u.user_id
         <where>
             <if test="params.timeStr != null and params.timeStr != ''">
-                and sir.create_time like concat('%',#{param.timeStr},'%')
+                and sir.create_time like concat('%',#{params.timeStr},'%')
+            </if>
+            <if test="params.productName != null and params.productName != ''">
+                and p.product_name like concat('%',#{params.productName},'%')
+            </if>
+            <if test="params.type != null and params.type != ''">
+                and sir.type = #{params.type}
+            </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
     </select>
-</mapper>
\ No newline at end of file
+    <select id="listStockInRecordExportData" resultType="com.ruoyi.stock.execl.StockInRecordExportData">
+        SELECT
+        sir.*,
+        p.product_name as product_name,
+        pm.model,
+        pm.unit,
+        u.nick_name as createBy
+        FROM stock_in_record as sir
+        LEFT JOIN product_model as pm on sir.product_model_id = pm.id
+        LEFT JOIN product as p on pm.product_id = p.id
+        LEFT JOIN sys_user as u on sir.create_user = u.user_id
+        <where>
+            <if test="params.timeStr != null and params.timeStr != ''">
+                and sir.create_time like concat('%',#{params.timeStr},'%')
+            </if>
+            <if test="params.productName != null and params.productName != ''">
+                and p.product_name like concat('%',#{params.productName},'%')
+            </if>
+            <if test="params.type != null and params.type != ''">
+                and sir.type = #{params.type}
+            </if>
+            <if test="params.recordType != null and params.recordType != ''">
+                and sir.record_type = #{params.recordType}
+            </if>
+        </where>
+        order by sir.id desc
+    </select>
+    <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
+        LEFT JOIN purchase_ledger pl ON sir.record_id = pl.id
+        LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = pl.id and slp.type = 2
+        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='7'
+        <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