<?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.seriousillegalPerson.mapper.XrSeriousIllegalPersonRemListMapper">

    <select id="listTodoByOrg"
            resultType="com.chinaweal.aiccs.aiccs.seriousillegalPerson.entity.XrSeriousIllegalPersonRemList">
        SELECT distinct *
        from (
        select
        task.accept_no as acceptNo,
        biz.biz_seq_no as bizSeqNo,
        biz.illegal_list_id as illegalListId,
        biz.inv as inv,
        biz.cer_type as cerType,
        biz.cer_no as cerNo,
        biz.ser_ill_rea as serIllRea,
        biz.abn_time as abnTime,
        biz.rem_excp_res as remExcpRes,
        biz.status as status,
        biz.apply_rem_rea as applyRemRea,
        biz.rem_type as remType,
        biz.dec_org as decOrg,
        biz.area_code as areaCode,
        biz.lost_credit_explain_rem as lostCreditExplainRem,
        biz.rem_sponsor_illegal as remSponsorIllegal,
        biz.is_accept as isAccept,
        biz.is_agree_repair as isAgreeRepair,
        biz.handle_status as handleStatus,
        biz.is_finished as finished,
        biz.create_time as createTime,
        biz.apply_time as applyTime,
        biz.is_displayed as displayed,
        task.bus_name as busName,
        task.bus_status as busStatus
        from xr_task_list task
        inner join xr_serious_illegal_person_rem_list 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'
            <if test="entity.authList.size > 0">
                and activity.ident in
                <foreach collection="entity.authList" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="entity.busStatus != null and entity.busStatus != ''">
                and task.bus_status = #{entity.busStatus}
            </if>
            <if test="entity.inv != null and entity.inv != ''">
                and biz.inv like concat('%', #{entity.inv}, '%')
            </if>
            <if test="entity.cerNo != null and entity.cerNo != ''">
                and biz.cer_no = #{entity.cerNo}
            </if>
            <if test="entity.acceptNo != null and entity.acceptNo != ''">
                and task.accept_no = #{entity.acceptNo}
            </if>
            AND biz.status not in ('5')
        </where>
        order by biz.update_time desc
        ) a
    </select>

    <select id="listRecordByOrg"
            resultType="com.chinaweal.aiccs.aiccs.seriousillegalPerson.entity.XrSeriousIllegalPersonRemList">
        SELECT
        biz.biz_ser_rem_id as bizSerRemId,
        biz.biz_seq_no as bizSeqNo,
        biz.illegal_list_id as illegalListId,
        biz.inv as inv,
        biz.cer_type as cerType,
        biz.cer_no as cerNo,
        biz.ser_ill_rea as serIllRea,
        biz.abn_time as abnTime,
        biz.rem_excp_res as remExcpRes,
        biz.status as status,
        biz.apply_rem_rea as applyRemRea,
        biz.rem_type as remType,
        biz.dec_org as decOrg,
        biz.dec_org_cn as decOrgCn,
        biz.area_code as areaCode,
        biz.lost_credit_explain_rem as lostCreditExplainRem,
        biz.rem_sponsor_illegal as remSponsorIllegal,
        biz.is_accept as isAccept,
        biz.is_agree_repair as isAgreeRepair,
        biz.handle_status as handleStatus,
        biz.is_finished as finished,
        biz.create_time as createTime,
        biz.update_time as updateTime,
        biz.add_dep_name as addDepName,
        biz.add_dep_id as addDepId,
        biz.is_displayed as displayed,
        biz.rem_date as remDate
        from xr_serious_illegal_person_rem_list biz
        <where>
            1=1
            <if test="entity.inv != null and entity.inv != ''">
                and inv like concat('%', #{entity.inv}, '%')
            </if>
            <if test="entity.pripid != null and entity.pripid != ''">
                and prip_id = #{entity.pripid}
            </if>
            <if test="entity.cerType != null and entity.cerType != ''">
                and cer_type = #{entity.cerType}
            </if>
            <if test="entity.status == null or entity.status == ''">
                and status != '5'
            </if>
            <if test="entity.status != null and entity.status != ''">
                and status = #{entity.status}
            </if>
            <if test="entity.decOrg != null and entity.decOrg != ''">
                and dec_org like #{entity.decOrg}
            </if>
            <if test="entity.areaCode != null and entity.areaCode != ''">
                and area_code like #{entity.areaCode}
            </if>
        </where>
        order by update_time desc
    </select>

</mapper>
