<?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="com.testor.module.environment.dao.TEnvironmentMonthlyDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.environment.model.domain.TEnvironmentMonthly">
        <id column="id" property="id"/>
        <id column="org_id" property="orgId"/>
        <id column="org_name" property="orgName"/>
        <id column="month" property="month"/>
        <id column="energy_coal" property="energyCoal"/>
        <id column="energy_power" property="energyPower"/>
        <id column="energy_gasoline" property="energyGasoline"/>
        <id column="energy_derv" property="energyDerv"/>
        <id column="energy_fuel" property="energyFuel"/>
        <id column="energy_natural" property="energyNatural"/>
        <id column="energy_heating" property="energyHeating"/>
        <id column="energy_other" property="energyOther"/>
        <id column="energy_synthesize" property="energySynthesize"/>
        <id column="water_new" property="waterNew"/>
        <id column="water_repetition" property="waterRepetition"/>
        <id column="water_rate" property="waterRate"/>
        <id column="w_pollutant_o_discharge" property="wPollutantODischarge"/>
        <id column="w_pollutant_o_cod" property="wPollutantOCod"/>
        <id column="w_pollutant_o_NH3N" property="wPollutantONh3n"/>
        <id column="w_pollutant_i_discharge" property="wPollutantIDischarge"/>
        <id column="w_pollutant_i_cod" property="wPollutantICod"/>
        <id column="w_pollutant_i_NH3N" property="wPollutantINh3n"/>
        <id column="w_pollutant_third_discharge" property="wPollutantThirdDischarge"/>
        <id column="w_pollutant_third_cod" property="wPollutantThirdCod"/>
        <id column="w_pollutant_third_NH3N" property="wPollutantThirdNh3n"/>
        <id column="w_pollutant_discharge_sum" property="wPollutantDischargeSum"/>
        <id column="w_pollutant_cod_sum" property="wPollutantCodSum"/>
        <id column="w_pollutant_NH3N_sum" property="wPollutantNh3nSum"/>
        <id column="atmosphere_pollutant_stack" property="atmospherePollutantStack"/>
        <id column="atmosphere_pollutant_so2" property="atmospherePollutantSo2"/>
        <id column="atmosphere_pollutant_NH3n" property="atmospherePollutantNh3n"/>
        <id column="atmosphere_pollutant_NH3n_organic" property="atmospherePollutantNh3nOrganic"/>
        <id column="atmosphere_pollutant_NH3n_co2" property="atmospherePollutantNh3nCo2"/>
        <id column="atmosphere_pollutant_NH3n_count" property="atmospherePollutantNh3nCount"/>
        <id column="solid_slag" property="solidSlag"/>
        <id column="solid_sieve" property="solidSieve"/>
        <id column="solid_other" property="solidOther"/>
        <id column="solid_produce" property="solidProduce"/>
        <id column="solid_use" property="solidUse"/>
        <id column="solid_municipal" property="solidMunicipal"/>
        <id column="solid_dispose" property="solidDispose"/>
        <id column="solid_ratio" property="solidRatio"/>
        <id column="risk_produce" property="riskProduce"/>
        <id column="risk_dispose" property="riskDispose"/>
        <id column="risk_ratio" property="riskRatio"/>
        <id column="energy_put" property="energyPut"/>
        <id column="recycle_put" property="recyclePut"/>
        <id column="appear_status" property="appearStatus"/>
        <id column="process_status" property="processStatus"/>
        <id column="reject_opinion" property="rejectOpinion"/>
    </resultMap>
    <update id="updateUnit">
        UPDATE t_environment_monthly
        SET
            energy_synthesize = CAST(energy_synthesize AS DECIMAL(18, 2)) * 10000,
            water_new = CAST(water_new AS DECIMAL(18, 2)) * 10000,
            water_rate = CAST(water_rate AS DECIMAL(18, 2) * 10000,
            w_pollutant_o_discharge = CAST(w_pollutant_o_discharge AS DECIMAL(18, 2)) * 10000,
            w_pollutant_i_discharge = CAST(w_pollutant_i_discharge AS DECIMAL(18, 2)) * 10000,
            energy_coal = CAST(energy_coal AS DECIMAL(18, 2)) * 10000
    </update>

    <select id="getListCount" parameterType="com.testor.module.environment.model.dto.TEnvironmentMonthlyParam"
            resultType="com.testor.module.environment.model.domain.TEnvironmentMonthly" databaseId="mysql">
        SELECT
        ROUND(SUM(energy_synthesize), 5) AS energySynthesize,
        CASE
        WHEN ROUND((SUM(water_repetition) * 100 / (SUM(water_new) + SUM(water_repetition))), 5) = ROUND((SUM(water_repetition) * 100 / (SUM(water_new) + SUM(water_repetition))), 0)
        THEN CAST(ROUND((SUM(water_repetition) * 100 / (SUM(water_new) + SUM(water_repetition))), 0) AS SIGNED)
        ELSE ROUND((SUM(water_repetition) * 100 / (SUM(water_new) + SUM(water_repetition))), 5)
        END AS waterRate,
        ROUND(SUM(w_pollutant_discharge_sum), 5) AS wpollutantDischargeSum,
        ROUND(SUM(w_pollutant_cod_sum), 5) AS wpollutantCodSum,
        ROUND(SUM(w_pollutant_NH3N_sum), 5) AS wpollutantNh3nSum,
        ROUND(SUM(atmosphere_pollutant_stack), 5) AS atmospherePollutantStack,
        ROUND(SUM(atmosphere_pollutant_so2), 5) AS atmospherePollutantSo2,
        ROUND(SUM(atmosphere_pollutant_NH3n), 5) AS atmospherePollutantNh3n,
        ROUND(SUM(atmosphere_pollutant_NH3n_organic), 5) AS atmospherePollutantNh3nOrganic,
        ROUND(SUM(atmosphere_pollutant_NH3n_co2), 5) AS atmospherePollutantNh3nCo2,
        CASE
        WHEN ROUND(SUM(solid_use) * 100 / SUM(solid_produce), 2) = ROUND(SUM(solid_use) * 100 / SUM(solid_produce), 0)
        THEN CAST(ROUND(SUM(solid_use) * 100 / SUM(solid_produce), 0) AS SIGNED)
        ELSE ROUND(SUM(solid_use) * 100 / SUM(solid_produce), 2)
        END AS solidRatio,
        IFNULL(ROUND(SUM(risk_dispose) * 100 / SUM(risk_produce), 2), 0) AS riskRatio,
        ROUND(SUM(energy_put), 5) AS energyPut,
        ROUND(SUM(recycle_put), 5) AS recyclePut
        FROM t_environment_monthly
        where
            status = 0
        <if test="param.startDate!=null and param.startDate!='' and param.endDate!=null and param.endDate!=''">
            AND month between #{param.startDate} and #{param.endDate}
        </if>
        <if test="param.processStatus!=null and param.processStatus!='' ">
            AND process_status = #{param.processStatus}
        </if>
        <if test="companyIds!=null and companyIds.size>0">
            AND org_id in
            <foreach open="(" close=")" separator="," collection="companyIds" item="item" index="index">
                #{item}
            </foreach>
        </if>
        and org_id in
        (select org.org_id from t_sys_org org where org.parent_ids like concat('%', #{orgId}, '%') or org.org_id = #{orgId})
    </select>
    <select id="getListCount" parameterType="com.testor.module.environment.model.dto.TEnvironmentMonthlyParam"
            resultType="com.testor.module.environment.model.domain.TEnvironmentMonthly" databaseId="kingbase">
        SELECT
        ROUND(SUM(energy_synthesize), 5) AS energySynthesize,
        CASE
        WHEN (SUM(water_new) + SUM(water_repetition)) = 0 THEN 0
        WHEN ROUND((SUM(water_repetition) * 100 / (SUM(water_new) + SUM(water_repetition))), 5) = ROUND((SUM(water_repetition) * 100 / (SUM(water_new) + SUM(water_repetition))), 0) THEN CAST(ROUND((SUM(water_repetition) * 100 / (SUM(water_new) + SUM(water_repetition))), 0) AS INTEGER)
        ELSE ROUND((SUM(water_repetition) * 100 / (SUM(water_new) + SUM(water_repetition))), 5)
        END AS waterRate,
        ROUND(SUM(NULLIF(w_pollutant_discharge_sum, 0)), 5) AS wpollutantDischargeSum,
        ROUND(SUM(NULLIF(w_pollutant_cod_sum, 0)), 5) AS wpollutantCodSum,
        ROUND(SUM(NULLIF(w_pollutant_NH3N_sum, 0)), 5) AS wpollutantNh3nSum,
        ROUND(SUM(NULLIF(atmosphere_pollutant_stack, 0)), 5) AS atmospherePollutantStack,
        ROUND(SUM(NULLIF(atmosphere_pollutant_so2, 0)), 5) AS atmospherePollutantSo2,
        ROUND(SUM(NULLIF(atmosphere_pollutant_NH3n, 0)), 5) AS atmospherePollutantNh3n,
        ROUND(SUM(NULLIF(atmosphere_pollutant_NH3n_organic, 0)), 5) AS atmospherePollutantNh3nOrganic,
        ROUND(SUM(NULLIF(atmosphere_pollutant_NH3n_co2, 0)), 5) AS atmospherePollutantNh3nCo2,
        CASE
        WHEN SUM(solid_produce) = 0 THEN 0
        WHEN ROUND(SUM(solid_use) * 100 / SUM(solid_produce), 2) = ROUND(SUM(solid_use) * 100 / SUM(solid_produce), 0) THEN CAST(ROUND(SUM(solid_use) * 100 / SUM(solid_produce), 0) AS INTEGER)
        ELSE ROUND(SUM(solid_use) * 100 / SUM(solid_produce), 2)
        END AS solidRatio,
        IFNULL(
        CASE
        WHEN SUM(risk_produce) = 0 THEN 0
        ELSE ROUND(SUM(risk_dispose) * 100 / SUM(risk_produce), 2)
        END,
        0
        ) AS riskRatio,
        ROUND(SUM(NULLIF(energy_put, 0)), 5) AS energyPut,
        ROUND(SUM(NULLIF(recycle_put, 0)), 5) AS recyclePut
        FROM
        t_environment_monthly
        where
        status = 0
        <if test="param.startDate!=null and param.startDate!='' and param.endDate!=null and param.endDate!=''">
            AND month between #{param.startDate} and #{param.endDate}
        </if>
        <if test="param.processStatus!=null and param.processStatus!='' ">
            AND process_status = #{param.processStatus}
        </if>
        <if test="companyIds!=null and companyIds.size>0">
            AND org_id in
            <foreach open="(" close=")" separator="," collection="companyIds" item="item" index="index">
                #{item}
            </foreach>
        </if>
        <if test="orgId!=null and orgId!='' ">
            and org_id in  (select org.org_id from t_sys_org org where org.parent_ids like concat('%',  #{orgId},  '%') or org.org_id =  #{orgId} )
        </if>
    </select>


    <select id="getListMonth" parameterType="com.testor.module.environment.model.dto.TEnvironmentMonthlyParam"
            resultType="com.testor.module.environment.model.domain.TEnvironmentMonthly" databaseId="mysql" >
        select mm.org_id,mm.org_name,basi.*
        from t_sys_org mm
        left join t_environment_monthly basi
        on mm.org_id = basi.org_id
        where mm.is_dept = '0'
        and mm.org_id in (select org.org_id
        from t_sys_org org
        where org.parent_ids like concat('%', #{orgId}, '%')
        or org.org_id = #{orgId})
        <if test="param.companyIds!=null and param.companyIds.size>0">
            AND mm.org_id in
            <foreach open="(" close=")" separator="," collection="param.companyIds" item="item" index="index">
                #{item}
            </foreach>
        </if>
        <if test="param.month!=null and param.month!=''">
            AND basi.month like concat('%', #{param.month}, '%')
        </if>
        order by basi.create_date desc
    </select>
    <select id="getListMonth" parameterType="com.testor.module.environment.model.dto.TEnvironmentMonthlyParam"
            resultType="com.testor.module.environment.model.domain.TEnvironmentMonthly" databaseId="kingbase">
        select mm.org_id,mm.org_name,basi.*
        from t_sys_org mm
        left join t_environment_monthly basi
        on mm.org_id = basi.org_id
        where mm.is_dept = '0'
            and mm.org_id in (select org.org_id  from t_sys_org org where org.parent_ids like concat('%', #{orgId}, '%')
            or org.org_id = #{orgId})
        <if test="param.companyIds!=null and param.companyIds.size>0">
                AND mm.org_id in
            <foreach open="(" close=")" separator="," collection="param.companyIds" item="item" index="index">
                #{item}
            </foreach>
        </if>
        <if test="param.month!=null and param.month!=''">
            AND     EXTRACT(YEAR FROM basi.month) = #{param.month}
        </if>
        order by basi.create_date desc
    </select>



    <select id="getById" resultType="com.testor.module.environment.model.domain.TEnvironmentMonthly" databaseId="mysql">
        SELECT
            id,
            org_id,
            org_name,
            month,
            CASE WHEN ROUND(energy_coal) = energy_coal THEN CAST(energy_coal AS SIGNED) ELSE ROUND(energy_coal, 5) END AS energy_coal,
    CASE WHEN ROUND(energy_power) = energy_power THEN CAST(energy_power AS SIGNED) ELSE ROUND(energy_power, 5) END AS energy_power,
    CASE WHEN ROUND(energy_gasoline) = energy_gasoline THEN CAST(energy_gasoline AS SIGNED) ELSE ROUND(energy_gasoline, 5) END AS energy_gasoline,
    CASE WHEN ROUND(energy_derv) = energy_derv THEN CAST(energy_derv AS SIGNED) ELSE ROUND(energy_derv, 5) END AS energy_derv,
    CASE WHEN ROUND(energy_fuel) = energy_fuel THEN CAST(energy_fuel AS SIGNED) ELSE ROUND(energy_fuel, 5) END AS energy_fuel,
    CASE WHEN ROUND(energy_natural) = energy_natural THEN CAST(energy_natural AS SIGNED) ELSE ROUND(energy_natural, 5) END AS energy_natural,
    CASE WHEN ROUND(energy_heating) = energy_heating THEN CAST(energy_heating AS SIGNED) ELSE ROUND(energy_heating, 5) END AS energy_heating,
    CASE WHEN ROUND(energy_other) = energy_other THEN CAST(energy_other AS SIGNED) ELSE ROUND(energy_other, 5) END AS energy_other,
    CASE WHEN ROUND(energy_synthesize) = energy_synthesize THEN CAST(energy_synthesize AS SIGNED) ELSE ROUND(energy_synthesize, 5) END AS energy_synthesize,
    CASE WHEN ROUND(water_new) = water_new THEN CAST(water_new AS SIGNED) ELSE ROUND(water_new, 5) END AS water_new,
    CASE WHEN ROUND(water_repetition) = water_repetition THEN CAST(water_repetition AS SIGNED) ELSE ROUND(water_repetition, 5) END AS water_repetition,
    CASE WHEN ROUND(water_rate) = water_rate THEN CAST(water_rate AS SIGNED) ELSE ROUND(water_rate, 2) END AS water_rate,
    CASE WHEN ROUND(w_pollutant_o_discharge) = w_pollutant_o_discharge THEN CAST(w_pollutant_o_discharge AS SIGNED) ELSE ROUND(w_pollutant_o_discharge, 5) END AS w_pollutant_o_discharge,
    CASE WHEN ROUND(w_pollutant_o_cod) = w_pollutant_o_cod THEN CAST(w_pollutant_o_cod AS SIGNED) ELSE ROUND(w_pollutant_o_cod, 5) END AS w_pollutant_o_cod,
    CASE WHEN ROUND(w_pollutant_o_NH3N) = w_pollutant_o_NH3N THEN CAST(w_pollutant_o_NH3N AS SIGNED) ELSE ROUND(w_pollutant_o_NH3N, 5) END AS w_pollutant_o_NH3N,
    CASE WHEN ROUND(w_pollutant_i_discharge) = w_pollutant_i_discharge THEN CAST(w_pollutant_i_discharge AS SIGNED) ELSE ROUND(w_pollutant_i_discharge, 5) END AS w_pollutant_i_discharge,
    CASE WHEN ROUND(w_pollutant_i_cod) = w_pollutant_i_cod THEN CAST(w_pollutant_i_cod AS SIGNED) ELSE ROUND(w_pollutant_i_cod, 5) END AS w_pollutant_i_cod,
    CASE WHEN ROUND(w_pollutant_i_NH3N) = w_pollutant_i_NH3N THEN CAST(w_pollutant_i_NH3N AS SIGNED) ELSE ROUND(w_pollutant_i_NH3N, 5) END AS w_pollutant_i_NH3N,
    CASE WHEN ROUND(w_pollutant_third_discharge) = w_pollutant_third_discharge THEN CAST(w_pollutant_third_discharge AS SIGNED) ELSE ROUND(w_pollutant_third_discharge, 5) END AS w_pollutant_third_discharge,
    CASE WHEN ROUND(w_pollutant_third_cod) = w_pollutant_third_cod THEN CAST(w_pollutant_third_cod AS SIGNED) ELSE ROUND(w_pollutant_third_cod, 5) END AS w_pollutant_third_cod,
    CASE WHEN ROUND(w_pollutant_third_NH3N) = w_pollutant_third_NH3N THEN CAST(w_pollutant_third_NH3N AS SIGNED) ELSE ROUND(w_pollutant_third_NH3N, 5) END AS w_pollutant_third_NH3N,
    CASE WHEN ROUND(w_pollutant_discharge_sum) = w_pollutant_discharge_sum THEN CAST(w_pollutant_discharge_sum AS SIGNED) ELSE ROUND(w_pollutant_discharge_sum, 5) END AS w_pollutant_discharge_sum,
    CASE WHEN ROUND(w_pollutant_cod_sum) = w_pollutant_cod_sum THEN CAST(w_pollutant_cod_sum AS SIGNED) ELSE ROUND(w_pollutant_cod_sum, 5) END AS w_pollutant_cod_sum,
    CASE WHEN ROUND(w_pollutant_NH3N_sum) = w_pollutant_NH3N_sum THEN CAST(w_pollutant_NH3N_sum AS SIGNED) ELSE ROUND(w_pollutant_NH3N_sum, 5) END AS w_pollutant_NH3N_sum,
    CASE WHEN ROUND(atmosphere_pollutant_stack) = atmosphere_pollutant_stack THEN CAST(atmosphere_pollutant_stack AS SIGNED) ELSE ROUND(atmosphere_pollutant_stack, 5) END AS atmosphere_pollutant_stack,
    CASE WHEN ROUND(atmosphere_pollutant_so2) = atmosphere_pollutant_so2 THEN CAST(atmosphere_pollutant_so2 AS SIGNED) ELSE ROUND(atmosphere_pollutant_so2, 5) END AS atmosphere_pollutant_so2,
    CASE WHEN ROUND(atmosphere_pollutant_NH3n) = atmosphere_pollutant_NH3n THEN CAST(atmosphere_pollutant_NH3n AS SIGNED) ELSE ROUND(atmosphere_pollutant_NH3n, 5) END AS atmosphere_pollutant_NH3n,
    CASE WHEN ROUND(atmosphere_pollutant_NH3n_organic) = atmosphere_pollutant_NH3n_organic THEN CAST(atmosphere_pollutant_NH3n_organic AS SIGNED) ELSE ROUND(atmosphere_pollutant_NH3n_organic, 5) END AS atmosphere_pollutant_NH3n_organic,
    CASE WHEN ROUND(atmosphere_pollutant_NH3n_co2) = atmosphere_pollutant_NH3n_co2 THEN CAST(atmosphere_pollutant_NH3n_co2 AS SIGNED) ELSE ROUND(atmosphere_pollutant_NH3n_co2, 5) END AS atmosphere_pollutant_NH3n_co2,
    CASE WHEN ROUND(atmosphere_pollutant_NH3n_count) = atmosphere_pollutant_NH3n_count THEN CAST(atmosphere_pollutant_NH3n_count AS SIGNED) ELSE ROUND(atmosphere_pollutant_NH3n_count, 5) END AS atmosphere_pollutant_NH3n_count,
    CASE WHEN ROUND(solid_slag) = solid_slag THEN CAST(solid_slag AS SIGNED) ELSE ROUND(solid_slag, 5) END AS solid_slag,
    CASE WHEN ROUND(solid_sieve) = solid_sieve THEN CAST(solid_sieve AS SIGNED) ELSE ROUND(solid_sieve, 5) END AS solid_sieve,
    CASE WHEN ROUND(solid_other) = solid_other THEN CAST(solid_other AS SIGNED) ELSE ROUND(solid_other, 5) END AS solid_other,
    CASE WHEN ROUND(solid_produce) = solid_produce THEN CAST(solid_produce AS SIGNED) ELSE ROUND(solid_produce, 5) END AS solid_produce,
    CASE WHEN ROUND(solid_use) = solid_use THEN CAST(solid_use AS SIGNED) ELSE ROUND(solid_use, 5) END AS solid_use,
    CASE WHEN ROUND(solid_municipal) = solid_municipal THEN CAST(solid_municipal AS SIGNED) ELSE ROUND(solid_municipal, 5) END AS solid_municipal,
    CASE WHEN ROUND(solid_dispose) = solid_dispose THEN CAST(solid_dispose AS SIGNED) ELSE ROUND(solid_dispose, 5) END AS solid_dispose,
    CASE WHEN ROUND(solid_ratio) = solid_ratio THEN CAST(solid_ratio AS SIGNED) ELSE ROUND(solid_ratio, 2) END AS solid_ratio,
    CASE WHEN ROUND(risk_produce) = risk_produce THEN CAST(risk_produce AS SIGNED) ELSE ROUND(risk_produce, 5) END AS risk_produce,
    CASE WHEN ROUND(risk_dispose) = risk_dispose THEN CAST(risk_dispose AS SIGNED) ELSE ROUND(risk_dispose, 5) END AS risk_dispose,
    CASE WHEN ROUND(risk_ratio) = risk_ratio THEN CAST(risk_ratio AS SIGNED) ELSE ROUND(risk_ratio, 2) END AS risk_ratio,
    CASE WHEN ROUND(energy_put) = energy_put THEN CAST(energy_put AS SIGNED) ELSE ROUND(energy_put, 5) END AS energy_put,
    CASE WHEN ROUND(recycle_put) = recycle_put THEN CAST(recycle_put AS SIGNED) ELSE ROUND(recycle_put, 5) END AS recycle_put,
		appear_status,
    status,
    process_status,
    reject_opinion,
    create_by,
    create_date,
    update_by,
    update_date,
    remarks,
    process_id,
		    CASE WHEN ROUND(operating_income) = recycle_put THEN CAST(operating_income AS SIGNED) ELSE ROUND(operating_income, 5) END AS operating_income,
		    CASE WHEN ROUND(energy_coal_amount ) = recycle_put THEN CAST(energy_coal_amount  AS SIGNED) ELSE ROUND(energy_coal_amount , 5) END AS energy_coal_amount,
    regional_org_name,
    regional_org_id
FROM t_environment_monthly
        where id = #{id}
    </select>
    <select id="getById" resultType="com.testor.module.environment.model.domain.TEnvironmentMonthly" databaseId="kingbase">
    SELECT
            id,
            org_id,
            org_name,
            MONTH,
            CASE

            WHEN ROUND(
            CAST( energy_coal AS NUMERIC )) = CAST( energy_coal AS NUMERIC ) THEN
            CAST( energy_coal AS INTEGER ) ELSE ROUND( CAST( energy_coal AS NUMERIC ), 5 )
                    END AS energy_coal,
            CASE

            WHEN ROUND(
            CAST( energy_power AS NUMERIC )) = CAST( energy_power AS NUMERIC ) THEN
            CAST( energy_power AS INTEGER ) ELSE ROUND( CAST( energy_power AS NUMERIC ), 5 )
                    END AS energy_power,
            CASE

            WHEN ROUND(
            CAST( energy_gasoline AS NUMERIC )) = CAST( energy_gasoline AS NUMERIC ) THEN
            CAST( energy_gasoline AS INTEGER ) ELSE ROUND( CAST( energy_gasoline AS NUMERIC ), 5 )
                    END AS energy_gasoline,
            CASE

            WHEN ROUND(
            CAST( energy_derv AS NUMERIC )) = CAST( energy_derv AS NUMERIC ) THEN
            CAST( energy_derv AS INTEGER ) ELSE ROUND( CAST( energy_derv AS NUMERIC ), 5 )
                    END AS energy_derv,
            CASE

            WHEN ROUND(
            CAST( energy_fuel AS NUMERIC )) = CAST( energy_fuel AS NUMERIC ) THEN
            CAST( energy_fuel AS INTEGER ) ELSE ROUND( CAST( energy_fuel AS NUMERIC ), 5 )
                    END AS energy_fuel,
            CASE

            WHEN ROUND(
            CAST( energy_natural AS NUMERIC )) = CAST( energy_natural AS NUMERIC ) THEN
            CAST( energy_natural AS INTEGER ) ELSE ROUND( CAST( energy_natural AS NUMERIC ), 5 )
                    END AS energy_natural,
            CASE

            WHEN ROUND(
            CAST( energy_heating AS NUMERIC )) = CAST( energy_heating AS NUMERIC ) THEN
            CAST( energy_heating AS INTEGER ) ELSE ROUND( CAST( energy_heating AS NUMERIC ), 5 )
                    END AS energy_heating,
            CASE

            WHEN ROUND(
            CAST( energy_other AS NUMERIC )) = CAST( energy_other AS NUMERIC ) THEN
            CAST( energy_other AS INTEGER ) ELSE ROUND( CAST( energy_other AS NUMERIC ), 5 )
                    END AS energy_other,
            CASE

            WHEN ROUND(
            CAST( energy_synthesize AS NUMERIC )) = CAST( energy_synthesize AS NUMERIC ) THEN
            CAST( energy_synthesize AS INTEGER ) ELSE ROUND( CAST( energy_synthesize AS NUMERIC ), 5 )
                    END AS energy_synthesize,
            CASE

            WHEN ROUND(
            CAST( water_new AS NUMERIC )) = CAST( water_new AS NUMERIC ) THEN
            CAST( water_new AS INTEGER ) ELSE ROUND( CAST( water_new AS NUMERIC ), 5 )
                    END AS water_new,
            CASE

            WHEN ROUND(
            CAST( water_repetition AS NUMERIC )) = CAST( water_repetition AS NUMERIC ) THEN
            CAST( water_repetition AS INTEGER ) ELSE ROUND( CAST( water_repetition AS NUMERIC ), 5 )
                    END AS water_repetition,
            CASE

            WHEN ROUND(
            CAST( water_rate AS NUMERIC )) = CAST( water_rate AS NUMERIC ) THEN
            CAST( water_rate AS INTEGER ) ELSE ROUND( CAST( water_rate AS NUMERIC ), 2 )
                    END AS water_rate,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_o_discharge AS NUMERIC )) = CAST( w_pollutant_o_discharge AS NUMERIC ) THEN
            CAST( w_pollutant_o_discharge AS INTEGER ) ELSE ROUND( CAST( w_pollutant_o_discharge AS NUMERIC ), 5 )
                    END AS w_pollutant_o_discharge,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_o_cod AS NUMERIC )) = CAST( w_pollutant_o_cod AS NUMERIC ) THEN
            CAST( w_pollutant_o_cod AS INTEGER ) ELSE ROUND( CAST( w_pollutant_o_cod AS NUMERIC ), 5 )
                    END AS w_pollutant_o_cod,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_o_NH3N AS NUMERIC )) = CAST( w_pollutant_o_NH3N AS NUMERIC ) THEN
            CAST( w_pollutant_o_NH3N AS INTEGER ) ELSE ROUND( CAST( w_pollutant_o_NH3N AS NUMERIC ), 5 )
                    END AS w_pollutant_o_NH3N,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_i_discharge AS NUMERIC )) = CAST( w_pollutant_i_discharge AS NUMERIC ) THEN
            CAST( w_pollutant_i_discharge AS INTEGER ) ELSE ROUND( CAST( w_pollutant_i_discharge AS NUMERIC ), 5 )
                    END AS w_pollutant_i_discharge,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_i_cod AS NUMERIC )) = CAST( w_pollutant_i_cod AS NUMERIC ) THEN
            CAST( w_pollutant_i_cod AS INTEGER ) ELSE ROUND( CAST( w_pollutant_i_cod AS NUMERIC ), 5 )
                    END AS w_pollutant_i_cod,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_i_NH3N AS NUMERIC )) = CAST( w_pollutant_i_NH3N AS NUMERIC ) THEN
            CAST( w_pollutant_i_NH3N AS INTEGER ) ELSE ROUND( CAST( w_pollutant_i_NH3N AS NUMERIC ), 5 )
                    END AS w_pollutant_i_NH3N,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_third_discharge AS NUMERIC )) = CAST( w_pollutant_third_discharge AS NUMERIC ) THEN
            CAST( w_pollutant_third_discharge AS INTEGER ) ELSE ROUND( CAST( w_pollutant_third_discharge AS NUMERIC ), 5 )
                    END AS w_pollutant_third_discharge,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_third_cod AS NUMERIC )) = CAST( w_pollutant_third_cod AS NUMERIC ) THEN
            CAST( w_pollutant_third_cod AS INTEGER ) ELSE ROUND( CAST( w_pollutant_third_cod AS NUMERIC ), 5 )
                    END AS w_pollutant_third_cod,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_third_NH3N AS NUMERIC )) = CAST( w_pollutant_third_NH3N AS NUMERIC ) THEN
            CAST( w_pollutant_third_NH3N AS INTEGER ) ELSE ROUND( CAST( w_pollutant_third_NH3N AS NUMERIC ), 5 )
                    END AS w_pollutant_third_NH3N,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_discharge_sum AS NUMERIC )) = CAST( w_pollutant_discharge_sum AS NUMERIC ) THEN
            CAST( w_pollutant_discharge_sum AS INTEGER ) ELSE ROUND( CAST( w_pollutant_discharge_sum AS NUMERIC ), 5 )
                    END AS w_pollutant_discharge_sum,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_cod_sum AS NUMERIC )) = CAST( w_pollutant_cod_sum AS NUMERIC ) THEN
            CAST( w_pollutant_cod_sum AS INTEGER ) ELSE ROUND( CAST( w_pollutant_cod_sum AS NUMERIC ), 5 )
                    END AS w_pollutant_cod_sum,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_NH3N_sum AS NUMERIC )) = CAST( w_pollutant_NH3N_sum AS NUMERIC ) THEN
            CAST( w_pollutant_NH3N_sum AS INTEGER ) ELSE ROUND( CAST( w_pollutant_NH3N_sum AS NUMERIC ), 5 )
                    END AS w_pollutant_NH3N_sum,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_stack AS NUMERIC )) = CAST( atmosphere_pollutant_stack AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_stack AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_stack AS NUMERIC ), 5 )
                    END AS atmosphere_pollutant_stack,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_so2 AS NUMERIC )) = CAST( atmosphere_pollutant_so2 AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_so2 AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_so2 AS NUMERIC ), 5 )
                    END AS atmosphere_pollutant_so2,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_NH3n AS NUMERIC )) = CAST( atmosphere_pollutant_NH3n AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_NH3n AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_NH3n AS NUMERIC ), 5 )
                    END AS atmosphere_pollutant_NH3n,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_NH3n_organic AS NUMERIC )) = CAST( atmosphere_pollutant_NH3n_organic AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_NH3n_organic AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_NH3n_organic AS NUMERIC ), 5 )
                    END AS atmosphere_pollutant_NH3n_organic,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_NH3n_co2 AS NUMERIC )) = CAST( atmosphere_pollutant_NH3n_co2 AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_NH3n_co2 AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_NH3n_co2 AS NUMERIC ), 5 )
                    END AS atmosphere_pollutant_NH3n_co2,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_NH3n_count AS NUMERIC )) = CAST( atmosphere_pollutant_NH3n_count AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_NH3n_count AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_NH3n_count AS NUMERIC ), 5 )
                    END AS atmosphere_pollutant_NH3n_count,
            CASE

            WHEN ROUND(
            CAST( solid_slag AS NUMERIC )) = CAST( solid_slag AS NUMERIC ) THEN
            CAST( solid_slag AS INTEGER ) ELSE ROUND( CAST( solid_slag AS NUMERIC ), 5 )
                    END AS solid_slag,
            CASE

            WHEN ROUND(
            CAST( solid_sieve AS NUMERIC )) = CAST( solid_sieve AS NUMERIC ) THEN
            CAST( solid_sieve AS INTEGER ) ELSE ROUND( CAST( solid_sieve AS NUMERIC ), 5 )
                    END AS solid_sieve,
            CASE

            WHEN ROUND(
            CAST( solid_other AS NUMERIC )) = CAST( solid_other AS NUMERIC ) THEN
            CAST( solid_other AS INTEGER ) ELSE ROUND( CAST( solid_other AS NUMERIC ), 5 )
                    END AS solid_other,
            CASE

            WHEN ROUND(
            CAST( solid_produce AS NUMERIC )) = CAST( solid_produce AS NUMERIC ) THEN
            CAST( solid_produce AS INTEGER ) ELSE ROUND( CAST( solid_produce AS NUMERIC ), 5 )
                    END AS solid_produce,
            CASE

            WHEN ROUND(
            CAST( solid_use AS NUMERIC )) = CAST( solid_use AS NUMERIC ) THEN
            CAST( solid_use AS INTEGER ) ELSE ROUND( CAST( solid_use AS NUMERIC ), 5 )
                    END AS solid_use,
            CASE

            WHEN ROUND(
            CAST( solid_municipal AS NUMERIC )) = CAST( solid_municipal AS NUMERIC ) THEN
            CAST( solid_municipal AS INTEGER ) ELSE ROUND( CAST( solid_municipal AS NUMERIC ), 5 )
                    END AS solid_municipal,
            CASE

            WHEN ROUND(
            CAST( solid_dispose AS NUMERIC )) = CAST( solid_dispose AS NUMERIC ) THEN
            CAST( solid_dispose AS INTEGER ) ELSE ROUND( CAST( solid_dispose AS NUMERIC ), 5 )
                    END AS solid_dispose,
            CASE

            WHEN ROUND(
            CAST( solid_ratio AS NUMERIC )) = CAST( solid_ratio AS NUMERIC ) THEN
            CAST( solid_ratio AS INTEGER ) ELSE ROUND( CAST( solid_ratio AS NUMERIC ), 2 )
                    END AS solid_ratio,
            CASE

            WHEN ROUND(
            CAST( risk_produce AS NUMERIC )) = CAST( risk_produce AS NUMERIC ) THEN
            CAST( risk_produce AS INTEGER ) ELSE ROUND( CAST( risk_produce AS NUMERIC ), 5 )
                    END AS risk_produce,
            CASE

            WHEN ROUND(
            CAST( risk_dispose AS NUMERIC )) = CAST( risk_dispose AS NUMERIC ) THEN
            CAST( risk_dispose AS INTEGER ) ELSE ROUND( CAST( risk_dispose AS NUMERIC ), 5 )
                    END AS risk_dispose,
            CASE

            WHEN ROUND(
            CAST( risk_ratio AS NUMERIC )) = CAST( risk_ratio AS NUMERIC ) THEN
            CAST( risk_ratio AS INTEGER ) ELSE ROUND( CAST( risk_ratio AS NUMERIC ), 2 )
                    END AS risk_ratio,
            CASE

            WHEN ROUND(
            CAST( energy_put AS NUMERIC )) = CAST( energy_put AS NUMERIC ) THEN
            CAST( energy_put AS INTEGER ) ELSE ROUND( CAST( energy_put AS NUMERIC ), 5 )
                    END AS energy_put,
            CASE

            WHEN ROUND(
            CAST( recycle_put AS NUMERIC )) = CAST( recycle_put AS NUMERIC ) THEN
            CAST( recycle_put AS INTEGER ) ELSE ROUND( CAST( recycle_put AS NUMERIC ), 5 )
                    END AS recycle_put,
            appear_status,
            STATUS,
            process_status,
            reject_opinion,
            create_by,
            create_date,
            update_by,
            update_date,
            remarks,
            process_id,
            CASE

            WHEN ROUND(
            CAST( operating_income AS NUMERIC )) = CAST( recycle_put AS NUMERIC ) THEN
            CAST( operating_income AS INTEGER ) ELSE ROUND( CAST( operating_income AS NUMERIC ), 5 )
                    END AS operating_income,
            CASE

            WHEN ROUND(
            CAST( energy_coal_amount AS NUMERIC )) = CAST( recycle_put AS NUMERIC ) THEN
            CAST( energy_coal_amount AS INTEGER ) ELSE ROUND( CAST( energy_coal_amount AS NUMERIC ), 5 )
                    END AS energy_coal_amount,
            regional_org_name,
            regional_org_id
        FROM t_environment_monthly
            where id = #{id}
    </select>


    <select id="getPage" resultType="com.testor.module.environment.model.domain.TEnvironmentMonthly" databaseId="mysql">
        SELECT
            id,
            org_id,
            org_name,
            month,
            CASE WHEN ROUND(energy_coal) = energy_coal THEN CAST(energy_coal AS SIGNED) ELSE ROUND(energy_coal, 5) END AS energy_coal,
    CASE WHEN ROUND(energy_power) = energy_power THEN CAST(energy_power AS SIGNED) ELSE ROUND(energy_power, 5) END AS energy_power,
    CASE WHEN ROUND(energy_gasoline) = energy_gasoline THEN CAST(energy_gasoline AS SIGNED) ELSE ROUND(energy_gasoline, 5) END AS energy_gasoline,
    CASE WHEN ROUND(energy_derv) = energy_derv THEN CAST(energy_derv AS SIGNED) ELSE ROUND(energy_derv, 5) END AS energy_derv,
    CASE WHEN ROUND(energy_fuel) = energy_fuel THEN CAST(energy_fuel AS SIGNED) ELSE ROUND(energy_fuel, 5) END AS energy_fuel,
    CASE WHEN ROUND(energy_natural) = energy_natural THEN CAST(energy_natural AS SIGNED) ELSE ROUND(energy_natural, 5) END AS energy_natural,
    CASE WHEN ROUND(energy_heating) = energy_heating THEN CAST(energy_heating AS SIGNED) ELSE ROUND(energy_heating, 5) END AS energy_heating,
    CASE WHEN ROUND(energy_other) = energy_other THEN CAST(energy_other AS SIGNED) ELSE ROUND(energy_other, 5) END AS energy_other,
    CASE WHEN ROUND(energy_synthesize) = energy_synthesize THEN CAST(energy_synthesize AS SIGNED) ELSE ROUND(energy_synthesize, 5) END AS energy_synthesize,
    CASE WHEN ROUND(water_new) = water_new THEN CAST(water_new AS SIGNED) ELSE ROUND(water_new, 5) END AS water_new,
    CASE WHEN ROUND(water_repetition) = water_repetition THEN CAST(water_repetition AS SIGNED) ELSE ROUND(water_repetition, 5) END AS water_repetition,
    CASE WHEN ROUND(water_rate) = water_rate THEN CAST(water_rate AS SIGNED) ELSE ROUND(water_rate, 2) END AS water_rate,
    CASE WHEN ROUND(w_pollutant_o_discharge) = w_pollutant_o_discharge THEN CAST(w_pollutant_o_discharge AS SIGNED) ELSE ROUND(w_pollutant_o_discharge, 5) END AS w_pollutant_o_discharge,
    CASE WHEN ROUND(w_pollutant_o_cod) = w_pollutant_o_cod THEN CAST(w_pollutant_o_cod AS SIGNED) ELSE ROUND(w_pollutant_o_cod, 5) END AS w_pollutant_o_cod,
    CASE WHEN ROUND(w_pollutant_o_NH3N) = w_pollutant_o_NH3N THEN CAST(w_pollutant_o_NH3N AS SIGNED) ELSE ROUND(w_pollutant_o_NH3N, 5) END AS w_pollutant_o_NH3N,
    CASE WHEN ROUND(w_pollutant_i_discharge) = w_pollutant_i_discharge THEN CAST(w_pollutant_i_discharge AS SIGNED) ELSE ROUND(w_pollutant_i_discharge, 5) END AS w_pollutant_i_discharge,
    CASE WHEN ROUND(w_pollutant_i_cod) = w_pollutant_i_cod THEN CAST(w_pollutant_i_cod AS SIGNED) ELSE ROUND(w_pollutant_i_cod, 5) END AS w_pollutant_i_cod,
    CASE WHEN ROUND(w_pollutant_i_NH3N) = w_pollutant_i_NH3N THEN CAST(w_pollutant_i_NH3N AS SIGNED) ELSE ROUND(w_pollutant_i_NH3N, 5) END AS w_pollutant_i_NH3N,
    CASE WHEN ROUND(w_pollutant_third_discharge) = w_pollutant_third_discharge THEN CAST(w_pollutant_third_discharge AS SIGNED) ELSE ROUND(w_pollutant_third_discharge, 5) END AS w_pollutant_third_discharge,
    CASE WHEN ROUND(w_pollutant_third_cod) = w_pollutant_third_cod THEN CAST(w_pollutant_third_cod AS SIGNED) ELSE ROUND(w_pollutant_third_cod, 5) END AS w_pollutant_third_cod,
    CASE WHEN ROUND(w_pollutant_third_NH3N) = w_pollutant_third_NH3N THEN CAST(w_pollutant_third_NH3N AS SIGNED) ELSE ROUND(w_pollutant_third_NH3N, 5) END AS w_pollutant_third_NH3N,
    CASE WHEN ROUND(w_pollutant_discharge_sum) = w_pollutant_discharge_sum THEN CAST(w_pollutant_discharge_sum AS SIGNED) ELSE ROUND(w_pollutant_discharge_sum, 5) END AS w_pollutant_discharge_sum,
    CASE WHEN ROUND(w_pollutant_cod_sum) = w_pollutant_cod_sum THEN CAST(w_pollutant_cod_sum AS SIGNED) ELSE ROUND(w_pollutant_cod_sum, 5) END AS w_pollutant_cod_sum,
    CASE WHEN ROUND(w_pollutant_NH3N_sum) = w_pollutant_NH3N_sum THEN CAST(w_pollutant_NH3N_sum AS SIGNED) ELSE ROUND(w_pollutant_NH3N_sum, 5) END AS w_pollutant_NH3N_sum,
    CASE WHEN ROUND(atmosphere_pollutant_stack) = atmosphere_pollutant_stack THEN CAST(atmosphere_pollutant_stack AS SIGNED) ELSE ROUND(atmosphere_pollutant_stack, 5) END AS atmosphere_pollutant_stack,
    CASE WHEN ROUND(atmosphere_pollutant_so2) = atmosphere_pollutant_so2 THEN CAST(atmosphere_pollutant_so2 AS SIGNED) ELSE ROUND(atmosphere_pollutant_so2, 5) END AS atmosphere_pollutant_so2,
    CASE WHEN ROUND(atmosphere_pollutant_NH3n) = atmosphere_pollutant_NH3n THEN CAST(atmosphere_pollutant_NH3n AS SIGNED) ELSE ROUND(atmosphere_pollutant_NH3n, 5) END AS atmosphere_pollutant_NH3n,
    CASE WHEN ROUND(atmosphere_pollutant_NH3n_organic) = atmosphere_pollutant_NH3n_organic THEN CAST(atmosphere_pollutant_NH3n_organic AS SIGNED) ELSE ROUND(atmosphere_pollutant_NH3n_organic, 5) END AS atmosphere_pollutant_NH3n_organic,
    CASE WHEN ROUND(atmosphere_pollutant_NH3n_co2) = atmosphere_pollutant_NH3n_co2 THEN CAST(atmosphere_pollutant_NH3n_co2 AS SIGNED) ELSE ROUND(atmosphere_pollutant_NH3n_co2, 5) END AS atmosphere_pollutant_NH3n_co2,
    CASE WHEN ROUND(atmosphere_pollutant_NH3n_count) = atmosphere_pollutant_NH3n_count THEN CAST(atmosphere_pollutant_NH3n_count AS SIGNED) ELSE ROUND(atmosphere_pollutant_NH3n_count, 5) END AS atmosphere_pollutant_NH3n_count,
    CASE WHEN ROUND(solid_slag) = solid_slag THEN CAST(solid_slag AS SIGNED) ELSE ROUND(solid_slag, 5) END AS solid_slag,
    CASE WHEN ROUND(solid_sieve) = solid_sieve THEN CAST(solid_sieve AS SIGNED) ELSE ROUND(solid_sieve, 5) END AS solid_sieve,
    CASE WHEN ROUND(solid_other) = solid_other THEN CAST(solid_other AS SIGNED) ELSE ROUND(solid_other, 5) END AS solid_other,
    CASE WHEN ROUND(solid_produce) = solid_produce THEN CAST(solid_produce AS SIGNED) ELSE ROUND(solid_produce, 5) END AS solid_produce,
    CASE WHEN ROUND(solid_use) = solid_use THEN CAST(solid_use AS SIGNED) ELSE ROUND(solid_use, 5) END AS solid_use,
    CASE WHEN ROUND(solid_municipal) = solid_municipal THEN CAST(solid_municipal AS SIGNED) ELSE ROUND(solid_municipal, 5) END AS solid_municipal,
    CASE WHEN ROUND(solid_dispose) = solid_dispose THEN CAST(solid_dispose AS SIGNED) ELSE ROUND(solid_dispose, 5) END AS solid_dispose,
    CASE WHEN ROUND(solid_ratio) = solid_ratio THEN CAST(solid_ratio AS SIGNED) ELSE ROUND(solid_ratio, 2) END AS solid_ratio,
    CASE WHEN ROUND(risk_produce) = risk_produce THEN CAST(risk_produce AS SIGNED) ELSE ROUND(risk_produce, 5) END AS risk_produce,
    CASE WHEN ROUND(risk_dispose) = risk_dispose THEN CAST(risk_dispose AS SIGNED) ELSE ROUND(risk_dispose, 5) END AS risk_dispose,
    CASE WHEN ROUND(risk_ratio) = risk_ratio THEN CAST(risk_ratio AS SIGNED) ELSE ROUND(risk_ratio, 2) END AS risk_ratio,
    CASE WHEN ROUND(energy_put) = energy_put THEN CAST(energy_put AS SIGNED) ELSE ROUND(energy_put, 5) END AS energy_put,
    CASE WHEN ROUND(recycle_put) = recycle_put THEN CAST(recycle_put AS SIGNED) ELSE ROUND(recycle_put, 5) END AS recycle_put,
		appear_status,
    status,
    process_status,
    reject_opinion,
    create_by,
    create_date,
    update_by,
    update_date,
    remarks,
    process_id,
		    CASE WHEN ROUND(operating_income) = recycle_put THEN CAST(operating_income AS SIGNED) ELSE ROUND(operating_income, 5) END AS operating_income,
		    CASE WHEN ROUND(energy_coal_amount ) = recycle_put THEN CAST(energy_coal_amount  AS SIGNED) ELSE ROUND(energy_coal_amount , 5) END AS energy_coal_amount,
    regional_org_name,
    regional_org_id
