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

    <resultMap type="AttKmBase" id="AttKmBaseResult">
        <result property="kmCode" column="KM_CODE"/>
        <result property="kmName" column="KM_NAME"/>
        <result property="adcd" column="ADCD"/>
        <result property="adnm" column="ADNM"/>
        <result property="lgtd" column="LGTD"/>
        <result property="lttd" column="LTTD"/>
        <result property="type" column="TYPE"/>
        <result property="oldCode" column="OLD_CODE"/>
        <result property="gcType" column="GC_TYPE"/>
        <result property="source" column="SOURCE"/>
        <result property="locrc" column="LOCRC"/>
        <result property="loc" column="LOC"/>
        <result property="ewBank" column="EW_BANK"/>
        <result property="snBank" column="SN_BANK"/>
        <result property="rcStat" column="RC_STAT"/>
        <result property="gcForm" column="GC_FORM"/>
        <result property="holeStaNum" column="HOLE_STA_NUM"/>
        <result property="widFlow" column="WID_FLOW"/>
        <result property="hoistForm" column="HOIST_FORM"/>
        <result property="gaTopHig" column="GA_TOP_HIG"/>
        <result property="gaBotHig" column="GA_BOT_HIG"/>
        <result property="desFlow" column="DES_FLOW"/>
        <result property="siteManaUnit" column="SITE_MANA_UNIT"/>
        <result property="phone" column="PHONE"/>
        <result property="comUnit" column="COM_UNIT"/>
        <result property="atlasNum" column="ATLAS_NUM"/>
    </resultMap>

    <sql id="selectAttKmBaseVo">
        select KM_CODE, KM_NAME, ADCD, ADNM, LGTD, LTTD, TYPE, OLD_CODE, GC_TYPE, SOURCE, LOCRC, LOC,
               EW_BANK, SN_BANK, RC_STAT, GC_FORM, HOLE_STA_NUM, WID_FLOW, HOIST_FORM, GA_TOP_HIG,
               GA_BOT_HIG, DES_FLOW, SITE_MANA_UNIT, PHONE, COM_UNIT, ATLAS_NUM
        from ATT_KM_BASE
    </sql>

    <select id="selectAttKmBaseList" parameterType="AttKmBase" resultMap="AttKmBaseResult">
        <include refid="selectAttKmBaseVo"/>
        <where>
            <if test="kmName != null and kmName != ''">
                and KM_NAME like concat('%', #{kmName}, '%')
            </if>
            <if test="type != null and type != ''">
                and TYPE = #{type}
            </if>
            <if test="gcType != null and gcType != ''">
                and GC_TYPE = #{gcType}
            </if>
            <if test="rcStat != null and rcStat != ''">
                and RC_STAT = #{rcStat}
            </if>
        </where>
        order by KM_CODE
    </select>

    <select id="selectAttKmBaseById" parameterType="String" resultMap="AttKmBaseResult">
        <include refid="selectAttKmBaseVo"/>
        where KM_CODE = #{kmCode}
    </select>

    <delete id="deleteAttKmBaseById" parameterType="String">
        delete from ATT_KM_BASE where KM_CODE = #{kmCode}
    </delete>

    <delete id="deleteAttKmBaseByIds" parameterType="String">
        delete from ATT_KM_BASE where KM_CODE in
        <foreach item="kmCode" collection="array" open="(" separator="," close=")">
            #{kmCode}
        </foreach>
    </delete>

    <insert id="insertAttKmBase" parameterType="AttKmBase">
        insert into ATT_KM_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="kmCode != null">KM_CODE,</if>
            <if test="kmName != null">KM_NAME,</if>
            <if test="adcd != null">ADCD,</if>
            <if test="adnm != null">ADNM,</if>
            <if test="lgtd != null">LGTD,</if>
            <if test="lttd != null">LTTD,</if>
            <if test="type != null">TYPE,</if>
            <if test="oldCode != null">OLD_CODE,</if>
            <if test="gcType != null">GC_TYPE,</if>
            <if test="source != null">SOURCE,</if>
            <if test="locrc != null">LOCRC,</if>
            <if test="loc != null">LOC,</if>
            <if test="ewBank != null">EW_BANK,</if>
            <if test="snBank != null">SN_BANK,</if>
            <if test="rcStat != null">RC_STAT,</if>
            <if test="gcForm != null">GC_FORM,</if>
            <if test="holeStaNum != null">HOLE_STA_NUM,</if>
            <if test="widFlow != null">WID_FLOW,</if>
            <if test="hoistForm != null">HOIST_FORM,</if>
            <if test="gaTopHig != null">GA_TOP_HIG,</if>
            <if test="gaBotHig != null">GA_BOT_HIG,</if>
            <if test="desFlow != null">DES_FLOW,</if>
            <if test="siteManaUnit != null">SITE_MANA_UNIT,</if>
            <if test="phone != null">PHONE,</if>
            <if test="comUnit != null">COM_UNIT,</if>
            <if test="atlasNum != null">ATLAS_NUM,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="kmCode != null">#{kmCode},</if>
            <if test="kmName != null">#{kmName},</if>
            <if test="adcd != null">#{adcd},</if>
            <if test="adnm != null">#{adnm},</if>
            <if test="lgtd != null">#{lgtd},</if>
            <if test="lttd != null">#{lttd},</if>
            <if test="type != null">#{type},</if>
            <if test="oldCode != null">#{oldCode},</if>
            <if test="gcType != null">#{gcType},</if>
            <if test="source != null">#{source},</if>
            <if test="locrc != null">#{locrc},</if>
            <if test="loc != null">#{loc},</if>
            <if test="ewBank != null">#{ewBank},</if>
            <if test="snBank != null">#{snBank},</if>
            <if test="rcStat != null">#{rcStat},</if>
            <if test="gcForm != null">#{gcForm},</if>
            <if test="holeStaNum != null">#{holeStaNum},</if>
            <if test="widFlow != null">#{widFlow},</if>
            <if test="hoistForm != null">#{hoistForm},</if>
            <if test="gaTopHig != null">#{gaTopHig},</if>
            <if test="gaBotHig != null">#{gaBotHig},</if>
            <if test="desFlow != null">#{desFlow},</if>
            <if test="siteManaUnit != null">#{siteManaUnit},</if>
            <if test="phone != null">#{phone},</if>
            <if test="comUnit != null">#{comUnit},</if>
            <if test="atlasNum != null">#{atlasNum},</if>
        </trim>
    </insert>

    <update id="updateAttKmBase" parameterType="AttKmBase">
        update ATT_KM_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="kmName != null">KM_NAME = #{kmName},</if>
            <if test="adcd != null">ADCD = #{adcd},</if>
            <if test="adnm != null">ADNM = #{adnm},</if>
            <if test="lgtd != null">LGTD = #{lgtd},</if>
            <if test="lttd != null">LTTD = #{lttd},</if>
            <if test="type != null">TYPE = #{type},</if>
            <if test="oldCode != null">OLD_CODE = #{oldCode},</if>
            <if test="gcType != null">GC_TYPE = #{gcType},</if>
            <if test="source != null">SOURCE = #{source},</if>
            <if test="locrc != null">LOCRC = #{locrc},</if>
            <if test="loc != null">LOC = #{loc},</if>
            <if test="ewBank != null">EW_BANK = #{ewBank},</if>
            <if test="snBank != null">SN_BANK = #{snBank},</if>
            <if test="rcStat != null">RC_STAT = #{rcStat},</if>
            <if test="gcForm != null">GC_FORM = #{gcForm},</if>
            <if test="holeStaNum != null">HOLE_STA_NUM = #{holeStaNum},</if>
            <if test="widFlow != null">WID_FLOW = #{widFlow},</if>
            <if test="hoistForm != null">HOIST_FORM = #{hoistForm},</if>
            <if test="gaTopHig != null">GA_TOP_HIG = #{gaTopHig},</if>
            <if test="gaBotHig != null">GA_BOT_HIG = #{gaBotHig},</if>
            <if test="desFlow != null">DES_FLOW = #{desFlow},</if>
            <if test="siteManaUnit != null">SITE_MANA_UNIT = #{siteManaUnit},</if>
            <if test="phone != null">PHONE = #{phone},</if>
            <if test="comUnit != null">COM_UNIT = #{comUnit},</if>
            <if test="atlasNum != null">ATLAS_NUM = #{atlasNum},</if>
        </trim>
        where KM_CODE = #{kmCode}
    </update>

</mapper>
