<?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.gonghang.h5clientapp.dao.CheckTaskMapper">

    <!--    上海工行掌上运维——查询任务列表-->
    <resultMap id="GhTaskMap" type="java.util.HashMap">
        <id column="id" jdbcType="INTEGER" property="taskId"/>
        <result column="task_name" jdbcType="VARCHAR" property="taskName"/>
        <result column="task_status" jdbcType="TINYINT" property="taskStatus"/>
        <result column="is_send" jdbcType="TINYINT" property="isSend"/>
        <result column="create_time" jdbcType="VARCHAR" property="createTime"/>
    </resultMap>
    <select id="selectTaskList" resultMap="GhTaskMap">
        SELECT
        t.id taskId,
        t.task_name,
        t.task_status,
        IF (t.send_time IS NULL , 0, 1 ) is_send,
        DATE_FORMAT(t.create_time,'%Y-%c-%d %H:%i:%s') create_time
        FROM
        check_task t
        WHERE
        t.task_status!=3
        <if test="robotId != null">
            and d.robot_id =#{robotId}
        </if>
        ORDER BY CASE WHEN t.task_status = 1 THEN 0 ELSE 1 END ASC,
        t.create_time DESC
    </select>
</mapper>