2021与蓝度共同重构项目,服务端
liuhaonan
2022-08-04 19d542ddaa4a2d5a737912505e3195948ffa9ebe
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
100
101
102
103
104
105
<?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.PoleMapper">
 
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.Pole">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="poleCode" column="pole_code" jdbcType="BIGINT"/>
        <result property="poleName" column="pole_name" jdbcType="VARCHAR"/>
        <result property="deviceType" column="device_type" jdbcType="INTEGER"/>
        <result property="centre" column="centre" jdbcType="INTEGER"/>
        <result property="userId" column="user_id" jdbcType="BIGINT"/>
        <result property="clientId" column="client_id" jdbcType="BIGINT"/>
        <result property="province" column="province" jdbcType="VARCHAR"/>
        <result property="city" column="city" jdbcType="VARCHAR"/>
        <result property="region" column="region" jdbcType="VARCHAR"/>
        <result property="address" column="address" jdbcType="VARCHAR"/>
        <result property="lon" column="lon" jdbcType="DECIMAL"/>
        <result property="lat" column="lat" jdbcType="DECIMAL"/>
        <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
        <result property="onLineState" column="on_line_state" jdbcType="VARCHAR"/>
        <result property="bindingCount" column="binding_count" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
 
    <sql id="Base_Column_List">
        id
        ,pole_code,pole_name,
        device_type,user_id,client_id,
        province,city,region,
        address,lon,lat,
        device_code,on_line_state,binding_count,
        create_time,update_time
    </sql>
    <update id="updateDeviceCode" parameterType="java.lang.Long">
        UPDATE pole
        SET device_code=null
        WHERE id = #{id}
    </update>
    <select id="queryPoleOnLineStatesList" resultType="com.sandu.ximon.dao.domain.Pole">
        SELECT
        t1.*
        FROM
        pole t1
        LEFT JOIN pole_group_relation t2 ON t1.id = t2.pole_id
        LEFT JOIN pole_group t3 ON t3.group_id = t2.pole_group_id
        <where>
            1=1
            <if test="userid != null">
                AND (t1.user_id = #{userid} OR t1.client_id = #{userid})
            </if>
            <if test="keyword != null and keyword != ''">
                AND ( t1.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t1.device_code LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t1.centre LIKE CONCAT(CONCAT('%', #{keyword}), '%'))
            </if>
            <if test="isTrue != null and isTrue == 1">
                AND t1.device_type = -1
            </if>
            <if test="isTrue != null and isTrue == 0">
                AND t1.device_type != -1
            </if>
            <if test="groupid != null">
                AND t3.group_id = #{groupid}
            </if>
            <if test="bingStates != null and bingStates == 0 ">
                AND t1.user_id != -1
            </if>
            <if test="bingStates != null and bingStates == 1 ">
                AND t1.user_id = -1
            </if>
            <if test="centre != null and centre == 0">
                AND t1.centre = 0
            </if>
            <if test="centre != null and centre == 1">
                AND t1.centre = 1
            </if>
        </where>
        GROUP BY t1.id
        <if test="orderBy != null">
            ORDER BY ${orderBy}
        </if>
    </select>
    <select id="getPoleListOnBinding" resultType="com.sandu.ximon.dao.domain.Pole">
        SELECT
        t1.*
        FROM
        pole t1
        LEFT JOIN pole_group_relation t2 ON t1.id = t2.pole_id
        LEFT JOIN pole_group t3 ON t3.group_id = t2.pole_group_id
        <where>
            <if test="userid != null">
                AND (t1.user_id = #{userid} OR t1.client_id = #{userid})
            </if>
            <if test="keyword != null and keyword != ''">
                AND ( t1.id LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t1.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%'))
            </if>
        </where>
        GROUP BY t1.id
 
    </select>
</mapper>