<?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="SDtpYypzFollowUpSopMapper" >
    <!-- 通用查询映射结果 -->

    <select id="selectSDtpYypzFollowUpSopList" parameterType="pd" resultType="pd">
        select up.*,dr.productName,dr.productCode,dr.specification from s_dtp_yypz_follow_up_sop up  left join s_dtp_yypz_template_drug dr on up.templateId=dr.templateId where 1=1
        <if test="id !=null and id !='' ">
            and up.id = #{id}
        </if>
        <if test="query != null and query != ''">
            AND (dr.productName LIKE CONCAT('%', #{query}, '%') OR dr.productCode LIKE CONCAT('%', #{query}, '%'))
        </if>
        <if test="businessBelonging !=null and businessBelonging !='' ">
            and up.businessBelonging = #{businessBelonging}
        </if>
        <if test="templateName !=null and templateName !='' ">
            and up.templateName = #{templateName}
        </if>
        <if test="templateId !=null and templateId !='' ">
            and up.templateId = #{templateId}
        </if>
        <if test="storeName !=null and storeName !='' ">
            and up.storeName= #{storeName}
        </if>
        <if test="storeId !=null and storeId !='' ">
            and up.storeId=  #{storeId}
        </if>
        <if test="createdBy !=null and createdBy !='' ">
            and up.createdBy = #{createdBy}
        </if>
        <if test="status !=null and status !='' ">
            and up.status = #{status}
        </if>
        <if test="beginTime != null and beginTime!='' and endTime != null and endTime!=''">
            and up.createdTime between #{beginTime} and #{endTime}
        </if>
        <if test="updatedTime !=null and updatedTime !='' ">
            and up.updatedTime = #{updatedTime}
        </if>
        <if test="updatedBy !=null and updatedBy !='' ">
            and up.updatedBy = #{updatedBy}
        </if>
    </select>

    <select id="selectDrugsByTemplateId" parameterType="pd" resultType="pd">
        SELECT * FROM s_dtp_yypz_template_drug WHERE templateId = #{templateId}
    </select>
    <select id="selectTemplateById" parameterType="pd" resultType="pd">
        SELECT * FROM s_dtp_yypz_follow_up_sop WHERE id = #{id}
    </select>
    <select id="selectNodeConfigByTemplateId" parameterType="pd" resultType="pd">
        SELECT * FROM s_dtp_yypz_nodeconfig WHERE templateId = #{templateId}
    </select>

    <update id="updateNodeconfigStatusByTemplateId" parameterType="pd" >
        update s_dtp_yypz_nodeconfig
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="status !=null and status !='' ">
            status = #{status},
        </if>
        </trim>
            <if test="templateId != null and templateId!=''">
                where templateId=#{templateId}
            </if>
    </update>
    <update id="updateSopStatusByTemplateId" parameterType="pd" >
        update s_dtp_yypz_follow_up_sop
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
            <if test="status !=null and status !='' ">
                status = #{status},
            </if>
            <if test="updatedTime !=null and updatedTime !='' ">
                updatedTime = #{updatedTime},
            </if>
            <if test="updatedBy !=null and updatedBy !='' ">
                updatedBy = #{updatedBy},
            </if>
        </trim>
            <if test="templateId != null and templateId!=''">
                where templateId=#{templateId}
            </if>
    </update>
    <update id="updateSDtpYypzFollowUpSop" parameterType="pd" >
        update s_dtp_yypz_follow_up_sop
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="drug !=null and drug !='' ">
            drug = #{drug},
        </if>
        <if test="businessBelonging !=null and businessBelonging !='' ">
            businessBelonging = #{businessBelonging},
        </if>
        <if test="templateName !=null and templateName !='' ">
            templateName = #{templateName},
        </if>
        <if test="storeName !=null and storeName !='' ">
            storeName= #{storeName},
        </if>
        <if test="storeId !=null and storeId !='' ">
            storeId=  #{storeId},
        </if>
        <if test="templateId !=null and templateId !='' ">
            templateId = #{templateId},
        </if>
        <if test="createdBy !=null and createdBy !='' ">
            createdBy = #{createdBy},
        </if>
        <if test="status !=null and status !='' ">
            status = #{status},
        </if>
        <if test="createdTime !=null and createdTime !='' ">
            createdTime = #{createdTime},
        </if>
        <if test="updatedTime !=null and updatedTime !='' ">
            updatedTime = #{updatedTime},
        </if>
        <if test="updatedBy !=null and updatedBy !='' ">
            updatedBy = #{updatedBy},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

    <delete id="SDtpYypzFollowUpSopRemove" parameterType="pd">
        <if test="ids != null">
            delete from s_dtp_yypz_follow_up_sop where
            <if test="ids != null">
                id in(${ids})
            </if>
        </if>
    </delete>

    <insert id="addSDtpYypzFollowUpSop" parameterType="pd" >

        insert into s_dtp_yypz_follow_up_sop
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">

        <if test="drug !=null and drug !='' ">
            drug,
        </if>
        <if test="businessBelonging !=null and businessBelonging !='' ">
            businessBelonging,
        </if>
        <if test="templateName !=null and templateName !='' ">
            templateName,
        </if>
        <if test="storeName !=null and storeName !='' ">
            storeName,
        </if>
        <if test="storeId !=null and storeId !=''">
            storeId,
        </if>
        <if test="templateId !=null and templateId !='' ">
            templateId,
        </if>
        <if test="createdBy !=null and createdBy !='' ">
            createdBy,
        </if>
        <if test="status !=null and status !='' ">
            status,
        </if>
        <if test="createdTime !=null and createdTime !='' ">
            createdTime,
        </if>
        <if test="updatedTime !=null and updatedTime !='' ">
            updatedTime,
        </if>
        <if test="updatedBy !=null and updatedBy !='' ">
            updatedBy,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="drug !=null and drug !='' ">
             #{drug},
        </if>
        <if test="businessBelonging !=null and businessBelonging !='' ">
             #{businessBelonging},
        </if>
        <if test="templateName !=null and templateName !='' ">
             #{templateName},
        </if>

        <if test="storeName !=null and storeName !='' ">
             #{storeName},
        </if>
        <if test="storeId !=null and storeId !=''">
            #{storeId},
        </if>
        <if test="templateId !=null and templateId !='' ">
            #{templateId},
        </if>
        <if test="createdBy !=null and createdBy !='' ">
             #{createdBy},
        </if>
        <if test="status !=null and status !='' ">
             #{status},
        </if>
        <if test="createdTime !=null and createdTime !='' ">
             #{createdTime},
        </if>
        <if test="updatedTime !=null and updatedTime !='' ">
             #{updatedTime},
        </if>
        <if test="updatedBy !=null and updatedBy !='' ">
             #{updatedBy},
        </if>
        </trim>

    </insert>


    <insert id="insertNodeConfig" parameterType="pd">
        INSERT INTO s_dtp_yypz_nodeconfig
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="templateId != null and templateId != ''">templateId,</if>
            <if test="nodeName != null and nodeName != ''">nodeName,</if>
            <if test="nodeCode != null and nodeCode != ''">nodeCode,</if>
            <if test="activateStructures != null and activateStructures != ''">activateStructures,</if>
            <if test="activateWhichDay != null and activateWhichDay != ''">activateWhichDay,</if>
            <if test="activateNodeRule != null and activateNodeRule != ''">activateNodeRule,</if>
            <if test="createTaskStructures != null and createTaskStructures != ''">createTaskStructures,</if>
            <if test="createTaskWhen != null and createTaskWhen != ''">createTaskWhen,</if>
            <if test="createTaskEvery != null and createTaskEvery != ''">createTaskEvery,</if>
            <if test="createTaskDi != null and createTaskDi != ''">createTaskDi,</if>
            <if test="createTaskTriggerValue != null and createTaskTriggerValue != ''">createTaskTriggerValue,</if>
            <if test="createTaskExecutionTimes != null and createTaskExecutionTimes != ''">createTaskExecutionTimes,</if>
            <if test="filterCondition != null">filterCondition,</if>
            <if test="trait != null and trait != ''">trait,</if>
            <if test="traitValue != null and traitValue != ''">traitValue,</if>
            <if test="judgingCondition != null and judgingCondition != ''">judgingCondition,</if>
            <if test="judgmentValue != null and judgmentValue != ''">judgmentValue,</if>
            <if test="taskActionMode != null and taskActionMode != ''">taskActionMode,</if>
            <if test="taskActionTaskType != null and taskActionTaskType != ''">taskActionTaskType,</if>
            <if test="taskActionRole != null and taskActionRole != ''">taskActionRole,</if>
            <if test="generationDaysAfter != null and generationDaysAfter != ''">generationDaysAfter,</if>
            <if test="generationHMS != null and generationHMS != ''">generationHMS,</if>
            <if test="followUpSubject != null and followUpSubject != ''">followUpSubject,</if>
            <if test="taskValidity != null">taskValidity,</if>
            <if test="taskMaterial != null and taskMaterial != ''">taskMaterial,</if>
            <if test="deliveryChannel != null and deliveryChannel != ''">deliveryChannel,</if>
            <if test="smsId != null and smsId != ''">smsId,</if>
            <if test="useForm != null and useForm != ''">useForm,</if>
            <if test="creator != null and creator != ''">creator,</if>
            <if test="createTime != null and createTime != ''">createTime,</if>
            <if test="status != null and status != ''">status</if>
        </trim>
        <trim prefix="VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="templateId != null and templateId != ''">#{templateId},</if>
            <if test="nodeName != null and nodeName != ''">#{nodeName},</if>
            <if test="nodeCode != null and nodeCode != ''">#{nodeCode},</if>
            <if test="activateStructures != null and activateStructures != ''">#{activateStructures},</if>
            <if test="activateWhichDay != null and activateWhichDay != ''">#{activateWhichDay},</if>
            <if test="activateNodeRule != null and activateNodeRule != ''">#{activateNodeRule},</if>
            <if test="createTaskStructures != null and createTaskStructures != ''">#{createTaskStructures},</if>
            <if test="createTaskWhen != null and createTaskWhen != ''">#{createTaskWhen},</if>
            <if test="createTaskEvery != null and createTaskEvery != ''">#{createTaskEvery},</if>
            <if test="createTaskDi != null and createTaskDi != ''">#{createTaskDi},</if>
            <if test="createTaskTriggerValue != null and createTaskTriggerValue != ''">#{createTaskTriggerValue},</if>
            <if test="createTaskExecutionTimes != null and createTaskExecutionTimes != ''">#{createTaskExecutionTimes},</if>
            <if test="filterCondition != null">#{filterCondition},</if>
            <if test="trait != null and trait != ''">#{trait},</if>
            <if test="traitValue != null and traitValue != ''">#{traitValue},</if>
            <if test="judgingCondition != null and judgingCondition != ''">#{judgingCondition},</if>
            <if test="judgmentValue != null and judgmentValue != ''">#{judgmentValue},</if>
            <if test="taskActionMode != null and taskActionMode != ''">#{taskActionMode},</if>
            <if test="taskActionTaskType != null and taskActionTaskType != ''">#{taskActionTaskType},</if>
            <if test="taskActionRole != null and taskActionRole != ''">#{taskActionRole},</if>
            <if test="generationDaysAfter != null and generationDaysAfter != ''">#{generationDaysAfter},</if>
            <if test="generationHMS != null and generationHMS != ''">#{generationHMS},</if>
            <if test="followUpSubject != null and followUpSubject != ''">#{followUpSubject},</if>
            <if test="taskValidity != null">#{taskValidity},</if>
            <if test="taskMaterial != null and taskMaterial != ''">#{taskMaterial},</if>
            <if test="deliveryChannel != null and deliveryChannel != ''">#{deliveryChannel},</if>
            <if test="smsId != null and smsId != ''">#{smsId},</if>
            <if test="useForm != null and useForm != ''">#{useForm},</if>
            <if test="creator != null and creator != ''">#{creator},</if>
            <if test="createTime != null and createTime != ''">#{createTime},</if>
            <if test="status != null and status != ''">#{status}</if>
        </trim>
    </insert>
    <update id="updateNodeConfig" parameterType="pd">
        UPDATE s_dtp_yypz_nodeconfig
        <set>
            <if test="templateId != null and templateId != ''">templateId = #{templateId},</if>
            <if test="nodeName != null and nodeName != ''">nodeName = #{nodeName},</if>
            <if test="nodeCode != null and nodeCode != ''">nodeCode = #{nodeCode},</if>
            <if test="activateStructures != null and activateStructures != ''">activateStructures = #{activateStructures},</if>
            <if test="activateWhichDay != null and activateWhichDay != ''">activateWhichDay = #{activateWhichDay},</if>
            <if test="activateNodeRule != null and activateNodeRule != ''">activateNodeRule = #{activateNodeRule},</if>
            <if test="createTaskStructures != null and createTaskStructures != ''">createTaskStructures = #{createTaskStructures},</if>
            <if test="createTaskWhen != null and createTaskWhen != ''">createTaskWhen = #{createTaskWhen},</if>
            <if test="createTaskEvery != null and createTaskEvery != ''">createTaskEvery = #{createTaskEvery},</if>
            <if test="createTaskDi != null and createTaskDi != ''">createTaskDi = #{createTaskDi},</if>
            <if test="createTaskTriggerValue != null and createTaskTriggerValue != ''">createTaskTriggerValue = #{createTaskTriggerValue},</if>
            <if test="createTaskExecutionTimes != null and createTaskExecutionTimes != ''">createTaskExecutionTimes = #{createTaskExecutionTimes},</if>
            <if test="filterCondition != null">filterCondition = #{filterCondition},</if>
            <if test="trait != null and trait != ''">trait = #{trait},</if>
            <if test="traitValue != null and traitValue != ''">traitValue = #{traitValue},</if>
            <if test="judgingCondition != null and judgingCondition != ''">judgingCondition = #{judgingCondition},</if>
            <if test="judgmentValue != null and judgmentValue != ''">judgmentValue = #{judgmentValue},</if>
            <if test="taskActionMode != null and taskActionMode != ''">taskActionMode = #{taskActionMode},</if>
            <if test="taskActionTaskType != null and taskActionTaskType != ''">taskActionTaskType = #{taskActionTaskType},</if>
            <if test="taskActionRole != null and taskActionRole != ''">taskActionRole = #{taskActionRole},</if>
            <if test="generationDaysAfter != null">generationDaysAfter = #{generationDaysAfter},</if>
            <if test="generationHMS != null and generationHMS != ''">generationHMS = #{generationHMS},</if>
            <if test="followUpSubject != null and followUpSubject != ''">followUpSubject = #{followUpSubject},</if>
            <if test="taskValidity != null">taskValidity = #{taskValidity},</if>
            <if test="taskMaterial != null and taskMaterial != ''">taskMaterial = #{taskMaterial},</if>
            <if test="deliveryChannel != null and deliveryChannel != ''">deliveryChannel = #{deliveryChannel},</if>
            <if test="smsId != null and smsId != ''">smsId = #{smsId},</if>
            <if test="useForm != null and useForm != ''">useForm = #{useForm},</if>
            <if test="creator != null and creator != ''">creator = #{creator},</if>
            <if test="createTime != null and createTime != ''">createTime = #{createTime},</if>
            <if test="status != null and status != ''">status = #{status}</if>
        </set>
        WHERE id = #{id}
    </update>
    <delete id="deleteNodeConfigByIds" parameterType="pd">
        delete from s_dtp_yypz_nodeconfig where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <delete id="deleteNodeConfigByTemplateId" parameterType="pd">
        delete from s_dtp_yypz_nodeconfig WHERE templateId = #{templateId}
    </delete>
    <select id="selectNodeConfigById" parameterType="pd" resultType="pd">
        SELECT * FROM s_dtp_yypz_nodeconfig WHERE id = #{id}
    </select>

    <select id="selectAllNodeConfigs" resultType="pd">
        SELECT * FROM s_dtp_yypz_nodeconfig
    </select>



    <!-- 批量插入节点信息 -->
    <insert id="batchAddNodeConfig" parameterType="java.util.List" useGeneratedKeys="false">
        INSERT INTO s_dtp_yypz_nodeconfig
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="dataList[0].templateId != null and dataList[0].templateId != ''">templateId,</if>
            <if test="dataList[0].nodeName != null and dataList[0].nodeName != ''">nodeName,</if>
            <if test="dataList[0].nodeCode != null and dataList[0].nodeCode != ''">nodeCode,</if>
            <if test="dataList[0].activateStructures != null and dataList[0].activateStructures != ''">activateStructures,</if>
            <if test="dataList[0].activateWhichDay != null and dataList[0].activateWhichDay != ''">activateWhichDay,</if>
            <if test="dataList[0].activateNodeRule != null and dataList[0].activateNodeRule != ''">activateNodeRule,</if>
            <if test="dataList[0].createTaskStructures != null and dataList[0].createTaskStructures != ''">createTaskStructures,</if>
            <if test="dataList[0].createTaskWhen != null and dataList[0].createTaskWhen != ''">createTaskWhen,</if>
            <if test="dataList[0].createTaskEvery != null and dataList[0].createTaskEvery != ''">createTaskEvery,</if>
            <if test="dataList[0].createTaskDi != null and dataList[0].createTaskDi != ''">createTaskDi,</if>
            <if test="dataList[0].createTaskTriggerValue != null and dataList[0].createTaskTriggerValue != ''">createTaskTriggerValue,</if>
            <if test="dataList[0].createTaskExecutionTimes != null and dataList[0].createTaskExecutionTimes != ''">createTaskExecutionTimes,</if>
            <if test="dataList[0].filterCondition != null">filterCondition,</if>
            <if test="dataList[0].trait != null and dataList[0].trait != ''">trait,</if>
            <if test="dataList[0].traitValue != null and dataList[0].traitValue != ''">traitValue,</if>
            <if test="dataList[0].judgingCondition != null and dataList[0].judgingCondition != ''">judgingCondition,</if>
            <if test="dataList[0].judgmentValue != null and dataList[0].judgmentValue != ''">judgmentValue,</if>
            <if test="dataList[0].taskActionMode != null and dataList[0].taskActionMode != ''">taskActionMode,</if>
            <if test="dataList[0].taskActionTaskType != null and dataList[0].taskActionTaskType != ''">taskActionTaskType,</if>
            <if test="dataList[0].taskActionRole != null and dataList[0].taskActionRole != ''">taskActionRole,</if>
            <if test="dataList[0].generationDaysAfter != null and dataList[0].generationDaysAfter != ''">generationDaysAfter,</if>
            <if test="dataList[0].generationHMS != null and dataList[0].generationHMS != ''">generationHMS,</if>
            <if test="dataList[0].followUpSubject != null and dataList[0].followUpSubject != ''">followUpSubject,</if>
            <if test="dataList[0].taskValidity != null and dataList[0].taskValidity != ''">taskValidity,</if>
            <if test="dataList[0].taskMaterial != null and dataList[0].taskMaterial != ''">taskMaterial,</if>
            <if test="dataList[0].deliveryChannel != null and dataList[0].deliveryChannel != ''">deliveryChannel,</if>
            <if test="dataList[0].smsId != null and dataList[0].smsId != ''">smsId,</if>
            <if test="dataList[0].useForm != null and dataList[0].useForm != ''">useForm,</if>
            <if test="dataList[0].creator != null and dataList[0].creator != ''">creator,</if>
            <if test="dataList[0].createTime != null and dataList[0].createTime != ''">createTime,</if>
            <if test="dataList[0].status != null">status</if>
        </trim>
        VALUES
        <foreach item="item" index="index" collection="dataList" separator=",">
            <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
                <if test="item.templateId != null and item.templateId != ''">#{templateId},</if>
                <if test="item.nodeName != null and item.nodeName != ''">#{item.nodeName},</if>
                <if test="item.nodeCode != null and item.nodeCode != ''">#{item.nodeCode},</if>
                <if test="item.activateStructures != null and item.activateStructures != ''">#{item.activateStructures},</if>
                <if test="item.activateWhichDay != null and item.activateWhichDay != ''">#{item.activateWhichDay},</if>
                <if test="item.activateNodeRule != null and item.activateNodeRule != ''">#{item.activateNodeRule},</if>
                <if test="item.createTaskStructures != null and item.createTaskStructures != ''">#{item.createTaskStructures},</if>
                <if test="item.createTaskWhen != null and item.createTaskWhen != ''">#{item.createTaskWhen},</if>
                <if test="item.createTaskEvery != null and item.createTaskEvery != ''">#{item.createTaskEvery},</if>
                <if test="item.createTaskDi != null and item.createTaskDi != ''">#{item.createTaskDi},</if>
                <if test="item.createTaskTriggerValue != null and item.createTaskTriggerValue != ''">#{item.createTaskTriggerValue},</if>
                <if test="item.createTaskExecutionTimes != null and item.createTaskExecutionTimes != ''">#{item.createTaskExecutionTimes},</if>
                <if test="item.filterCondition != null">#{item.filterCondition},</if>
                <if test="item.trait != null and item.trait != ''">#{item.trait},</if>
                <if test="item.traitValue != null and item.traitValue != ''">#{item.traitValue},</if>
                <if test="item.judgingCondition != null and item.judgingCondition != ''">#{item.judgingCondition},</if>
                <if test="item.judgmentValue != null and item.judgmentValue != ''">#{item.judgmentValue},</if>
                <if test="item.taskActionMode != null and item.taskActionMode != ''">#{item.taskActionMode},</if>
                <if test="item.taskActionTaskType != null and item.taskActionTaskType != ''">#{item.taskActionTaskType},</if>
                <if test="item.taskActionRole != null and item.taskActionRole != ''">#{item.taskActionRole},</if>
                <if test="item.generationDaysAfter != null and item.generationDaysAfter != ''">#{item.generationDaysAfter},</if>
                <if test="item.generationHMS != null and item.generationHMS != ''">#{item.generationHMS},</if>
                <if test="item.followUpSubject != null and item.followUpSubject != ''">#{item.followUpSubject},</if>
                <if test="item.taskValidity != null and item.taskValidity != ''">#{item.taskValidity},</if>
                <if test="item.taskMaterial != null and item.taskMaterial != ''">#{item.taskMaterial},</if>
                <if test="item.deliveryChannel != null and item.deliveryChannel != ''">#{item.deliveryChannel},</if>
                <if test="item.smsId != null and item.smsId != ''">#{item.smsId},</if>
                <if test="item.useForm != null and item.useForm != ''">#{item.useForm},</if>
                <if test="item.creator != null and item.creator != ''">#{item.creator},</if>
                <if test="item.createTime != null and item.createTime != ''">#{item.createTime},</if>
                <if test="item.status != null">#{item.status}</if>
            </trim>
        </foreach>
    </insert>
    <!-- 批量修改节点信息 -->
    <update id="batchUpdateNodeConfig" parameterType="java.util.List">
        <foreach item="item" index="index" collection="list" separator=";">
            UPDATE s_dtp_yypz_nodeconfig
            SET
            <trim prefix="" suffixOverrides=",">
                <if test="item.templateId != null and item.templateId != ''">
                    templateId = #{templateId},
                </if>
                <if test="item.nodeName != null and item.nodeName != ''">
                    nodeName = #{item.nodeName},
                </if>
                <if test="item.nodeCode != null and item.nodeCode != ''">
                    nodeCode = #{item.nodeCode},
                </if>
                <if test="item.activateStructures != null and item.activateStructures != ''">
                    activateStructures = #{item.activateStructures},
                </if>
                <if test="item.activateWhichDay != null  and item.activateWhichDay != ''">
                    activateWhichDay = #{item.activateWhichDay},
                </if>
                <if test="item.activateNodeRule != null and item.activateNodeRule != ''">
                    activateNodeRule = #{item.activateNodeRule},
                </if>
                <if test="item.createTaskStructures != null and item.createTaskStructures != ''">
                    createTaskStructures = #{item.createTaskStructures},
                </if>
                <if test="item.createTaskWhen != null and item.createTaskWhen != ''">
                    createTaskWhen = #{item.createTaskWhen},
                </if>
                <if test="item.createTaskEvery != null and item.createTaskEvery != ''">
                    createTaskEvery = #{item.createTaskEvery},
                </if>
                <if test="item.createTaskDi != null and item.createTaskDi != ''">
                    createTaskDi = #{item.createTaskDi},
                </if>
                <if test="item.createTaskTriggerValue != null and item.createTaskTriggerValue != ''">
                    createTaskTriggerValue = #{item.createTaskTriggerValue},
                </if>
                <if test="item.createTaskExecutionTimes != null and item.createTaskExecutionTimes != ''">
                    createTaskExecutionTimes = #{item.createTaskExecutionTimes},
                </if>
                <if test="item.filterCondition != null">
                    filterCondition = #{item.filterCondition},
                </if>
                <if test="item.trait != null and item.trait != ''">
                    trait = #{item.trait},
                </if>
                <if test="item.traitValue != null and item.traitValue != ''">
                    traitValue = #{item.traitValue},
                </if>
                <if test="item.judgingCondition != null and item.judgingCondition != ''">
                    judgingCondition = #{item.judgingCondition},
                </if>
                <if test="item.judgmentValue != null and item.judgmentValue != ''">
                    judgmentValue = #{item.judgmentValue},
                </if>
                <if test="item.taskActionMode != null and item.taskActionMode != ''">
                    taskActionMode = #{item.taskActionMode},
                </if>
                <if test="item.taskActionTaskType != null and item.taskActionTaskType != ''">
                    taskActionTaskType = #{item.taskActionTaskType},
                </if>
                <if test="item.taskActionRole != null and item.taskActionRole != ''">
                    taskActionRole = #{item.taskActionRole},
                </if>
                <if test="item.generationDaysAfter != null and item.generationDaysAfter != ''">
                    generationDaysAfter = #{item.generationDaysAfter},
                </if>
                <if test="item.generationHMS != null and item.generationHMS != ''">
                    generationHMS = #{item.generationHMS},
                </if>
                <if test="item.followUpSubject != null and item.followUpSubject != ''">
                    followUpSubject = #{item.followUpSubject},
                </if>
                <if test="item.taskValidity != null and item.taskValidity != ''">
                    taskValidity = #{item.taskValidity},
                </if>
                <if test="item.taskMaterial != null and item.taskMaterial != ''">
                    taskMaterial = #{item.taskMaterial},
                </if>
                <if test="item.deliveryChannel != null and item.deliveryChannel != ''">
                    deliveryChannel = #{item.deliveryChannel},
                </if>
                <if test="item.smsId != null and item.smsId != ''">
                    smsId = #{item.smsId},
                </if>
                <if test="item.useForm != null and item.useForm != ''">
                    useForm = #{item.useForm},
                </if>
                <if test="item.creator != null and item.creator != ''">
                    creator = #{item.creator},
                </if>
                <if test="item.createTime != null and item.createTime != ''">
                    createTime = #{item.createTime},
                </if>
                <if test="item.status != null and item.status != ''">
                    status = #{item.status},
                </if>
            </trim>
            WHERE id = #{item.id}
        </foreach>
    </update>





    <select id="selectTemplateDrug" parameterType="pd" resultType="pd">
        select * from s_dtp_yypz_template_drug where 1=1
        <if test="templateName != null and templateName != ''">
            and templateName = #{templateName}
        </if>
        <if test="templateId != null and templateId != ''">
            and templateId = #{templateId}
        </if>
        <if test="productName != null and productName != ''">
            and productName = #{productName}
        </if>
        <if test="productCode != null and productCode != ''">
            and productCode = #{productCode}
        </if>
        <if test="specification != null and specification != ''">
            and specification = #{specification}
        </if>
        <if test="storeId != null and storeId != ''">
            and storeId = #{storeId}
        </if>
        <if test="createdTime != null">
            and createdTime = #{createdTime}
        </if>
        <if test="updatedTime != null">
            and updatedTime = #{updatedTime}
        </if>
    </select>

    <select id="selectOneById" parameterType="pd" resultType="pd">
        select * from s_dtp_yypz_template_drug where id = #{id}
    </select>

    <select id="checkValueByCode" parameterType="pd" resultType="pd">
        select * from s_dtp_yypz_template_drug where productCode = #{productCode}
    </select>

    <delete id="deleteTemplateDrugByIds" parameterType="java.util.List">
        <if test="list != null and list.size() > 0">
            delete from s_dtp_yypz_template_drug
            where id in
            <foreach item="id" index="index" collection="list" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </delete>


    <delete id="deleteTemplateDrugByTemplateId" parameterType="pd">
            delete from s_dtp_yypz_template_drug  where templateId = #{templateId}
    </delete>

    <update id="updateTemplateDrug" parameterType="pd">
        update s_dtp_yypz_template_drug
        <trim prefix="SET " suffix="" prefixOverrides="," suffixOverrides=",">
            <if test="templateName != null and templateName != ''">
                templateName = #{templateName},
            </if>
            <if test="templateId != null and templateId != ''">
                templateId = #{templateId},
            </if>
            <if test="productName != null and productName != ''">
                productName = #{productName},
            </if>
            <if test="productCode != null and productCode != ''">
                productCode = #{productCode},
            </if>
            <if test="specification != null and specification != ''">
                specification = #{specification},
            </if>
            <if test="storeId != null and storeId != ''">
                storeId = #{storeId},
            </if>
            <if test="updatedBy != null and updatedBy != ''">
                updatedBy = #{updatedBy},
            </if>
            <if test="updatedTime != null">
                updatedTime = #{updatedTime},
            </if>
        </trim>
        <if test="id != null">
            where id = #{id}
        </if>
    </update>



    <insert id="insertTemplateDrug" parameterType="pd">
        insert into s_dtp_yypz_template_drug
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="templateName != null and templateName != ''">
                templateName,
            </if>
            <if test="templateId != null and templateId != ''">
                templateId,
            </if>
            <if test="productName != null and productName != ''">
                productName,
            </if>
            <if test="productCode != null and productCode != ''">
                productCode,
            </if>
            <if test="specification != null and specification != ''">
                specification,
            </if>
            <if test="storeId != null and storeId != ''">
                storeId,
            </if>
            <if test="createdTime != null">
                createdTime,
            </if>
            <if test="updatedTime != null">
                updatedTime,
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="templateName != null and templateName != ''">
                #{templateName},
            </if>
            <if test="templateId != null and templateId != ''">
                #{templateId},
            </if>
            <if test="productName != null and productName != ''">
                #{productName},
            </if>
            <if test="productCode != null and productCode != ''">
                #{productCode},
            </if>
            <if test="specification != null and specification != ''">
                #{specification},
            </if>
            <if test="storeId != null and storeId != ''">
                #{storeId},
            </if>
            <if test="createdTime != null">
                #{createdTime},
            </if>
            <if test="updatedTime != null">
                #{updatedTime},
            </if>
        </trim>
    </insert>

    <insert id="batchAddTemplateDrugDynamic" parameterType="java.util.List">
        INSERT INTO s_dtp_yypz_template_drug
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="dataList[0].templateName != null and dataList[0].templateName != ''">templateName,</if>
            <if test="dataList[0].templateId != null and dataList[0].templateId != ''">templateId,</if>
            <if test="dataList[0].productName != null and dataList[0].productName != ''">productName,</if>
            <if test="dataList[0].productCode != null and dataList[0].productCode != ''">productCode,</if>
            <if test="dataList[0].specification != null and dataList[0].specification != ''">specification,</if>
            <if test="dataList[0].storeId != null and dataList[0].storeId != ''">storeId,</if>
            <if test="dataList[0].createdTime != null">createdTime,</if>
            <if test="dataList[0].updatedTime != null">updatedTime</if>
        </trim>
        VALUES
        <foreach collection="dataList" item="item" separator=",">
            <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
                <if test="item.templateName != null and item.templateName != ''">#{item.templateName},</if>
                <if test="item.templateId != null and item.templateId != ''">#{item.templateId},</if>
                <if test="item.productName != null and item.productName != ''">#{item.productName},</if>
                <if test="item.productCode != null and item.productCode != ''">#{item.productCode},</if>
                <if test="item.specification != null and item.specification != ''">#{item.specification},</if>
                <if test="item.storeId != null and item.storeId != ''">#{item.storeId},</if>
                <if test="item.createdTime != null">#{item.createdTime},</if>
                <if test="item.updatedTime != null">#{item.updatedTime}</if>
            </trim>
        </foreach>
    </insert>
</mapper>
