<?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="cn.gov.customs.wxjy.task.dao.TaskLogMapper">

    <resultMap type="TaskLog" id="TaskLogResult">
        <result property="pkTaskLog" column="PK_TASK_LOG"/>
        <result property="businessType" column="BUSINESS_TYPE"/>
        <result property="taskTime" column="TASK_TIME"/>
        <result property="status" column="STATUS"/>
        <result property="costTime" column="COST_TIME"/>
        <result property="errorMessage" column="ERROR_MESSAGE"/>
    </resultMap>

    <sql id="baseVo">
        select PK_TASK_LOG, BUSINESS_TYPE, TASK_TIME,STATUS,COST_TIME,ERROR_MESSAGE
        from WXJY_TASK_LOG
    </sql>

    <select id="selectList" parameterType="TaskLogQuery" resultMap="TaskLogResult">
        <include refid="baseVo"/>
        <where>
        <if test="businessType != null  and businessType != ''">
            and BUSINESS_TYPE = #{businessType}
        </if>
        <if test="taskTime != null  and taskTime != ''">
            and TASK_TIME = #{taskTime}
        </if>
        </where>
    </select>

    <select id="selectByPkTaskLog" parameterType="String"
        resultMap="TaskLogResult">
        <include refid="baseVo"/>
        where PK_TASK_LOG = #{pkTaskLog}
    </select>
    <select id="getMaxBussinessDate" resultType="java.util.Date">
        select max(TASK_TIME) FROM WXJY_TASK_LOG WHERE BUSINESS_TYPE = #{businessType}
    </select>

    <insert id="insert" parameterType="TaskLog">
        insert into WXJY_TASK_LOG
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pkTaskLog != null and pkTaskLog != ''">PK_TASK_LOG,
            </if>
            <if test="businessType != null">BUSINESS_TYPE,
            </if>
            <if test="taskTime != null">TASK_TIME,
            </if>
            <if test="status != null">STATUS,
            </if>
            <if test="costTime != null">COST_TIME,
            </if>
            <if test="errorMessage != null">ERROR_MESSAGE,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pkTaskLog != null and pkTaskLog != ''">#{pkTaskLog},
            </if>
            <if test="businessType != null">#{businessType},
            </if>
            <if test="taskTime != null">#{taskTime},
            </if>
            <if test="status != null">#{status},
            </if>
            <if test="costTime != null">#{costTime},
            </if>
            <if test="errorMessage != null">#{errorMessage},
            </if>
        </trim>
    </insert>

    <update id="update" parameterType="TaskLog">
        update WXJY_TASK_LOG
        <trim prefix="SET" suffixOverrides=",">
            <if test="businessType != null">BUSINESS_TYPE =
                #{businessType},
            </if>
            <if test="taskTime != null">TASK_TIME =
                #{taskTime},
            </if>
        </trim>
        where PK_TASK_LOG = #{pkTaskLog}
    </update>

    <delete id="deleteByPkTaskLog" parameterType="String">
        delete
        from WXJY_TASK_LOG where PK_TASK_LOG = #{pkTaskLog}
    </delete>

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

    <delete id="logicDelete" parameterType="String">
        update  WXJY_TASK_LOG set is_del = 1  where PK_TASK_LOG = #{pkTaskLog}
    </delete>
</mapper>