<?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.RptAretTemperSummaryChaobiaolvMapper">
	<sql id="Base_Column_List">
            id as id,
            site_id as siteId,
            sub_equipment_id as subEquipmentId,
            main_equipment_id as mainEquipmentId,
            chaobiao_count as chaobiaoCount,
            data_count as dataCount,
            chaobiaolv as chaobiaolv,
            rtp_time as rtpTime,
            createTime as createtime
    </sql>
    <delete id="deleteOneDayData">
    	delete from rpt_aret_temper_summary_chaobiaolv where rtp_time = #{day}
    </delete>
    <select id="findOneDayCountData" resultType="java.util.Map">
    	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,
		  COUNT(*) AS dataCount
		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,
		         t.sensor_id
    </select>
    <select id="getChaoBiaoCount" resultType="java.math.BigDecimal">
    	SELECT
		  COUNT(*) AS dataCount
		FROM transformer_infrared_temperature t
		WHERE t.site_id = #{siteId}
		AND t.main_tree_id = #{mainTreeId}
		AND t.main_equipment_id = #{mainEquipmentId}
		AND t.sub_tree_id = #{subTreeId}
		AND t.sub_equipment_id = #{subEquipmentId}
		AND t.run_state = #{runState}
		AND t.sensor_id = #{sensorId}
		AND t.time_stamp &gt;= #{startTime}
		AND t.time_stamp &lt; #{endTime}
		AND CAST(t.max_tmp AS decimal(20, 8)) > #{regionThreshold}
    </select>
</mapper>