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

    <resultMap type="cn.cecep.talroad.domain.BStatTableZxbgHdGasPollution" id="BStatTableZxbgHdGasPollutionResult">
        <result property="id"    column="id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="zxbgType"    column="zxbg_type"    />
        <result property="zxbgPeriod"    column="zxbg_period"    />
        <result property="productionFacilityName"    column="production_facility_name"    />
        <result property="productionFacilityCode"    column="production_facility_code"    />
        <result property="governanceFacilityCode"    column="governance_facility_code"    />
        <result property="governanceFacilityName"    column="governance_facility_name"    />
        <result property="governanceFacilityTime"    column="governance_facility_time"    />
        <result property="flyAshProduction"    column="fly_ash_production"    />
        <result property="bagFilter"    column="bag_filter"    />
        <result property="dustRemovalEfficiency"    column="dust_removal_efficiency"    />
        <result property="actualValue"    column="actual_value"    />
        <result property="desulfurizerDosage"    column="desulfurizer_dosage"    />
        <result property="amountProduct"    column="amount_product"    />
        <result property="designValues"    column="design_values"    />
        <result property="actualEfficiency"    column="actual_efficiency"    />
        <result property="reducingAgentDosage"    column="reducing_agent_dosage"    />
        <result property="denitrationEfficiency"    column="denitration_efficiency"    />
        <result property="efficiencyPractical"    column="efficiency_practical"    />
        <result property="facilityOperatingCosts"    column="facility_operating_costs"    />
        <result property="efficiencyDesignValues"    column="efficiency_design_values"    />
        <result property="actualDustRemoval"    column="actual_dust_removal"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>


    <sql id="selectBStatTableZxbgHdGasPollutionVo">
        select id, factory_id, zxbg_type, zxbg_period, production_facility_name, production_facility_code, governance_facility_code, governance_facility_name, governance_facility_time, fly_ash_production, bag_filter, dust_removal_efficiency, actual_value, desulfurizer_dosage, amount_product, design_values, actual_efficiency, reducing_agent_dosage, denitration_efficiency, efficiency_practical, facility_operating_costs, efficiency_design_values, actual_dust_removal, create_time from b_stat_table_zxbg_hd_gas_pollution
    </sql>

    <select id="selectBStatTableZxbgHdGasPollutionList" parameterType="cn.cecep.talroad.domain.BStatTableZxbgHdGasPollution" resultMap="BStatTableZxbgHdGasPollutionResult">
        <include refid="selectBStatTableZxbgHdGasPollutionVo"/>
        <where>
            <if test="factoryId != null  and factoryId != ''"> and factory_id = #{factoryId}</if>
            <if test="zxbgType != null  and zxbgType != ''"> and zxbg_type = #{zxbgType}</if>
            <if test="zxbgPeriod != null  and zxbgPeriod != ''"> and zxbg_period = #{zxbgPeriod}</if>
            <if test="productionFacilityName != null  and productionFacilityName != ''"> and production_facility_name like concat('%', #{productionFacilityName}, '%')</if>
            <if test="productionFacilityCode != null  and productionFacilityCode != ''"> and production_facility_code = #{productionFacilityCode}</if>
            <if test="governanceFacilityCode != null  and governanceFacilityCode != ''"> and governance_facility_code = #{governanceFacilityCode}</if>
            <if test="governanceFacilityName != null  and governanceFacilityName != ''"> and governance_facility_name like concat('%', #{governanceFacilityName}, '%')</if>
            <if test="governanceFacilityTime != null  and governanceFacilityTime != ''"> and governance_facility_time = #{governanceFacilityTime}</if>
            <if test="flyAshProduction != null  and flyAshProduction != ''"> and fly_ash_production = #{flyAshProduction}</if>
            <if test="bagFilter != null  and bagFilter != ''"> and bag_filter = #{bagFilter}</if>
            <if test="dustRemovalEfficiency != null  and dustRemovalEfficiency != ''"> and dust_removal_efficiency = #{dustRemovalEfficiency}</if>
            <if test="actualValue != null  and actualValue != ''"> and actual_value = #{actualValue}</if>
            <if test="desulfurizerDosage != null  and desulfurizerDosage != ''"> and desulfurizer_dosage = #{desulfurizerDosage}</if>
            <if test="amountProduct != null  and amountProduct != ''"> and amount_product = #{amountProduct}</if>
            <if test="designValues != null  and designValues != ''"> and design_values = #{designValues}</if>
            <if test="actualEfficiency != null  and actualEfficiency != ''"> and actual_efficiency = #{actualEfficiency}</if>
            <if test="reducingAgentDosage != null  and reducingAgentDosage != ''"> and reducing_agent_dosage = #{reducingAgentDosage}</if>
            <if test="denitrationEfficiency != null  and denitrationEfficiency != ''"> and denitration_efficiency = #{denitrationEfficiency}</if>
            <if test="efficiencyPractical != null  and efficiencyPractical != ''"> and efficiency_practical = #{efficiencyPractical}</if>
            <if test="facilityOperatingCosts != null  and facilityOperatingCosts != ''"> and facility_operating_costs = #{facilityOperatingCosts}</if>
            <if test="efficiencyDesignValues != null  and efficiencyDesignValues != ''"> and efficiency_design_values = #{efficiencyDesignValues}</if>
            <if test="actualDustRemoval != null  and actualDustRemoval != ''"> and actual_dust_removal = #{actualDustRemoval}</if>
        </where>
    </select>

    <select id="selectListAndFactory" resultMap="BStatTableZxbgHdGasPollutionResult">
        SELECT
        zxbg.*,
        pf.factory_name,
        pf.country_name,
        pf.license_man_type,
        pf.poll_dis_license_code,
        pf.industrial_park_name,
        pf.industrial_park_code,
        pf.industry_permission_name,
        pf.river_basin
        FROM
        (select * from b_stat_table_zxbg_hd_gas_pollution
        <where>
            <if test="zxbgType != null  and zxbgType != ''"> and zxbg_type = #{zxbgType}</if>
            <if test="zxbgPeriod != null  and zxbgPeriod != ''"> and zxbg_period  like concat('%', #{zxbgPeriod}, '%')</if>
        </where>
        )zxbg
        right JOIN pc_factory pf ON pf.ID = zxbg.factory_id
        <where>
            <if test="factoryIdList != null and factoryIdList.size() != 0">
                and 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>
