<?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.yunfeiyun.agmp.fms.mapper.MppTaskMapper">
    
    <resultMap type="MppTask" id="MppTaskResult">
        <result property="taskId"    column="taskId"    />
        <result property="stockId"    column="stockId"    />
        <result property="taskNo"    column="taskNo"    />
        <result property="taskType"    column="taskType"    />
        <result property="taskCreator"    column="taskCreator"    />
        <result property="taskCreateddate"    column="taskCreateddate"    />
        <result property="taskRemark"    column="taskRemark"    />
        <result property="taskdetailNum"    column="taskdetailNum"    />
        <result property="taskdetailOrg"    column="taskdetailOrg"    />
        <result property="taskdetailCreateddate"    column="taskdetailCreateddate"    />
    </resultMap>

    <sql id="selectMppTaskVo">
        select taskId, stockId, taskNo, taskType, taskCreator, taskCreateddate, taskRemark, taskdetailNum, taskdetailOrg, taskdetailCreateddate from MppTask
    </sql>

    <select id="selectMppTaskList" parameterType="MppTask" resultMap="MppTaskResult">
        <include refid="selectMppTaskVo"/>
        <where>  
            <if test="stockId != null  and stockId != ''"> and stockId = #{stockId}</if>
            <if test="taskNo != null  and taskNo != ''"> and taskNo = #{taskNo}</if>
            <if test="taskType != null  and taskType != ''"> and taskType = #{taskType}</if>
            <if test="taskCreator != null  and taskCreator != ''"> and taskCreator = #{taskCreator}</if>
            <if test="taskCreateddate != null  and taskCreateddate != ''"> and taskCreateddate = #{taskCreateddate}</if>
            <if test="taskRemark != null  and taskRemark != ''"> and taskRemark = #{taskRemark}</if>
            <if test="taskdetailNum != null "> and taskdetailNum = #{taskdetailNum}</if>
            <if test="taskdetailOrg != null  and taskdetailOrg != ''"> and taskdetailOrg = #{taskdetailOrg}</if>
            <if test="taskdetailCreateddate != null  and taskdetailCreateddate != ''"> and taskdetailCreateddate = #{taskdetailCreateddate}</if>
        </where>
    </select>
    
    <select id="selectMppTaskByTaskId" parameterType="String" resultMap="MppTaskResult">
        <include refid="selectMppTaskVo"/>
        where taskId = #{taskId}
    </select>
        
    <insert id="insertMppTask" parameterType="MppTask">
        insert into MppTask
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">taskId,</if>
            <if test="stockId != null">stockId,</if>
            <if test="taskNo != null">taskNo,</if>
            <if test="taskType != null">taskType,</if>
            <if test="taskCreator != null">taskCreator,</if>
            <if test="taskCreateddate != null">taskCreateddate,</if>
            <if test="taskRemark != null">taskRemark,</if>
            <if test="taskdetailNum != null">taskdetailNum,</if>
            <if test="taskdetailOrg != null">taskdetailOrg,</if>
            <if test="taskdetailCreateddate != null">taskdetailCreateddate,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskId != null">#{taskId},</if>
            <if test="stockId != null">#{stockId},</if>
            <if test="taskNo != null">#{taskNo},</if>
            <if test="taskType != null">#{taskType},</if>
            <if test="taskCreator != null">#{taskCreator},</if>
            <if test="taskCreateddate != null">#{taskCreateddate},</if>
            <if test="taskRemark != null">#{taskRemark},</if>
            <if test="taskdetailNum != null">#{taskdetailNum},</if>
            <if test="taskdetailOrg != null">#{taskdetailOrg},</if>
            <if test="taskdetailCreateddate != null">#{taskdetailCreateddate},</if>
         </trim>
    </insert>

    <update id="updateMppTask" parameterType="MppTask">
        update MppTask
        <trim prefix="SET" suffixOverrides=",">
            <if test="stockId != null">stockId = #{stockId},</if>
            <if test="taskNo != null">taskNo = #{taskNo},</if>
            <if test="taskType != null">taskType = #{taskType},</if>
            <if test="taskCreator != null">taskCreator = #{taskCreator},</if>
            <if test="taskCreateddate != null">taskCreateddate = #{taskCreateddate},</if>
            <if test="taskRemark != null">taskRemark = #{taskRemark},</if>
            <if test="taskdetailNum != null">taskdetailNum = #{taskdetailNum},</if>
            <if test="taskdetailOrg != null">taskdetailOrg = #{taskdetailOrg},</if>
            <if test="taskdetailCreateddate != null">taskdetailCreateddate = #{taskdetailCreateddate},</if>
        </trim>
        where taskId = #{taskId}
    </update>

    <delete id="deleteMppTaskByTaskId" parameterType="String">
        delete from MppTask where taskId = #{taskId}
    </delete>

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