zss
2025-01-13 8d85246f061e3da623c7b9eb4e323ee724b4de0b
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?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.yuanchu.mom.mapper.DeviceRecordMapper">
 
    <select id="deviceRecordPage" resultType="com.yuanchu.mom.dto.DeviceRecordDto">
        select dr.*,
               d.device_name,
               d.management_number
        from device_record dr
                 left join device d on d.id = dr.device_id
        where 1=1
        <if test="deviceId != null">
            and dr.device_id = #{deviceId}
        </if>
        <if test="sampleCode != '' and sampleCode != null">
            and dr.sample_code like concat('%', #{sampleCode}, '%')
        </if>
        <if test="managementNumber != '' and managementNumber != null">
            and d.management_number like concat('%', #{managementNumber}, '%')
        </if>
        <if test="userId != null">
            and dr.use_person_id = #{userId}
            and dr.use_start_date is null
        </if>
        ORDER BY (dr.use_start_date IS NULL) desc , dr.use_start_date DESC
    </select>
 
 
    <select id="selectNotFilled" resultType="com.yuanchu.mom.dto.DeviceRecordDto">
        select dr.*,
               d.device_name,
               d.management_number
        from device_record dr
                 left join device d on d.id = dr.device_id
        where dr.use_start_date is null
    </select>
 
    <!-- 查询导出设备使用记录 -->
    <select id="selectExportList" resultType="com.yuanchu.mom.pojo.DeviceRecord">
        select dr.*
        from device_record dr
        where dr.use_start_date is not null
        <if test="deviceId != null">
            and dr.device_id = #{deviceId}
        </if>
        <if test="exportDate != '' and exportDate != null">
            and DATE_FORMAT(dr.use_start_date, '%Y-%m') = #{exportDate};
        </if>
    </select>
</mapper>