<?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.XrSeriousIllegalPersonSpeListMapper">
    <resultMap id="BaseResultMap" type="com.chinaweal.aiccs.aiccs.seriousillegalPerson.entity.XrSeriousIllegalPersonSpeList">
        <result column="illegal_list_id" property="illegalListId"/>
        <result column="biz_seq_no" property="bizSeqNo"/>
        <result column="inv" property="inv"/>
        <result column="cer_type" property="cerType"/>
        <result column="cer_no" property="cerNo"/>
        <result column="serill_rea" property="serillRea"/>
        <result column="serill_rea_string" property="serillReaString"/>
        <result column="approval_date" property="approvalDate"/>
        <result column="dec_org" property="decOrg"/>
        <result column="area_code" property="areaCode"/>
        <result column="laup_time" property="laupTime"/>
        <result column="lost_credit_explain" property="lostCreditExplain"/>
        <result column="reconsideration_org" property="reconsiderationOrg"/>
        <result column="government_org" property="governmentOrg"/>
        <result column="liti_org" property="litiOrg"/>
        <result column="status" property="status"/>
        <result column="into_sponsor_illegal" property="intoSponsorIllegal"/>
        <result column="end_apply" property="endApply"/>
        <result column="end_reason" property="endReason"/>
        <result column="abn_time" property="abnTime"/>
        <result column="writs_no" property="writsNo"/>
        <result column="party" property="party"/>
        <result column="certificate" property="certificate"/>
        <result column="uscc_id" property="usccId"/>
        <result column="legal_name" property="legalName"/>
        <result column="id_number" property="idNumber"/>
        <result column="phone" property="phone"/>
        <result column="other_cert" property="otherCert"/>
        <result column="residence" property="residence"/>
        <result column="ill_operating_id" property="illOperatingId"/>
        <result column="opinion" property="opinion"/>
        <result column="is_hea" property="isHea"/>
        <result column="hea_op" property="heaOp"/>
        <result column="jud_doc_title" property="judDocTitle"/>
        <result column="jud_doc_no" property="judDocNo"/>
        <result column="case_id" property="caseId"/>
        <result column="correct_biz_seq" property="correctBizSeq"/>
        <result column="hea_opinion" property="heaOpinion"/>
        <result column="sbook_code" property="sbookCode"/>
        <result column="sgist_type_name" property="sgistTypeName"/>
        <result column="spun_type_name" property="spunTypeName"/>
        <result column="pen_am" property="penAm"/>
        <result column="forf_am" property="forfAm"/>
        <result column="penauth" property="penauth"/>
        <result column="penauth_cn" property="penauthCn"/>
        <result column="punishment_decision_date" property="punishmentDecisionDate"/>
        <result column="party_name" property="partyName"/>
        <result column="spun_content" property="spunContent"/>
        <result column="serial_id" property="serialId"/>
        <result column="add_dep_name" property="addDepName"/>
        <result column="add_dep_id" property="addDepId"/>
        <result column="is_finished" property="finished"/>
        <result column="bus_type" property="busType"/>
        <result column="is_displayed" property="displayed"/>
        <result column="is_approve" property="approve"/>
        <result column="source_type" property="sourceType"/>
    </resultMap>

    <select id="selectXrSeriousIllegalPersonSpeListTodo" resultType="com.chinaweal.aiccs.aiccs.seriousillegalPerson.entity.XrSeriousIllegalPersonSpeList">
        SELECT DISTINCT *
        FROM (
        SELECT task.biz_seq_no as bizSeqNo,
        biz.serill_rea as serillRea,
        biz.inv as inv,
        biz.cer_type as cerType,
        biz.cer_no as cerNo,
        biz.area_code as areaCode,
        biz.status as status,
        biz.abn_time as abnTime,
        task.accept_no as acceptNo,
        task.bus_name as entName,
        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 xr_serious_illegal_person_spe_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'
            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.cerType != null and param.cerType != ''">
                and biz.cer_type = #{param.cerType}
            </if>
            <if test="param.cerNo != null and param.cerNo != ''">
                and biz.cer_no = #{param.cerNo}
            </if>
            <if test="param.inv != null and param.inv != ''">
                and biz.inv like concat('%', #{param.inv}, '%')
            </if>
            <if test="param.serillRea != null and param.serillRea != ''">
                and biz.serill_rea = #{param.serillRea}
            </if>
            <if test="param.status != null and param.status != ''">
                and biz.status = #{param.status}
            </if>
        </where>
        order by biz.update_time desc
        ) a
    </select>

    <select id="selectXrSeriousIllegalPersonSpeListHistory" resultType="com.chinaweal.aiccs.aiccs.seriousillegalPerson.entity.XrSeriousIllegalPersonSpeList">
        select
        biz.illegal_list_id as illegalListId,
        biz.biz_seq_no as bizSeqNo,
        biz.serill_rea as serillRea,
        biz.inv as inv,
        biz.cer_type as cerType,
        biz.cer_no as cerNo,
        biz.area_code as areaCode,
        biz.status as status,
        biz.serill_rea_string as serillReaString,
        biz.abn_time as abnTime,
        biz.dec_org as decOrg,
        biz.dec_org_cn as decOrgCn,
        xtf.open_name as openName,
        xtf.transfer_reason as transferReason
        from xr_serious_illegal_person_spe_list biz
        left join xr_task_forward xtf ON biz.biz_seq_no = xtf.biz_seq_no
        <where>
            1=1
            <if test="param.cerType != null and param.cerType != ''">
                and biz.cer_type = #{param.cerType}
            </if>
            <if test="param.cerNo != null and param.cerNo != ''">
                and biz.cer_no = #{param.cerNo}
            </if>
            <if test="param.inv != null and param.inv != ''">
                and biz.inv like concat('%', #{param.inv}, '%')
            </if>
            <if test="param.serillRea != null and param.serillRea != ''">
                and biz.serill_rea = #{param.serillRea}
            </if>
            <if test="param.areaCode != null and param.areaCode != ''">
                and biz.area_code like #{param.areaCode}
            </if>
            <if test="param.status != null and param.status != ''">
                and biz.status = #{param.status}
            </if>
            <if test="param.status == null or param.status == ''">
                and biz.status != '5'
            </if>
        </where>
        order by biz.update_time desc
    </select>

</mapper>
