<?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.xinelu.manage.mapper.patientnodeparamslcurrent.PatientNodeParamsCurrentMapper">

    <resultMap type="PatientNodeParamsCurrent" id="PatientNodeParamsCurrentResult">
            <result property="id" column="id"/>
            <result property="patientId" column="patient_id"/>
            <result property="patientName" column="patient_name"/>
            <result property="taskPartitionDictId" column="task_partition_dict_id"/>
            <result property="taskPartitionDictName" column="task_partition_dict_name"/>
            <result property="taskTypeId" column="task_type_id"/>
            <result property="taskTypeName" column="task_type_name"/>
            <result property="routeId" column="route_id"/>
            <result property="routeName" column="route_name"/>
            <result property="routeNodeId" column="route_node_id"/>
            <result property="routeNodeName" column="route_node_name"/>
	        <result property="paramName" column="param_name"/>
            <result property="paramKey" column="param_key"/>
            <result property="paramValue" column="param_value"/>
		    <result property="manageRouteNodeId" column="manage_route_node_id"/>
		    <result property="portraitSn" column="portrait_sn"/>
            <result property="createTime" column="create_time"/>
            <result property="updateBy" column="update_by"/>
            <result property="updateTime" column="update_time"/>
            <result property="createBy" column="create_by"/>
    </resultMap>

    <sql id="selectPatientNodeParamsCurrentVo">
        select id, patient_id, patient_name, task_partition_dict_id, task_partition_dict_name, task_type_id, task_type_name, route_id, route_name, route_node_id, route_node_name, param_name, param_key, param_value,manage_route_node_id, portrait_sn, create_time, update_by, update_time, create_by from patient_node_params_current
    </sql>

    <select id="selectPatientNodeParamsCurrentList" parameterType="PatientNodeParamsCurrent" resultMap="PatientNodeParamsCurrentResult">
        <include refid="selectPatientNodeParamsCurrentVo"/>
        <where>
                        <if test="patientId != null ">
                            and patient_id = #{patientId}
                        </if>
                        <if test="patientName != null  and patientName != ''">
                            and patient_name like concat('%', #{patientName}, '%')
                        </if>
                        <if test="taskPartitionDictId != null ">
                            and task_partition_dict_id = #{taskPartitionDictId}
                        </if>
                        <if test="taskPartitionDictName != null  and taskPartitionDictName != ''">
                            and task_partition_dict_name like concat('%', #{taskPartitionDictName}, '%')
                        </if>
                        <if test="taskTypeId != null ">
                            and task_type_id = #{taskTypeId}
                        </if>
                        <if test="taskTypeName != null  and taskTypeName != ''">
                            and task_type_name like concat('%', #{taskTypeName}, '%')
                        </if>
                        <if test="routeId != null ">
                            and route_id = #{routeId}
                        </if>
                        <if test="routeName != null  and routeName != ''">
                            and route_name like concat('%', #{routeName}, '%')
                        </if>
                        <if test="routeNodeId != null ">
                            and route_node_id = #{routeNodeId}
                        </if>
                        <if test="routeNodeName != null  and routeNodeName != ''">
                            and route_node_name like concat('%', #{routeNodeName}, '%')
                        </if>
				        <if test="paramName != null  and paramName != ''">
					        and param_name = #{paramName}
				        </if>
                        <if test="paramKey != null  and paramKey != ''">
                            and param_key = #{paramKey}
                        </if>
                        <if test="paramValue != null  and paramValue != ''">
                            and param_value = #{paramValue}
                        </if>
        </where>
    </select>

    <select id="selectPatientNodeParamsCurrentById" parameterType="Long"
            resultMap="PatientNodeParamsCurrentResult">
            <include refid="selectPatientNodeParamsCurrentVo"/>
            where id = #{id}
    </select>

    <insert id="insertPatientNodeParamsCurrent" parameterType="PatientNodeParamsCurrent" useGeneratedKeys="true"
            keyProperty="id">
        insert into patient_node_params_current
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="patientId != null">patient_id,
                    </if>
                    <if test="patientName != null">patient_name,
                    </if>
                    <if test="taskPartitionDictId != null">task_partition_dict_id,
                    </if>
                    <if test="taskPartitionDictName != null">task_partition_dict_name,
                    </if>
                    <if test="taskTypeId != null">task_type_id,
                    </if>
                    <if test="taskTypeName != null">task_type_name,
                    </if>
                    <if test="routeId != null">route_id,
                    </if>
                    <if test="routeName != null">route_name,
                    </if>
                    <if test="routeNodeId != null">route_node_id,
                    </if>
                    <if test="routeNodeName != null">route_node_name,
                    </if>
			        <if test="paramName != null">param_name,
			        </if>
                    <if test="paramKey != null">param_key,
                    </if>
                    <if test="paramValue != null">param_value,
                    </if>
			        <if test="manageRouteNodeId != null">manage_route_node_id,
			        </if>
			        <if test="portraitSn != null">portrait_sn,
			        </if>
                    <if test="createTime != null">create_time,
                    </if>
                    <if test="updateBy != null">update_by,
                    </if>
                    <if test="updateTime != null">update_time,
                    </if>
                    <if test="createBy != null">create_by,
                    </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="patientId != null">#{patientId},
                    </if>
                    <if test="patientName != null">#{patientName},
                    </if>
                    <if test="taskPartitionDictId != null">#{taskPartitionDictId},
                    </if>
                    <if test="taskPartitionDictName != null">#{taskPartitionDictName},
                    </if>
                    <if test="taskTypeId != null">#{taskTypeId},
                    </if>
                    <if test="taskTypeName != null">#{taskTypeName},
                    </if>
                    <if test="routeId != null">#{routeId},
                    </if>
                    <if test="routeName != null">#{routeName},
                    </if>
                    <if test="routeNodeId != null">#{routeNodeId},
                    </if>
                    <if test="routeNodeName != null">#{routeNodeName},
                    </if>
			        <if test="paramName != null">#{paramName},
			        </if>
                    <if test="paramKey != null">#{paramKey},
                    </if>
                    <if test="paramValue != null">#{paramValue},
                    </if>
			        <if test="manageRouteNodeId != null">#{manageRouteNodeId},
			        </if>
			        <if test="portraitSn != null">#{portraitSn},
			        </if>
                    <if test="createTime != null">#{createTime},
                    </if>
                    <if test="updateBy != null">#{updateBy},
                    </if>
                    <if test="updateTime != null">#{updateTime},
                    </if>
                    <if test="createBy != null">#{createBy},
                    </if>
        </trim>
    </insert>

    <update id="updatePatientNodeParamsCurrent" parameterType="PatientNodeParamsCurrent">
        update patient_node_params_current
        <trim prefix="SET" suffixOverrides=",">
                    <if test="patientId != null">patient_id =
                        #{patientId},
                    </if>
                    <if test="patientName != null">patient_name =
                        #{patientName},
                    </if>
                    <if test="taskPartitionDictId != null">task_partition_dict_id =
                        #{taskPartitionDictId},
                    </if>
                    <if test="taskPartitionDictName != null">task_partition_dict_name =
                        #{taskPartitionDictName},
                    </if>
                    <if test="taskTypeId != null">task_type_id =
                        #{taskTypeId},
                    </if>
                    <if test="taskTypeName != null">task_type_name =
                        #{taskTypeName},
                    </if>
                    <if test="routeId != null">route_id =
                        #{routeId},
                    </if>
                    <if test="routeName != null">route_name =
                        #{routeName},
                    </if>
                    <if test="routeNodeId != null">route_node_id =
                        #{routeNodeId},
                    </if>
                    <if test="routeNodeName != null">route_node_name =
                        #{routeNodeName},
                    </if>
			        <if test="paramName != null">param_name =
				        #{paramName},
			        </if>
                    <if test="paramKey != null">param_key =
                        #{paramKey},
                    </if>
                    <if test="paramValue != null">param_value =
                        #{paramValue},
                    </if>
			        <if test="manageRouteNodeId != null">manage_route_node_id =
				        #{manageRouteNodeId},
			        </if>
			        <if test="portraitSn != null">portrait_sn =
				        #{portraitSn},
			        </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>
                    <if test="createBy != null">create_by =
                        #{createBy},
                    </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePatientNodeParamsCurrentById" parameterType="Long">
        delete from patient_node_params_current where id = #{id}
    </delete>

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

	<insert id="insertList">
		insert into patient_node_params_current
		    (patient_id, patient_name, task_partition_dict_id, task_partition_dict_name,
		     task_type_id, task_type_name, route_id, route_name, route_node_id, route_node_name,
		     param_name, param_key, param_value, manage_route_node_id, portrait_sn, create_time, update_by, update_time, create_by)
		values
		<foreach collection="list" separator="," item="item">
			(#{item.patientId}, #{item.patientName}, #{item.taskPartitionDictId}, #{item.taskPartitionDictName},
			#{item.taskTypeId}, #{item.taskTypeName}, #{item.routeId},
			#{item.routeName}, #{item.routeNodeId}, #{item.routeNodeName},
			#{item.paramName},#{item.paramKey},#{item.paramValue},#{item.manageRouteNodeId},#{item.portraitSn}, #{item.createTime}, #{item.updateBy},
			#{item.updateTime}, #{item.createBy}
			)
		</foreach>
	</insert>

</mapper>