<?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.RpeiExeInfoTaskMapper">

    <select id="selectRpeiExeInfoTaskTodo" resultType="com.chinaweal.aiccs.aiccs.seriousillegal.entity.RpeiExeInfoTask">
        select distinct
        task.biz_seq_no as bizSeqNo,
        biz.TASKID as taskId,
        biz.EXEID as exeId,
        biz.PRIPID as pripId,
        biz.ENTNAME as entName,
        biz.UNISCID as uniscId,
        biz.REGNO as regNo,
        biz.STATUS as status,
        biz.EXESTATE_BEF as exeStateBef,
        biz.EXESTATE_AFT as exeStateAft,
        biz.REGAUTH as regAuth,
        biz.REGAUTH_CN as regAuthCn,
        biz.apply_time as applyTime,
        task.accept_no as acceptNo,
        task.bus_name as busName,
        task.bus_status as busStatus,
        activity.link_type as linkType,
        activity.link_name as linkName,
        xtf.open_name as openName,
        xtf.transfer_reason as transferReason
        from xr_task_list task
        inner join rpei_exe_info_task biz on task.biz_seq_no = biz.biz_seq_no
        inner join xr_activity activity on task.task_like_id = activity.task_id
        left join xr_task_forward xtf ON biz.biz_seq_no = xtf.biz_seq_no
        <where>
            activity.link_status = '1'
            and biz.status != '5'
            <if test="param.authList.size > 0">
                and activity.ident in
                <foreach collection="param.authList" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="param.busStatus != null and param.busStatus != ''">
                and task.bus_status = #{param.busStatus}
            </if>
            <if test="param.searchUscc != null and param.searchUscc != ''">
                and (biz.UNISCID = #{param.searchUscc} or biz.REGNO = #{param.searchUscc})
            </if>
            <if test="param.entName != null and param.entName != ''">
                and biz.ENTNAME like concat('%', #{param.entName}, '%')
            </if>
            <if test="param.status != null and param.status != ''">
                and biz.status = #{param.status}
            </if>
        </where>
        order by biz.apply_time desc
    </select>

</mapper>
