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

	<sql id="Base_Column_List">
		id as id,
		site_id as siteId,
		sensor_id as sensorId,
		main_tree_id as mainTreeId,
		sub_tree_id as subTreeId,
		d_time as dTime,
		average_temper as averageTemper,
		increase_rate as increaseRate,
		create_time as createTime
	</sql>

	<delete id="deleteItem">
		delete from temper_increase_rate_cache where sensor_id = #{sensorCode} and d_time = #{dTime}
	</delete>

	<select id="getNearlyItem" resultType="com.huatek.busi.entity.TemperIncreaseRateCache">
		select
			<include refid="Base_Column_List" />
		from
			temper_increase_rate_cache t
		where 
			t.sensor_id = #{sensorCode}
			and t.d_time &lt; #{dTime}
		order by t.d_time desc
		limit 1
	</select>
</mapper>