<?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.ruoyi.execution.produce.dispersed.mapper.BpmExecuteProcessMapper">
    
    <resultMap type="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteProcess" id="BpmExecuteProcessResult">
        <result property="id"    column="id"    />
        <result property="taskKey"    column="task_key"    />
        <result property="taskName"    column="task_name"    />
        <result property="taskNodeKey"    column="task_node_key"    />
        <result property="taskProcessKey"    column="task_process_key"    />
        <result property="taskProcessXmlContent"    column="task_process_xml_content"    />
        <result property="taskProcessState"    column="task_process_state"    />
        <result property="taskProcessNote"    column="task_process_note"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="remark"    column="remark"    />
        <result property="taskProcessType"    column="task_process_type"    />
    </resultMap>

    <sql id="selectBpmExecuteProcessVo">
        select id, task_key, task_name, task_node_key, task_process_key, task_process_xml_content, task_process_state, task_process_note, del_flag, remark, task_process_type from bpm_execute_process
    </sql>

    <select id="selectBpmExecuteProcessList" parameterType="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteProcess" resultMap="BpmExecuteProcessResult">
        <include refid="selectBpmExecuteProcessVo"/>
        <where>  
            <if test="taskKey != null  and taskKey != ''"> and task_key = #{taskKey}</if>
            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
            <if test="taskNodeKey != null  and taskNodeKey != ''"> and task_node_key = #{taskNodeKey}</if>
            <if test="taskProcessKey != null  and taskProcessKey != ''"> and task_process_key = #{taskProcessKey}</if>
            <if test="taskProcessXmlContent != null  and taskProcessXmlContent != ''"> and task_process_xml_content = #{taskProcessXmlContent}</if>
            <if test="taskProcessState != null "> and task_process_state = #{taskProcessState}</if>
            <if test="taskProcessNote != null  and taskProcessNote != ''"> and task_process_note = #{taskProcessNote}</if>
            <if test="taskProcessType != null  and taskProcessType != ''"> and task_process_type = #{taskProcessType}</if>
        </where>
    </select>
    
    <select id="selectBpmExecuteProcessById" parameterType="Long" resultMap="BpmExecuteProcessResult">
        <include refid="selectBpmExecuteProcessVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBpmExecuteProcess" parameterType="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteProcess" useGeneratedKeys="true" keyProperty="id">
        insert into bpm_execute_process
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskKey != null">task_key,</if>
            <if test="taskName != null">task_name,</if>
            <if test="taskNodeKey != null">task_node_key,</if>
            <if test="taskProcessKey != null">task_process_key,</if>
            <if test="taskProcessXmlContent != null">task_process_xml_content,</if>
            <if test="taskProcessState != null">task_process_state,</if>
            <if test="taskProcessNote != null">task_process_note,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="remark != null">remark,</if>
            <if test="taskProcessType != null">task_process_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskKey != null">#{taskKey},</if>
            <if test="taskName != null">#{taskName},</if>
            <if test="taskNodeKey != null">#{taskNodeKey},</if>
            <if test="taskProcessKey != null">#{taskProcessKey},</if>
            <if test="taskProcessXmlContent != null">#{taskProcessXmlContent},</if>
            <if test="taskProcessState != null">#{taskProcessState},</if>
            <if test="taskProcessNote != null">#{taskProcessNote},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="remark != null">#{remark},</if>
            <if test="taskProcessType != null">#{taskProcessType},</if>
         </trim>
    </insert>

    <update id="updateBpmExecuteProcess" parameterType="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteProcess">
        update bpm_execute_process
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskKey != null">task_key = #{taskKey},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="taskNodeKey != null">task_node_key = #{taskNodeKey},</if>
            <if test="taskProcessKey != null">task_process_key = #{taskProcessKey},</if>
            <if test="taskProcessXmlContent != null">task_process_xml_content = #{taskProcessXmlContent},</if>
            <if test="taskProcessState != null">task_process_state = #{taskProcessState},</if>
            <if test="taskProcessNote != null">task_process_note = #{taskProcessNote},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="taskProcessType != null">task_process_type = #{taskProcessType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBpmExecuteProcessById" parameterType="Long">
        delete from bpm_execute_process where id = #{id}
    </delete>

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