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

	<sql id="Base_Column_List">
		id as id,
		sensor_id as sensorId,
		cac_monitor_type_code as cacMonitorTypeCode,
		time_stamp as timeStamp,
		site_id as siteId,
		capacitance as capacitance,
		loss_factor as lossFactor,
		unbalance_current as unbalanceCurrent,
		unbalance_voltage as unbalanceVoltage,
		total_current as totalCurrent,
		system_voltage as systemVoltage,
		main_equipment_id as mainEquipmentId,
		sub_equipment_id as subEquipmentId,
		main_tree_id as mainTreeId,
		sub_tree_id as subTreeId,
		run_state as runState,
		type as type,
		create_time as createTime,
		phase as phase
	</sql>

	<select id="getCapacitanceEquipmentImCache" resultType="com.huatek.busi.entity.CapacitanceEquipmentImCache">
		select
			<include refid="Base_Column_List"/>
		from
			capacitance_equipment_im_cache t
		where
			t.sub_tree_id = #{subTreeId} and t.sensor_id = #{sensorCode}
		limit 1
	</select>
	
	<select id="getUptoDateCapacitanceMonitor" resultType="com.huatek.busi.vo.CapacitanceEquipmentImCacheVo">
		select
			<include refid="Base_Column_List"/>
		from
			capacitance_equipment_im_cache t
		<where>
			<if test="mainTreeId != null and mainTreeId != ''">
				t.main_tree_id = #{mainTreeId}			
			</if>
			<if test="sensorId != null and sensorId != ''">
				and t.sensor_id = #{sensorId}			
			</if>
			<if test="type != null and type != ''">
				and t.type = #{type}			
			</if>
		</where>
			
	</select>
</mapper>