TDeviceInfoMapper.xml 7.95 KB
Newer Older
1 2 3 4
<?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">
5
<mapper namespace="com.zehong.system.mapper.TDeviceInfoMapper">
6
    
7 8
    <resultMap type="TDeviceInfo" id="TDeviceInfoResult">
        <result property="deviceId"    column="device_id"    />
9
        <result property="enterpriseId"    column="enterprise_id"    />
王晓倩's avatar
王晓倩 committed
10
        <result property="pipeId"    column="pipe_id"    />
11
        <result property="deviceName"    column="device_name"    />
12
        <result property="deviceCode"    column="device_code"    />
13 14
        <result property="deviceAddr"    column="device_addr"    />
        <result property="deviceModel"    column="device_model"    />
15
        <result property="deviceType"    column="device_type"    />
16 17 18 19 20 21 22 23
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="iotNo"    column="iot_no"    />
        <result property="iconUrl"    column="icon_url"    />
        <result property="linkman"    column="linkman"    />
        <result property="phone"    column="phone"    />
        <result property="installationTime"    column="installation_time"    />
        <result property="inspectionTime"    column="inspection_time"    />
24
        <result property="isDel"    column="is_del"    />
25 26 27
        <result property="remarks"    column="remarks"    />
    </resultMap>

28
    <sql id="selectTDeviceInfoVo">
王晓倩's avatar
王晓倩 committed
29
        select device_id, enterprise_id, pipe_id, device_name, device_code, device_addr, device_model, device_type, longitude, latitude, iot_no, icon_url, linkman, phone, installation_time, inspection_time, is_del, remarks from t_device_info
30 31
    </sql>

32 33
    <select id="selectTDeviceInfoList" parameterType="TDeviceInfo" resultMap="TDeviceInfoResult">
        <include refid="selectTDeviceInfoVo"/>
34 35
        <where>
            is_del = '0'
36
            <if test="enterpriseId != null and enterpriseId != 0 "> and enterprise_id = #{enterpriseId}</if>
37
            <if test="deviceName != null  and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
38
            <if test="deviceCode != null  and deviceCode != ''"> and device_code like concat('%', #{deviceCode}, '%')</if>
39 40
            <if test="deviceAddr != null  and deviceAddr != ''"> and device_addr = #{deviceAddr}</if>
            <if test="deviceModel != null  and deviceModel != ''"> and device_model = #{deviceModel}</if>
41
            <if test="deviceType != null  and deviceType != ''"> and device_type = #{deviceType}</if>
42 43 44 45 46 47 48 49 50 51 52 53
            <if test="longitude != null "> and longitude = #{longitude}</if>
            <if test="latitude != null "> and latitude = #{latitude}</if>
            <if test="iotNo != null  and iotNo != ''"> and iot_no = #{iotNo}</if>
            <if test="iconUrl != null  and iconUrl != ''"> and icon_url = #{iconUrl}</if>
            <if test="linkman != null  and linkman != ''"> and linkman = #{linkman}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="installationTime != null "> and installation_time = #{installationTime}</if>
            <if test="inspectionTime != null "> and inspection_time = #{inspectionTime}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
王晓倩's avatar
王晓倩 committed
54
    <select id="selectTDeviceInfoById" parameterType="int" resultMap="TDeviceInfoResult">
55 56
        <include refid="selectTDeviceInfoVo"/>
        where device_id = #{deviceId}
57
    </select>
58

59
    <select id="selectTDeviceInfoByPipeId" parameterType="int" resultMap="TDeviceInfoResult">
60
        <include refid="selectTDeviceInfoVo"/>
61
        where pipe_id = #{pipeId}
62 63
    </select>

64 65
    <select id="countDeviceByType" resultType="map">
        select count(device_id) number, device_type type from t_device_info
66
        where is_del = '0'
67 68
        group by device_type
    </select>
69
        
70 71
    <insert id="insertTDeviceInfo" parameterType="TDeviceInfo" useGeneratedKeys="true" keyProperty="deviceId">
        insert into t_device_info
72
        <trim prefix="(" suffix=")" suffixOverrides=",">
73
            <if test="enterpriseId != null and enterpriseId != 0">enterprise_id,</if>
王晓倩's avatar
王晓倩 committed
74
            <if test="pipeId != null">pipe_id,</if>
75
            <if test="deviceName != null">device_name,</if>
76
            <if test="deviceCode != null">device_code,</if>
77 78
            <if test="deviceAddr != null">device_addr,</if>
            <if test="deviceModel != null">device_model,</if>
79
            <if test="deviceType != null">device_type,</if>
80 81 82 83 84 85 86 87 88 89 90
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="iotNo != null">iot_no,</if>
            <if test="iconUrl != null">icon_url,</if>
            <if test="linkman != null">linkman,</if>
            <if test="phone != null">phone,</if>
            <if test="installationTime != null">installation_time,</if>
            <if test="inspectionTime != null">inspection_time,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
91
            <if test="enterpriseId != null and enterpriseId != 0">#{enterpriseId},</if>
王晓倩's avatar
王晓倩 committed
92
            <if test="pipeId != null">#{pipeId},</if>
93
            <if test="deviceName != null">#{deviceName},</if>
94
            <if test="deviceCode != null">#{deviceCode},</if>
95 96
            <if test="deviceAddr != null">#{deviceAddr},</if>
            <if test="deviceModel != null">#{deviceModel},</if>
97
            <if test="deviceType != null">#{deviceType},</if>
98 99 100 101 102 103 104 105 106 107 108 109
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="iotNo != null">#{iotNo},</if>
            <if test="iconUrl != null">#{iconUrl},</if>
            <if test="linkman != null">#{linkman},</if>
            <if test="phone != null">#{phone},</if>
            <if test="installationTime != null">#{installationTime},</if>
            <if test="inspectionTime != null">#{inspectionTime},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

110 111
    <update id="updateTDeviceInfo" parameterType="TDeviceInfo">
        update t_device_info
112
        <trim prefix="SET" suffixOverrides=",">
113
            <if test="enterpriseId != null and enterpriseId != 0">enterprise_id = #{enterpriseId},</if>
王晓倩's avatar
王晓倩 committed
114
            <if test="pipeId != null">pipe_id = #{pipeId},</if>
115
            <if test="deviceName != null">device_name = #{deviceName},</if>
116
            <if test="deviceCode != null">device_code = #{deviceCode},</if>
117 118
            <if test="deviceAddr != null">device_addr = #{deviceAddr},</if>
            <if test="deviceModel != null">device_model = #{deviceModel},</if>
119
            <if test="deviceType != null">device_type = #{deviceType},</if>
120 121 122 123 124 125 126 127 128
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="iotNo != null">iot_no = #{iotNo},</if>
            <if test="iconUrl != null">icon_url = #{iconUrl},</if>
            <if test="linkman != null">linkman = #{linkman},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="installationTime != null">installation_time = #{installationTime},</if>
            <if test="inspectionTime != null">inspection_time = #{inspectionTime},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
129
            <if test="isDel != null">is_del = #{isDel},</if>
130
        </trim>
131
        where device_id = #{deviceId}
132 133
    </update>

134 135
    <delete id="deleteTDeviceInfoById" parameterType="Long">
        delete from t_device_info where device_id = #{deviceId}
136 137
    </delete>

138 139 140 141
    <delete id="deleteTDeviceInfoByIds" parameterType="String">
        delete from t_device_info where device_id in 
        <foreach item="deviceId" collection="array" open="(" separator="," close=")">
            #{deviceId}
142 143 144
        </foreach>
    </delete>
</mapper>