FROM t_environment_monthly
        ${ew.customSqlSegment}
    </select>
    <select id="getPage" resultType="com.testor.module.environment.model.domain.TEnvironmentMonthly" databaseId="kingbase">
        SELECT
            id,
            org_id,
            org_name,
            MONTH,
            CASE

            WHEN ROUND(
            CAST( energy_coal AS NUMERIC )) = CAST( energy_coal AS NUMERIC ) THEN
            CAST( energy_coal AS INTEGER ) ELSE ROUND( CAST( energy_coal AS NUMERIC ), 5 )
        END AS energy_coal,
            CASE

            WHEN ROUND(
            CAST( energy_power AS NUMERIC )) = CAST( energy_power AS NUMERIC ) THEN
            CAST( energy_power AS INTEGER ) ELSE ROUND( CAST( energy_power AS NUMERIC ), 5 )
        END AS energy_power,
            CASE

            WHEN ROUND(
            CAST( energy_gasoline AS NUMERIC )) = CAST( energy_gasoline AS NUMERIC ) THEN
            CAST( energy_gasoline AS INTEGER ) ELSE ROUND( CAST( energy_gasoline AS NUMERIC ), 5 )
        END AS energy_gasoline,
            CASE

            WHEN ROUND(
            CAST( energy_derv AS NUMERIC )) = CAST( energy_derv AS NUMERIC ) THEN
            CAST( energy_derv AS INTEGER ) ELSE ROUND( CAST( energy_derv AS NUMERIC ), 5 )
        END AS energy_derv,
            CASE

            WHEN ROUND(
            CAST( energy_fuel AS NUMERIC )) = CAST( energy_fuel AS NUMERIC ) THEN
            CAST( energy_fuel AS INTEGER ) ELSE ROUND( CAST( energy_fuel AS NUMERIC ), 5 )
        END AS energy_fuel,
            CASE

            WHEN ROUND(
            CAST( energy_natural AS NUMERIC )) = CAST( energy_natural AS NUMERIC ) THEN
            CAST( energy_natural AS INTEGER ) ELSE ROUND( CAST( energy_natural AS NUMERIC ), 5 )
        END AS energy_natural,
            CASE

            WHEN ROUND(
            CAST( energy_heating AS NUMERIC )) = CAST( energy_heating AS NUMERIC ) THEN
            CAST( energy_heating AS INTEGER ) ELSE ROUND( CAST( energy_heating AS NUMERIC ), 5 )
        END AS energy_heating,
            CASE

            WHEN ROUND(
            CAST( energy_other AS NUMERIC )) = CAST( energy_other AS NUMERIC ) THEN
            CAST( energy_other AS INTEGER ) ELSE ROUND( CAST( energy_other AS NUMERIC ), 5 )
        END AS energy_other,
            CASE

            WHEN ROUND(
            CAST( energy_synthesize AS NUMERIC )) = CAST( energy_synthesize AS NUMERIC ) THEN
            CAST( energy_synthesize AS INTEGER ) ELSE ROUND( CAST( energy_synthesize AS NUMERIC ), 5 )
        END AS energy_synthesize,
            CASE

            WHEN ROUND(
            CAST( water_new AS NUMERIC )) = CAST( water_new AS NUMERIC ) THEN
            CAST( water_new AS INTEGER ) ELSE ROUND( CAST( water_new AS NUMERIC ), 5 )
        END AS water_new,
            CASE

            WHEN ROUND(
            CAST( water_repetition AS NUMERIC )) = CAST( water_repetition AS NUMERIC ) THEN
            CAST( water_repetition AS INTEGER ) ELSE ROUND( CAST( water_repetition AS NUMERIC ), 5 )
        END AS water_repetition,
            CASE

            WHEN ROUND(
            CAST( water_rate AS NUMERIC )) = CAST( water_rate AS NUMERIC ) THEN
            CAST( water_rate AS INTEGER ) ELSE ROUND( CAST( water_rate AS NUMERIC ), 2 )
        END AS water_rate,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_o_discharge AS NUMERIC )) = CAST( w_pollutant_o_discharge AS NUMERIC ) THEN
            CAST( w_pollutant_o_discharge AS INTEGER ) ELSE ROUND( CAST( w_pollutant_o_discharge AS NUMERIC ), 5 )
        END AS w_pollutant_o_discharge,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_o_cod AS NUMERIC )) = CAST( w_pollutant_o_cod AS NUMERIC ) THEN
            CAST( w_pollutant_o_cod AS INTEGER ) ELSE ROUND( CAST( w_pollutant_o_cod AS NUMERIC ), 5 )
        END AS w_pollutant_o_cod,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_o_NH3N AS NUMERIC )) = CAST( w_pollutant_o_NH3N AS NUMERIC ) THEN
            CAST( w_pollutant_o_NH3N AS INTEGER ) ELSE ROUND( CAST( w_pollutant_o_NH3N AS NUMERIC ), 5 )
        END AS w_pollutant_o_NH3N,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_i_discharge AS NUMERIC )) = CAST( w_pollutant_i_discharge AS NUMERIC ) THEN
            CAST( w_pollutant_i_discharge AS INTEGER ) ELSE ROUND( CAST( w_pollutant_i_discharge AS NUMERIC ), 5 )
        END AS w_pollutant_i_discharge,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_i_cod AS NUMERIC )) = CAST( w_pollutant_i_cod AS NUMERIC ) THEN
            CAST( w_pollutant_i_cod AS INTEGER ) ELSE ROUND( CAST( w_pollutant_i_cod AS NUMERIC ), 5 )
        END AS w_pollutant_i_cod,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_i_NH3N AS NUMERIC )) = CAST( w_pollutant_i_NH3N AS NUMERIC ) THEN
            CAST( w_pollutant_i_NH3N AS INTEGER ) ELSE ROUND( CAST( w_pollutant_i_NH3N AS NUMERIC ), 5 )
        END AS w_pollutant_i_NH3N,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_third_discharge AS NUMERIC )) = CAST( w_pollutant_third_discharge AS NUMERIC ) THEN
            CAST( w_pollutant_third_discharge AS INTEGER ) ELSE ROUND( CAST( w_pollutant_third_discharge AS NUMERIC ), 5 )
        END AS w_pollutant_third_discharge,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_third_cod AS NUMERIC )) = CAST( w_pollutant_third_cod AS NUMERIC ) THEN
            CAST( w_pollutant_third_cod AS INTEGER ) ELSE ROUND( CAST( w_pollutant_third_cod AS NUMERIC ), 5 )
        END AS w_pollutant_third_cod,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_third_NH3N AS NUMERIC )) = CAST( w_pollutant_third_NH3N AS NUMERIC ) THEN
            CAST( w_pollutant_third_NH3N AS INTEGER ) ELSE ROUND( CAST( w_pollutant_third_NH3N AS NUMERIC ), 5 )
        END AS w_pollutant_third_NH3N,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_discharge_sum AS NUMERIC )) = CAST( w_pollutant_discharge_sum AS NUMERIC ) THEN
            CAST( w_pollutant_discharge_sum AS INTEGER ) ELSE ROUND( CAST( w_pollutant_discharge_sum AS NUMERIC ), 5 )
        END AS w_pollutant_discharge_sum,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_cod_sum AS NUMERIC )) = CAST( w_pollutant_cod_sum AS NUMERIC ) THEN
            CAST( w_pollutant_cod_sum AS INTEGER ) ELSE ROUND( CAST( w_pollutant_cod_sum AS NUMERIC ), 5 )
        END AS w_pollutant_cod_sum,
            CASE

            WHEN ROUND(
            CAST( w_pollutant_NH3N_sum AS NUMERIC )) = CAST( w_pollutant_NH3N_sum AS NUMERIC ) THEN
            CAST( w_pollutant_NH3N_sum AS INTEGER ) ELSE ROUND( CAST( w_pollutant_NH3N_sum AS NUMERIC ), 5 )
        END AS w_pollutant_NH3N_sum,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_stack AS NUMERIC )) = CAST( atmosphere_pollutant_stack AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_stack AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_stack AS NUMERIC ), 5 )
        END AS atmosphere_pollutant_stack,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_so2 AS NUMERIC )) = CAST( atmosphere_pollutant_so2 AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_so2 AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_so2 AS NUMERIC ), 5 )
        END AS atmosphere_pollutant_so2,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_NH3n AS NUMERIC )) = CAST( atmosphere_pollutant_NH3n AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_NH3n AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_NH3n AS NUMERIC ), 5 )
        END AS atmosphere_pollutant_NH3n,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_NH3n_organic AS NUMERIC )) = CAST( atmosphere_pollutant_NH3n_organic AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_NH3n_organic AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_NH3n_organic AS NUMERIC ), 5 )
        END AS atmosphere_pollutant_NH3n_organic,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_NH3n_co2 AS NUMERIC )) = CAST( atmosphere_pollutant_NH3n_co2 AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_NH3n_co2 AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_NH3n_co2 AS NUMERIC ), 5 )
        END AS atmosphere_pollutant_NH3n_co2,
            CASE

            WHEN ROUND(
            CAST( atmosphere_pollutant_NH3n_count AS NUMERIC )) = CAST( atmosphere_pollutant_NH3n_count AS NUMERIC ) THEN
            CAST( atmosphere_pollutant_NH3n_count AS INTEGER ) ELSE ROUND( CAST( atmosphere_pollutant_NH3n_count AS NUMERIC ), 5 )
        END AS atmosphere_pollutant_NH3n_count,
            CASE

            WHEN ROUND(
            CAST( solid_slag AS NUMERIC )) = CAST( solid_slag AS NUMERIC ) THEN
            CAST( solid_slag AS INTEGER ) ELSE ROUND( CAST( solid_slag AS NUMERIC ), 5 )
        END AS solid_slag,
            CASE

            WHEN ROUND(
            CAST( solid_sieve AS NUMERIC )) = CAST( solid_sieve AS NUMERIC ) THEN
            CAST( solid_sieve AS INTEGER ) ELSE ROUND( CAST( solid_sieve AS NUMERIC ), 5 )
        END AS solid_sieve,
            CASE

            WHEN ROUND(
            CAST( solid_other AS NUMERIC )) = CAST( solid_other AS NUMERIC ) THEN
            CAST( solid_other AS INTEGER ) ELSE ROUND( CAST( solid_other AS NUMERIC ), 5 )
        END AS solid_other,
            CASE

            WHEN ROUND(
            CAST( solid_produce AS NUMERIC )) = CAST( solid_produce AS NUMERIC ) THEN
            CAST( solid_produce AS INTEGER ) ELSE ROUND( CAST( solid_produce AS NUMERIC ), 5 )
        END AS solid_produce,
            CASE

            WHEN ROUND(
            CAST( solid_use AS NUMERIC )) = CAST( solid_use AS NUMERIC ) THEN
            CAST( solid_use AS INTEGER ) ELSE ROUND( CAST( solid_use AS NUMERIC ), 5 )
        END AS solid_use,
            CASE

            WHEN ROUND(
            CAST( solid_municipal AS NUMERIC )) = CAST( solid_municipal AS NUMERIC ) THEN
            CAST( solid_municipal AS INTEGER ) ELSE ROUND( CAST( solid_municipal AS NUMERIC ), 5 )
        END AS solid_municipal,
            CASE

            WHEN ROUND(
            CAST( solid_dispose AS NUMERIC )) = CAST( solid_dispose AS NUMERIC ) THEN
            CAST( solid_dispose AS INTEGER ) ELSE ROUND( CAST( solid_dispose AS NUMERIC ), 5 )
        END AS solid_dispose,
            CASE

            WHEN ROUND(
            CAST( solid_ratio AS NUMERIC )) = CAST( solid_ratio AS NUMERIC ) THEN
            CAST( solid_ratio AS INTEGER ) ELSE ROUND( CAST( solid_ratio AS NUMERIC ), 2 )
        END AS solid_ratio,
            CASE

            WHEN ROUND(
            CAST( risk_produce AS NUMERIC )) = CAST( risk_produce AS NUMERIC ) THEN
            CAST( risk_produce AS INTEGER ) ELSE ROUND( CAST( risk_produce AS NUMERIC ), 5 )
        END AS risk_produce,
            CASE

            WHEN ROUND(
            CAST( risk_dispose AS NUMERIC )) = CAST( risk_dispose AS NUMERIC ) THEN
            CAST( risk_dispose AS INTEGER ) ELSE ROUND( CAST( risk_dispose AS NUMERIC ), 5 )
        END AS risk_dispose,
            CASE

            WHEN ROUND(
            CAST( risk_ratio AS NUMERIC )) = CAST( risk_ratio AS NUMERIC ) THEN
            CAST( risk_ratio AS INTEGER ) ELSE ROUND( CAST( risk_ratio AS NUMERIC ), 2 )
        END AS risk_ratio,
            CASE

            WHEN ROUND(
            CAST( energy_put AS NUMERIC )) = CAST( energy_put AS NUMERIC ) THEN
            CAST( energy_put AS INTEGER ) ELSE ROUND( CAST( energy_put AS NUMERIC ), 5 )
        END AS energy_put,
            CASE

            WHEN ROUND(
            CAST( recycle_put AS NUMERIC )) = CAST( recycle_put AS NUMERIC ) THEN
            CAST( recycle_put AS INTEGER ) ELSE ROUND( CAST( recycle_put AS NUMERIC ), 5 )
        END AS recycle_put,
            appear_status,
            STATUS,
            process_status,
            reject_opinion,
            create_by,
            create_date,
            update_by,
            update_date,
            remarks,
            process_id,
            CASE

            WHEN ROUND(
            CAST( operating_income AS NUMERIC )) = CAST( recycle_put AS NUMERIC ) THEN
            CAST( operating_income AS INTEGER ) ELSE ROUND( CAST( operating_income AS NUMERIC ), 5 )
        END AS operating_income,
            CASE

            WHEN ROUND(
            CAST( energy_coal_amount AS NUMERIC )) = CAST( recycle_put AS NUMERIC ) THEN
            CAST( energy_coal_amount AS INTEGER ) ELSE ROUND( CAST( energy_coal_amount AS NUMERIC ), 5 )
        END AS energy_coal_amount,
            regional_org_name,
            regional_org_id
        FROM t_environment_monthly
        ${ew.customSqlSegment}
    </select>
</mapper>