<?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.force.mapper.XrForceDeregisterRemMapper">
    <resultMap id="BaseResultMap" type="com.chinaweal.aiccs.aiccs.force.entity.XrForceDeregisterRem">
        <result column="forceremid" property="forceRemId"/>
        <result column="forceresid" property="forceResId"/>
        <result column="forceid" property="forceId"/>
        <result column="pripid" property="pripId"/>
        <result column="entname" property="entName"/>
        <result column="unisc_id" property="uniscId"/>
        <result column="regno" property="regno"/>
        <result column="reg_org" property="regOrg"/>
        <result column="reg_org_cn" property="regOrgCn"/>
        <result column="notice_title" property="noticeTitle"/>
        <result column="notice_content" property="noticeContent"/>
        <result column="status" property="status"/>
        <result column="biz_seq_no" property="bizSeqNo"/>
        <result column="judauth" property="judauth"/>
        <result column="judauth_cn" property="judauthCn"/>
        <result column="forcerra" property="forceRra"/>
        <result column="forcerra_date" property="forceRraDate"/>
        <result column="end_forcerra" property="endForceRra"/>
        <result column="forceres" property="forceRes"/>
        <result column="forceres_date" property="forceResDate"/>
        <result column="apply_time" property="applyTime"/>
        <result column="notice_from" property="noticeFrom"/>
        <result column="notice_to" property="noticeTo"/>
        <result column="is_accept" property="isAccept"/>
        <result column="back_proposal" property="backProposal"/>
        <result column="end_forcerra_cn" property="endForceRraCn"/>
        <result column="rem_type" property="remType"/>
        <result column="force_rem_type" property="forceRemType"/>
        <result column="decision_content" property="decisionContent"/>
        <result column="accept_org" property="acceptOrg"/>
    </resultMap>

    <select id="selectXrForceDeregisterRemTodo" resultType="com.chinaweal.aiccs.aiccs.force.entity.XrForceDeregisterRem">
        select distinct
        task.biz_seq_no as bizSeqNo,
        biz.forceremid as forceRemId,
        biz.pripid as pripId,
        biz.entname as entName,
        biz.unisc_id as uniscId,
        biz.regno as regno,
        biz.reg_org as regOrg,
        biz.forcerra as forceRra,
        biz.status as status,
        biz.end_forcerra as endForceRra,
        biz.apply_time as applyTime,
        biz.force_rem_type as forceRemType,
        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
        from xr_task_list task
        inner join xr_force_deregister_rem biz on task.biz_seq_no = biz.biz_seq_no
        inner join xr_activity activity on task.task_like_id = activity.task_id
        <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.forceRemType != null and param.forceRemType != ''">
                and biz.force_rem_type = #{param.forceRemType}
            </if>
            <if test="param.searchUscc != null and param.searchUscc != ''">
                and (biz.unisc_id = #{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.forceRra != null and param.forceRra != ''">
                and biz.forcerra = #{param.forceRra}
            </if>
            <if test="param.status != null and param.status != ''">
                and biz.status = #{param.status}
            </if>
        </where>
        order by biz.apply_time desc
    </select>

    <select id="selectXrForceDeregisterRemHistory" resultType="com.chinaweal.aiccs.aiccs.force.entity.XrForceDeregisterRem">
        select
        biz.forceremid as forceRemId,
        biz.biz_seq_no as bizSeqNo,
        biz.pripid as pripId,
        biz.entname as entName,
        biz.unisc_id as uniscId,
        biz.regno as regno,
        biz.reg_org as regOrg,
        biz.reg_org_cn as regorgCn,
        biz.forcerra as forceRra,
        biz.status as status,
        biz.end_forcerra as endForceRra,
        biz.forceres_date as forceResDate,
        biz.apply_time as applyTime,
        biz.judauth as judauth,
        biz.judauth_cn as judauthCn,
        biz.forcerra_date as forceRraDate,
        biz.force_rem_type as forceRemType
        from xr_force_deregister_rem biz
        <where>
            1=1
            <if test="param.forceRemType != null and param.forceRemType != ''">
                and biz.force_rem_type = #{param.forceRemType}
            </if>
            <if test="param.searchUscc != null and param.searchUscc != ''">
                and (biz.unisc_id = #{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.forceRra != null and param.forceRra != ''">
                and biz.forcerra = #{param.forceRra}
            </if>
            <if test="param.regOrg != null and param.regOrg != ''">
                and biz.reg_org like #{param.regOrg}
            </if>
            <if test="param.judauth != null and param.judauth != ''">
                and biz.judauth like #{param.judauth}
            </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.apply_time desc
    </select>

</mapper>
