<?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.revoke.mapper.BizRevEntMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.chinaweal.aiccs.aiccs.revoke.entity.BizRevEnt">
        <id column="REVLISTID" property="revlistid" />
        <result column="BIZSEQ" property="bizseq" />
        <result column="UNISCID" property="uniscid" />
        <result column="PRIPID" property="pripid" />
        <result column="REGNO" property="regno" />
        <result column="ENTNAME" property="entname" />
        <result column="NAME" property="name" />
        <result column="ENTTYPE" property="enttype" />
        <result column="ENTTYPE_CN" property="enttypeCn" />
        <result column="REMNO" property="remno" />
        <result column="ISREMOVE" property="isremove" />
        <result column="REMOVEREASON" property="removereason" />
        <result column="REMOVETIME" property="removetime" />
        <result column="REMHANDLER" property="remhandler" />
        <result column="ISHEARING" property="ishearing" />
        <result column="ISHEARINGPUBLISH" property="ishearingpublish" />
        <result column="HEARINGPUBLISHDATE" property="hearingpublishdate" />
        <result column="ISDECISIONPUBLISH" property="isdecisionpublish" />
        <result column="DECISIONPUBLISHDATE" property="decisionpublishdate" />
        <result column="NOOPENSTATE" property="noopenstate" />
        <result column="INSERTTIME" property="inserttime" />
        <result column="LAUPTIME" property="lauptime" />
        <result column="PRE_PUN_DEC_WRITSNO" property="prePunDecWritsno" />
        <result column="PRE_HEAR_NOT_WRITSNO" property="preHearNotWritsno" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        REVLISTID, BIZSEQ, UNISCID, PRIPID, REGNO, ENTNAME, NAME, ENTTYPE, ENTTYPE_CN, REMNO, ISREMOVE, REMOVEREASON,
        REMOVETIME, REMHANDLER, ISHEARING, ISHEARINGPUBLISH, HEARINGPUBLISHDATE, ISDECISIONPUBLISH, DECISIONPUBLISHDATE,
         NOOPENSTATE, INSERTTIME, LAUPTIME,PRE_PUN_DEC_WRITSNO,PRE_HEAR_NOT_WRITSNO
    </sql>

    <!--    <select id="selectFirstEnt" resultType="com.chinaweal.aiccs.aiccs.revoke.entity.Tsbizrevlist">-->
    <!--        select <include refid="Base_Column_List"/>-->
    <!--        from biz_rev_ent-->
    <!--        where BIZSEQ = #{bizseq} and ISREMOVE = '0'-->
    <!--        order by INSERTTIME desc-->
    <!--    </select>-->

    <insert id="insertOrUpdateBatch" parameterType="java.util.List">
        insert into biz_rev_ent (REVLISTID,PRE_PUN_DEC_WRITSNO,LAUPTIME) values
        <foreach collection="list" index="index" item="item" separator=",">
            ( #{item.revlistid,jdbcType=VARCHAR},
            #{item.prePunDecWritsno,jdbcType=VARCHAR},
            #{item.lauptime,jdbcType=TIMESTAMP}
            )
        </foreach>
        on duplicate key update PRE_PUN_DEC_WRITSNO = values(PRE_PUN_DEC_WRITSNO),LAUPTIME = values(LAUPTIME)
    </insert>

    <select id="selectBizEntAttachList" parameterType="java.lang.String" resultType="com.chinaweal.aiccs.aiccs.revoke.entity.dto.BizRevEntAttachDto">
        SELECT b.REVLISTID, b.BIZSEQ, b.UNISCID, b.PRIPID, b.REGNO, b.ENTNAME, b.NAME, ENTTYPE, ENTTYPE_CN, b.REMNO, ISREMOVE, REMOVEREASON,
               b.REMOVETIME, b.REMHANDLER, ISHEARING, ISHEARINGPUBLISH, HEARINGPUBLISHDATE, ISDECISIONPUBLISH, DECISIONPUBLISHDATE,
               NOOPENSTATE, INSERTTIME, b.LAUPTIME,PRE_PUN_DEC_WRITSNO,PRE_HEAR_NOT_WRITSNO,a.ATTACHMENTID
        FROM biz_rev_ent b
                 LEFT JOIN tsattachment a on a.BIZSEQ = b.BIZSEQ and a.pripid = b.pripid
        WHERE a.BIZSEQ = #{bizseq} and a.ATTACHTYPE = #{attachType} and b.ISREMOVE = '0'
        order by INSERTTIME asc
    </select>


</mapper>
