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

    <resultMap type="AttIrrBase" id="AttIrrBaseResult">
        <result property="irrCode" column="IRR_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="irrName" column="IRR_NAME"/>
        <result property="lowLeftLong" column="LOW_LEFT_LONG"/>
        <result property="lowLeftLat" column="LOW_LEFT_LAT"/>
        <result property="upRightLong" column="UP_RIGHT_LONG"/>
        <result property="upRightLat" column="UP_RIGHT_LAT"/>
        <result property="irrRang" column="IRR_RANG"/>
        <result property="wausType" column="WAUS_TYPE"/>
        <result property="wasoType" column="WASO_TYPE"/>
        <result property="engScal" column="ENG_SCAL"/>
        <result property="totIrrArea" column="TOT_IRR_AREA"/>
        <result property="effIrrArea" column="EFF_IRR_AREA"/>
        <result property="desIrrArea" column="DES_IRR_AREA"/>
        <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="selectAttIrrBaseVo">
        select IRR_CODE, COLL_DATE, IRR_NAME, LOW_LEFT_LONG, LOW_LEFT_LAT, UP_RIGHT_LONG, UP_RIGHT_LAT,
               IRR_RANG, WAUS_TYPE, WASO_TYPE, ENG_SCAL, TOT_IRR_AREA, EFF_IRR_AREA, DES_IRR_AREA,
               ENG_STAT, RUN_STAT, START_DATE, COMP_DATE, NOTE, UPD_DATE
        from ATT_IRR_BASE
    </sql>

    <select id="selectAttIrrBaseList" parameterType="AttIrrBase" resultMap="AttIrrBaseResult">
        <include refid="selectAttIrrBaseVo"/>
        <where>
            <if test="irrName != null and irrName != ''">
                and IRR_NAME like concat('%', #{irrName}, '%')
            </if>
            <if test="engScal != null and engScal != ''">
                and ENG_SCAL = #{engScal}
            </if>
            <if test="wausType != null and wausType != ''">
                and WAUS_TYPE = #{wausType}
            </if>
            <if test="wasoType != null and wasoType != ''">
                and WASO_TYPE = #{wasoType}
            </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 IRR_CODE
    </select>

    <select id="selectAttIrrBaseById" parameterType="String" resultMap="AttIrrBaseResult">
        <include refid="selectAttIrrBaseVo"/>
        where IRR_CODE = #{irrCode}
    </select>

    <delete id="deleteAttIrrBaseById" parameterType="String">
        delete from ATT_IRR_BASE where IRR_CODE = #{irrCode}
    </delete>

    <delete id="deleteAttIrrBaseByIds" parameterType="String">
        delete from ATT_IRR_BASE where IRR_CODE in
        <foreach item="irrCode" collection="array" open="(" separator="," close=")">
            #{irrCode}
        </foreach>
    </delete>

    <insert id="insertAttIrrBase" parameterType="AttIrrBase">
        insert into ATT_IRR_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="irrCode != null">IRR_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="irrName != null">IRR_NAME,</if>
            <if test="lowLeftLong != null">LOW_LEFT_LONG,</if>
            <if test="lowLeftLat != null">LOW_LEFT_LAT,</if>
            <if test="upRightLong != null">UP_RIGHT_LONG,</if>
            <if test="upRightLat != null">UP_RIGHT_LAT,</if>
            <if test="irrRang != null">IRR_RANG,</if>
            <if test="wausType != null">WAUS_TYPE,</if>
            <if test="wasoType != null">WASO_TYPE,</if>
            <if test="engScal != null">ENG_SCAL,</if>
            <if test="totIrrArea != null">TOT_IRR_AREA,</if>
            <if test="effIrrArea != null">EFF_IRR_AREA,</if>
            <if test="desIrrArea != null">DES_IRR_AREA,</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="irrCode != null">#{irrCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="irrName != null">#{irrName},</if>
            <if test="lowLeftLong != null">#{lowLeftLong},</if>
            <if test="lowLeftLat != null">#{lowLeftLat},</if>
            <if test="upRightLong != null">#{upRightLong},</if>
            <if test="upRightLat != null">#{upRightLat},</if>
            <if test="irrRang != null">#{irrRang},</if>
            <if test="wausType != null">#{wausType},</if>
            <if test="wasoType != null">#{wasoType},</if>
            <if test="engScal != null">#{engScal},</if>
            <if test="totIrrArea != null">#{totIrrArea},</if>
            <if test="effIrrArea != null">#{effIrrArea},</if>
            <if test="desIrrArea != null">#{desIrrArea},</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="updateAttIrrBase" parameterType="AttIrrBase">
        update ATT_IRR_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="irrName != null">IRR_NAME = #{irrName},</if>
            <if test="lowLeftLong != null">LOW_LEFT_LONG = #{lowLeftLong},</if>
            <if test="lowLeftLat != null">LOW_LEFT_LAT = #{lowLeftLat},</if>
            <if test="upRightLong != null">UP_RIGHT_LONG = #{upRightLong},</if>
            <if test="upRightLat != null">UP_RIGHT_LAT = #{upRightLat},</if>
            <if test="irrRang != null">IRR_RANG = #{irrRang},</if>
            <if test="wausType != null">WAUS_TYPE = #{wausType},</if>
            <if test="wasoType != null">WASO_TYPE = #{wasoType},</if>
            <if test="engScal != null">ENG_SCAL = #{engScal},</if>
            <if test="totIrrArea != null">TOT_IRR_AREA = #{totIrrArea},</if>
            <if test="effIrrArea != null">EFF_IRR_AREA = #{effIrrArea},</if>
            <if test="desIrrArea != null">DES_IRR_AREA = #{desIrrArea},</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 IRR_CODE = #{irrCode}
    </update>

</mapper>
