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

    <resultMap type="AttRudABase" id="AttRudABaseResult">
        <result property="rudaCode" column="RUDA_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="rudaName" column="RUDA_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="rudaLoc" column="RUDA_LOC"/>
        <result property="rudaHeig" column="RUDA_HEIG"/>
        <result property="rudaDamLen" column="RUDA_DAM_LEN"/>
        <result property="engGrad" column="ENG_GRAD"/>
        <result property="mainBuildGrad" column="MAIN_BUILD_GRAD"/>
        <result property="retType" column="RET_TYPE"/>
        <result property="filEmType" column="FIL_EM_TYPE"/>
        <result property="inflMed" column="INFL_MED"/>
        <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="admDep" column="ADM_DEP"/>
        <result property="note" column="NOTE"/>
        <result property="updDate" column="UPD_DATE"/>
    </resultMap>

    <sql id="selectAttRudABaseVo">
        select RUDA_CODE, COLL_DATE, RUDA_NAME, START_LONG, START_LAT, END_LONG, END_LAT, RUDA_LOC,
               RUDA_HEIG, RUDA_DAM_LEN, ENG_GRAD, MAIN_BUILD_GRAD, RET_TYPE, FIL_EM_TYPE, INFL_MED,
               ENG_STAT, RUN_STAT, START_DATE, COMP_DATE, ADM_DEP, NOTE, UPD_DATE
        from ATT_RUDA_BASE
    </sql>

    <select id="selectAttRudABaseList" parameterType="AttRudABase" resultMap="AttRudABaseResult">
        <include refid="selectAttRudABaseVo"/>
        <where>
            <if test="rudaName != null and rudaName != ''">
                and RUDA_NAME like concat('%', #{rudaName}, '%')
            </if>
            <if test="engGrad != null and engGrad != ''">
                and ENG_GRAD = #{engGrad}
            </if>
            <if test="mainBuildGrad != null and mainBuildGrad != ''">
                and MAIN_BUILD_GRAD = #{mainBuildGrad}
            </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 RUDA_CODE
    </select>

    <select id="selectAttRudABaseById" parameterType="String" resultMap="AttRudABaseResult">
        <include refid="selectAttRudABaseVo"/>
        where RUDA_CODE = #{rudaCode}
    </select>

    <delete id="deleteAttRudABaseById" parameterType="String">
        delete from ATT_RUDA_BASE where RUDA_CODE = #{rudaCode}
    </delete>

    <delete id="deleteAttRudABaseByIds" parameterType="String">
        delete from ATT_RUDA_BASE where RUDA_CODE in
        <foreach item="rudaCode" collection="array" open="(" separator="," close=")">
            #{rudaCode}
        </foreach>
    </delete>

    <insert id="insertAttRudABase" parameterType="AttRudABase">
        insert into ATT_RUDA_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="rudaCode != null">RUDA_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="rudaName != null">RUDA_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="rudaLoc != null">RUDA_LOC,</if>
            <if test="rudaHeig != null">RUDA_HEIG,</if>
            <if test="rudaDamLen != null">RUDA_DAM_LEN,</if>
            <if test="engGrad != null">ENG_GRAD,</if>
            <if test="mainBuildGrad != null">MAIN_BUILD_GRAD,</if>
            <if test="retType != null">RET_TYPE,</if>
            <if test="filEmType != null">FIL_EM_TYPE,</if>
            <if test="inflMed != null">INFL_MED,</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="admDep != null">ADM_DEP,</if>
            <if test="note != null">NOTE,</if>
            <if test="updDate != null">UPD_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="rudaCode != null">#{rudaCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="rudaName != null">#{rudaName},</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="rudaLoc != null">#{rudaLoc},</if>
            <if test="rudaHeig != null">#{rudaHeig},</if>
            <if test="rudaDamLen != null">#{rudaDamLen},</if>
            <if test="engGrad != null">#{engGrad},</if>
            <if test="mainBuildGrad != null">#{mainBuildGrad},</if>
            <if test="retType != null">#{retType},</if>
            <if test="filEmType != null">#{filEmType},</if>
            <if test="inflMed != null">#{inflMed},</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="admDep != null">#{admDep},</if>
            <if test="note != null">#{note},</if>
            <if test="updDate != null">#{updDate},</if>
        </trim>
    </insert>

    <update id="updateAttRudABase" parameterType="AttRudABase">
        update ATT_RUDA_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="rudaName != null">RUDA_NAME = #{rudaName},</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="rudaLoc != null">RUDA_LOC = #{rudaLoc},</if>
            <if test="rudaHeig != null">RUDA_HEIG = #{rudaHeig},</if>
            <if test="rudaDamLen != null">RUDA_DAM_LEN = #{rudaDamLen},</if>
            <if test="engGrad != null">ENG_GRAD = #{engGrad},</if>
            <if test="mainBuildGrad != null">MAIN_BUILD_GRAD = #{mainBuildGrad},</if>
            <if test="retType != null">RET_TYPE = #{retType},</if>
            <if test="filEmType != null">FIL_EM_TYPE = #{filEmType},</if>
            <if test="inflMed != null">INFL_MED = #{inflMed},</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="admDep != null">ADM_DEP = #{admDep},</if>
            <if test="note != null">NOTE = #{note},</if>
            <if test="updDate != null">UPD_DATE = #{updDate},</if>
        </trim>
        where RUDA_CODE = #{rudaCode}
    </update>

</mapper>
