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

    <resultMap type="AttFlumBase" id="AttFlumBaseResult">
        <result property="flumCode" column="FLUM_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="flumName" column="FLUM_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="flumLoc" column="FLUM_LOC"/>
        <result property="flumWatProp" column="FLUM_WAT_PROP"/>
        <result property="flumPatt" column="FLUM_PATT"/>
        <result property="flumSecPatt" column="FLUM_SEC_PATT"/>
        <result property="crRvLen" column="CR_RV_LEN"/>
        <result property="suppType" column="SUPP_TYPE"/>
        <result property="suppOrifNum" column="SUPP_ORIF_NUM"/>
        <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="selectAttFlumBaseVo">
        select FLUM_CODE, COLL_DATE, FLUM_NAME, START_LONG, START_LAT, END_LONG, END_LAT, FLUM_LOC,
               FLUM_WAT_PROP, FLUM_PATT, FLUM_SEC_PATT, CR_RV_LEN, SUPP_TYPE, SUPP_ORIF_NUM,
               ENG_STAT, RUN_STAT, START_DATE, COMP_DATE, NOTE, UPD_DATE
        from ATT_FLUM_BASE
    </sql>

    <select id="selectAttFlumBaseList" parameterType="AttFlumBase" resultMap="AttFlumBaseResult">
        <include refid="selectAttFlumBaseVo"/>
        <where>
            <if test="flumName != null and flumName != ''">
                and FLUM_NAME like concat('%', #{flumName}, '%')
            </if>
            <if test="flumPatt != null and flumPatt != ''">
                and FLUM_PATT = #{flumPatt}
            </if>
            <if test="flumSecPatt != null and flumSecPatt != ''">
                and FLUM_SEC_PATT = #{flumSecPatt}
            </if>
            <if test="suppType != null and suppType != ''">
                and SUPP_TYPE = #{suppType}
            </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 FLUM_CODE
    </select>

    <select id="selectAttFlumBaseById" parameterType="String" resultMap="AttFlumBaseResult">
        <include refid="selectAttFlumBaseVo"/>
        where FLUM_CODE = #{flumCode}
    </select>

    <delete id="deleteAttFlumBaseById" parameterType="String">
        delete from ATT_FLUM_BASE where FLUM_CODE = #{flumCode}
    </delete>

    <delete id="deleteAttFlumBaseByIds" parameterType="String">
        delete from ATT_FLUM_BASE where FLUM_CODE in
        <foreach item="flumCode" collection="array" open="(" separator="," close=")">
            #{flumCode}
        </foreach>
    </delete>

    <insert id="insertAttFlumBase" parameterType="AttFlumBase">
        insert into ATT_FLUM_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="flumCode != null">FLUM_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="flumName != null">FLUM_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="flumLoc != null">FLUM_LOC,</if>
            <if test="flumWatProp != null">FLUM_WAT_PROP,</if>
            <if test="flumPatt != null">FLUM_PATT,</if>
            <if test="flumSecPatt != null">FLUM_SEC_PATT,</if>
            <if test="crRvLen != null">CR_RV_LEN,</if>
            <if test="suppType != null">SUPP_TYPE,</if>
            <if test="suppOrifNum != null">SUPP_ORIF_NUM,</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="flumCode != null">#{flumCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="flumName != null">#{flumName},</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="flumLoc != null">#{flumLoc},</if>
            <if test="flumWatProp != null">#{flumWatProp},</if>
            <if test="flumPatt != null">#{flumPatt},</if>
            <if test="flumSecPatt != null">#{flumSecPatt},</if>
            <if test="crRvLen != null">#{crRvLen},</if>
            <if test="suppType != null">#{suppType},</if>
            <if test="suppOrifNum != null">#{suppOrifNum},</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="updateAttFlumBase" parameterType="AttFlumBase">
        update ATT_FLUM_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="flumName != null">FLUM_NAME = #{flumName},</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="flumLoc != null">FLUM_LOC = #{flumLoc},</if>
            <if test="flumWatProp != null">FLUM_WAT_PROP = #{flumWatProp},</if>
            <if test="flumPatt != null">FLUM_PATT = #{flumPatt},</if>
            <if test="flumSecPatt != null">FLUM_SEC_PATT = #{flumSecPatt},</if>
            <if test="crRvLen != null">CR_RV_LEN = #{crRvLen},</if>
            <if test="suppType != null">SUPP_TYPE = #{suppType},</if>
            <if test="suppOrifNum != null">SUPP_ORIF_NUM = #{suppOrifNum},</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 FLUM_CODE = #{flumCode}
    </update>

</mapper>
