<?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.ximai.mes.pro.mapper.task.ProTaskWorkunitOpRecordMapper">
    
    <resultMap type="ProTaskWorkunitOpRecord" id="ProTaskWorkunitOpRecordResult">
        <result property="id"    column="id"    />
        <result property="taskWorkunitId"    column="task_workunit_id"    />
        <result property="taskId"    column="task_id"    />
        <result property="idx"    column="idx"    />
        <result property="workunitId"    column="workunit_id"    />
        <result property="oldWorkunitId"    column="old_workunit_id"    />
        <result property="oldScheduleStartDate"    column="old_schedule_start_date"    />
        <result property="oldScheduleEndDate"    column="old_schedule_end_date"    />
        <result property="scheduleStartDate"    column="schedule_start_date"    />
        <result property="scheduleEndDate"    column="schedule_end_date"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectProTaskWorkunitOpRecordVo">
        select * from pro_task_workunit_op_record
    </sql>

    <select id="selectProTaskWorkunitOpRecordList" parameterType="ProTaskWorkunitOpRecord" resultMap="ProTaskWorkunitOpRecordResult">
        <include refid="selectProTaskWorkunitOpRecordVo"/>
        <where>  
            <if test="taskWorkunitId != null "> and task_workunit_id = #{taskWorkunitId}</if>
            <if test="taskId != null "> and task_id = #{taskId}</if>
            <if test="idx != null "> and idx = #{idx}</if>
            <if test="workunitId != null "> and workunit_id = #{workunitId}</if>
            <if test="oldScheduleStartDate != null "> and old_schedule_start_date = #{oldScheduleStartDate}</if>
            <if test="oldScheduleEndDate != null "> and old_schedule_end_date = #{oldScheduleEndDate}</if>
            <if test="scheduleStartDate != null "> and schedule_start_date = #{scheduleStartDate}</if>
            <if test="scheduleEndDate != null "> and schedule_end_date = #{scheduleEndDate}</if>
        </where>
    </select>
    
    <select id="selectProTaskWorkunitOpRecordById" parameterType="Long" resultMap="ProTaskWorkunitOpRecordResult">
        <include refid="selectProTaskWorkunitOpRecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertProTaskWorkunitOpRecord" parameterType="ProTaskWorkunitOpRecord" useGeneratedKeys="true" keyProperty="id">
        insert into pro_task_workunit_op_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskWorkunitId != null">task_workunit_id,</if>
            <if test="taskId != null">task_id,</if>
            <if test="idx != null">idx,</if>
            <if test="workunitId != null">workunit_id,</if>
            <if test="oldWorkunitId != null">old_workunit_id,</if>
            <if test="oldScheduleStartDate != null">old_schedule_start_date,</if>
            <if test="oldScheduleEndDate != null">old_schedule_end_date,</if>
            <if test="scheduleStartDate != null">schedule_start_date,</if>
            <if test="scheduleEndDate != null">schedule_end_date,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskWorkunitId != null">#{taskWorkunitId},</if>
            <if test="taskId != null">#{taskId},</if>
            <if test="idx != null">#{idx},</if>
            <if test="workunitId != null">#{workunitId},</if>
            <if test="oldWorkunitId != null">#{oldWorkunitId},</if>
            <if test="oldScheduleStartDate != null">#{oldScheduleStartDate},</if>
            <if test="oldScheduleEndDate != null">#{oldScheduleEndDate},</if>
            <if test="scheduleStartDate != null">#{scheduleStartDate},</if>
            <if test="scheduleEndDate != null">#{scheduleEndDate},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateProTaskWorkunitOpRecord" parameterType="ProTaskWorkunitOpRecord">
        update pro_task_workunit_op_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskWorkunitId != null">task_workunit_id = #{taskWorkunitId},</if>
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="idx != null">idx = #{idx},</if>
            <if test="workunitId != null">workunit_id = #{workunitId},</if>
            <if test="oldScheduleStartDate != null">old_schedule_start_date = #{oldScheduleStartDate},</if>
            <if test="oldScheduleEndDate != null">old_schedule_end_date = #{oldScheduleEndDate},</if>
            <if test="scheduleStartDate != null">schedule_start_date = #{scheduleStartDate},</if>
            <if test="scheduleEndDate != null">schedule_end_date = #{scheduleEndDate},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteProTaskWorkunitOpRecordById" parameterType="Long">
        delete from pro_task_workunit_op_record where id = #{id}
    </delete>

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