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

    <resultMap type="AttInsiBase" id="AttInsiBaseResult">
        <result property="insiCode" column="INSI_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="insiName" column="INSI_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="insiLoc" column="INSI_LOC"/>
        <result property="insiType" column="INSI_TYPE"/>
        <result property="pipeNetHeig" column="PIPE_NET_HEIG"/>
        <result property="pipeNetWid" column="PIPE_NET_WID"/>
        <result property="pipeIndi" column="PIPE_INDI"/>
        <result property="orifNum" column="ORIF_NUM"/>
        <result property="baseStrPatt" column="BASE_STR_PATT"/>
        <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="selectAttInsiBaseVo">
        select INSI_CODE, COLL_DATE, INSI_NAME, START_LONG, START_LAT, END_LONG, END_LAT, INSI_LOC,
               INSI_TYPE, PIPE_NET_HEIG, PIPE_NET_WID, PIPE_INDI, ORIF_NUM, BASE_STR_PATT,
               ENG_STAT, RUN_STAT, START_DATE, COMP_DATE, NOTE, UPD_DATE
        from ATT_INSI_BASE
    </sql>

    <select id="selectAttInsiBaseList" parameterType="AttInsiBase" resultMap="AttInsiBaseResult">
        <include refid="selectAttInsiBaseVo"/>
        <where>
            <if test="insiName != null and insiName != ''">
                and INSI_NAME like concat('%', #{insiName}, '%')
            </if>
            <if test="insiType != null and insiType != ''">
                and INSI_TYPE = #{insiType}
            </if>
            <if test="baseStrPatt != null and baseStrPatt != ''">
                and BASE_STR_PATT = #{baseStrPatt}
            </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 INSI_CODE
    </select>

    <select id="selectAttInsiBaseById" parameterType="String" resultMap="AttInsiBaseResult">
        <include refid="selectAttInsiBaseVo"/>
        where INSI_CODE = #{insiCode}
    </select>

    <delete id="deleteAttInsiBaseById" parameterType="String">
        delete from ATT_INSI_BASE where INSI_CODE = #{insiCode}
    </delete>

    <delete id="deleteAttInsiBaseByIds" parameterType="String">
        delete from ATT_INSI_BASE where INSI_CODE in
        <foreach item="insiCode" collection="array" open="(" separator="," close=")">
            #{insiCode}
        </foreach>
    </delete>

    <insert id="insertAttInsiBase" parameterType="AttInsiBase">
        insert into ATT_INSI_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="insiCode != null">INSI_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="insiName != null">INSI_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="insiLoc != null">INSI_LOC,</if>
            <if test="insiType != null">INSI_TYPE,</if>
            <if test="pipeNetHeig != null">PIPE_NET_HEIG,</if>
            <if test="pipeNetWid != null">PIPE_NET_WID,</if>
            <if test="pipeIndi != null">PIPE_INDI,</if>
            <if test="orifNum != null">ORIF_NUM,</if>
            <if test="baseStrPatt != null">BASE_STR_PATT,</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="insiCode != null">#{insiCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="insiName != null">#{insiName},</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="insiLoc != null">#{insiLoc},</if>
            <if test="insiType != null">#{insiType},</if>
            <if test="pipeNetHeig != null">#{pipeNetHeig},</if>
            <if test="pipeNetWid != null">#{pipeNetWid},</if>
            <if test="pipeIndi != null">#{pipeIndi},</if>
            <if test="orifNum != null">#{orifNum},</if>
            <if test="baseStrPatt != null">#{baseStrPatt},</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="updateAttInsiBase" parameterType="AttInsiBase">
        update ATT_INSI_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="insiName != null">INSI_NAME = #{insiName},</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="insiLoc != null">INSI_LOC = #{insiLoc},</if>
            <if test="insiType != null">INSI_TYPE = #{insiType},</if>
            <if test="pipeNetHeig != null">PIPE_NET_HEIG = #{pipeNetHeig},</if>
            <if test="pipeNetWid != null">PIPE_NET_WID = #{pipeNetWid},</if>
            <if test="pipeIndi != null">PIPE_INDI = #{pipeIndi},</if>
            <if test="orifNum != null">ORIF_NUM = #{orifNum},</if>
            <if test="baseStrPatt != null">BASE_STR_PATT = #{baseStrPatt},</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 INSI_CODE = #{insiCode}
    </update>

</mapper>
