2021与蓝度共同重构项目,服务端
liuhaonan
2022-04-13 d65594e37be2179b60cdc1730819ff156b39639c
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
<?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.MonitorMapper">
 
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.Monitor">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="deviceSerial" column="device_serial" jdbcType="VARCHAR"/>
        <result property="devicesCode" column="devices_code" jdbcType="VARCHAR"/>
        <result property="deviceName" column="device_name" jdbcType="VARCHAR"/>
        <result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
        <result property="equipmentStatus" column="equipment_status" jdbcType="INTEGER"/>
        <result property="isEncrypt" column="is_encrypt" jdbcType="INTEGER"/>
        <result property="workState" column="work_state" jdbcType="INTEGER"/>
        <result property="bindingState" column="binding_state" jdbcType="INTEGER"/>
        <result property="note" column="note" jdbcType="VARCHAR"/>
        <result property="addTime" column="add_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="netAddress" column="net_address" jdbcType="VARCHAR"/>
    </resultMap>
    <select id="listMonitorByKeyword" resultType="com.sandu.ximon.dao.domain.Monitor">
        SELECT    * FROM   (SELECT    * FROM    (SELECT    * FROM    monitor AS table1
              WHERE device_serial  LIKE CONCAT(CONCAT('%', #{keyword}), '%')
              ) AS table2
         WHERE equipment_status = #{equipmentState1}
         OR equipment_status = #{equipmentState2}) AS table3
        WHERE binding_state = #{bindingState1} OR binding_state = #{bindingState2};
    </select>
    <select id="listMonitorByKeyword1" resultType="com.sandu.ximon.dao.domain.Monitor">
        SELECT
            t1.*, t2.pole_id,
            t3.pole_name
        FROM
            monitor t1
        LEFT JOIN pole_binding t2 ON t1.device_serial = t2.device_code
        AND t2.device_type = 7
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        WHERE
            t1.device_serial  LIKE CONCAT(CONCAT('%', #{keyword}), '%')
        OR t2.pole_id LIKE CONCAT(CONCAT('%', #{keyword}), '%')
        OR t3.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
        AND binding_state = #{bindingState1}
        OR binding_state = #{bindingState2}
        ORDER BY
            t1.id DESC
    </select>
 
    <select id="listMonitorByIds" resultType="com.sandu.ximon.dao.bo.MonitorBo">
        SELECT
        t1.*, t2.pole_id,
        t3.pole_name, t3.province,t3.city,t3.region,t3.address
        FROM
        monitor t1
        LEFT JOIN pole_binding t2 ON t1.device_serial = t2.device_code
        AND t2.device_type = 7
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        <where>
            <if test="keyword != null and keyword != ''">
                AND t3.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t1.device_serial LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t1.note LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t3.pole_code LIKE CONCAT(CONCAT('%', #{keyword}), '%')
            </if>
            <if test="bindingState != 2">
                AND t1.binding_state = #{bindingState}
            </if>
            <if test="equipmentState != 2">
                AND t1.equipment_state = #{equipmentState}
            </if>
            <if test="userid != null">
                AND (t3.user_id = #{userid} OR t3.client_id = #{userid})
            </if>
        </where>
    </select>
    <select id="listMonitorDeviceSerial" resultType="java.lang.String">
        SELECT device_serial FROM monitor;
    </select>
 
</mapper>