<?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.zhitan.alarm.mapper.AlarmItemMapper">
|
|
<resultMap type="AlarmItem" id="AlarmItemResult">
|
<result property="id" column="id"/>
|
<result property="createTime" column="create_time"/>
|
<result property="createBy" column="create_by"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="updateBy" column="update_by"/>
|
<result property="dwid" column="dwid"/>
|
<result property="startStop" column="start_stop"/>
|
<result property="timeSlot" column="time_slot"/>
|
<result property="limitType" column="limit_type"/>
|
<result property="limitVal" column="limit_val"/>
|
<result property="alarmLevel" column="alarm_level"/>
|
<result property="nodeId" column="node_id"/>
|
<result property="indexCode" column="index_code"/>
|
<result property="alarmCode" column="alarm_code"/>
|
</resultMap>
|
|
<sql id="selectAlarmItemVo">
|
select id,
|
create_time,
|
create_by,
|
update_time,
|
update_by,
|
dwid,
|
start_stop,
|
time_slot,
|
limit_type,
|
limit_val,
|
alarm_level,
|
node_id
|
from alarm_item
|
</sql>
|
|
<select id="selectAlarmItemList" parameterType="AlarmItem" resultMap="AlarmItemResult">
|
<include refid="selectAlarmItemVo"/>
|
<where>
|
</where>
|
</select>
|
|
<select id="selectAlarmItemById" parameterType="String" resultMap="AlarmItemResult">
|
<include refid="selectAlarmItemVo"/>
|
where id = #{id}
|
</select>
|
|
<insert id="insertAlarmItem" parameterType="AlarmItem">
|
insert into alarm_item
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null and id != ''">id,</if>
|
<if test="createTime != null ">create_time,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="updateTime != null ">update_time,</if>
|
<if test="updateBy != null and updateBy != ''">update_by,</if>
|
<if test="dwid != null and dwid != ''">dwid,</if>
|
<if test="startStop != null and startStop != ''">start_stop,</if>
|
<if test="timeSlot != null and timeSlot != ''">time_slot,</if>
|
<if test="limit_type != null and limit_type != ''">limit_type,</if>
|
<if test="limitVal != null and limitVal != ''">limit_val,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null and id != ''">#{id},</if>
|
<if test="createTime != null ">#{createTime},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="updateTime != null ">#{updateTime},</if>
|
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
|
<if test="dwid != null and dwid != ''">#{dwid},</if>
|
<if test="startStop != null and startStop != ''">#{startStop},</if>
|
<if test="timeSlot != null and timeSlot != ''">#{timeSlot},</if>
|
<if test="limitType != null and limitType != ''">#{limitType},</if>
|
<if test="limitVal != null and limitVal != ''">#{limitVal},</if>
|
</trim>
|
</insert>
|
|
<update id="updateAlarmItem" parameterType="AlarmItem">
|
update alarm_item
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="createTime != null ">create_time = #{createTime},</if>
|
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
|
<if test="updateTime != null ">update_time = #{updateTime},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="dwid != null and dwid != ''">dwid = #{dwid},</if>
|
<if test="startStop != null and startStop != ''">start_stop = #{startStop},</if>
|
<if test="timeSlot != null and timeSlot != ''">time_slot = #{timeSlot},</if>
|
<if test="limitType != null and limitType != ''">limit = #{limitType},</if>
|
<if test="limitVal != null and limitVal != ''">limit_val = #{limitVal},</if>
|
</trim>
|
where id = #{id}
|
</update>
|
|
<delete id="deleteAlarmItemById" parameterType="String">
|
delete
|
from alarm_item
|
where id = #{id}
|
</delete>
|
|
<delete id="deleteAlarmItemByIds" parameterType="String">
|
delete from alarm_item where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
|
<select id="selectAlarmItemtingById" parameterType="String" resultMap="AlarmItemResult">
|
<include refid="selectAlarmItemVo"/>
|
where dwid = #{id}
|
</select>
|
|
<update id="updateStartStop">
|
update alarm_item SET start_stop=#{flag},update_time=now(),update_by=#{update_by} where dwid in
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</update>
|
<select id="getStartStop" resultType="String">
|
select DISTINCT start_stop
|
from alarm_item
|
where dwid = #{indexid};
|
</select>
|
|
<update id="updateLimitVal">
|
delete from alarm_item where dwid = #{id};
|
<foreach collection="data" item="item" index="index" separator=";">
|
insert into alarm_item
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null and id != ''">id,</if>
|
<if test="item.indexId != null and item.indexId != ''">dwid,</if>
|
<if test="item.state != null and item.state != ''">start_stop,</if>
|
<if test="item.timeSlotVal != null and item.timeSlotVal != ''">time_slot,</if>
|
<if test="item.limitTypeVal != null and item.limitTypeVal != ''">limit_type,</if>
|
<if test="item.limitVal != null and item.limitVal != ''">limit_val,</if>
|
<if test="item.alarmLevel != null and item.alarmLevel != ''">alarm_level,</if>
|
<if test="item.nodeId != null and item.nodeId != ''">node_id,</if>
|
<if test="id != null and id != ''">update_time,</if>
|
<if test="id != null and id != ''">create_time,</if>
|
<if test="id != null and id != ''">update_by,</if>
|
<if test="id != null and id != ''">create_by,</if>
|
<if test="id != null and id != ''">alarm_code,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null and id != ''">#{item.id},</if>
|
<if test="item.indexId != null and item.indexId != ''">#{item.indexId},</if>
|
<if test="item.state != null and item.state != ''">#{item.state},</if>
|
<if test="item.timeSlotVal != null and item.timeSlotVal != ''">#{item.timeSlotVal},</if>
|
<if test="item.limitTypeVal != null and item.limitTypeVal != ''">#{item.limitTypeVal},</if>
|
<if test="item.limitVal != null and item.limitVal != ''">#{item.limitVal},</if>
|
<if test="item.alarmLevel != null and item.alarmLevel != ''">#{item.alarmLevel},</if>
|
<if test="item.nodeId != null and item.nodeId != ''">#{item.nodeId},</if>
|
<if test="id != null and id != ''">now(),</if>
|
<if test="id != null and id != ''">now(),</if>
|
<if test="id != null and id != ''">#{username},</if>
|
<if test="id != null and id != ''">#{username},</if>
|
<if test="id != null and id != ''">#{item.alarmCode},</if>
|
</trim>
|
</foreach>
|
</update>
|
<!-- <insert id="updateLimitValNoDel">-->
|
<!-- <foreach collection="data" item="item" index="index" separator=";">-->
|
<!-- insert into alarm_item-->
|
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
|
<!-- <if test="id != null and id != ''">id,</if>-->
|
<!-- <if test="item.indexId != null and item.indexId != ''">dwid,</if>-->
|
<!-- <if test="item.state != null and item.state != ''">start_stop,</if>-->
|
<!-- <if test="item.timeSlotVal != null and item.timeSlotVal != ''">time_slot,</if>-->
|
<!-- <if test="item.limitTypeVal != null and item.limitTypeVal != ''">limit_type,</if>-->
|
<!-- <if test="item.limitVal != null and item.limitVal != ''">limit_val,</if>-->
|
<!-- <if test="item.alarmLevel != null and item.alarmLevel != ''">alarm_level,</if>-->
|
<!-- <if test="item.nodeId != null and item.nodeId != ''">node_id,</if>-->
|
<!-- <if test="id != null and id != ''">update_time,</if>-->
|
<!-- <if test="id != null and id != ''">create_time,</if>-->
|
<!-- <if test="id != null and id != ''">update_by,</if>-->
|
<!-- <if test="id != null and id != ''">create_by,</if>-->
|
<!-- <if test="id != null and id != ''">alarm_code,</if>-->
|
<!-- </trim>-->
|
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
|
<!-- <if test="id != null and id != ''">#{item.id},</if>-->
|
<!-- <if test="item.indexId != null and item.indexId != ''">#{item.indexId},</if>-->
|
<!-- <if test="item.state != null and item.state != ''">#{item.state},</if>-->
|
<!-- <if test="item.timeSlotVal != null and item.timeSlotVal != ''">#{item.timeSlotVal},</if>-->
|
<!-- <if test="item.limitTypeVal != null and item.limitTypeVal != ''">#{item.limitTypeVal},</if>-->
|
<!-- <if test="item.limitVal != null and item.limitVal != ''">#{item.limitVal},</if>-->
|
<!-- <if test="item.alarmLevel != null and item.alarmLevel != ''">#{item.alarmLevel},</if>-->
|
<!-- <if test="item.nodeId != null and item.nodeId != ''">#{item.nodeId},</if>-->
|
<!-- <if test="id != null and id != ''">now(),</if>-->
|
<!-- <if test="id != null and id != ''">now(),</if>-->
|
<!-- <if test="id != null and id != ''">#{username},</if>-->
|
<!-- <if test="id != null and id != ''">#{username},</if>-->
|
<!-- <if test="id != null and id != ''">#{item.alarm_code},</if>-->
|
<!-- </trim>-->
|
<!-- </foreach>-->
|
<!-- </insert>-->
|
<insert id="updateLimitValNoDel">
|
insert into alarm_item (id, create_time, create_by, update_time, update_by, dwid, start_stop, time_slot,
|
limit_type, limit_val, alarm_level, node_id, alarm_code)
|
values
|
<foreach collection="data" item="item" index="index" separator=",">
|
(#{item.id},now(),#{username},now(),#{username},#{item.indexId},#{item.state},#{item.timeSlotVal},
|
#{item.limitTypeVal},#{item.limitVal},#{item.alarmLevel},#{item.nodeId},#{item.alarmCode})
|
</foreach>
|
</insert>
|
<select id="selectCountById" resultType="int">
|
select count(id)
|
from alarm_item
|
where dwid = #{id};
|
</select>
|
<delete id="deleteAllLimitVal">
|
delete
|
from alarm_item
|
where dwid = #{id};
|
</delete>
|
<select id="getSettingCount" resultType="int">
|
select count(id)
|
from alarm_item
|
where dwid = #{id};
|
</select>
|
<select id="getAllAlarmItem" resultMap="AlarmItemResult">
|
select ai.*, ei.code as index_code
|
from alarm_item ai
|
left join energy_index ei on ai.dwid = ei.index_id
|
where start_stop = '1';
|
</select>
|
</mapper>
|