<?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.goldenwater.slgc.mapper.AttPipeBaseMapper">

    <resultMap type="AttPipeBase" id="AttPipeBaseResult">
        <result property="pipeCode" column="PIPE_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="pipeName" column="PIPE_NAME"/>
        <result property="startLong" column="START_LONG"/>
        <result property="startLat" column="START_LAT"/>
        <result property="endLong" column="END_LONG"/>
        <result property="endLat" column="END_LAT"/>
        <result property="pipeLoc" column="PIPE_LOC"/>
        <result property="pipeType" column="PIPE_TYPE"/>
        <result property="pipeOudi" column="PIPE_OUDI"/>
        <result property="pipeUse" column="PIPE_USE"/>
        <result property="crRvForm" column="CR_RV_FORM"/>
        <result property="crRvLen" column="CR_RV_LEN"/>
        <result property="engStat" column="ENG_STAT"/>
        <result property="runStat" column="RUN_STAT"/>
        <result property="startDate" column="START_DATE"/>
        <result property="compDate" column="COMP_DATE"/>
        <result property="note" column="NOTE"/>
        <result property="updDate" column="UPD_DATE"/>
    </resultMap>

    <sql id="selectAttPipeBaseVo">
        select PIPE_CODE, COLL_DATE, PIPE_NAME, START_LONG, START_LAT, END_LONG, END_LAT, PIPE_LOC,
               PIPE_TYPE, PIPE_OUDI, PIPE_USE, CR_RV_FORM, CR_RV_LEN, ENG_STAT, RUN_STAT,
               START_DATE, COMP_DATE, NOTE, UPD_DATE
        from ATT_PIPE_BASE
    </sql>

    <select id="selectAttPipeBaseList" parameterType="AttPipeBase" resultMap="AttPipeBaseResult">
        <include refid="selectAttPipeBaseVo"/>
        <where>
            <if test="pipeName != null and pipeName != ''">
                and PIPE_NAME like concat('%', #{pipeName}, '%')
            </if>
            <if test="pipeType != null and pipeType != ''">
                and PIPE_TYPE = #{pipeType}
            </if>
            <if test="pipeUse != null and pipeUse != ''">
                and PIPE_USE = #{pipeUse}
            </if>
            <if test="crRvForm != null and crRvForm != ''">
                and CR_RV_FORM = #{crRvForm}
            </if>
            <if test="engStat != null and engStat != ''">
                and ENG_STAT = #{engStat}
            </if>
            <if test="runStat != null and runStat != ''">
                and RUN_STAT = #{runStat}
            </if>
        </where>
        order by PIPE_CODE
    </select>

    <select id="selectAttPipeBaseById" parameterType="String" resultMap="AttPipeBaseResult">
        <include refid="selectAttPipeBaseVo"/>
        where PIPE_CODE = #{pipeCode}
    </select>

    <delete id="deleteAttPipeBaseById" parameterType="String">
        delete from ATT_PIPE_BASE where PIPE_CODE = #{pipeCode}
    </delete>

    <delete id="deleteAttPipeBaseByIds" parameterType="String">
        delete from ATT_PIPE_BASE where PIPE_CODE in
        <foreach item="pipeCode" collection="array" open="(" separator="," close=")">
            #{pipeCode}
        </foreach>
    </delete>

    <insert id="insertAttPipeBase" parameterType="AttPipeBase">
        insert into ATT_PIPE_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pipeCode != null">PIPE_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="pipeName != null">PIPE_NAME,</if>
            <if test="startLong != null">START_LONG,</if>
            <if test="startLat != null">START_LAT,</if>
            <if test="endLong != null">END_LONG,</if>
            <if test="endLat != null">END_LAT,</if>
            <if test="pipeLoc != null">PIPE_LOC,</if>
            <if test="pipeType != null">PIPE_TYPE,</if>
            <if test="pipeOudi != null">PIPE_OUDI,</if>
            <if test="pipeUse != null">PIPE_USE,</if>
            <if test="crRvForm != null">CR_RV_FORM,</if>
            <if test="crRvLen != null">CR_RV_LEN,</if>
            <if test="engStat != null">ENG_STAT,</if>
            <if test="runStat != null">RUN_STAT,</if>
            <if test="startDate != null">START_DATE,</if>
            <if test="compDate != null">COMP_DATE,</if>
            <if test="note != null">NOTE,</if>
            <if test="updDate != null">UPD_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pipeCode != null">#{pipeCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="pipeName != null">#{pipeName},</if>
            <if test="startLong != null">#{startLong},</if>
            <if test="startLat != null">#{startLat},</if>
            <if test="endLong != null">#{endLong},</if>
            <if test="endLat != null">#{endLat},</if>
            <if test="pipeLoc != null">#{pipeLoc},</if>
            <if test="pipeType != null">#{pipeType},</if>
            <if test="pipeOudi != null">#{pipeOudi},</if>
            <if test="pipeUse != null">#{pipeUse},</if>
            <if test="crRvForm != null">#{crRvForm},</if>
            <if test="crRvLen != null">#{crRvLen},</if>
            <if test="engStat != null">#{engStat},</if>
            <if test="runStat != null">#{runStat},</if>
            <if test="startDate != null">#{startDate},</if>
            <if test="compDate != null">#{compDate},</if>
            <if test="note != null">#{note},</if>
            <if test="updDate != null">#{updDate},</if>
        </trim>
    </insert>

    <update id="updateAttPipeBase" parameterType="AttPipeBase">
        update ATT_PIPE_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="pipeName != null">PIPE_NAME = #{pipeName},</if>
            <if test="startLong != null">START_LONG = #{startLong},</if>
            <if test="startLat != null">START_LAT = #{startLat},</if>
            <if test="endLong != null">END_LONG = #{endLong},</if>
            <if test="endLat != null">END_LAT = #{endLat},</if>
            <if test="pipeLoc != null">PIPE_LOC = #{pipeLoc},</if>
            <if test="pipeType != null">PIPE_TYPE = #{pipeType},</if>
            <if test="pipeOudi != null">PIPE_OUDI = #{pipeOudi},</if>
            <if test="pipeUse != null">PIPE_USE = #{pipeUse},</if>
            <if test="crRvForm != null">CR_RV_FORM = #{crRvForm},</if>
            <if test="crRvLen != null">CR_RV_LEN = #{crRvLen},</if>
            <if test="engStat != null">ENG_STAT = #{engStat},</if>
            <if test="runStat != null">RUN_STAT = #{runStat},</if>
            <if test="startDate != null">START_DATE = #{startDate},</if>
            <if test="compDate != null">COMP_DATE = #{compDate},</if>
            <if test="note != null">NOTE = #{note},</if>
            <if test="updDate != null">UPD_DATE = #{updDate},</if>
        </trim>
        where PIPE_CODE = #{pipeCode}
    </update>

</mapper>
