<?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.forcedCancellation.mapper.ForceLogoutNoticeDetailMapper">

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        FORCERESID,
    FORCEID,
    BIZSEQID,
    PRIPID,
    ENTNAME,
    UNISCID,
    ENTTYPE,
    ENTTYPE_CN,
    STATUS,
    ISREMOVE,
    REMNO,
    REMOVEREASON,
    REMOVETIME,
    IS_CANCEL_NOTICE,
    INTOSPONSOR,
    INTOSPONSORID,
    REMHANDLER,
    ISDECISIONPUBLISH,
    DECISIONPUBLISHDATE,
    NOOPENSTATE,
    DECWRITSTARTNO,
    DECFIRSTWRIT,
    HANDLEORG,
    HANDLEORGCN,
    REGORG,
    REGORG_CN,
    DECDATE,
    ANNDATE,
    NOTICEFROM,
    NOTICETO,
    FORCERRA,
    FORCERRADATE,
    WEBSITE,
    REGNO,
    DOM,
    LEREP,
    FORCEREGOPI,
    FORCERES,
    FORCERESDATE,
    ENDFORCERRA,
    S_EXT_FROMNODE,
    S_EXT_DATATIME,
    CREATE_TIME,
    LAUPTIME
    </sql>


    <!-- 根据公告ID查询明细列表 -->
    <select id="selectByForceId" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE FORCEID = #{forceId}
        ORDER BY S_EXT_DATATIME DESC
    </select>

    <!-- 根据业务ID查询明细列表 -->
    <select id="selectByBizSeqId" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE BIZSEQID = #{bizseqId}
        ORDER BY S_EXT_DATATIME DESC
    </select>

    <!-- 根据主体标识查询明细列表 -->
    <select id="selectByPripid" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE PRIPID = #{pripid}
        ORDER BY S_EXT_DATATIME DESC
    </select>

    <!-- 根据统一社会信用代码查询 -->
    <select id="selectByUniscid" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE UNISCID = #{uniscid}
        ORDER BY S_EXT_DATATIME DESC
    </select>

    <!-- 根据企业名称查询 -->
    <select id="selectByEntName" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE ENTNAME LIKE CONCAT('%', #{entName}, '%')
        ORDER BY S_EXT_DATATIME DESC
    </select>

    <!-- 根据登记机关查询 -->
    <select id="selectByRegOrg" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE REGORG = #{regOrg}
        ORDER BY S_EXT_DATATIME DESC
    </select>

    <!-- 根据处理结果查询 -->
    <select id="selectByForceRes" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE FORCERES = #{forceRes}
        ORDER BY S_EXT_DATATIME DESC
    </select>

    <!-- 根据公告日期范围查询 -->
    <select id="selectByNoticeDateRange" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE NOTICEFROM >= #{noticeFrom}
        AND NOTICETO &lt;= #{noticeTo}
        ORDER BY S_EXT_DATATIME DESC
    </select>

    <!-- 根据二级部署标识查询 -->
    <select id="selectBySExtFromnode" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE S_EXT_FROMNODE = #{sExtFromnode}
        ORDER BY S_EXT_DATATIME DESC
    </select>

    <!-- 批量更新处理结果 -->
    <update id="batchUpdateResult">
        UPDATE AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        SET FORCERES = #{forceRes},
            FORCERESDATE = #{forceResDate},
            S_EXT_DATATIME = SYSTIMESTAMP
        WHERE FORCERESID IN
        <foreach collection="forceResIds" item="forceResId" open="(" separator="," close=")">
            #{forceResId}
        </foreach>
    </update>

    <!-- 根据业务ID和主体标识查询最新明细 -->
    <select id="selectLatestByBizAndPripid" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE BIZSEQID = #{bizseqId}
        AND PRIPID = #{pripid}
        ORDER BY S_EXT_DATATIME DESC
        LIMIT 1
    </select>

    <!-- 统计不同处理结果的数量 -->
    <select id="statisticsByForceRes" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT FORCERES
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE FORCEID = #{forceId}
        GROUP BY FORCERES
    </select>

    <!-- 根据公告ID和登记机关查询 -->
    <select id="selectByForceIdAndRegOrg" resultType="com.chinaweal.aiccs.aiccs.forcedCancellation.entity.ForceLogoutNoticeDetail">
        SELECT
        <include refid="Base_Column_List"/>
        FROM AICCS.FORCE_LOGOUT_NOTICE_DETAIL
        WHERE FORCEID = #{forceId}
        AND REGORG = #{regOrg}
        ORDER BY S_EXT_DATATIME DESC
    </select>



</mapper>
