<?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.huatek.busi.mapper.TransformerEpaDeviationStatisticsMapper">

    <sql id="Base_Column_List">
            id as id,
            d_time as dTime,
            h2_deviation as h2Deviation,
            ch4_deviation as ch4Deviation,
            c2h6_deviation as c2h6Deviation,
            c2h4_deviation as c2h4Deviation,
            c2h2_deviation as c2h2Deviation,
            co_deviation as coDeviation,
            o2_deviation as o2Deviation,
            n2_deviation as n2Deviation,
            total_hydrocarbon_deviation as totalHydrocarbonDeviation,
            h2o_deviation as h2oDeviation,
            co2_deviation as co2Deviation,
            site_id as siteId,
            equipment_id as equipmentId,
            sub_equipment_id as subEquipmentId,
            main_equipment_id as mainEquipmentId,
            main_tree_id as mainTreeId,
            sub_tree_id as subTreeId,
            sensor_code as sensorCode
    </sql>
    <delete id="deleteTransformerEpaDeviationStatistics">
    	delete from transformer_epa_deviation_statistics where d_time = #{day}
    </delete>
  <!--   <select id="getWorstEpaDeviation" resultType="java.math.BigDecimal">
		SELECT 
			MAX(t.total_hydrocarbon_deviation) 
		FROM 
			transformer_epa_deviation_statistics t 
		WHERE 
			t.sensor_code = #{sensorCode}
    </select> -->
    
    <select id="getWorstEpaDeviation" resultType="java.math.BigDecimal">
		SELECT 
			t.total_hydrocarbon_deviation
		FROM 
			transformer_epa_deviation_statistics t 
		WHERE 
			t.sensor_code = #{sensorCode} and d_time = #{day}
    </select>
    
    
    <select id="getTransformerEpaDeviationStatisticsInfo" resultType="com.huatek.busi.entity.TransformerEpaDeviationStatistics">
		SELECT 
			h2_deviation as h2Deviation,
            ch4_deviation as ch4Deviation,
            c2h6_deviation as c2h6Deviation,
            c2h4_deviation as c2h4Deviation,
            c2h2_deviation as c2h2Deviation,
            co_deviation as coDeviation,
            o2_deviation as o2Deviation,
            n2_deviation as n2Deviation,
            total_hydrocarbon_deviation as totalHydrocarbonDeviation,
            h2o_deviation as h2oDeviation,
            co2_deviation as co2Deviation
		FROM 
			transformer_epa_deviation_statistics
		WHERE 
			sensor_code = #{sensorCode}
			and d_time = #{day}
    </select>
</mapper>