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

    <resultMap type="AttPoldBase" id="AttPoldBaseResult">
        <result property="poldCode" column="POLD_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="poldName" column="POLD_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="poldLoc" column="POLD_LOC"/>
        <result property="poldClas" column="POLD_CLAS"/>
        <result property="desFlow" column="DES_FLOW"/>
        <result property="opPr" column="OP_PR"/>
        <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="selectAttPoldBaseVo">
        select POLD_CODE, COLL_DATE, POLD_NAME, LOW_LEFT_LONG, LOW_LEFT_LAT, UP_RIGHT_LONG, UP_RIGHT_LAT,
               POLD_LOC, POLD_CLAS, DES_FLOW, OP_PR, ENG_STAT, RUN_STAT, START_DATE, COMP_DATE, NOTE, UPD_DATE
        from ATT_POLD_BASE
    </sql>

    <select id="selectAttPoldBaseList" parameterType="AttPoldBase" resultMap="AttPoldBaseResult">
        <include refid="selectAttPoldBaseVo"/>
        <where>
            <if test="poldName != null and poldName != ''">
                and POLD_NAME like concat('%', #{poldName}, '%')
            </if>
            <if test="poldClas != null and poldClas != ''">
                and POLD_CLAS = #{poldClas}
            </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 POLD_CODE
    </select>

    <select id="selectAttPoldBaseById" parameterType="String" resultMap="AttPoldBaseResult">
        <include refid="selectAttPoldBaseVo"/>
        where POLD_CODE = #{poldCode}
    </select>

    <delete id="deleteAttPoldBaseById" parameterType="String">
        delete from ATT_POLD_BASE where POLD_CODE = #{poldCode}
    </delete>

    <delete id="deleteAttPoldBaseByIds" parameterType="String">
        delete from ATT_POLD_BASE where POLD_CODE in
        <foreach item="poldCode" collection="array" open="(" separator="," close=")">
            #{poldCode}
        </foreach>
    </delete>

    <insert id="insertAttPoldBase" parameterType="AttPoldBase">
        insert into ATT_POLD_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="poldCode != null">POLD_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="poldName != null">POLD_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="poldLoc != null">POLD_LOC,</if>
            <if test="poldClas != null">POLD_CLAS,</if>
            <if test="desFlow != null">DES_FLOW,</if>
            <if test="opPr != null">OP_PR,</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="poldCode != null">#{poldCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="poldName != null">#{poldName},</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="poldLoc != null">#{poldLoc},</if>
            <if test="poldClas != null">#{poldClas},</if>
            <if test="desFlow != null">#{desFlow},</if>
            <if test="opPr != null">#{opPr},</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="updateAttPoldBase" parameterType="AttPoldBase">
        update ATT_POLD_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="poldName != null">POLD_NAME = #{poldName},</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="poldLoc != null">POLD_LOC = #{poldLoc},</if>
            <if test="poldClas != null">POLD_CLAS = #{poldClas},</if>
            <if test="desFlow != null">DES_FLOW = #{desFlow},</if>
            <if test="opPr != null">OP_PR = #{opPr},</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 POLD_CODE = #{poldCode}
    </update>

</mapper>
