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


    <select id="getYspEvaluateData" resultType="com.huatek.busi.vo.epa.EpaEvaluateDataVo">
        SELECT
        CONVERT(AVG(CAST(t.h2 AS DECIMAL (10, 4))), DECIMAL(10,2)) AS h2,
        CONVERT(AVG(CAST(t.ch4 AS DECIMAL (10, 4))), DECIMAL(10,2)) AS ch4,
        CONVERT(AVG(CAST(t.h2 AS DECIMAL (10, 4))), DECIMAL(10,2)) AS h2,
        CONVERT(AVG(CAST(t.c2h2 AS DECIMAL (10, 4))), DECIMAL(10,2)) AS c2h2,
        CONVERT(AVG(CAST(t.c2h4 AS DECIMAL (10, 4))), DECIMAL(10,2)) AS c2h4,
        CONVERT(AVG(CAST(t.c2h6 AS DECIMAL (10, 4))), DECIMAL(10,2)) AS c2h6,
        CONVERT(AVG(CAST(t.co AS DECIMAL (10, 4))), DECIMAL(10,2)) AS co,
        CONVERT(AVG(CAST(t.co2 AS DECIMAL (10, 4))), DECIMAL(10,2)) AS co2,
        CONVERT(AVG(CAST(t.tmp AS DECIMAL (10, 4))), DECIMAL(10,2)) AS tmp,
        CONVERT(AVG(CAST(t.dew AS DECIMAL (10, 4))), DECIMAL(10,2)) AS dew,
        CONVERT(AVG(CAST(t.mst AS DECIMAL (10, 4))), DECIMAL(10,2)) AS mst,
        CONVERT(AVG(CAST(t.flatgas AS DECIMAL (10, 4))), DECIMAL(10,2)) AS flatGas,
        CONVERT(AVG(CAST(t.cmbugas AS DECIMAL (10, 4))), DECIMAL(10,2)) AS cmbuGas,
        CONVERT(AVG(CAST(t.total_hydrocarbon AS DECIMAL (10, 4))), DECIMAL(10,2)) AS zt
        FROM
        `transformer_epa_data_statistics` t
        WHERE
        t.main_equipment_id = #{mainEquipmentId}
        AND t.d_time &gt; #{startDate}
        AND t.d_time &lt; #{endDate}
    </select>

    <select id="getPdEvaluateData" resultType="com.huatek.busi.vo.epa.EpaPdDataVo">
        SELECT
        CONVERT ( AVG( CAST( t.electric_quantity AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS electricQuantity
        FROM
        `transformer_pd_statistics` t
        WHERE
        t.main_tree_id = #{mainTreeId}
        AND t.d_time &gt; #{startDate}
        AND t.d_time &lt; #{endDate}
    </select>

    <select id="getSoundEvaluateData" resultType="com.huatek.busi.vo.epa.EpaSoundVibrationVo">
        SELECT
        CONVERT(AVG(CAST(t.high_point AS DECIMAL (10, 4))), DECIMAL(10,2)) AS highPoint,
        CONVERT(AVG(CAST(t.low_point AS DECIMAL (10, 4))), DECIMAL(10,2)) AS lowPoint,
        CONVERT(AVG(CAST(t.center_point AS DECIMAL (10, 4))), DECIMAL(10,2)) AS centerPoint,
        CONVERT(AVG(CAST(t.noise_point AS DECIMAL (10, 4))), DECIMAL(10,2)) AS noisePoint
        FROM
        `sound_vibration_params` t
        WHERE
        t.main_tree_id = #{mainTreeId}
        AND t.create_time &gt; #{startDate}
        AND t.create_time &lt; #{endDate}
    </select>


    <select id="getIcgeEvaluateData" resultType="com.huatek.busi.vo.epa.EpaIcgeDataVo">
        SELECT
        CONVERT(AVG(CAST(t.total_core_current AS DECIMAL (10, 4))), DECIMAL(10,2)) AS totalCoreCurrent
        FROM
        `transformer_icge_statistics` t
        WHERE
        t.main_equipment_id = #{mainEquipmentId}
        AND t.type ='1'
        AND t.d_time &gt; #{startDate}
        AND t.d_time &lt; #{endDate}
    </select>

    <select id="getRunStatusEvaluateData" resultType="com.huatek.busi.vo.epa.EpaRunStatusDataVo">
        SELECT
        CONVERT(AVG(CAST(t.avg_cooling_entry_pressure AS DECIMAL (10, 4))), DECIMAL(10,2)) AS entryPressure,
        CONVERT(AVG(CAST(t.avg_cooling_exit_pressure AS DECIMAL (10, 4))), DECIMAL(10,2)) AS exitPressure,
        CONVERT(AVG(CAST(t.avg_coolingwater_inlet_temperature AS DECIMAL (10, 4))), DECIMAL(10,2)) AS inletTemperature,
        CONVERT(AVG(CAST(t.avg_coolingwater_outlet_temperature AS DECIMAL (10, 4))), DECIMAL(10,2)) AS outletTemperature
        FROM
        `transformer_run_status_statistics` t
        WHERE
        t.main_tree_id = #{mainTreeId}
        AND t.d_time &gt; #{startDate}
        AND t.d_time &lt; #{endDate}
    </select>

    <select id="geInfraredMonitorEvaluateData" resultType="com.huatek.busi.vo.epa.EpaInfraredMonitorDataVo">
        SELECT
        CONVERT( AVG( CAST( t.avg_avg_tmp AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS avgTemp
        FROM
        `transformer_infrared_monitoring_statistics` t
        WHERE
        t.main_tree_id = #{mainTreeId}
        AND t.d_time > #{startDate}
        AND t.d_time &lt; #{endDate}
    </select>

    <select id="getEnvironmentEvaluateData" resultType="com.huatek.busi.vo.epa.EpaEnvironmentDataVo">
        SELECT
        CONVERT( AVG( CAST( t.avg_air_temperature AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS temperature
        FROM
        `transformer_meteorological_statistics` t
        WHERE
        t.main_tree_id = #{mainTreeId}
        AND t.d_time > #{startDate}
        AND t.d_time &lt; #{endDate}
    </select>


    <select id="getCapacitanceEvaluateData" resultType="com.huatek.busi.vo.epa.EpaCapacitanceDataVo">
        SELECT
        CONVERT( AVG( CAST( t.a_full_current AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS aFullCurrent,
        CONVERT( AVG( CAST( t.a_capacitance AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS aCapacitance,
        CONVERT( AVG( CAST( t.a_loss_factor AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS aLossFactor,

        CONVERT( AVG( CAST( t.b_full_current AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS bFullCurrent,
        CONVERT( AVG( CAST( t.b_capacitance AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS bCapacitance,
        CONVERT( AVG( CAST( t.b_loss_factor AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS bLossFactor,

        CONVERT( AVG( CAST( t.c_full_current AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS cFullCurrent,
        CONVERT( AVG( CAST( t.c_capacitance AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS cCapacitance,
        CONVERT( AVG( CAST( t.c_loss_factor AS DECIMAL ( 10, 4 ) ) ), DECIMAL ( 10, 2 ) ) AS cLossFactor
        FROM
        `capacitance_equipment_summary` t
        WHERE
        t.main_tree_id = #{mainTreeId}
        AND t.d_time > #{startDate}
        AND t.d_time &lt; #{endDate}
    </select>



</mapper>