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

    <resultMap type="cn.cecep.talroad.domain.BMainAllowablePollutionAir" id="BMainAllowablePollutionAirResult">
        <result property="id"    column="id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="pollDisId"    column="poll_dis_id"    />
        <result property="pollutionCategory"    column="pollution_category"    />
        <result property="pollName"    column="poll_name"    />
        <result property="organizedFrist"    column="organized_frist"    />
        <result property="organizedSecond"    column="organized_second"    />
        <result property="organizedThird"    column="organized_third"    />
        <result property="organizedFourth"    column="organized_fourth"    />
        <result property="organizedFifth"    column="organized_fifth"    />
        <result property="inorganizationFrist"    column="inorganization_frist"    />
        <result property="inorganizationSecond"    column="inorganization_second"    />
        <result property="inorganizationThird"    column="inorganization_third"    />
        <result property="inorganizationFourth"    column="inorganization_fourth"    />
        <result property="inorganizationFifth"    column="inorganization_fifth"    />
        <result property="totalFrist"    column="total_frist"    />
        <result property="totalSecond"    column="total_second"    />
        <result property="totalThird"    column="total_third"    />
        <result property="totalFourth"    column="total_fourth"    />
        <result property="totalFifth"    column="total_fifth"    />
    </resultMap>


    <sql id="selectBMainAllowablePollutionAirVo">
        select bmapa.id, factory_id, poll_dis_id, pollution_category, pp.poll_name, organized_frist, organized_second, organized_third, organized_fourth, organized_fifth, inorganization_frist, inorganization_second, inorganization_third, inorganization_fourth, inorganization_fifth, total_frist, total_second, total_third, total_fourth, total_fifth from b_main_allowable_pollution_air bmapa
    </sql>

    <select id="selectBMainAllowablePollutionAirList" parameterType="cn.cecep.talroad.domain.BMainAllowablePollutionAir" resultMap="BMainAllowablePollutionAirResult">
        <include refid="selectBMainAllowablePollutionAirVo"/>
        <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="pollutionCategory != null  and pollutionCategory != ''"> and pollution_category = #{pollutionCategory}</if>
            <if test="organizedFrist != null  and organizedFrist != ''"> and organized_frist = #{organizedFrist}</if>
            <if test="organizedSecond != null  and organizedSecond != ''"> and organized_second = #{organizedSecond}</if>
            <if test="organizedThird != null  and organizedThird != ''"> and organized_third = #{organizedThird}</if>
            <if test="organizedFourth != null  and organizedFourth != ''"> and organized_fourth = #{organizedFourth}</if>
            <if test="organizedFifth != null  and organizedFifth != ''"> and organized_fifth = #{organizedFifth}</if>
            <if test="inorganizationFrist != null  and inorganizationFrist != ''"> and inorganization_frist = #{inorganizationFrist}</if>
            <if test="inorganizationSecond != null  and inorganizationSecond != ''"> and inorganization_second = #{inorganizationSecond}</if>
            <if test="inorganizationThird != null  and inorganizationThird != ''"> and inorganization_third = #{inorganizationThird}</if>
            <if test="inorganizationFourth != null  and inorganizationFourth != ''"> and inorganization_fourth = #{inorganizationFourth}</if>
            <if test="inorganizationFifth != null  and inorganizationFifth != ''"> and inorganization_fifth = #{inorganizationFifth}</if>
            <if test="totalFrist != null  and totalFrist != ''"> and total_frist = #{totalFrist}</if>
            <if test="totalSecond != null  and totalSecond != ''"> and total_second = #{totalSecond}</if>
            <if test="totalThird != null  and totalThird != ''"> and total_third = #{totalThird}</if>
            <if test="totalFourth != null  and totalFourth != ''"> and total_fourth = #{totalFourth}</if>
            <if test="totalFifth != null  and totalFifth != ''"> and total_fifth = #{totalFifth}</if>
        </where>
    </select>

    <select id="selectBMainAllowablePollutionAirPageList" resultMap="BMainAllowablePollutionAirResult">
        <include refid="selectBMainAllowablePollutionAirVo"/>
        LEFT JOIN pc_pollutant pp on pp.id = bmapa.pollution_category
        ${ew.customSqlSegment}
    </select>
    <select id="selectLabelBMainAllowablePollutionAir" resultMap="BMainAllowablePollutionAirResult">
        <include refid="selectBMainAllowablePollutionAirVo"/>
        LEFT JOIN pc_pollutant pp on pp.id = bmapa.pollution_category
    </select>

</mapper>
