TGasuserSafetyDeviceInfoMapper.xml 10.3 KB
Newer Older
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
<?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.zehong.system.mapper.TGasuserSafetyDeviceInfoMapper">
    
    <resultMap type="TGasuserSafetyDeviceInfo" id="TGasuserSafetyDeviceInfoResult">
        <result property="gasUserSafetyDeviceId"    column="f_gasUser_safety_device_id"    />
        <result property="relationGasuserId"    column="f_relation_gasUser_id"    />
        <result property="relationDeviceType"    column="f_relation_device_type"    />
        <result property="deviceName"    column="f_device_name"    />
        <result property="deviceModel"    column="f_device_model"    />
        <result property="fIotNo"    column="f_iot_no"    />
        <result property="detectionMedium"    column="f_detection_medium"    />
        <result property="deviceInstallTime"    column="f_device_install_time"    />
        <result property="deviceInstallPosition"    column="f_device_install_position"    />
        <result property="head"    column="f_head"    />
        <result property="phone"    column="f_phone"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectTGasuserSafetyDeviceInfoVo">
        select f_gasUser_safety_device_id, f_relation_gasUser_id, f_relation_device_type, f_device_name, f_device_model, f_iot_no, f_detection_medium, f_device_install_time, f_device_install_position, f_head, f_phone, is_del from t_gasuser_safety_device_info
    </sql>

    <select id="selectTGasuserSafetyDeviceInfoList" parameterType="TGasuserSafetyDeviceInfo" resultMap="TGasuserSafetyDeviceInfoResult">
        <include refid="selectTGasuserSafetyDeviceInfoVo"/>
        <where>  
            <if test="relationGasuserId != null "> and f_relation_gasUser_id = #{relationGasuserId}</if>
            <if test="relationDeviceType != null  and relationDeviceType != ''"> and f_relation_device_type = #{relationDeviceType}</if>
            <if test="deviceName != null  and deviceName != ''"> and f_device_name like concat('%', #{deviceName}, '%')</if>
            <if test="deviceModel != null  and deviceModel != ''"> and f_device_model = #{deviceModel}</if>
            <if test="fIotNo != null  and fIotNo != ''"> and f_iot_no = #{fIotNo}</if>
            <if test="detectionMedium != null  and detectionMedium != ''"> and f_detection_medium = #{detectionMedium}</if>
            <if test="deviceInstallTime != null "> and f_device_install_time = #{deviceInstallTime}</if>
            <if test="deviceInstallPosition != null "> and f_device_install_position = #{deviceInstallPosition}</if>
            <if test="head != null  and head != ''"> and f_head = #{head}</if>
            <if test="phone != null  and phone != ''"> and f_phone = #{phone}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>

    <select id="queryNoSelectSafeDeviceInfoList" parameterType="tGasuserSafetyDeviceInfo" resultMap="TGasuserSafetyDeviceInfoResult">
        <include refid="selectTGasuserSafetyDeviceInfoVo"/>
        <where>
            is_del='0' and f_relation_gasUser_id is  null
            <if test="relationGasuserId != null "> and f_relation_gasUser_id = #{relationGasuserId}</if>
            <if test="relationDeviceType != null  and relationDeviceType != ''"> and f_relation_device_type = #{relationDeviceType}</if>
            <if test="deviceName != null  and deviceName != ''"> and f_device_name like concat('%', #{deviceName}, '%')</if>
            <if test="deviceModel != null  and deviceModel != ''"> and f_device_model = #{deviceModel}</if>
            <if test="fIotNo != null  and fIotNo != ''"> and f_iot_no = #{fIotNo}</if>
            <if test="detectionMedium != null  and detectionMedium != ''"> and f_detection_medium = #{detectionMedium}</if>
            <if test="deviceInstallTime != null "> and f_device_install_time = #{deviceInstallTime}</if>
            <if test="deviceInstallPosition != null "> and f_device_install_position = #{deviceInstallPosition}</if>
            <if test="head != null  and head != ''"> and f_head = #{head}</if>
            <if test="phone != null  and phone != ''"> and f_phone = #{phone}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectTGasuserSafetyDeviceInfoById" parameterType="Long" resultMap="TGasuserSafetyDeviceInfoResult">
        <include refid="selectTGasuserSafetyDeviceInfoVo"/>
        where f_gasUser_safety_device_id = #{gasUserSafetyDeviceId}
    </select>
        
    <insert id="insertTGasuserSafetyDeviceInfo" parameterType="TGasuserSafetyDeviceInfo" useGeneratedKeys="true" keyProperty="gasUserSafetyDeviceId">
        insert into t_gasuser_safety_device_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="relationGasuserId != null">f_relation_gasUser_id,</if>
            <if test="relationDeviceType != null">f_relation_device_type,</if>
            <if test="deviceName != null">f_device_name,</if>
            <if test="deviceModel != null">f_device_model,</if>
            <if test="fIotNo != null">f_iot_no,</if>
            <if test="detectionMedium != null">f_detection_medium,</if>
            <if test="deviceInstallTime != null">f_device_install_time,</if>
            <if test="deviceInstallPosition != null">f_device_install_position,</if>
            <if test="head != null">f_head,</if>
            <if test="phone != null">f_phone,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="relationGasuserId != null">#{relationGasuserId},</if>
            <if test="relationDeviceType != null">#{relationDeviceType},</if>
            <if test="deviceName != null">#{deviceName},</if>
            <if test="deviceModel != null">#{deviceModel},</if>
            <if test="fIotNo != null">#{fIotNo},</if>
            <if test="detectionMedium != null">#{detectionMedium},</if>
            <if test="deviceInstallTime != null">#{deviceInstallTime},</if>
            <if test="deviceInstallPosition != null">#{deviceInstallPosition},</if>
            <if test="head != null">#{head},</if>
            <if test="phone != null">#{phone},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
    <insert id="insertBatch" parameterType="list">

        insert into t_gasuser_safety_device_info (f_relation_gasUser_id, f_relation_device_type, f_device_name,
                                                  f_device_model, f_iot_no,f_detection_medium, f_device_install_time,
                                                  f_device_install_position,f_head,f_phone)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.relationGasuserId}, #{item.relationDeviceType,jdbcType=VARCHAR},
            #{item.deviceName,jdbcType=VARCHAR}, #{item.deviceModel,jdbcType=VARCHAR}, #{item.fIotNo,jdbcType=VARCHAR},
            #{item.detectionMedium,jdbcType=DECIMAL}, #{item.deviceInstallTime,jdbcType=DECIMAL},
             #{item.deviceInstallPosition,jdbcType=VARCHAR},#{item.head,jdbcType=VARCHAR}, #{item.phone,jdbcType=TIMESTAMP}
            )
        </foreach>
    </insert>

