<?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.yjjt.mapper.YjjtStationMapper">

    <resultMap type="com.goldenwater.yjjt.domain.YjjtStation" id="YjjtStationResult">
        <result property="stcd"       column="stcd"       />
        <result property="stnm"       column="stnm"       />
        <result property="sttp"       column="sttp"       />
        <result property="rvnm"       column="rvnm"       />
        <result property="hnnm"       column="hnnm"       />
        <result property="bsnm"       column="bsnm"       />
        <result property="stlc"       column="stlc"       />
        <result property="lgtd"       column="lgtd"       />
        <result property="lttd"       column="lttd"       />
        <result property="addvcd"     column="addvcd"     />
        <result property="jcdw"       column="jcdw"       />
        <result property="jcpc"       column="jcpc"       />
        <result property="jcxm"       column="jcxm"       />
        <result property="flag"       column="flag"       />
        <result property="dbcd"       column="dbcd"       />
        <result property="year"       column="year"       />
        <result property="prov"       column="prov"       />
        <result property="delFlag"    column="del_flag"   />
        <result property="createBy"   column="create_by"  />
        <result property="createTime" column="create_time"/>
        <result property="updateBy"   column="update_by"  />
        <result property="updateTime" column="update_time"/>
        <result property="remark"     column="remark"     />
    </resultMap>

    <sql id="selectYjjtStationVo">
        select stcd, stnm, sttp, rvnm, hnnm, bsnm, stlc, lgtd, lttd, addvcd, jcdw, jcpc, jcxm, flag, dbcd, year, prov, del_flag, create_by, create_time, update_by, update_time, remark
        from YJJT_STATION
    </sql>

    <select id="selectYjjtStationList" parameterType="com.goldenwater.yjjt.domain.YjjtStation" resultMap="YjjtStationResult">
        <include refid="selectYjjtStationVo" />
        where del_flag = '0'
        <if test="stcd != null and stcd != ''">
            and stcd like concat('%', #{stcd}, '%')
        </if>
        <if test="stnm != null and stnm != ''">
            and stnm like concat('%', #{stnm}, '%')
        </if>
        <if test="sttp != null and sttp != ''">
            and sttp = #{sttp}
        </if>
        <if test="rvnm != null and rvnm != ''">
            and rvnm like concat('%', #{rvnm}, '%')
        </if>
        <if test="addvcd != null and addvcd != ''">
            and addvcd = #{addvcd}
        </if>
        <if test="jcxm != null and jcxm != ''">
            and jcxm = #{jcxm}
        </if>
        <if test="prov != null and prov != ''">
            and prov = #{prov}
        </if>
        <if test="year != null and year != ''">
            and year = #{year}
        </if>
        order by year desc,stcd asc
    </select>

    <select id="selectYjjtStationByPk" resultMap="YjjtStationResult">
        <include refid="selectYjjtStationVo" />
        where stcd = #{stcd} and year = #{year}
    </select>

    <insert id="insertYjjtStation" parameterType="com.goldenwater.yjjt.domain.YjjtStation">
        insert into YJJT_STATION
        <trim prefix="(" suffix=")" suffixOverrides=",">
            stcd,
            <if test="stnm != null">stnm,</if>
            <if test="sttp != null">sttp,</if>
            <if test="rvnm != null">rvnm,</if>
            <if test="hnnm != null">hnnm,</if>
            <if test="bsnm != null">bsnm,</if>
            <if test="stlc != null">stlc,</if>
            <if test="lgtd != null">lgtd,</if>
            <if test="lttd != null">lttd,</if>
            <if test="addvcd != null">addvcd,</if>
            <if test="jcdw != null">jcdw,</if>
            <if test="jcpc != null">jcpc,</if>
            <if test="jcxm != null">jcxm,</if>
            <if test="flag != null">flag,</if>
            <if test="dbcd != null">dbcd,</if>
            year,
            <if test="prov != null">prov,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            create_time,
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{stcd},
            <if test="stnm != null">#{stnm},</if>
            <if test="sttp != null">#{sttp},</if>
            <if test="rvnm != null">#{rvnm},</if>
            <if test="hnnm != null">#{hnnm},</if>
            <if test="bsnm != null">#{bsnm},</if>
            <if test="stlc != null">#{stlc},</if>
            <if test="lgtd != null">#{lgtd},</if>
            <if test="lttd != null">#{lttd},</if>
            <if test="addvcd != null">#{addvcd},</if>
            <if test="jcdw != null">#{jcdw},</if>
            <if test="jcpc != null">#{jcpc},</if>
            <if test="jcxm != null">#{jcxm},</if>
            <if test="flag != null">#{flag},</if>
            <if test="dbcd != null">#{dbcd},</if>
            #{year},
            <if test="prov != null">#{prov},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            SYSDATE,
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateYjjtStation" parameterType="com.goldenwater.yjjt.domain.YjjtStation">
        update YJJT_STATION
        <trim prefix="SET" suffixOverrides=",">
            <if test="stnm != null">stnm = #{stnm},</if>
            <if test="sttp != null">sttp = #{sttp},</if>
            <if test="rvnm != null">rvnm = #{rvnm},</if>
            <if test="hnnm != null">hnnm = #{hnnm},</if>
            <if test="bsnm != null">bsnm = #{bsnm},</if>
            <if test="stlc != null">stlc = #{stlc},</if>
            <if test="lgtd != null">lgtd = #{lgtd},</if>
            <if test="lttd != null">lttd = #{lttd},</if>
            <if test="addvcd != null">addvcd = #{addvcd},</if>
            <if test="jcdw != null">jcdw = #{jcdw},</if>
            <if test="jcpc != null">jcpc = #{jcpc},</if>
            <if test="jcxm != null">jcxm = #{jcxm},</if>
            <if test="flag != null">flag = #{flag},</if>
            <if test="dbcd != null">dbcd = #{dbcd},</if>
            <if test="prov != null">prov = #{prov},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            update_time = SYSDATE,
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where stcd = #{stcd} and year = #{year}
    </update>

    <delete id="deleteYjjtStationByPk" parameterType="String">
        delete from YJJT_STATION where stcd = #{stcd} and year = #{year}
    </delete>

    <delete id="deleteYjjtStationByPks" parameterType="com.goldenwater.yjjt.domain.YjjtStation">
        delete from YJJT_STATION where (stcd, year) in
        <foreach item="item" collection="list" open="(" separator="," close=")">
            (#{item.stcd}, #{item.year})
        </foreach>
    </delete>
</mapper>
