<?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.bonus.sgzb.material.mapper.ToDoMapper">

    <select id="getToDoList" resultType="com.bonus.sgzb.material.domain.ToDoBean">
        SELECT
            tt.task_id as taskId,
            tt.`code` as taskCode,
            tt.task_type as taskTypeId,
            sd2.`name` as taskType,
            sd.`name` as taskEvent,
            us.user_name as createName,
            tt.create_by as createBy,
            tt.create_time as createTime
        FROM
            tm_task tt
                LEFT JOIN sys_dic sd on sd.id=tt.task_status
                LEFT JOIN sys_dic sd2 on sd2.id=tt.task_type
                LEFT JOIN sys_user us on us.user_id=tt.create_by
        WHERE
            tt.`status` = '1'
          and tt.task_status in ('24','25','30','31','32','33','34','37','39','42','43','46','53','58','68','69')
        <if test="taskTypeId != null  and taskTypeId != ''">
            and tt.task_type=#{taskTypeId}
        </if>
        <if test="taskCode != null  and taskCode != ''">
            and tt.`code` like concat('%', #{taskCode}, '%')
        </if>
        <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
            AND tt.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
        </if>
        <if test="keyWord != null  and keyWord != ''">
            and sd2.`name` like concat('%', #{keyWord}, '%') or
            us.user_name like concat('%', #{keyWord}, '%')
        </if>
        ORDER BY tt.create_time desc
    </select>
    <select id="getTaskType" resultType="com.bonus.sgzb.material.domain.ToDoBean">
        SELECT
            id as taskTypeId,`name` as taskType
        FROM
            sys_dic
        WHERE
            `status`='0'
          and p_id='0'
          and id not in (1,5,8,13,81)
    </select>
</mapper>