2026-05-30 8e52d3e600ff49869cc612fd9bf1cc64ac304f50
src/main/resources/mapper/device/DeviceLedgerMapper.xml
@@ -11,6 +11,8 @@
        dl.device_name,
        dl.device_model,
        dl.supplier_name,
        dl.device_brand,
        dl.storage_location,
        dl.unit,
        dl.number,
        dl.status,
@@ -24,11 +26,19 @@
        dl.un_tax_including_price_total,
        dl.create_time,
        dl.update_time ,
        su.user_name AS createUser,
        su.nick_name AS createUser,
        dl.update_user,
        dl.tenant_id
        dl.tenant_id,
        dl.is_depr,
        dl.annual_depreciation_amount,
        dl.type,
        dl.area_id,
        dl.is_iot_device,
        dl.external_code,
        da.area_name AS areaName
        FROM device_ledger dl
        left join sys_user su on dl.create_user = su.user_id
        left join device_area da on dl.area_id = da.id
        <where>
            <!-- 设备名称 -->
            <if test="deviceLedger.deviceName != null and deviceLedger.deviceName != ''">
@@ -71,6 +81,21 @@
            <if test="deviceLedger.tenantId != null">
                AND tenant_id = #{deviceLedger.tenantId}
            </if>
            <!-- 设备区域 -->
            <if test="deviceLedger.areaId != null">
                AND dl.area_id = #{deviceLedger.areaId}
            </if>
            <!-- 是否物联设备 -->
            <if test="deviceLedger.isIotDevice != null">
                AND dl.is_iot_device = #{deviceLedger.isIotDevice}
            </if>
            <!-- 外部编码 -->
            <if test="deviceLedger.externalCode != null and deviceLedger.externalCode != ''">
                AND dl.external_code LIKE CONCAT('%', #{deviceLedger.externalCode}, '%')
            </if>
        </where>
        ORDER BY create_time DESC
    </select>
@@ -82,5 +107,18 @@
        from device_ledger
        where id = #{id}
    </select>
    <select id="getDeviceTypeDistributionByYear"
            resultType="com.ruoyi.account.bean.dto.DeviceTypeDetail"
            parameterType="java.lang.Integer">
        SELECT
            `type`,
            SUM(`number`) AS `count`,
            SUM(tax_including_price_unit) AS amount
        FROM device_ledger
        WHERE YEAR(create_time) = #{year}
          AND type IS NOT NULL
        GROUP BY type
    </select>
</mapper>