<?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.GisSF6ThresholdMapper">
	<sql id="Base_Column_List">
            id as id,
            sensor_code as sensorCode,
            sf6wd as sf6wd,
            sf6ws as sf6ws,
            sf6yl as sf6yl,
            sf6wdzzl as sf6wdzzl,
            sf6wszzl as sf6wszzl,
            sf6rxll as sf6rxll,
            sf6yxll as sf6yxll,
            sf6wd_warn as sf6wdWarn,
            sf6ws_warn as sf6wsWarn,
            sf6yl_warn as sf6ylWarn,
            sf6wszzl_warn as sf6wszzlWarn,
            sf6rxll_warn as sf6rxllWarn,
            sf6yxll_warn as sf6yxllWarn,
            created_time as createdTime,
            creator as creator,
            modified_time as modifiedTime,
            modifier_id as modifierId
    </sql>

	<sql id="Base_Column_List2">
           t.id as id,
           t.sensor_code as sensorCode,
           t.sf6wd as sf6wd,
           t.sf6ws as sf6ws,
           t.sf6yl as sf6yl,
           t.sf6wdzzl as sf6wdzzl,
           t.sf6wszzl as sf6wszzl,
           t.sf6rxll as sf6rxll,
           t.sf6yxll as sf6yxll,
           t.sf6wd_warn as sf6wdWarn,
           t.sf6ws_warn as sf6wsWarn,
           t.sf6yl_warn as sf6ylWarn,
           t.sf6wszzl_warn as sf6wszzlWarn,
           t.sf6rxll_warn as sf6rxllWarn,
           t.sf6yxll_warn as sf6yxllWarn,
           t.created_time as createdTime,
           t.creator as creator,
           t.modified_time as modifiedTime,
           t.modifier_id as modifierId
    </sql>

	<select id="queryGisSF6Threshold"
		parameterType="java.lang.String" resultType="com.huatek.busi.vo.GisSf6ThresholdVo">
		select
			<include refid="Base_Column_List2" />,
			s.`position` AS phase,
			s.monitor_site monitorSite
		from gis_sf6_threshold t, busi_gis_sensor s
		<where>
			and t.sensor_code = s.sensor_code
			<if test="sensorCode != null and sensorCode != ''">
				and t.sensor_code = #{sensorCode}
			</if>
		</where>
	</select>

	<!-- 根据sensor编码更新GIS SF6 阈值 -->
	<update id="updateGisSensorThresholdBySensorCode">
		update gis_sf6_threshold
		<set>
			<if test="newSensorCode != null and newSensorCode !=''">
				sensor_code = #{newSensorCode,jdbcType=VARCHAR},
			</if>
		</set>
		where sensor_code = #{oldSensorCode,jdbcType=VARCHAR}
	</update>
	<!-- 根据sensor编码更新GIS SF6 阈值 -->
	<delete id="deleteGisSensorThresholdBySensorCode"
		parameterType="java.lang.String">
		DELETE FROM gis_sf6_threshold
		WHERE sensor_code = #{sensorCode,jdbcType=VARCHAR}
	</delete>
</mapper>