<?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.slaj.eme.mapper.BusiTrainRecordMapper">
    <resultMap type="com.goldenwater.slaj.eme.domain.BusiTrainRecord" id="BusiTrainRecordResult">
        <result property="trGuid" column="tr_guid"/>
        <result property="basicId" column="basic_id"/>
        <result property="trainType" column="train_type"/>
        <result property="trainTime" column="train_time"/>
        <result property="partNum" column="part_num"/>
        <result property="trainCont" column="train_cont"/>
        <result property="orgGuid" column="org_guid"/>
        <result property="creperGuid" column="creper_guid"/>
        <result property="createTime" column="create_time"/>
        <result property="updperGuid" column="updper_guid"/>
        <result property="updateTime" column="update_time"/>
        <result property="trainName" column="train_name"/>
        <result property="trainAddr" column="train_addr"/>
    </resultMap>
    <sql id="selectBusiTrainRecordVo">
        select tr_guid, basic_id, train_type, train_time, part_num, train_cont,
               org_guid, creper_guid, create_time, updper_guid, update_time,
               train_name, train_addr
        from t_busi_train_record
    </sql>
    <select id="selectBusiTrainRecordByGuid" parameterType="String" resultMap="BusiTrainRecordResult">
        <include refid="selectBusiTrainRecordVo"/>
        where tr_guid = #{trGuid}
    </select>
    <select id="selectBusiTrainRecordList" parameterType="com.goldenwater.slaj.eme.domain.BusiTrainRecord" resultMap="BusiTrainRecordResult">
        <include refid="selectBusiTrainRecordVo"/>
        <where>
            <if test="trainName != null and trainName != ''">AND train_name like concat('%', #{trainName}, '%')</if>
            <if test="basicId != null and basicId != ''">AND basic_id = #{basicId}</if>
            <if test="trainType != null and trainType != ''">AND train_type = #{trainType}</if>
        </where>
    </select>
    <insert id="insertBusiTrainRecord" parameterType="com.goldenwater.slaj.eme.domain.BusiTrainRecord">
        insert into t_busi_train_record (
            tr_guid, basic_id, train_type, train_time, part_num, train_cont,
            org_guid, creper_guid, create_time, updper_guid, update_time,
            train_name, train_addr
        ) values (
            #{trGuid}, #{basicId}, #{trainType}, #{trainTime}, #{partNum}, #{trainCont},
            #{orgGuid}, #{creperGuid}, #{createTime}, #{updperGuid}, #{updateTime},
            #{trainName}, #{trainAddr}
        )
    </insert>
    <update id="updateBusiTrainRecord" parameterType="com.goldenwater.slaj.eme.domain.BusiTrainRecord">
        update t_busi_train_record
        <set>
            <if test="basicId != null">basic_id = #{basicId},</if>
            <if test="trainType != null">train_type = #{trainType},</if>
            <if test="trainTime != null">train_time = #{trainTime},</if>
            <if test="partNum != null">part_num = #{partNum},</if>
            <if test="trainCont != null">train_cont = #{trainCont},</if>
            <if test="orgGuid != null">org_guid = #{orgGuid},</if>
            <if test="creperGuid != null">creper_guid = #{creperGuid},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updperGuid != null">updper_guid = #{updperGuid},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="trainName != null">train_name = #{trainName},</if>
            <if test="trainAddr != null">train_addr = #{trainAddr},</if>
        </set>
        where tr_guid = #{trGuid}
    </update>
    <delete id="deleteBusiTrainRecordByGuid" parameterType="String">
        delete from t_busi_train_record where tr_guid = #{trGuid}
    </delete>
    <delete id="deleteBusiTrainRecordByGuids" parameterType="String">
        delete from t_busi_train_record where tr_guid in
        <foreach item="trGuid" collection="array" open="(" separator="," close=")">
            #{trGuid}
        </foreach>
    </delete>
</mapper>
