<?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.tofly.xrtymis.mapper.ResultdispMapper">

    <resultMap id="resultdispMap" type="com.tofly.xrtymis.entity.Resultdisp">
        <result property="id" column="ID"/>
        <result property="gdbh" column="GDBH"/>
        <result property="importLcjd" column="IMPORT_LCJD"/>
        <result property="lcjdName" column="LCJD_NAME"/>
        <result property="departId" column="DEPART_ID"/>
        <result property="departName" column="DEPART_NAME"/>
        <result property="personId" column="PERSON_ID"/>
        <result property="personName" column="PERSON_NAME"/>
        <result property="isCollect" column="IS_COLLECT"/>
        <result property="isFinish" column="IS_FINISH"/>
        <result property="czyj" column="CZYJ"/>
        <result property="czsj" column="CZSJ"/>
        <result property="importDate" column="IMPORT_DATE"/>
        <result property="isDeploy" column="IS_DEPLOY"/>
        <result property="fileInfo" column="FILE_INFO"/>
        <association property="jgczFileInfo" column="FILE_INFO" select="jgczFile"/>
    </resultMap>

    <select id="jgczFile" resultType="File">
        select * FROM TF_YWPN_FILE_W WHERE ID in
        <if test="jgczFileid != null and jgczFileid.trim() != ''">
            <foreach item="jgczFileid" index="jgczFileid" collection="jgczFileid.split(',')" separator="," open="("
                     close=")">
                #{jgczFileid}
            </foreach>
        </if>
    </select>

    <select id="getMaxId" resultType="java.lang.Long">
        select nvl(max(id), 0) + 1
        from TF_YWPN_RESULTDISP_W
    </select>

    <select id="getResultdis" resultMap="resultdispMap">
        SELECT *
        FROM TF_YWPN_RESULTDISP_W
        WHERE GDBH = #{gdbh}
    </select>

    <insert id="insertBatch">
        insert into TF_YWPN_RESULTDISP_W(ID, GDBH , IMPORT_LCJD , LCJD_NAME , DEPART_ID , DEPART_NAME ,
                                         PERSON_ID , PERSON_NAME ,IS_COLLECT , IS_FINISH , IMPORT_DATE)
        <foreach collection="list" item="dis" separator="union all">
            select
            #{dis.id},
            #{dis.gdbh},
            #{dis.importLcjd},
            #{dis.lcjdName},
            #{dis.departId},
            #{dis.departName},
            #{dis.personId},
            #{dis.personName},
            #{dis.isCollect},
            #{dis.isFinish},
            #{dis.importDate}
            from dual
        </foreach>
    </insert>


</mapper>