112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
    <update id="updateTGasuserSafetyDeviceInfo" parameterType="TGasuserSafetyDeviceInfo">
        update t_gasuser_safety_device_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="relationGasuserId != null">f_relation_gasUser_id = #{relationGasuserId},</if>
            <if test="relationDeviceType != null">f_relation_device_type = #{relationDeviceType},</if>
            <if test="deviceName != null">f_device_name = #{deviceName},</if>
            <if test="deviceModel != null">f_device_model = #{deviceModel},</if>
            <if test="fIotNo != null">f_iot_no = #{fIotNo},</if>
            <if test="detectionMedium != null">f_detection_medium = #{detectionMedium},</if>
            <if test="deviceInstallTime != null">f_device_install_time = #{deviceInstallTime},</if>
            <if test="deviceInstallPosition != null">f_device_install_position = #{deviceInstallPosition},</if>
            <if test="head != null">f_head = #{head},</if>
            <if test="phone != null">f_phone = #{phone},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where f_gasUser_safety_device_id = #{gasUserSafetyDeviceId}
    </update>

    <delete id="deleteTGasuserSafetyDeviceInfoById" parameterType="Long">
        delete from t_gasuser_safety_device_info where f_gasUser_safety_device_id = #{gasUserSafetyDeviceId}
    </delete>
133 134 135
    <select id="deleteTGasuserSafetyDeviceInfoByUserId" parameterType="Long">
        delete from t_gasuser_safety_device_info where f_relation_gasUser_id = #{userId}
    </select>
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151

    <delete id="deleteTGasuserSafetyDeviceInfoByIds" parameterType="String">
        delete from t_gasuser_safety_device_info where f_gasUser_safety_device_id in 
        <foreach item="gasUserSafetyDeviceId" collection="array" open="(" separator="," close=")">
            #{gasUserSafetyDeviceId}
        </foreach>
    </delete>
    <update id="deleteSafetyDeviceListInfo" >
        update  t_gasuser_safety_device_info set is_del='1' where f_gasUser_safety_device_id in
        <foreach item="deviceId" collection="array" open="(" separator="," close=")">
            #{deviceId}
        </foreach>
    </update>
    <update id="deleteSafetyDeviceInfo">
        update t_gasuser_safety_device_info set is_del='1' where f_gasUser_safety_device_id = #{deviceId}
    </update>
152 153 154 155 156 157 158 159 160 161 162 163 164 165
    <select id="selectSafetyDeviceDetailInfoList" resultMap="TGasuserSafetyDeviceInfoResult" parameterType="Long">
        <include refid="selectTGasuserSafetyDeviceInfoVo"/>
        where f_relation_gasUser_id = #{userId} and is_del='0'
    </select>

    <!--将关联设备信息与设备进行绑定-->
    <update id="updatetRelationSafetyDeviceInfo" parameterType="java.util.List">
        update t_gasuser_safety_device_info set f_relation_gasUser_id = #{id}
        where
        f_gasUser_safety_device_id in
        <foreach collection="gettDeviceInfoS" item="items" index="key" open="(" separator="," close=")">
            #{items.gasUserSafetyDeviceId}
        </foreach>
    </update>
166
</mapper>