2021与蓝度共同重构项目,服务端
liuhaonan
2022-11-04 e55c8b0a92eb9715edd90c31dfd4de51a47b588b
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
99
<?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.LightReportDataMapper">
 
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightReportData">
        <id property="lightReportDataId" column="light_report_data_id" jdbcType="BIGINT"/>
        <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
        <result property="voltage" column="voltage" jdbcType="FLOAT"/>
        <result property="electricCurrent" column="electric_current" jdbcType="FLOAT"/>
        <result property="deviceTemperature" column="device_temperature" jdbcType="FLOAT"/>
        <result property="powerFactor" column="power_factor" jdbcType="FLOAT"/>
        <result property="activePower" column="active_power" jdbcType="FLOAT"/>
        <result property="reactivePower" column="reactive_power" jdbcType="FLOAT"/>
        <result property="lightPercent" column="light_percent" jdbcType="INTEGER"/>
        <result property="light2Percent" column="light2_percent" jdbcType="INTEGER"/>
        <result property="recentlyLightSec" column="recently_light_sec" jdbcType="BIGINT"/>
        <result property="totalLightSec" column="total_light_sec" jdbcType="BIGINT"/>
        <result property="recentlyUsingPower" column="recently_using_power" jdbcType="DOUBLE"/>
        <result property="totalUsingPower" column="total_using_power" jdbcType="DOUBLE"/>
        <result property="createTime1" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime1" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
 
    <resultMap id="listReportData" type="com.sandu.ximon.dao.bo.LightReportDataBo" extends="BaseResultMap">
        <result property="poleName" column="pole_name" jdbcType="VARCHAR"/>
    </resultMap>
 
    <select id="getNewestReportByDeviceCode" resultMap="BaseResultMap">
        SELECT
        t1.*
        FROM
        light_report_data t1
        JOIN (
        SELECT
        MAX( light_report_data_id ) AS light_report_data_id
        FROM
        light_report_data
        WHERE device_code IN
        <foreach collection="deviceCodeList" open="(" close=")" separator="," item="deviceCode">
            #{deviceCode}
        </foreach>
        GROUP BY device_code
        ) AS t2 USING ( light_report_data_id )
    </select>
    <select id="listReportData" resultMap="listReportData">
        SELECT
        t1.* ,t2.pole_name
        FROM
        light_report_data t1
        LEFT JOIN pole t2 USING ( device_code )
        <where>
            1 = 1
 
            <if test="deviceCode != null and deviceCode != ''">
                AND t1.device_code = #{deviceCode}
            </if>
            <if test="keyword != null and keyword != ''">
                AND (
                t1.device_code LIKE CONCAT('%', #{keyword},'%')
                OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
                )
            </if>
 
        </where>
        ORDER BY t1.light_report_data_id DESC
    </select>
    <select id="listReportDataByUserid" resultType="com.sandu.ximon.dao.bo.LightReportDataBo">
        SELECT
        t1.* ,t2.pole_name
        FROM
        light_report_data 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>
            1 = 1
 
            <if test="deviceCode != null and deviceCode != ''">
                AND t1.device_code = #{deviceCode}
            </if>
            <if test="keyword != null and keyword != ''">
                AND (
                t1.device_code LIKE CONCAT('%', #{keyword},'%')
                OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
                )
            </if>
            <if test="userid != null">
                AND (t3.user_id = #{userid} OR t3.client_id = #{userid})
            </if>
 
        </where>
        ORDER BY t1.light_report_data_id DESC
    </select>
    <select id="reportDataList" resultType="com.sandu.ximon.dao.bo.LightReportDataBo">
 
    </select>
</mapper>