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

    <sql id="Base_Column_List">
            id as id,
            site_id as siteId,
            main_tree_id as mainTreeId,
            sensor_code as sensorCode,
            run_state as runState,
            a_leakage_current_threshold as aLeakageCurrentThreshold,
            a_leakage_current_warning as aLeakageCurrentWarning,
            a_capacitance_threshold as aCapacitanceThreshold,
            a_capacitance_warning as aCapacitanceWarning,
            a_loss_factor_threshold as aLossFactorThreshold,
            a_loss_factor_warning as aLossFactorWarning,
            b_leakage_current_threshold as bLeakageCurrentThreshold,
            b_leakage_current_warning as bLeakageCurrentWarning,
            b_capacitance_threshold as bCapacitanceThreshold,
            b_capacitance_warning as bCapacitanceWarning,
            b_loss_factor_threshold as bLossFactorThreshold,
            b_loss_factor_warning as bLossFactorWarning,
            c_leakage_current_threshold as cLeakageCurrentThreshold,
            c_leakage_current_warning as cLeakageCurrentWarning,
            c_capacitance_threshold as cCapacitanceThreshold,
            c_capacitance_warning as cCapacitanceWarning,
            c_loss_factor_threshold as cLossFactorThreshold,
            c_loss_factor_warning as cLossFactorWarning,
            created_time as createdTime,
            creator as creator,
            modified_time as modifiedTime,
            modifier as modifier
    </sql>

    <select id="selectTransformerTgThresholdPage" parameterType="com.huatek.busi.dto.TransformerTgThresholdDto" resultType="com.huatek.busi.vo.TransformerTgThresholdVo">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        transformer_tg_threshold t
        WHERE 1=1
        <if test="id != null and id != ''">
             and t.id = #{id}
        </if>
        <if test="siteId != null and siteId != ''">
             and t.site_id = #{siteId}
        </if>
        <if test="mainTreeId != null and mainTreeId != ''">
             and t.main_tree_id = #{mainTreeId}
        </if>
        <if test="sensorCode != null and sensorCode != ''">
             and t.sensor_code = #{sensorCode}
        </if>
        <if test="runState != null and runState != ''">
             and t.run_state = #{runState}
        </if>
        <if test="aLeakageCurrentThreshold != null and aLeakageCurrentThreshold != ''">
             and t.a_leakage_current_threshold = #{aLeakageCurrentThreshold}
        </if>
        <if test="aLeakageCurrentWarning != null and aLeakageCurrentWarning != ''">
             and t.a_leakage_current_warning = #{aLeakageCurrentWarning}
        </if>
        <if test="aCapacitanceThreshold != null and aCapacitanceThreshold != ''">
             and t.a_capacitance_threshold = #{aCapacitanceThreshold}
        </if>
        <if test="aCapacitanceWarning != null and aCapacitanceWarning != ''">
             and t.a_capacitance_warning = #{aCapacitanceWarning}
        </if>
        <if test="aLossFactorThreshold != null and aLossFactorThreshold != ''">
             and t.a_loss_factor_threshold = #{aLossFactorThreshold}
        </if>
        <if test="aLossFactorWarning != null and aLossFactorWarning != ''">
             and t.a_loss_factor_warning = #{aLossFactorWarning}
        </if>
        <if test="bLeakageCurrentThreshold != null and bLeakageCurrentThreshold != ''">
             and t.b_leakage_current_threshold = #{bLeakageCurrentThreshold}
        </if>
        <if test="bLeakageCurrentWarning != null and bLeakageCurrentWarning != ''">
             and t.b_leakage_current_warning = #{bLeakageCurrentWarning}
        </if>
        <if test="bCapacitanceThreshold != null and bCapacitanceThreshold != ''">
             and t.b_capacitance_threshold = #{bCapacitanceThreshold}
        </if>
        <if test="bCapacitanceWarning != null and bCapacitanceWarning != ''">
             and t.b_capacitance_warning = #{bCapacitanceWarning}
        </if>
        <if test="bLossFactorThreshold != null and bLossFactorThreshold != ''">
             and t.b_loss_factor_threshold = #{bLossFactorThreshold}
        </if>
        <if test="bLossFactorWarning != null and bLossFactorWarning != ''">
             and t.b_loss_factor_warning = #{bLossFactorWarning}
        </if>
        <if test="cLeakageCurrentThreshold != null and cLeakageCurrentThreshold != ''">
             and t.c_leakage_current_threshold = #{cLeakageCurrentThreshold}
        </if>
        <if test="cLeakageCurrentWarning != null and cLeakageCurrentWarning != ''">
             and t.c_leakage_current_warning = #{cLeakageCurrentWarning}
        </if>
        <if test="cCapacitanceThreshold != null and cCapacitanceThreshold != ''">
             and t.c_capacitance_threshold = #{cCapacitanceThreshold}
        </if>
        <if test="cCapacitanceWarning != null and cCapacitanceWarning != ''">
             and t.c_capacitance_warning = #{cCapacitanceWarning}
        </if>
        <if test="cLossFactorThreshold != null and cLossFactorThreshold != ''">
             and t.c_loss_factor_threshold = #{cLossFactorThreshold}
        </if>
        <if test="cLossFactorWarning != null and cLossFactorWarning != ''">
             and t.c_loss_factor_warning = #{cLossFactorWarning}
        </if>
        <if test="createdTime != null">
             and t.created_time = #{createdTime}
        </if>
        <if test="creator != null and creator != ''">
             and t.creator = #{creator}
        </if>
        <if test="modifiedTime != null">
             and t.modified_time = #{modifiedTime}
        </if>
        <if test="modifier != null and modifier != ''">
             and t.modifier = #{modifier}
        </if>
    </select>
	<select id="selectTransformerTgThreshold" parameterType="com.huatek.busi.dto.TransformerTgThresholdDto" resultType="com.huatek.busi.entity.TransformerTgThreshold">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        transformer_tg_threshold t
        <where>	
        <if test="siteId != null and siteId != ''">
             t.site_id = #{siteId}
        </if>
        <if test="mainTreeId != null and mainTreeId != ''">
             and t.main_tree_id = #{mainTreeId}
        </if>
        <if test="sensorCode != null and sensorCode != ''">
             and t.sensor_code = #{sensorCode}
        </if>
        <if test="runState != null and runState != ''">
             and t.run_state = #{runState}
        </if>
        </where>
    </select>
    
    <select id="findTransformerTgThresholdList" parameterType="com.huatek.busi.dto.TransformerTgThresholdDto" resultType="com.huatek.busi.vo.TransformerTgThresholdVo">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        transformer_tg_threshold t
        <where>	
        <if test="siteId != null and siteId != ''">
             t.site_id = #{siteId}
        </if>
        <if test="mainTreeId != null and mainTreeId != ''">
             and t.main_tree_id = #{mainTreeId}
        </if>
        <if test="sensorCode != null and sensorCode != ''">
             and t.sensor_code = #{sensorCode}
        </if>
        <if test="runState != null and runState != ''">
             and t.run_state = #{runState}
        </if>
        </where>
    </select>
    
    <!-- 根据sensor编码更新变压器套管阈值 -->
    <update id="updateTransformerTgThresholdBySensorCode">
	  	update transformer_tg_threshold
	    <set>
	      <if test="newSensorCode != null and newSensorCode !=''">
	        sensor_code = #{newSensorCode,jdbcType=VARCHAR},
	      </if>
	    </set>
	    where sensor_code = #{oldSensorCode,jdbcType=VARCHAR}
     </update>
     <!-- 根据sensor编码删除变压器套管阈值 -->
    <delete id="delTransformerTgThresholdBySensorCode" parameterType="java.lang.String" >
	  	DELETE FROM  transformer_tg_threshold
	    where sensor_code = #{sensorCode,jdbcType=VARCHAR}
     </delete>
</mapper>