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

    <resultMap type="AttBridBase" id="AttBridBaseResult">
        <result property="bridCode" column="BRID_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="bridName" column="BRID_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="bridLoc" column="BRID_LOC"/>
        <result property="mainBridYtpe" column="MAIN_BRID_YTYPE"/>
        <result property="mainBridLen" column="MAIN_BRID_LEN"/>
        <result property="mainBridWid" column="MAIN_BRID_WID"/>
        <result property="mainBridHoleNum" column="MAIN_BRID_HOLE_NUM"/>
        <result property="depuBridHoleNum" column="DEPU_BRID_HOLE_NUM"/>
        <result property="mainBridHoleNetSpan" column="MAIN_BRID_HOLE_NET_SPAN"/>
        <result property="bridDesLoad" column="BRID_DES_LOAD"/>
        <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="selectAttBridBaseVo">
        select BRID_CODE, COLL_DATE, BRID_NAME, START_LONG, START_LAT, END_LONG, END_LAT, BRID_LOC,
               MAIN_BRID_YTYPE, MAIN_BRID_LEN, MAIN_BRID_WID, MAIN_BRID_HOLE_NUM, DEPU_BRID_HOLE_NUM,
               MAIN_BRID_HOLE_NET_SPAN, BRID_DES_LOAD, ENG_STAT, RUN_STAT, START_DATE, COMP_DATE, NOTE, UPD_DATE
        from ATT_BRID_BASE
    </sql>

    <select id="selectAttBridBaseList" parameterType="AttBridBase" resultMap="AttBridBaseResult">
        <include refid="selectAttBridBaseVo"/>
        <where>
            <if test="bridName != null and bridName != ''">
                and BRID_NAME like concat('%', #{bridName}, '%')
            </if>
            <if test="mainBridYtpe != null and mainBridYtpe != ''">
                and MAIN_BRID_YTYPE = #{mainBridYtpe}
            </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 BRID_CODE
    </select>

    <select id="selectAttBridBaseById" parameterType="String" resultMap="AttBridBaseResult">
        <include refid="selectAttBridBaseVo"/>
        where BRID_CODE = #{bridCode}
    </select>

    <delete id="deleteAttBridBaseById" parameterType="String">
        delete from ATT_BRID_BASE where BRID_CODE = #{bridCode}
    </delete>

    <delete id="deleteAttBridBaseByIds" parameterType="String">
        delete from ATT_BRID_BASE where BRID_CODE in
        <foreach item="bridCode" collection="array" open="(" separator="," close=")">
            #{bridCode}
        </foreach>
    </delete>

    <insert id="insertAttBridBase" parameterType="AttBridBase">
        insert into ATT_BRID_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bridCode != null">BRID_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="bridName != null">BRID_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="bridLoc != null">BRID_LOC,</if>
            <if test="mainBridYtpe != null">MAIN_BRID_YTYPE,</if>
            <if test="mainBridLen != null">MAIN_BRID_LEN,</if>
            <if test="mainBridWid != null">MAIN_BRID_WID,</if>
            <if test="mainBridHoleNum != null">MAIN_BRID_HOLE_NUM,</if>
            <if test="depuBridHoleNum != null">DEPU_BRID_HOLE_NUM,</if>
            <if test="mainBridHoleNetSpan != null">MAIN_BRID_HOLE_NET_SPAN,</if>
            <if test="bridDesLoad != null">BRID_DES_LOAD,</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="bridCode != null">#{bridCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="bridName != null">#{bridName},</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="bridLoc != null">#{bridLoc},</if>
            <if test="mainBridYtpe != null">#{mainBridYtpe},</if>
            <if test="mainBridLen != null">#{mainBridLen},</if>
            <if test="mainBridWid != null">#{mainBridWid},</if>
            <if test="mainBridHoleNum != null">#{mainBridHoleNum},</if>
            <if test="depuBridHoleNum != null">#{depuBridHoleNum},</if>
            <if test="mainBridHoleNetSpan != null">#{mainBridHoleNetSpan},</if>
            <if test="bridDesLoad != null">#{bridDesLoad},</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="updateAttBridBase" parameterType="AttBridBase">
        update ATT_BRID_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="bridName != null">BRID_NAME = #{bridName},</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="bridLoc != null">BRID_LOC = #{bridLoc},</if>
            <if test="mainBridYtpe != null">MAIN_BRID_YTYPE = #{mainBridYtpe},</if>
            <if test="mainBridLen != null">MAIN_BRID_LEN = #{mainBridLen},</if>
            <if test="mainBridWid != null">MAIN_BRID_WID = #{mainBridWid},</if>
            <if test="mainBridHoleNum != null">MAIN_BRID_HOLE_NUM = #{mainBridHoleNum},</if>
            <if test="depuBridHoleNum != null">DEPU_BRID_HOLE_NUM = #{depuBridHoleNum},</if>
            <if test="mainBridHoleNetSpan != null">MAIN_BRID_HOLE_NET_SPAN = #{mainBridHoleNetSpan},</if>
            <if test="bridDesLoad != null">BRID_DES_LOAD = #{bridDesLoad},</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 BRID_CODE = #{bridCode}
    </update>

</mapper>
