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

    <resultMap type="AttRvBase" id="AttRvBaseResult">
        <result property="rvCode" column="RV_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="rvName" column="RV_NAME"/>
        <result property="rvSourLong" column="RV_SOUR_LONG"/>
        <result property="rvSourLat" column="RV_SOUR_LAT"/>
        <result property="rvMouLong" column="RV_MOU_LONG"/>
        <result property="rvMouLat" column="RV_MOU_LAT"/>
        <result property="rvSourLoc" column="RV_SOUR_LOC"/>
        <result property="rvMouLoc" column="RV_MOU_LOC"/>
        <result property="crOverType" column="CR_OVER_TYPE"/>
        <result property="flowArea" column="FLOW_AREA"/>
        <result property="rvType" column="RV_TYPE"/>
        <result property="rvGrad" column="RV_GRAD"/>
        <result property="bank" column="BANK"/>
        <result property="rvLen" column="RV_LEN"/>
        <result property="rvBasArea" column="RV_BAS_AREA"/>
        <result property="lonAverAnnFlow" column="LON_AVER_ANN_FLOW"/>
        <result property="meaAnnRuof" column="MEA_ANN_RUOF"/>
        <result property="averSlop" column="AVER_SLOP"/>
        <result property="note" column="NOTE"/>
        <result property="updDate" column="UPD_DATE"/>
    </resultMap>

    <sql id="selectAttRvBaseVo">
        select RV_CODE, COLL_DATE, RV_NAME, RV_SOUR_LONG, RV_SOUR_LAT, RV_MOU_LONG, RV_MOU_LAT,
               RV_SOUR_LOC, RV_MOU_LOC, CR_OVER_TYPE, FLOW_AREA, RV_TYPE, RV_GRAD, BANK,
               RV_LEN, RV_BAS_AREA, LON_AVER_ANN_FLOW, MEA_ANN_RUOF, AVER_SLOP, NOTE, UPD_DATE
        from ATT_RV_BASE
    </sql>

    <select id="selectAttRvBaseList" parameterType="AttRvBase" resultMap="AttRvBaseResult">
        <include refid="selectAttRvBaseVo"/>
        <where>
            <if test="rvName != null and rvName != ''">
                and RV_NAME like concat('%', #{rvName}, '%')
            </if>
            <if test="rvType != null and rvType != ''">
                and RV_TYPE = #{rvType}
            </if>
            <if test="rvGrad != null and rvGrad != ''">
                and RV_GRAD = #{rvGrad}
            </if>
            <if test="crOverType != null and crOverType != ''">
                and CR_OVER_TYPE = #{crOverType}
            </if>
            <if test="bank != null and bank != ''">
                and BANK = #{bank}
            </if>
        </where>
        order by RV_CODE
    </select>

    <select id="selectAttRvBaseById" parameterType="String" resultMap="AttRvBaseResult">
        <include refid="selectAttRvBaseVo"/>
        where RV_CODE = #{rvCode}
    </select>

    <delete id="deleteAttRvBaseById" parameterType="String">
        delete from ATT_RV_BASE where RV_CODE = #{rvCode}
    </delete>

    <delete id="deleteAttRvBaseByIds" parameterType="String">
        delete from ATT_RV_BASE where RV_CODE in
        <foreach item="rvCode" collection="array" open="(" separator="," close=")">
            #{rvCode}
        </foreach>
    </delete>

    <insert id="insertAttRvBase" parameterType="AttRvBase">
        insert into ATT_RV_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="rvCode != null">RV_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="rvName != null">RV_NAME,</if>
            <if test="rvSourLong != null">RV_SOUR_LONG,</if>
            <if test="rvSourLat != null">RV_SOUR_LAT,</if>
            <if test="rvMouLong != null">RV_MOU_LONG,</if>
            <if test="rvMouLat != null">RV_MOU_LAT,</if>
            <if test="rvSourLoc != null">RV_SOUR_LOC,</if>
            <if test="rvMouLoc != null">RV_MOU_LOC,</if>
            <if test="crOverType != null">CR_OVER_TYPE,</if>
            <if test="flowArea != null">FLOW_AREA,</if>
            <if test="rvType != null">RV_TYPE,</if>
            <if test="rvGrad != null">RV_GRAD,</if>
            <if test="bank != null">BANK,</if>
            <if test="rvLen != null">RV_LEN,</if>
            <if test="rvBasArea != null">RV_BAS_AREA,</if>
            <if test="lonAverAnnFlow != null">LON_AVER_ANN_FLOW,</if>
            <if test="meaAnnRuof != null">MEA_ANN_RUOF,</if>
            <if test="averSlop != null">AVER_SLOP,</if>
            <if test="note != null">NOTE,</if>
            <if test="updDate != null">UPD_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="rvCode != null">#{rvCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="rvName != null">#{rvName},</if>
            <if test="rvSourLong != null">#{rvSourLong},</if>
            <if test="rvSourLat != null">#{rvSourLat},</if>
            <if test="rvMouLong != null">#{rvMouLong},</if>
            <if test="rvMouLat != null">#{rvMouLat},</if>
            <if test="rvSourLoc != null">#{rvSourLoc},</if>
            <if test="rvMouLoc != null">#{rvMouLoc},</if>
            <if test="crOverType != null">#{crOverType},</if>
            <if test="flowArea != null">#{flowArea},</if>
            <if test="rvType != null">#{rvType},</if>
            <if test="rvGrad != null">#{rvGrad},</if>
            <if test="bank != null">#{bank},</if>
            <if test="rvLen != null">#{rvLen},</if>
            <if test="rvBasArea != null">#{rvBasArea},</if>
            <if test="lonAverAnnFlow != null">#{lonAverAnnFlow},</if>
            <if test="meaAnnRuof != null">#{meaAnnRuof},</if>
            <if test="averSlop != null">#{averSlop},</if>
            <if test="note != null">#{note},</if>
            <if test="updDate != null">#{updDate},</if>
        </trim>
    </insert>

    <update id="updateAttRvBase" parameterType="AttRvBase">
        update ATT_RV_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="rvName != null">RV_NAME = #{rvName},</if>
            <if test="rvSourLong != null">RV_SOUR_LONG = #{rvSourLong},</if>
            <if test="rvSourLat != null">RV_SOUR_LAT = #{rvSourLat},</if>
            <if test="rvMouLong != null">RV_MOU_LONG = #{rvMouLong},</if>
            <if test="rvMouLat != null">RV_MOU_LAT = #{rvMouLat},</if>
            <if test="rvSourLoc != null">RV_SOUR_LOC = #{rvSourLoc},</if>
            <if test="rvMouLoc != null">RV_MOU_LOC = #{rvMouLoc},</if>
            <if test="crOverType != null">CR_OVER_TYPE = #{crOverType},</if>
            <if test="flowArea != null">FLOW_AREA = #{flowArea},</if>
            <if test="rvType != null">RV_TYPE = #{rvType},</if>
            <if test="rvGrad != null">RV_GRAD = #{rvGrad},</if>
            <if test="bank != null">BANK = #{bank},</if>
            <if test="rvLen != null">RV_LEN = #{rvLen},</if>
            <if test="rvBasArea != null">RV_BAS_AREA = #{rvBasArea},</if>
            <if test="lonAverAnnFlow != null">LON_AVER_ANN_FLOW = #{lonAverAnnFlow},</if>
            <if test="meaAnnRuof != null">MEA_ANN_RUOF = #{meaAnnRuof},</if>
            <if test="averSlop != null">AVER_SLOP = #{averSlop},</if>
            <if test="note != null">NOTE = #{note},</if>
            <if test="updDate != null">UPD_DATE = #{updDate},</if>
        </trim>
        where RV_CODE = #{rvCode}
    </update>

</mapper>
