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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.chinaweal.aiccs.aiccs.seriousillegal.entity.TSForIllOperatingBn">
        <id column="ILLOPERATINGID" property="illoperatingid" />
        <result column="BIZSEQ" property="bizseq" />
        <result column="ABNLISTID" property="abnlistid" />
        <result column="PRIPID" property="pripid" />
        <result column="REGNO" property="regno" />
        <result column="UNISCID" property="uniscid" />
        <result column="ENTNAME" property="entname" />
        <result column="SERILLREA" property="serillrea" />
        <result column="ABNTIME" property="abntime" />
        <result column="DECORG" property="decorg" />
        <result column="AREA_CODE" property="areaCode" />
        <result column="LAUPTIME" property="lauptime" />
        <result column="LOSTCREDITEXPLAIN" property="lostcreditexplain" />
        <result column="ReconsiderationOrg" property="reconsiderationOrg" />
        <result column="GovernmentOrg" property="governmentOrg" />
        <result column="LitiOrg" property="litiOrg" />
        <result column="intoSponsorIllegal" property="intoSponsorIllegal" />
        <result column="remSponsorIllegal" property="remSponsorIllegal" />
        <result column="operationStatus" property="operationStatus" />
        <result column="INTOWRITID" property="intowritid" />
    </resultMap>


    <select id="selectSerIllegalByPageList" parameterType="com.chinaweal.aiccs.aiccs.seriousillegal.entity.TSForIllOperatingBn" resultMap="BaseResultMap">
        SELECT  t.*,l.acceptno from TSForIllOperatingBn t, tstasklist l,e_baseinfo e
        <where>
            t.BIZSEQ = l.bizseqid
            and t.pripid = e.pripid
            and t.operationStatus = '0'
            and ((DATEDIFF(DD, CURDATE(), t.ABNTIME) > 60 and t.batchAndCase = '0') or (DATEDIFF(DD, CURDATE(), t.ABNTIME) > 60 and t.batchAndCase = '1'))
        <if test="params.acceptRegorg != null and params.acceptRegorg !='' ">
            and e.acceptRegorg = #{params.acceptRegorg}
        </if>
        <if test="params.regorg != null and params.regorg !='' ">
            and e.regorg like #{params.regorg}
        </if>
        <if test="params.regno != null and params.regno != ''">
            and t.regno = #{params.regno,jdbcType=VARCHAR}
        </if>
        <if test="params.uniscid != null and params.uniscid != ''">
            and t.UNISCID = #{params.uniscid,jdbcType=VARCHAR}
        </if>
        <if test="params.searchName != null and params.searchName != ''">
            and t.entname like concat('%',#{params.searchName}, '%')
        </if>
        <if test="params.acceptno != null and params.acceptno != ''">
            and l.acceptno = #{params.acceptno,jdbcType=CHAR}
        </if>
        <if test="params.serillrea != null and params.serillrea != ''">
            and t.SERILLREA = #{params.serillrea,jdbcType=CHAR}
        </if>
        <if test="params.abntime != null and params.abntime != ''">
            and t.ABNTIME = #{params.abntime}
        </if>
        </where>
        ORDER BY t.ABNTIME desc
    </select>

    <select id="queryByAbnTime" resultMap="BaseResultMap">
        select * from aiccs.tsforilloperatingbn t
        where date_format(date_add(abntime, interval 61 day), '%Y-%m-%d') = date_format(now(), '%Y-%m-%d')
        and operationStatus = '0'
    </select>

</mapper>
