<?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.chinaweal.aiccs.aiccs.seriousillegal.mapper.EOtIlldisdetailTempMapper">

    <select id="selectTaskListTodoPage" resultType="com.chinaweal.aiccs.aiccs.business.entity.TSTaskList">
        select ta.*
        from tstasklist ta LEFT JOIN TSTwfProcessNode n on ta.WorkflowID = n.processid
        where n.status = 0 and ta.BUSSTATUS in ('0','-1')
        <if test="param != null">
            <if test="param.bustype != null and param.bustype != ''">
                and ta.bustype = #{param.bustype}
            </if>
            <if test="param.bustypeIn != null and !bustypeIn.isEmpty()">
                and ta.bustype in
                <foreach collection="param.bustypeIn" open="(" close=")" item="each" separator=",">
                    #{each}
                </foreach>
            </if>
            <if test="param.currentUserId != null and param.currentUserId != ''">
                and n.CURRUSERID = #{param.currentUserId}
            </if>
        </if>
        ORDER BY ta.ISDEADLINE desc, ta.LAUPTIME DESC
    </select>
    <select id="selectTodoHistoryPage"
            resultType="com.chinaweal.aiccs.aiccs.seriousillegal.entity.EOtIlldisdetailTemp">
        select ot.*
        from E_OT_ILLDISDETAIL_TEMP ot
        <if test='param.bustype eq "80"'>
            left join tstasklist ta on ot.IN_WORKFLOW_ID = ta.WORKFLOWID
        </if>
        <if test='param.bustype eq "81"'>
            left join tstasklist ta on ot.OUT_WORKFLOW_ID = ta.WORKFLOWID
        </if>
        <where>
            <if test="param.currentUserId != null and param.currentUserId != ''">
                and exists(select 1 from TSTWFPROCESSNODE twf
                where ta.WORKFLOWID = twf.PROCESSID
                and twf.CURRUSERID = #{param.currentUserId})
            </if>
        </where>
        ORDER BY ta.LAUPTIME DESC
    </select>
</mapper>