<?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.TPipeInfoMapper">

    <resultMap type="TPipeInfo" id="TPipeInfoResult">
        <result property="pipeId"    column="pipe_id"    />
        <result property="pipeLength"    column="pipe_length"    />
        <result property="pipeDiameter"    column="pipe_diameter"    />
        <result property="pipePressure"    column="pipe_pressure"    />
        <result property="pipeMaterial"    column="pipe_material"    />
        <result property="pipeAddr"    column="pipe_addr"    />
        <result property="buriedDepth"    column="buried_depth"    />
        <result property="pipeTrend"    column="pipe_trend"    />
        <result property="buildDate"    column="build_date"    />
        <result property="buildUnit"    column="build_unit"    />
        <result property="beyondEnterpriseId"    column="beyond_enterprise_id"    />
        <result property="beyondEnterpriseName"    column="beyond_enterprise_name"    />
        <result property="coordinates"    column="coordinates"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remarks"    column="remarks"    />

        <result property="pipeName"    column="pipe_name"    />
        <result property="detaildAddress"    column="detaild_address"    />
        <result property="indRegAuth"    column="ind_reg_auth"    />
        <result property="indRegAuthPer"    column="ind_reg_auth_per"    />
        <result property="indRegAuthPerCon"    column="ind_reg_auth_per_con"    />
        <result property="keyAreasGasUsage"    column="key_areas_gas_usage"    />
        <result property="affGasCom"    column="aff_gas_com"    />
        <result property="affGasComSecPer"    column="aff_gas_com_sec_per"    />
        <result property="affGasComSecPerCon"    column="aff_gas_com_sec_per_con"    />
        <result property="secCheckTime"    column="sec_check_time"    />
        <result property="unitGasUserRes"    column="unit_gas_user_res"    />
        <result property="unitGasUserResCon"    column="unit_gas_user_res_con"    />
    </resultMap>

    <sql id="selectTPipeInfoVo">
        select pipe_id,pipe_length, pipe_diameter, pipe_pressure, pipe_material, pipe_addr, buried_depth, pipe_trend, build_date, build_unit, beyond_enterprise_id, beyond_enterprise_name, coordinates, create_by, create_time, update_by, update_time, is_del,pipe_name,detaild_address,ind_reg_auth,ind_reg_auth_per,ind_reg_auth_per_con,key_areas_gas_usage,aff_gas_com,aff_gas_com_sec_per,aff_gas_com_sec_per_con,sec_check_time,unit_gas_user_res,unit_gas_user_res_con, remarks from t_pipe_info
    </sql>

    <select id="selectTPipeInfoList" parameterType="TPipeInfo" resultMap="TPipeInfoResult">
        <include refid="selectTPipeInfoVo"/>
        <where>
            is_del='0'
            <if test="pipeLength != null "> and pipe_length = #{pipeLength}</if>
            <if test="pipeDiameter != null "> and pipe_diameter = #{pipeDiameter}</if>
            <if test="pipePressure != null "> and pipe_pressure = #{pipePressure}</if>
            <if test="pipeMaterial != null  and pipeMaterial != ''"> and pipe_material = #{pipeMaterial}</if>
            <if test="pipeAddr != null  and pipeAddr != ''"> and pipe_addr = #{pipeAddr}</if>
            <if test="buriedDepth != null "> and buried_depth = #{buriedDepth}</if>
            <if test="pipeTrend != null  and pipeTrend != ''"> and pipe_trend = #{pipeTrend}</if>
            <if test="buildDate != null  and buildDate != ''"> and build_date = #{buildDate}</if>
            <if test="buildUnit != null  and buildUnit != ''"> and build_unit = #{buildUnit}</if>
            <if test="beyondEnterpriseId != null and beyondEnterpriseId != -2"> and beyond_enterprise_id = #{beyondEnterpriseId}</if>
            <if test="beyondEnterpriseName != null  and beyondEnterpriseName != ''"> and beyond_enterprise_name like concat('%', #{beyondEnterpriseName}, '%')</if>
            <if test="coordinates != null  and coordinates != ''"> and coordinates = #{coordinates}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>

            <if test="pipeName != null  and pipeName != ''"> and pipe_name = #{pipeName}</if>
            <if test="detaildAddress != null  and detaildAddress != ''"> and detaild_address = #{detaildAddress}</if>
            <if test="indRegAuth != null  and indRegAuth != ''"> and ind_reg_auth = #{indRegAuth}</if>
            <if test="indRegAuthPer != null  and indRegAuthPer != ''"> and ind_reg_auth_per = #{indRegAuthPer}</if>
            <if test="indRegAuthPerCon != null  and indRegAuthPerCon != ''"> and ind_reg_auth_per_con = #{indRegAuthPerCon}</if>
            <if test="keyAreasGasUsage != null  and keyAreasGasUsage != ''"> and key_areas_gas_usage = #{keyAreasGasUsage}</if>
            <if test="affGasCom != null  and affGasCom != ''"> and aff_gas_com = #{affGasCom}</if>
            <if test="affGasComSecPer != null  and affGasComSecPer != ''"> and aff_gas_com_sec_per = #{affGasComSecPer}</if>
            <if test="affGasComSecPerCon != null  and affGasComSecPerCon != ''"> and aff_gas_com_sec_per_con = #{affGasComSecPerCon}</if>
            <if test="secCheckTime != null  and secCheckTime != ''"> and sec_check_time = #{secCheckTime}</if>
            <if test="unitGasUserRes != null  and unitGasUserRes != ''"> and unit_gas_user_res = #{unitGasUserRes}</if>
            <if test="unitGasUserResCon != null  and unitGasUserResCon != ''"> and unit_gas_user_res_con = #{unitGasUserResCon}</if>
        </where>
        order by pipe_id desc
    </select>

    <select id="selectTPipeInfoById" parameterType="Long" resultMap="TPipeInfoResult">
        <include refid="selectTPipeInfoVo"/>
        where pipe_id = #{pipeId} and is_del='0'
    </select>

    <insert id="insertTPipeInfo" parameterType="TPipeInfo" useGeneratedKeys="true" keyProperty="pipeId">
        insert into t_pipe_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pipeLength != null">pipe_length,</if>
            <if test="pipeDiameter != null">pipe_diameter,</if>
            <if test="pipePressure != null">pipe_pressure,</if>
            <if test="pipeMaterial != null">pipe_material,</if>
            <if test="pipeAddr != null">pipe_addr,</if>
            <if test="buriedDepth != null">buried_depth,</if>
            <if test="pipeTrend != null">pipe_trend,</if>
            <if test="buildDate != null">build_date,</if>
            <if test="buildUnit != null">build_unit,</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id,</if>
            <if test="beyondEnterpriseName != null">beyond_enterprise_name,</if>
            <if test="coordinates != null">coordinates,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remarks != null">remarks,</if>

            <if test="pipeName != null">pipe_name,</if>
            <if test="detaildAddress != null">detaild_address,</if>
            <if test="indRegAuth != null">ind_reg_auth,</if>
            <if test="indRegAuthPer != null">ind_reg_auth_per,</if>
            <if test="indRegAuthPerCon != null">ind_reg_auth_per_con,</if>
            <if test="keyAreasGasUsage != null">key_areas_gas_usage,</if>
            <if test="affGasCom != null">aff_gas_com,</if>
            <if test="affGasComSecPer != null">aff_gas_com_sec_per,</if>
            <if test="affGasComSecPerCon != null">aff_gas_com_sec_per_con,</if>
            <if test="secCheckTime != null">sec_check_time,</if>
            <if test="unitGasUserRes != null">unit_gas_user_res,</if>
            <if test="unitGasUserResCon != null">unit_gas_user_res_con,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pipeLength != null">#{pipeLength},</if>
            <if test="pipeDiameter != null">#{pipeDiameter},</if>
            <if test="pipePressure != null">#{pipePressure},</if>
            <if test="pipeMaterial != null">#{pipeMaterial},</if>
            <if test="pipeAddr != null">#{pipeAddr},</if>
            <if test="buriedDepth != null">#{buriedDepth},</if>
            <if test="pipeTrend != null">#{pipeTrend},</if>
            <if test="buildDate != null">#{buildDate},</if>
            <if test="buildUnit != null">#{buildUnit},</if>
            <if test="beyondEnterpriseId != null">#{beyondEnterpriseId},</if>
            <if test="beyondEnterpriseName != null">#{beyondEnterpriseName},</if>
            <if test="coordinates != null">#{coordinates},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remarks != null">#{remarks},</if>

            <if test="pipeName != null">#{pipeName},</if>
            <if test="detaildAddress != null">#{detaildAddress},</if>
            <if test="indRegAuth != null">#{indRegAuth},</if>
            <if test="indRegAuthPer != null">#{indRegAuthPer},</if>
            <if test="indRegAuthPerCon != null">#{indRegAuthPerCon},</if>
            <if test="keyAreasGasUsage != null">#{keyAreasGasUsage},</if>
            <if test="affGasCom != null">#{affGasCom},</if>
            <if test="affGasComSecPer != null">#{affGasComSecPer},</if>
            <if test="affGasComSecPerCon != null">#{affGasComSecPerCon},</if>
            <if test="secCheckTime != null">#{secCheckTime},</if>
            <if test="unitGasUserRes != null">#{unitGasUserRes},</if>
            <if test="unitGasUserResCon != null">#{unitGasUserResCon},</if>
         </trim>
    </insert>

    <update id="updateTPipeInfo" parameterType="TPipeInfo">
        update t_pipe_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="pipeLength != null">pipe_length = #{pipeLength},</if>
            <if test="pipeDiameter != null">pipe_diameter = #{pipeDiameter},</if>
            <if test="pipePressure != null">pipe_pressure = #{pipePressure},</if>
            <if test="pipeMaterial != null">pipe_material = #{pipeMaterial},</if>
            <if test="pipeAddr != null">pipe_addr = #{pipeAddr},</if>
            <if test="buriedDepth != null">buried_depth = #{buriedDepth},</if>
            <if test="pipeTrend != null">pipe_trend = #{pipeTrend},</if>
            <if test="buildDate != null">build_date = #{buildDate},</if>
            <if test="buildUnit != null">build_unit = #{buildUnit},</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id = #{beyondEnterpriseId},</if>
            <if test="beyondEnterpriseName != null">beyond_enterprise_name = #{beyondEnterpriseName},</if>
            <if test="coordinates != null">coordinates = #{coordinates},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remarks != null">remarks = #{remarks},</if>

            <if test="pipeName != null">pipe_name = #{pipeName},</if>
            <if test="detaildAddress != null">detaild_address =#{detaildAddress},</if>
            <if test="indRegAuth != null">ind_reg_auth =#{indRegAuth},</if>
            <if test="indRegAuthPer != null">ind_reg_auth_per =#{indRegAuthPer},</if>
            <if test="indRegAuthPerCon != null">ind_reg_auth_per_con =#{indRegAuthPerCon},</if>
            <if test="keyAreasGasUsage != null">key_areas_gas_usage =#{keyAreasGasUsage},</if>
            <if test="affGasCom != null">aff_gas_com =#{affGasCom},</if>
            <if test="affGasComSecPer != null">aff_gas_com_sec_per =#{affGasComSecPer},</if>
            <if test="affGasComSecPerCon != null">aff_gas_com_sec_per_con =#{affGasComSecPerCon},</if>
            <if test="secCheckTime != null">sec_check_time =#{secCheckTime},</if>
            <if test="unitGasUserRes != null">unit_gas_user_res =#{unitGasUserRes},</if>
            <if test="unitGasUserResCon != null">unit_gas_user_res_con =#{unitGasUserResCon},</if>
        </trim>
        where pipe_id = #{pipeId}
    </update>

    <update id="deleteTPipeInfoById" parameterType="Long">
        update  t_pipe_info  set is_del='1' where pipe_id = #{pipeId}
    </update>

    <update id="deleteTPipeInfoByIds" parameterType="String">
        update  t_pipe_info set is_del='1'  where pipe_id in
        <foreach item="pipeId" collection="array" open="(" separator="," close=")">
            #{pipeId}
        </foreach>
    </update>
</mapper>
