<?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.RptAretTemperSummaryMapper">
	<sql id="Base_Column_List">
            id as id,
            site_id as siteId,
            sub_equipment_id as subEquipmentId,
            main_equipment_id as mainEquipmentId,
            sensor_id as sensorId,
            area_id as areaId,
            area_name as areaName,
            htemper as htemper,
            ltemper as ltemper,
            rtp_time as rtpTime,
            createTime as createtime
    </sql>
    <delete id="deleteOneDayData">
    	DELETE FROM rpt_aret_temper_summary WHERE rtp_time = #{day} 
    </delete>
    <select id="findOneDayData" resultType="com.huatek.busi.entity.RptAretTemperSummary">
    	SELECT
		  t.site_id as siteId,
		  t.main_tree_id as mainTreeId,
		  t.sub_tree_id as subTreeId,
		  t.main_equipment_id as mainEquipmentId,
		  t.sub_equipment_id as subEquipmentId,
		  t.sensor_id as sensorId,
		  CAST(AVG(t.max_tmp) AS decimal(20, 8)) AS htemper,
		  CAST(AVG(t.min_tmp) AS decimal(20, 8)) AS ltemper
		  <!-- ,CAST(AVG(t.avg_tmp) AS decimal(20, 8)) AS avgTmp -->
		FROM transformer_infrared_temperature t
		WHERE t.time_stamp &gt;= #{startTime}
			AND t.time_stamp &lt; #{endTime}
			AND t.cac_monitor_type_code = '023002'
		GROUP BY t.site_id,
		         t.main_tree_id,
		         t.main_equipment_id,
		         t.sub_tree_id,
		         t.sub_equipment_id
    </select>
</mapper>