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

    <resultMap type="cn.cecep.talroad.domain.BMainPollDisEnforcement" id="BMainPollDisEnforcementResult">
        <result property="enforcementId"    column="enforcement_id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="pollDisId"    column="poll_dis_id"    />
        <result property="emlType"    column="eml_type"    />
        <result property="recordContent"    column="record_content"    />
        <result property="recordFrequency"    column="record_frequency"    />
        <result property="openContent"    column="open_content"    />
        <result property="otherInformation"    column="other_information"    />
    </resultMap>


    <sql id="selectBMainPollDisEnforcementVo">
        select enforcement_id, factory_id, poll_dis_id, ........pg.dropped.4........, ........pg.dropped.5........, eml_type, ........pg.dropped.7........, ........pg.dropped.8........, ........pg.dropped.9........, ........pg.dropped.10........, ........pg.dropped.11........, ........pg.dropped.12........, ........pg.dropped.13........, ........pg.dropped.14........, ........pg.dropped.15........, ........pg.dropped.16........, ........pg.dropped.17........, record_content, record_frequency, open_content, other_information from b_main_poll_dis_enforcement
    </sql>

    <select id="selectBMainPollDisEnforcementList" parameterType="cn.cecep.talroad.domain.BMainPollDisEnforcement" resultMap="BMainPollDisEnforcementResult">
        <include refid="selectBMainPollDisEnforcementVo"/>
        <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="........pg.dropped.4........ != null  and ........pg.dropped.4........ != ''"> and ........pg.dropped.4........ = #{........pg.dropped.4........}</if>
            <if test="........pg.dropped.5........ != null  and ........pg.dropped.5........ != ''"> and ........pg.dropped.5........ = #{........pg.dropped.5........}</if>
            <if test="emlType != null  and emlType != ''"> and eml_type = #{emlType}</if>
            <if test="........pg.dropped.7........ != null  and ........pg.dropped.7........ != ''"> and ........pg.dropped.7........ = #{........pg.dropped.7........}</if>
            <if test="........pg.dropped.8........ != null  and ........pg.dropped.8........ != ''"> and ........pg.dropped.8........ = #{........pg.dropped.8........}</if>
            <if test="........pg.dropped.9........ != null  and ........pg.dropped.9........ != ''"> and ........pg.dropped.9........ = #{........pg.dropped.9........}</if>
            <if test="........pg.dropped.10........ != null  and ........pg.dropped.10........ != ''"> and ........pg.dropped.10........ = #{........pg.dropped.10........}</if>
            <if test="........pg.dropped.11........ != null  and ........pg.dropped.11........ != ''"> and ........pg.dropped.11........ = #{........pg.dropped.11........}</if>
            <if test="........pg.dropped.12........ != null  and ........pg.dropped.12........ != ''"> and ........pg.dropped.12........ = #{........pg.dropped.12........}</if>
            <if test="........pg.dropped.13........ != null  and ........pg.dropped.13........ != ''"> and ........pg.dropped.13........ = #{........pg.dropped.13........}</if>
            <if test="........pg.dropped.14........ != null  and ........pg.dropped.14........ != ''"> and ........pg.dropped.14........ = #{........pg.dropped.14........}</if>
            <if test="........pg.dropped.15........ != null  and ........pg.dropped.15........ != ''"> and ........pg.dropped.15........ = #{........pg.dropped.15........}</if>
            <if test="........pg.dropped.16........ != null  and ........pg.dropped.16........ != ''"> and ........pg.dropped.16........ = #{........pg.dropped.16........}</if>
            <if test="........pg.dropped.17........ != null  and ........pg.dropped.17........ != ''"> and ........pg.dropped.17........ = #{........pg.dropped.17........}</if>
            <if test="recordContent != null  and recordContent != ''"> and record_content = #{recordContent}</if>
            <if test="recordFrequency != null  and recordFrequency != ''"> and record_frequency = #{recordFrequency}</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.BMainPollDisEnforcementVo">
        SELECT
        bmpde.*,
        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_enforcement bmpde ON pf.ID = bmpde.factory_id
        <if test="recordFrequencys != null and recordFrequencys.size() != 0">
            AND bmpde.record_frequency
            <foreach collection="recordFrequencys" close=")" open=" IN (" separator="," item="item">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <where>
            <if test="factoryIdList != null and factoryIdList.size() != 0">
                pf.id
                <foreach collection="factoryIdList" close=")" open=" IN (" separator="," item="item">
                    #{item,jdbcType=VARCHAR}
                </foreach>
            </if>
        </where>
        ORDER BY pf.order_num, pf.id
    </select>
</mapper>
