hsy
2026-08-28 cd2ed591a01abcaef8dac4cc5ad3b398abacbaef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.vehicle.mapper.FuelRecordMapper">
    <select id="selectFuelRecordPage" resultType="com.ruoyi.vehicle.pojo.FuelRecord">
        SELECT r.*, d.dept_name as deptName, v.plate_number as plateNumber, c.card_number as cardNumber
        FROM p_fuel_record r
        LEFT JOIN sys_dept d ON r.dept_id = d.dept_id
        LEFT JOIN p_vehicle_info v ON r.vehicle_id = v.id
        LEFT JOIN p_fuel_card c ON r.fuel_card_id = c.id
        WHERE r.del_flag = '0'
        <if test="query.vehicleId != null">
            AND r.vehicle_id = #{query.vehicleId}
        </if>
        <if test="query.fuelCardId != null">
            AND r.fuel_card_id = #{query.fuelCardId}
        </if>
        <if test="query.deptId != null">
            AND (r.dept_id = #{query.deptId} OR r.dept_id IN (SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET (#{query.deptId}, ancestors)))
        </if>
        <if test="beginDate != null and beginDate != '' and endDate != null and endDate != ''">
            AND r.fuel_date BETWEEN #{beginDate} AND #{endDate}
        </if>
        
        <if test="query.status != null and query.status != ''">
            AND r.status = #{query.status}
        </if>
ORDER BY r.fuel_date DESC
    </select>
</mapper>