2021与蓝度共同重构项目,服务端
liuhaonan
2022-10-21 0a30812acaa26ebe654340f7e749a6801b63b194
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.sandu.ximon.dao.mapper.AirDataMapper">
 
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.AirData">
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="deviceMac" column="device_mac" jdbcType="VARCHAR"/>
            <result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
            <result property="moduleWarmUpStatusFlag" column="module_warm_up_status_flag" jdbcType="VARCHAR"/>
            <result property="temperature" column="temperature" jdbcType="VARCHAR"/>
            <result property="humidity" column="humidity" jdbcType="VARCHAR"/>
            <result property="windSpeed" column="wind_speed" jdbcType="VARCHAR"/>
            <result property="windDirection" column="wind_direction" jdbcType="VARCHAR"/>
            <result property="windPower" column="wind_power" jdbcType="VARCHAR"/>
            <result property="pressure" column="pressure" jdbcType="VARCHAR"/>
            <result property="lightIntensity" column="light_intensity" jdbcType="VARCHAR"/>
            <result property="noise" column="noise" jdbcType="VARCHAR"/>
            <result property="pm25" column="pm25" jdbcType="VARCHAR"/>
            <result property="pm10" column="pm10" jdbcType="VARCHAR"/>
            <result property="tsp" column="tsp" jdbcType="VARCHAR"/>
            <result property="rain" column="rain" jdbcType="VARCHAR"/>
            <result property="ech2o" column="ech2o" jdbcType="VARCHAR"/>
            <result property="tvoc" column="tvoc" jdbcType="VARCHAR"/>
            <result property="co2" column="co2" jdbcType="VARCHAR"/>
            <result property="so2" column="so2" jdbcType="VARCHAR"/>
            <result property="no2" column="no2" jdbcType="VARCHAR"/>
            <result property="co" column="co" jdbcType="VARCHAR"/>
            <result property="o3" column="o3" jdbcType="VARCHAR"/>
            <result property="fluoride" column="fluoride" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
 
    <select id="listAirId" resultType="java.lang.Long">
        SELECT
        MAX(t1.id) AS air_id
        FROM
        air_data t1
        <if test="keyword != null and keyword != ''">
            LEFT JOIN pole_binding t2 ON t1.device_mac = t2.device_code
            AND t2.device_type = 3
            LEFT JOIN pole t3 ON t3.id = t2.pole_id
        </if>
        <where>
            <if test="keyword != null and keyword != ''">
                AND (t3.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t1.device_mac  LIKE CONCAT(CONCAT('%', #{keyword}), '%'))
            </if>
            <if test="userid != null">
                AND (t3.user_id = #{userid} OR t3.client_id = #{userid})
            </if>
        </where>
        GROUP BY
        t1.device_mac
    </select>
 
    <select id="listAirDataByIds" resultType="com.sandu.ximon.dao.bo.AirDataBo">
        SELECT
        t1.*, t2.pole_id,
        t3.pole_name
        FROM
        air_data t1
        LEFT JOIN pole_binding t2 ON t1.device_mac = t2.device_code
        AND t2.device_type = 3
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        <where>
            t1.id IN
            <foreach collection="airIdList" open="(" close=")" item="airId" separator=",">
                #{airId}
            </foreach>
        </where>
    </select>
    <select id="getCodeByPoleId" resultType="java.lang.String">
        select t1.device_code
        from pole_binding t1
        left join pole t2 on t1.pole_id = t2.id
        where t1.device_type = 3
        and t1.pole_id = #{poleId}
        <if test="clientId != null">
            AND (t2.user_id = #{clientId} OR t2.client_id = #{clientId})
        </if>
 
    </select>
    <select id="listAirDataHistory" resultType="com.sandu.ximon.dao.bo.AirDataBo">
        SELECT
        t1.*, t2.pole_id,
        t3.pole_name
        FROM
        air_data t1
        LEFT JOIN pole_binding t2 ON t1.device_mac = t2.device_code
        AND t2.device_type = 3
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        WHERE  t1.device_mac = #{deviceMac}
        ORDER BY t1.create_time DESC
    </select>
</mapper>