<?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.cable.CableCirculationtemperIncreaseRateCacheMapper">

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

	<select id = "getMonthlyGrowThRateBySensorCode" resultType="java.util.Map">
		select
			monthly_growth_rate as GrowthRate
		from
			busi_cable_circulation_increase_rate
		where
			sensor_id = #{sensorCode}
		  And
			d_time = #{d_time}
		Group BY
			sensor_id
	</select>

	<select id="getItem" resultType="com.huatek.busi.entity.BusiCableCirculationIncreaseRate">
		SELECT
			t.id AS id,
			t.site_id AS siteId,
			t.sensor_id AS sensorId,
			t.main_tree_id AS mainTreeId,
			t.sub_tree_id AS subTreeId,
			t.daily_growth_rate AS dailyGrowthRate,
			t.monthly_growth_rate AS monthlyGrowthRate,
			t.d_time AS dTime,
			t.create_time AS createTime,
			o.relative_growth_day_val AS dailyGrowthRateVal,
			o.relative_growth_month_val AS monthlyGrowthRateVal,
			o.relative_growth_prewarning_day_val AS predailyGrowthRate,
			o.relative_growth_prewarning_month_val AS premonthlyGrowthRate
		FROM
			busi_cable_circulation_increase_rate t
		LEFT JOIN busi_other_threshold o on o.sensor_code = t.sensor_id and o.run_state = ''
		where
		t.sensor_id = #{sensorCode}
		and t.d_time = #{day}
		Group By
		t.sensor_id
	</select>

</mapper>