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

    <resultMap type="cn.cecep.talroad.domain.BMainPollDisNoiseRegulation" id="BMainPollDisNoiseRegulationResult">
        <result property="id"    column="id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="pollDisId"    column="poll_dis_id"    />
        <result property="rectificationProblem"    column="rectification_problem"    />
        <result property="rectificationMeasures"    column="rectification_measures"    />
        <result property="rectificationTime"    column="rectification_time"    />
        <result property="rectificationPlan"    column="rectification_plan"    />
        <result property="rectificationIsComplete"    column="rectification_is_complete"    />
    </resultMap>


    <sql id="selectBMainPollDisNoiseRegulationVo">
        select id, factory_id, poll_dis_id, rectification_problem, rectification_measures, rectification_time, rectification_plan, rectification_is_complete from b_main_poll_dis_noise_regulation
    </sql>

    <select id="selectBMainPollDisNoiseRegulationList" parameterType="cn.cecep.talroad.domain.BMainPollDisNoiseRegulation" resultMap="BMainPollDisNoiseRegulationResult">
        <include refid="selectBMainPollDisNoiseRegulationVo"/>
        <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="rectificationProblem != null  and rectificationProblem != ''"> and rectification_problem = #{rectificationProblem}</if>
            <if test="rectificationMeasures != null  and rectificationMeasures != ''"> and rectification_measures = #{rectificationMeasures}</if>
            <if test="rectificationTime != null  and rectificationTime != ''"> and rectification_time = #{rectificationTime}</if>
            <if test="rectificationPlan != null  and rectificationPlan != ''"> and rectification_plan = #{rectificationPlan}</if>
            <if test="rectificationIsComplete != null  and rectificationIsComplete != ''"> and rectification_is_complete = #{rectificationIsComplete}</if>
        </where>
    </select>

    <select id="selectListAndFactory" resultType="cn.cecep.talroad.vo.BMainPollDisNoiseRegulationVo">
        SELECT
        bmpdnr.*,
        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
        b_main_poll_dis_noise_regulation bmpdnr
        Right JOIN pc_factory pf ON pf.ID = bmpdnr.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>
