<?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.uavps.system.mapper.UavpsTaskMapper">
    
    <resultMap type="UavpsTask" id="UavpsTaskResult">
        <result property="bizId"    column="biz_id"    />
        <result property="bizName"    column="biz_name"    />
        <result property="bizType"    column="biz_type"    />
        <result property="multiTarget"    column="multi_target"    />
        <result property="smartAlgorithm"    column="smart_algorithm"    />
        <result property="noiseType"    column="noise_type"    />
        <result property="noiseVariance"    column="noise_variance"    />
        <result property="noiseMean"    column="noise_mean"    />
        <result property="platformUavStr"    column="platform_uav_str"    />
        <result property="fixedMultiTargetFormationStr"    column="fixed_multi_target_formation_str"    />
        <result property="customizedMultiTargetFormationStr"    column="customized_multi_target_formation_str"    />
        <result property="status"    column="status"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="filePath"    column="file_path"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectUavpsTaskVo">
        select biz_id, biz_name, biz_type, multi_target, smart_algorithm, noise_type, noise_variance, noise_mean, platform_uav_str, fixed_multi_target_formation_str, customized_multi_target_formation_str, status, start_time, end_time, file_path, create_by, create_time, update_by, update_time from uavps_task
    </sql>

    <select id="selectUavpsTaskList" parameterType="UavpsTask" resultMap="UavpsTaskResult">
        <include refid="selectUavpsTaskVo"/>
        <where>  
            <if test="bizName != null  and bizName != ''"> and biz_name like concat('%', #{bizName}, '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
        </where>
    </select>
    
    <select id="selectUavpsTaskByBizId" parameterType="Long" resultMap="UavpsTaskResult">
        <include refid="selectUavpsTaskVo"/>
        where biz_id = #{bizId}
    </select>

    <insert id="insertUavpsTask" parameterType="UavpsTask" useGeneratedKeys="true" keyProperty="bizId">
        insert into uavps_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bizName != null">biz_name,</if>
            <if test="bizType != null">biz_type,</if>
            <if test="multiTarget != null">multi_target,</if>
            <if test="smartAlgorithm != null">smart_algorithm,</if>
            <if test="noiseType != null">noise_type,</if>
            <if test="noiseVariance != null">noise_variance,</if>
            <if test="noiseMean != null">noise_mean,</if>
            <if test="platformUavStr != null">platform_uav_str,</if>
            <if test="fixedMultiTargetFormationStr != null">fixed_multi_target_formation_str,</if>
            <if test="customizedMultiTargetFormationStr != null">customized_multi_target_formation_str,</if>
            <if test="status != null">status,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="filePath != null">file_path,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="bizName != null">#{bizName},</if>
            <if test="bizType != null">#{bizType},</if>
            <if test="multiTarget != null">#{multiTarget},</if>
            <if test="smartAlgorithm != null">#{smartAlgorithm},</if>
            <if test="noiseType != null">#{noiseType},</if>
            <if test="noiseVariance != null">#{noiseVariance},</if>
            <if test="noiseMean != null">#{noiseMean},</if>
            <if test="platformUavStr != null">#{platformUavStr},</if>
            <if test="fixedMultiTargetFormationStr != null">#{fixedMultiTargetFormationStr},</if>
            <if test="customizedMultiTargetFormationStr != null">#{customizedMultiTargetFormationStr},</if>
            <if test="status != null">#{status},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateUavpsTask" parameterType="UavpsTask">
        update uavps_task
        <trim prefix="SET" suffixOverrides=",">
            <if test="bizName != null">biz_name = #{bizName},</if>
            <if test="bizType != null">biz_type = #{bizType},</if>
            <if test="multiTarget != null">multi_target = #{multiTarget},</if>
            <if test="smartAlgorithm != null">smart_algorithm = #{smartAlgorithm},</if>
            <if test="noiseType != null">noise_type = #{noiseType},</if>
            <if test="noiseVariance != null">noise_variance = #{noiseVariance},</if>
            <if test="noiseMean != null">noise_mean = #{noiseMean},</if>
            <if test="platformUavStr != null">platform_uav_str = #{platformUavStr},</if>
            <if test="fixedMultiTargetFormationStr != null">fixed_multi_target_formation_str = #{fixedMultiTargetFormationStr},</if>
            <if test="customizedMultiTargetFormationStr != null">customized_multi_target_formation_str = #{customizedMultiTargetFormationStr},</if>
            <if test="status != null">status = #{status},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
            <if test="createBy != null">create_by = #{createBy},</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>
        </trim>
        where biz_id = #{bizId}
    </update>

    <delete id="deleteUavpsTaskByBizId" parameterType="Long">
        delete from uavps_task where biz_id = #{bizId}
    </delete>

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