|
|
<?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="org.dromara.ems.base.mapper.EmsAlarmActionStepMapper">
|
|
|
|
|
|
<resultMap type="EmsAlarmActionStep" id="EmsAlarmActionStepResult">
|
|
|
<result property="objId" column="obj_id" />
|
|
|
<result property="ruleObjId" column="rule_obj_id" />
|
|
|
<result property="stepSequence" column="step_sequence" />
|
|
|
<result property="description" column="description" />
|
|
|
<result property="createBy" column="create_by" />
|
|
|
<result property="createTime" column="create_time" />
|
|
|
<result property="updateBy" column="update_by" />
|
|
|
<result property="updateTime" column="update_time" />
|
|
|
<result property="remark" column="remark" />
|
|
|
<result property="ossIds" column="oss_ids" />
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectEmsAlarmActionStepVo">
|
|
|
select obj_id, rule_obj_id, step_sequence, description, create_by, create_time, update_by, update_time, remark, oss_ids from ems_alarm_action_step
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectEmsAlarmActionStepList" parameterType="EmsAlarmActionStep" resultMap="EmsAlarmActionStepResult">
|
|
|
<include refid="selectEmsAlarmActionStepVo"/>
|
|
|
<where>
|
|
|
<if test="ruleObjId != null and ruleObjId != ''"> and rule_obj_id = #{ruleObjId}</if>
|
|
|
<if test="stepSequence != null "> and step_sequence = #{stepSequence}</if>
|
|
|
<if test="description != null and description != ''"> and description = #{description}</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
<select id="selectEmsAlarmActionStepByObjId" parameterType="String" resultMap="EmsAlarmActionStepResult">
|
|
|
<include refid="selectEmsAlarmActionStepVo"/>
|
|
|
where obj_id = #{objId}
|
|
|
</select>
|
|
|
|
|
|
<select id="selectEmsAlarmActionStepByRuleObjId" parameterType="String" resultMap="EmsAlarmActionStepResult">
|
|
|
<include refid="selectEmsAlarmActionStepVo"/>
|
|
|
WHERE rule_obj_id = #{ruleObjId}
|
|
|
ORDER BY step_sequence ASC
|
|
|
</select>
|
|
|
|
|
|
<select id="selectActionStepsByAlarmInfo" resultMap="EmsAlarmActionStepResult">
|
|
|
SELECT
|
|
|
step.obj_id,
|
|
|
step.rule_obj_id,
|
|
|
step.step_sequence,
|
|
|
step.description,
|
|
|
step.create_by,
|
|
|
step.create_time,
|
|
|
step.update_by,
|
|
|
step.update_time,
|
|
|
step.remark,
|
|
|
step.oss_ids
|
|
|
FROM ems_alarm_action_step step
|
|
|
INNER JOIN ems_record_alarm_rule rule ON step.rule_obj_id = rule.obj_id
|
|
|
WHERE rule.monitor_id = #{monitorId}
|
|
|
AND (
|
|
|
-- 新版本规则:基于monitor_field字段匹配
|
|
|
(rule.monitor_field IS NOT NULL AND
|
|
|
CASE rule.monitor_field
|
|
|
WHEN 0 THEN #{cause} = '温度'
|
|
|
WHEN 1 THEN #{cause} = '湿度'
|
|
|
WHEN 2 THEN #{cause} = '振动-速度(mm/s)'
|
|
|
WHEN 3 THEN #{cause} = '振动-位移(um)'
|
|
|
WHEN 4 THEN #{cause} = '振动-加速度(g)'
|
|
|
WHEN 5 THEN #{cause} = '振动-温度(℃)'
|
|
|
WHEN 6 THEN #{cause} = '噪音'
|
|
|
WHEN 7 THEN #{cause} = '照度'
|
|
|
WHEN 8 THEN #{cause} = '气体浓度'
|
|
|
ELSE 0
|
|
|
END = 1
|
|
|
)
|
|
|
OR
|
|
|
-- 历史版本规则:monitor_field为空,匹配所有字段类型
|
|
|
(rule.monitor_field IS NULL)
|
|
|
)
|
|
|
ORDER BY step.step_sequence ASC
|
|
|
</select>
|
|
|
|
|
|
<insert id="insertEmsAlarmActionStep" parameterType="EmsAlarmActionStep" useGeneratedKeys="true" keyProperty="objId">
|
|
|
insert into ems_alarm_action_step
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
<if test="ruleObjId != null and ruleObjId != ''">rule_obj_id,</if>
|
|
|
<if test="stepSequence != null">step_sequence,</if>
|
|
|
<if test="description != null">description,</if>
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
<if test="remark != null">remark,</if>
|
|
|
<if test="ossIds != null and ossIds != ''">oss_ids,</if>
|
|
|
</trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="ruleObjId != null and ruleObjId != ''">#{ruleObjId},</if>
|
|
|
<if test="stepSequence != null">#{stepSequence},</if>
|
|
|
<if test="description != null">#{description},</if>
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
<if test="ossIds != null and ossIds != ''">#{ossIds},</if>
|
|
|
</trim>
|
|
|
</insert>
|
|
|
|
|
|
<update id="updateEmsAlarmActionStep" parameterType="EmsAlarmActionStep">
|
|
|
update ems_alarm_action_step
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
<if test="ruleObjId != null and ruleObjId != ''">rule_obj_id = #{ruleObjId},</if>
|
|
|
<if test="stepSequence != null">step_sequence = #{stepSequence},</if>
|
|
|
<if test="description != null">description = #{description},</if>
|
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
<if test="ossIds != null">oss_ids = #{ossIds},</if>
|
|
|
</trim>
|
|
|
where obj_id = #{objId}
|
|
|
</update>
|
|
|
|
|
|
<delete id="deleteEmsAlarmActionStepByObjId" parameterType="String">
|
|
|
delete from ems_alarm_action_step where obj_id = #{objId}
|
|
|
</delete>
|
|
|
|
|
|
<delete id="deleteEmsAlarmActionStepByObjIds" parameterType="String">
|
|
|
delete from ems_alarm_action_step where obj_id in
|
|
|
<foreach item="objId" collection="array" open="(" separator="," close=")">
|
|
|
#{objId}
|
|
|
</foreach>
|
|
|
</delete>
|
|
|
</mapper>
|