<?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="cn.cecep.talroad.mapper.BMainPollDisInformationMapper">

    <resultMap type="cn.cecep.talroad.domain.BMainPollDisInformation" id="BMainPollDisInformationResult">
        <result property="informationId"    column="information_id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="pollDisId"    column="poll_dis_id"    />
        <result property="openProcedure"    column="open_procedure"    />
        <result property="timeNodes"    column="time_nodes"    />
        <result property="openContent"    column="open_content"    />
        <result property="otherInformation"    column="other_information"    />
    </resultMap>


    <sql id="selectBMainPollDisInformationVo">
        select information_id, factory_id, poll_dis_id, open_procedure, time_nodes, open_content, other_information from b_main_poll_dis_information
    </sql>

    <select id="selectBMainPollDisInformationList" parameterType="cn.cecep.talroad.domain.BMainPollDisInformation" resultMap="BMainPollDisInformationResult">
        <include refid="selectBMainPollDisInformationVo"/>
        <where>
            <if test="factoryId != null  and factoryId != ''"> and factory_id = #{factoryId}</if>
            <if test="pollDisId != null  and pollDisId != ''"> and poll_dis_id = #{pollDisId}</if>
            <if test="openProcedure != null  and openProcedure != ''"> and open_procedure = #{openProcedure}</if>
            <if test="timeNodes != null  and timeNodes != ''"> and time_nodes = #{timeNodes}</if>
            <if test="openContent != null  and openContent != ''"> and open_content = #{openContent}</if>
            <if test="otherInformation != null  and otherInformation != ''"> and other_information = #{otherInformation}</if>
        </where>
    </select>

    <select id="selectListAndFactory" resultType="cn.cecep.talroad.vo.BMainPollDisInformationVo">
        SELECT
        bmpdi.*,
        pf.factory_name,
        pf.city_code,
        pf.city_name,
        pf.country_code,
        pf.country_name,
        pf.license_man_type,
        pf.poll_dis_license_code,
        pf.usc_code,
        pf.ins_fram_code,
        pf.whether_local_park,
        pf.industrial_park_name,
        pf.industrial_park_code,
        pf.industry_permission_name,
        pf.river_basin
        FROM
        pc_factory pf
        LEFT JOIN b_main_poll_dis_information bmpdi ON pf.ID = bmpdi.factory_id
        <where>
            <if test="collection != null and collection.size() != 0">
                pf.id
                <foreach collection="collection" close=")" open=" IN (" separator="," item="item">
                    #{item,jdbcType=VARCHAR}
                </foreach>
            </if>
        </where>
        ORDER BY pf.order_num, pf.id
    </select>
</mapper>
