<?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.hw.mes.mapper.MesBaseRouteProcessMapper">
    
    <resultMap type="MesBaseRouteProcess" id="MesBaseRouteProcessResult">
        <result property="routeProcessId"    column="route_process_id"    />
        <result property="routeId"    column="route_id"    />
        <result property="processId"    column="process_id"    />
        <result property="processOrder"    column="process_order"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectMesBaseRouteProcessVo">
        select route_process_id, route_id, process_id, process_order, remark, create_by, create_time, update_by, update_time from mes_base_route_process
    </sql>

    <select id="selectMesBaseRouteProcessList" parameterType="MesBaseRouteProcess" resultMap="MesBaseRouteProcessResult">
        <include refid="selectMesBaseRouteProcessVo"/>
        <where>  
            <if test="routeId != null "> and route_id = #{routeId}</if>
            <if test="processId != null "> and process_id = #{processId}</if>
            <if test="processOrder != null "> and process_order = #{processOrder}</if>
            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="updateBy != null  and updateBy != ''"> and update_by = #{updateBy}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectMesBaseRouteProcessByRouteProcessId" parameterType="Long" resultMap="MesBaseRouteProcessResult">
        <include refid="selectMesBaseRouteProcessVo"/>
        where route_process_id = #{routeProcessId}
    </select>
        
    <insert id="insertMesBaseRouteProcess" parameterType="MesBaseRouteProcess" useGeneratedKeys="true" keyProperty="routeProcessId">
        insert into mes_base_route_process
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="routeId != null">route_id,</if>
            <if test="processId != null">process_id,</if>
            <if test="processOrder != null">process_order,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="routeId != null">#{routeId},</if>
            <if test="processId != null">#{processId},</if>
            <if test="processOrder != null">#{processOrder},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateMesBaseRouteProcess" parameterType="MesBaseRouteProcess">
        update mes_base_route_process
        <trim prefix="SET" suffixOverrides=",">
            <if test="routeId != null">route_id = #{routeId},</if>
            <if test="processId != null">process_id = #{processId},</if>
            <if test="processOrder != null">process_order = #{processOrder},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where route_process_id = #{routeProcessId}
    </update>

    <delete id="deleteMesBaseRouteProcessByRouteProcessId" parameterType="Long">
        delete from mes_base_route_process where route_process_id = #{routeProcessId}
    </delete>

    <delete id="deleteMesBaseRouteProcessByRouteProcessIds" parameterType="String">
        delete from mes_base_route_process where route_process_id in 
        <foreach item="routeProcessId" collection="array" open="(" separator="," close=")">
            #{routeProcessId}
        </foreach>
    </delete>
</mapper>