From 27d8f8fbb2e02be63338b80f808969faa35adac0 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 19 九月 2025 11:36:49 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-system/src/main/resources/mapper/system/AssetMainMapper.xml |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/AssetMainMapper.xml b/ruoyi-system/src/main/resources/mapper/system/AssetMainMapper.xml
index 1ecd079..5bb2d5c 100644
--- a/ruoyi-system/src/main/resources/mapper/system/AssetMainMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/AssetMainMapper.xml
@@ -44,4 +44,53 @@
         id, approval_application_id, asset_original_code, asset_code, asset_name, specification_model, asset_type_id, asset_category, asset_main_type, measurement_unit, quantity, unit_price, total_value, useful_life, ownership_dept_id, user_name, use_dept_id, warehouse_id, warehouse_name, address, asset_status, remarks, accounting_status, accounting_date, accounting_voucher_no, accounting_subject, accounting_amount, attachment_urls, create_time, create_by, update_time, update_by, disabled
     </sql>
 
+    <!-- 分页查询:审批通过的资产列表(关联审批记录、资产类型与部门) -->
+    <select id="selectApprovedAssetPage" resultType="com.ruoyi.system.vo.asset.AssetMainPageVO">
+        SELECT
+            am.id AS id,
+            am.asset_code AS assetCode,
+            am.asset_name AS assetName,
+            at.type_name AS assetTypeName,
+            od.dept_name AS ownershipDeptName,
+            am.asset_status AS assetStatus,
+            oas.storage_time AS storageTime,
+            CASE
+                WHEN am.address_type = 0 THEN
+                ud.dept_name
+                WHEN am.address_type = 1 THEN
+                am.warehouse_name
+                WHEN am.address_type = 2 THEN
+                am.address
+                ELSE ''
+            END AS useDeptOrLocation
+        FROM asset_main am
+            INNER JOIN oa_approval_applications aaa ON aaa.id = am.approval_application_id
+            LEFT JOIN oa_approval_application_storage oas ON oas.approval_application_id = am.approval_application_id
+            LEFT JOIN asset_type at ON at.id = am.asset_type_id
+            LEFT JOIN t_dept od ON od.id = am.ownership_dept_id
+            LEFT JOIN t_dept ud ON ud.id = am.use_dept_id
+        <where>
+            AND IFNULL(am.disabled, 0) = 0
+            AND IFNULL(aaa.disabled, 0) = 0
+            AND aaa.approval_status = 2 AND aaa.approval_id = '${@com.ruoyi.system.emums.ApprovalTypeEnum@IN_STOCK.getCode()}'
+            AND IFNULL(am.is_disposed, 0) = 0
+            AND IFNULL(am.is_in_use, 0) = 0
+            AND IFNULL(am.is_borrowed, 0) = 0
+            <if test="query != null and query.assetTypeId != null">
+                AND am.asset_type_id = #{query.assetTypeId}
+            </if>
+            <if test="query != null and query.ownershipDeptId != null">
+                AND am.ownership_dept_id = #{query.ownershipDeptId}
+            </if>
+            <if test="query != null and query.assetStatus != null and query.assetStatus != ''">
+                AND am.asset_status = #{query.assetStatus}
+            </if>
+            <if test="query != null and query.keyword != null and query.keyword != ''">
+                AND (am.asset_name LIKE CONCAT('%', #{query.keyword}, '%')
+                OR am.asset_code LIKE CONCAT('%', #{query.keyword}, '%'))
+            </if>
+        </where>
+        ORDER BY COALESCE(oas.storage_time, DATE(am.create_time)) DESC, am.id DESC
+    </select>
+
 </mapper>

--
Gitblit v1.7.1