TDeviceInfoMapper.xml 7.88 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"    />
10
        <result property="pipeCode"    column="pipe_code"    />
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 24 25 26
        <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"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

27
    <sql id="selectTDeviceInfoVo">
28
        select device_id, enterprise_id, pipe_code, device_name, device_code, device_addr, device_model, device_type, longitude, latitude, iot_no, icon_url, linkman, phone, installation_time, inspection_time, remarks from t_device_info
29 30
    </sql>

31 32
    <select id="selectTDeviceInfoList" parameterType="TDeviceInfo" resultMap="TDeviceInfoResult">
        <include refid="selectTDeviceInfoVo"/>
33
        <where>  
34
            <if test="enterpriseId != null and enterpriseId != 0 "> and enterprise_id = #{enterpriseId}</if>
35
            <if test="pipeCode != null "> and pipe_code = #{pipeCode}</if>
36
            <if test="deviceName != null  and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
37
            <if test="deviceCode != null  and deviceCode != ''"> and device_code like concat('%', #{deviceCode}, '%')</if>
38 39
            <if test="deviceAddr != null  and deviceAddr != ''"> and device_addr = #{deviceAddr}</if>
            <if test="deviceModel != null  and deviceModel != ''"> and device_model = #{deviceModel}</if>
40
            <if test="deviceType != null  and deviceType != ''"> and device_type = #{deviceType}</if>
41 42 43 44 45 46 47 48 49 50 51 52
            <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
53
    <select id="selectTDeviceInfoById" parameterType="int" resultMap="TDeviceInfoResult">
54 55
        <include refid="selectTDeviceInfoVo"/>
        where device_id = #{deviceId}
56
    </select>
57

58 59 60 61 62
    <select id="selectTDeviceInfoByCode" parameterType="String" resultMap="TDeviceInfoResult">
        <include refid="selectTDeviceInfoVo"/>
        where device_code = #{deviceCode}
    </select>

63 64 65 66
    <select id="countDeviceByType" resultType="map">
        select count(device_id) number, device_type type from t_device_info
        group by device_type
    </select>
67
        
68 69
    <insert id="insertTDeviceInfo" parameterType="TDeviceInfo" useGeneratedKeys="true" keyProperty="deviceId">
        insert into t_device_info
70
        <trim prefix="(" suffix=")" suffixOverrides=",">
71
            <if test="enterpriseId != null and enterpriseId != 0">enterprise_id,</if>
72
            <if test="pipeCode != null">pipe_code,</if>
73
            <if test="deviceName != null">device_name,</if>
74
            <if test="deviceCode != null">device_code,</if>
75 76
            <if test="deviceAddr != null">device_addr,</if>
            <if test="deviceModel != null">device_model,</if>
77
            <if test="deviceType != null">device_type,</if>
78 79 80 81 82 83 84 85 86 87 88
            <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=",">
89
            <if test="enterpriseId != null and enterpriseId != 0">#{enterpriseId},</if>
90
            <if test="pipeCode != null">#{pipeCode},</if>
91
            <if test="deviceName != null">#{deviceName},</if>
92
            <if test="deviceCode != null">#{deviceCode},</if>
93 94
            <if test="deviceAddr != null">#{deviceAddr},</if>
            <if test="deviceModel != null">#{deviceModel},</if>
95
            <if test="deviceType != null">#{deviceType},</if>
96 97 98 99 100 101 102 103 104 105 106 107
            <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>

108 109
    <update id="updateTDeviceInfo" parameterType="TDeviceInfo">
        update t_device_info
110
        <trim prefix="SET" suffixOverrides=",">
111
            <if test="enterpriseId != null and enterpriseId != 0">enterprise_id = #{enterpriseId},</if>
112
            <if test="pipeCode != null">pipe_code = #{pipeCode},</if>
113
            <if test="deviceName != null">device_name = #{deviceName},</if>
114
            <if test="deviceCode != null">device_code = #{deviceCode},</if>
115 116
            <if test="deviceAddr != null">device_addr = #{deviceAddr},</if>
            <if test="deviceModel != null">device_model = #{deviceModel},</if>
117
            <if test="deviceType != null">device_type = #{deviceType},</if>
118 119 120 121 122 123 124 125 126 127
            <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>
        </trim>
128
        where device_id = #{deviceId}
129 130
    </update>

131 132
    <delete id="deleteTDeviceInfoById" parameterType="Long">
        delete from t_device_info where device_id = #{deviceId}
133 134
    </delete>

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