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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?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.qianwen.smartman.modules.tpm.mapper.CheckRecordMapper">
 
 
    <select id="pageCheckRecord" resultType="com.qianwen.smartman.modules.tpm.vo.CheckRecordVO">
        select id,
        check_code checkCode,
        device_id deviceId,
        device_code deviceCode,
        device_name deviceName,
        device_type_id deviceTypeId,
        device_type_name deviceTypeName,
        check_user_id checkUserId,
        check_user_name checkUserName,
        check_time checkTime,
        check_result checkResult,
        check_project_id checkProjectId,
        check_project_code checkProjectCode,
        check_project_name checkProjectName,
        remark,
        machine_model machineModel
        from blade_check_record
        WHERE is_deleted = 0
        <if test="keyWords != null and keyWords != ''">
            and (
            check_code like CONCAT(#{keyWords},'%')
            or
            device_code like CONCAT(#{keyWords},'%')
            or
            device_name like CONCAT(#{keyWords},'%')
            )
        </if>
        <if test="deviceTypeId != null and deviceTypeId != ''">
            and device_type_id = #{deviceTypeId}
        </if>
        order by create_time desc,id desc
    </select>
 
    <select id="getTodayPage" resultType="com.qianwen.smartman.modules.tpm.vo.CheckRecordTodayVO">
        select
        cr.id,
        cr.check_code as checkCode,
        wm.machine_code as machineCode,
        wm.machine_name as machineName,
        dt.name as typeName,
        cp.name as checkProjectName,
        cr.check_time as checkTime
        from
        blade_check_record cr
        left join blade_check_project cp on cr.check_project_id = cp.id and cr.is_deleted =0
        left join blade_device_type dt on cr.device_type_id = dt.id and dt.is_deleted =0
        LEFT JOIN blade_machine wm on cr.device_id = wm.id and wm.is_deleted = 0
        where cr.is_deleted =0 and date_format(cr.create_time, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d')
        <if test="searchDTO.machineCode != null and searchDTO.machineCode !=''">
            and wm.machine_code like concat(#{searchDTO.machineCode},'%')
        </if>
        <if test="searchDTO.machineName != null and searchDTO.machineName !=''">
            and wm.machine_name like concat(#{searchDTO.machineName},'%')
        </if>
        <if test="searchDTO.checkProjectName != null and searchDTO.checkProjectName !=''">
            and cp.name like concat(#{searchDTO.checkProjectName},'%')
        </if>
    </select>
 
    <select id="exportCheckRecord" resultType="com.qianwen.smartman.modules.tpm.vo.CheckRecordVO">
        select id,
        check_code checkCode,
        device_id deviceId,
        device_code deviceCode,
        device_name deviceName,
        device_type_id deviceTypeId,
        device_type_name deviceTypeName,
        check_user_id checkUserId,
        check_user_name checkUserName,
        check_time checkTime,
        check_result checkResult,
        check_project_id checkProjectId,
        check_project_code checkProjectCode,
        check_project_name checkProjectName,
        remark
        from blade_check_record
        WHERE is_deleted = 0
        <if test="keyWords != null and keyWords != ''">
            and (
            check_code like CONCAT(#{keyWords},'%')
            or
            device_code like CONCAT(#{keyWords},'%')
            or
            device_name like CONCAT(#{keyWords},'%')
            )
        </if>
        <if test="deviceTypeId != null and deviceTypeId != ''">
            and device_type_id = #{deviceTypeId}
        </if>
        order by create_time desc,id desc
    </select>
</mapper>