2021与蓝度共同重构项目,服务端
MercuryZ
2022-10-18 ea94079e74182be590b9fff356c97f522d9a7828
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
<?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.sandu.ximon.dao.mapper.LightReportErrorMapper">
 
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightReportError">
        <id property="lightReportErrorId" column="light_report_error_id" jdbcType="BIGINT"/>
        <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
        <result property="lightAddress" column="light_address" jdbcType="VARCHAR"/>
        <result property="errorCode" column="error_code" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
    <resultMap id="listReportError" type="com.sandu.ximon.dao.bo.LightReportErrorBo" extends="BaseResultMap">
        <result property="poleName" column="pole_name" jdbcType="INTEGER"/>
    </resultMap>
 
    <select id="listReportError" resultMap="listReportError">
        SELECT
        t1.*,
        t3.pole_name,
        t3.id
        FROM
        light_report_error t1
        LEFT JOIN pole_binding t2 ON t1.device_code = t2.device_code
        AND t2.device_type = 0
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        <where>
            t1.error_code != 0
            <if test="keyword != null and keyword != ''">
                AND (
                t3.id LIKE CONCAT('%', #{keyword},'%')
                OR t3.pole_name LIKE CONCAT('%', #{keyword},'%')
                OR t1.device_code LIKE CONCAT('%', #{keyword},'%')
                )
            </if>
            <if test="userid != null">
                AND (t3.user_id = #{userid} OR t3.client_id = #{userid})
            </if>
            <if test="error_code != null">
                AND t1.error_code = #{error_code}
            </if>
        </where>
        ORDER BY t1.light_report_error_id DESC
    </select>
    <select id="listError" resultType="com.sandu.ximon.dao.bo.LightReportErrorBo"
            parameterType="java.lang.Long">
        SELECT
        t1.*
        FROM
        light_report_error t1
        LEFT JOIN pole t3 ON t1.device_code = t3.device_code
        WHERE
        <if test="userid != null">
            t3.client_id = #{userId} OR t3.user_id = #{userId}
        </if>
        t1.light_report_error_id IN ( SELECT t.max_id FROM ( SELECT Max( light_report_error.light_report_error_id ) AS
        max_id FROM light_report_error GROUP BY light_report_error.device_code ) AS t )
        ORDER BY
        t1.create_time DESC
    </select>
</mapper>