@ -9,23 +9,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property= "alarmRuleName" column= "alarm_rule_name" />
<result property= "tenantId" column= "tenant_id" />
<result property= "sceneId" column= "scene_id" />
<result property= "languageCode" column= "language_code" />
<result property= "alarmLevelId" column= "alarm_level_id" />
<result property= "alarmTypeId" column= "alarm_type_id" />
<result property= "ruleType" column= "rule_type" />
<result property= "deviceId" column= "device_id" />
<result property= "deviceModeId" column= "device_mode_id" />
<result property= "modeFunctionId" column= "mode_function_id" />
<result property= "triggerCondition" column= "trigger_condition" />
<result property= "triggerDataA" column= "trigger_data_a" />
<result property= "triggerDataB" column= "trigger_data_b" />
<result property= "triggerDeadzone" column= "trigger_deadzone" />
<result property= "triggerNumber" column= "trigger_number" />
<result property= "triggerTimeFrame" column= "trigger_time_frame" />
<result property= "ruleDeviceId" column= "rule_device_id" />
<result property= "ruleFunctionTotal" column= "rule_function_total" />
<result property= "triggerExpression" column= "trigger_expression" />
<result property= "linkFlag" column= "link_flag" />
<result property= "linkType" column= "link_type" />
<result property= "linkDeviceId" column= "link_device_id" />
<result property= "linkDeviceFunctionId" column= "link_device_function_id" />
<result property= "linkDeviceFunctionData" column= "link_device_function_data" />
<result property= "alarmRuleStatus" column= "alarm_rule_status" />
<result property= "alarmPushFlag" column= "alarm_push_flag" />
<result property= "alarmPushContent" column= "alarm_push_content" />
@ -36,46 +27,77 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "alarmRuleField" column= "alarm_rule_field" />
<result property= "tenantName" column= "tenant_name" />
<result property= "sceneName" column= "scene_name" />
<result property= "alarmTypeName" column= "alarm_type_name" />
<result property= "alarmLevelName" column= "alarm_level_name" />
<result property= "ruleDeviceName" column= "device_name" />
</resultMap>
<resultMap id= "HwAlarmRuleHwAlarmRuleLinkResult" type= "HwAlarmRule" extends= "HwAlarmRuleResult" >
<collection property= "hwAlarmRuleLinkList" notNullColumn= "sub_rule_link_id" javaType= "java.util.List" resultMap= "HwAlarmRuleLinkResult" />
</resultMap>
<resultMap type= "HwAlarmRuleLink" id= "HwAlarmRuleLinkResult" >
<result property= "ruleLinkId" column= "sub_rule_link_id" />
<result property= "alarmRuleId" column= "sub_alarm_rule_id" />
<result property= "linkType" column= "sub_link_type" />
<result property= "linkDeviceId" column= "sub_link_device_id" />
<result property= "linkDeviceFunctionId" column= "sub_link_device_function_id" />
<result property= "linkDeviceFunctionIdentifier" column= "sub_link_device_function_identifier" />
<result property= "linkDeviceFunctionData" column= "sub_link_device_function_data" />
<result property= "linkDeviceName" column= "sub_link_device_name" />
<result property= "linkDeviceModeFunctionName" column= "sub_link_device_mode_function_name" />
</resultMap>
<sql id= "selectHwAlarmRuleVo" >
select alarm_rule_id, alarm_rule_name, tenant_id, scene_id, alarm_level_id, alarm_type_id, rule_type, device_id, device_mode_id, mode_function_id, trigger_condition, trigger_data_a, trigger_data_b, trigger_deadzone, trigger_number, trigger_time_frame, link_flag, link_type, link_device_id, link_device_function_id, link_device_function_data, alarm_rule_status, alarm_push_flag, alarm_push_content, alarm_recover_content, remark, create_by, create_time, update_by, update_time, alarm_rule_field from hw_alarm_rule
select alarm_rule_id, alarm_rule_name, tenant_id, scene_id, language_code, alarm_level_id, alarm_type_id, rule_type, rule_device_id, rule_function_total, trigger_expression, link_flag , alarm_rule_status, alarm_push_flag, alarm_push_content, alarm_recover_content, remark, create_by, create_time, update_by, update_time, alarm_rule_field from hw_alarm_rule
</sql>
<select id= "selectHwAlarmRuleList" parameterType= "HwAlarmRule" resultMap= "HwAlarmRuleResult" >
<include refid= "selectHwAlarmRuleVo" />
<where >
<if test= "alarmRuleName != null and alarmRuleName != ''" > and alarm_rule_name like concat('%', #{alarmRuleName}, '%')</if>
<if test= "tenantId != null " > and tenant_id = #{tenantId}</if>
<if test= "sceneId != null " > and scene_id = #{sceneId}</if>
<if test= "alarmLevelId != null " > and alarm_level_id = #{alarmLevelId}</if>
<if test= "alarmTypeId != null " > and alarm_type_id = #{alarmTypeId}</if>
<if test= "ruleType != null and ruleType != ''" > and rule_type = #{ruleType}</if>
<if test= "deviceId != null " > and device_id = #{deviceId}</if>
<if test= "deviceModeId != null " > and device_mode_id = #{deviceModeId}</if>
<if test= "modeFunctionId != null " > and mode_function_id = #{modeFunctionId}</if>
<if test= "triggerCondition != null and triggerCondition != ''" > and trigger_condition = #{triggerCondition}</if>
<if test= "triggerDataA != null and triggerDataA != ''" > and trigger_data_a = #{triggerDataA}</if>
<if test= "triggerDataB != null and triggerDataB != ''" > and trigger_data_b = #{triggerDataB}</if>
<if test= "triggerDeadzone != null and triggerDeadzone != ''" > and trigger_deadzone = #{triggerDeadzone}</if>
<if test= "triggerNumber != null " > and trigger_number = #{triggerNumber}</if>
<if test= "triggerTimeFrame != null " > and trigger_time_frame = #{triggerTimeFrame}</if>
<if test= "linkFlag != null and linkFlag != ''" > and link_flag = #{linkFlag}</if>
<if test= "linkType != null and linkType != ''" > and link_type = #{linkType}</if>
<if test= "linkDeviceId != null " > and link_device_id = #{linkDeviceId}</if>
<if test= "linkDeviceFunctionId != null " > and link_device_function_id = #{linkDeviceFunctionId}</if>
<if test= "linkDeviceFunctionData != null and linkDeviceFunctionData != ''" > and link_device_function_data = #{linkDeviceFunctionData}</if>
<if test= "alarmRuleStatus != null and alarmRuleStatus != ''" > and alarm_rule_status = #{alarmRuleStatus}</if>
<if test= "alarmPushFlag != null and alarmPushFlag != ''" > and alarm_push_flag = #{alarmPushFlag}</if>
<if test= "alarmPushContent != null and alarmPushContent != ''" > and alarm_push_content = #{alarmPushContent}</if>
<if test= "alarmRecoverContent != null and alarmRecoverContent != ''" > and alarm_recover_content = #{alarmRecoverContent}</if>
<if test= "alarmRuleField != null and alarmRuleField != ''" > and alarm_rule_field = #{alarmRuleField}</if>
<select id= "selectHwAlarmRuleJoinList" parameterType= "HwAlarmRule" resultMap= "HwAlarmRuleResult" >
select har.alarm_rule_id,har.alarm_rule_name, har.alarm_type_id,har.alarm_level_id,har.scene_id,
har.link_flag,har.alarm_rule_status,har.alarm_push_flag,har.tenant_id,har.trigger_expression,har.rule_device_id,har.rule_type,har.language_code,
ht.tenant_name,hs.scene_name,hat.alarm_type_name,hal.alarm_level_name,hd.device_name
from hw_alarm_rule har
left join hw_tenant ht on har.tenant_id=ht.tenant_id
left join hw_scene hs on har.scene_id=hs.scene_id
left join hw_alarm_type hat on har.alarm_type_id= hat.alarm_type_id
left join hw_alarm_level hal on har.alarm_level_id = hal.alarm_level_id
left join hw_device hd on har.rule_device_id=hd.device_id
<where >
har.alarm_rule_status !='9'
<if test= "alarmRuleName != null and alarmRuleName != ''" > and har.alarm_rule_name like concat('%', #{alarmRuleName}, '%')</if>
<if test= "tenantId != null " > and har.tenant_id = #{tenantId}</if>
<if test= "sceneId != null " > and har.scene_id = #{sceneId}</if>
<if test= "languageCode != null and languageCode != ''" > and har.language_code = #{languageCode}</if>
<if test= "alarmLevelId != null " > and har.alarm_level_id = #{alarmLevelId}</if>
<if test= "alarmTypeId != null " > and har.alarm_type_id = #{alarmTypeId}</if>
<if test= "ruleType != null and ruleType != ''" > and har.rule_type = #{ruleType}</if>
<if test= "ruleDeviceId != null " > and har.rule_device_id = #{ruleDeviceId}</if>
<if test= "ruleFunctionTotal != null " > and har.rule_function_total = #{ruleFunctionTotal}</if>
<if test= "triggerExpression != null and triggerExpression != ''" > and har.trigger_expression = #{triggerExpression}</if>
<if test= "linkFlag != null and linkFlag != ''" > and har.link_flag = #{linkFlag}</if>
<if test= "alarmRuleStatus != null and alarmRuleStatus != ''" > and har.alarm_rule_status = #{alarmRuleStatus}</if>
<if test= "alarmPushFlag != null and alarmPushFlag != ''" > and har.alarm_push_flag = #{alarmPushFlag}</if>
<if test= "alarmPushContent != null and alarmPushContent != ''" > and har.alarm_push_content = #{alarmPushContent}</if>
<if test= "alarmRecoverContent != null and alarmRecoverContent != ''" > and har.alarm_recover_content = #{alarmRecoverContent}</if>
<if test= "alarmRuleField != null and alarmRuleField != ''" > and har.alarm_rule_field = #{alarmRuleField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
order by har.alarm_rule_id desc
</select>
<select id= "selectHwAlarmRuleByAlarmRuleId" parameterType= "Long" resultMap= "HwAlarmRuleResult" >
<include refid= "selectHwAlarmRuleVo" />
where alarm_rule_id = #{alarmRuleId}
<select id= "selectHwAlarmRuleByAlarmRuleId" parameterType= "Long" resultMap= "HwAlarmRuleHwAlarmRuleLinkResult" >
select a.alarm_rule_id, a.alarm_rule_name, a.tenant_id, a.scene_id, a.language_code, a.alarm_level_id, a.alarm_type_id, a.rule_type, a.rule_device_id, a.rule_function_total, a.trigger_expression, a.link_flag, a.alarm_rule_status, a.alarm_push_flag, a.alarm_push_content, a.alarm_recover_content, a.remark, a.create_by, a.create_time, a.update_by, a.update_time, a.alarm_rule_field,
b.rule_link_id as sub_rule_link_id, b.alarm_rule_id as sub_alarm_rule_id, b.link_type as sub_link_type, b.link_device_id as sub_link_device_id, b.link_device_function_id as sub_link_device_function_id, b.link_device_function_identifier as sub_link_device_function_identifier, b.link_device_function_data as sub_link_device_function_data, hd.device_name as sub_link_device_name,hdmf.function_name as sub_link_device_mode_function_name
from hw_alarm_rule a
left join hw_alarm_rule_link b on b.alarm_rule_id = a.alarm_rule_id
left join hw_device hd on b.link_device_id = hd.device_id
left join hw_device_mode_function hdmf on b.link_device_function_id=hdmf.mode_function_id
where a.alarm_rule_id = #{alarmRuleId}
</select>
<insert id= "insertHwAlarmRule" parameterType= "HwAlarmRule" useGeneratedKeys= "true" keyProperty= "alarmRuleId" >
@ -84,23 +106,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test= "alarmRuleName != null and alarmRuleName != ''" > alarm_rule_name,</if>
<if test= "tenantId != null" > tenant_id,</if>
<if test= "sceneId != null" > scene_id,</if>
<if test= "languageCode != null" > language_code,</if>
<if test= "alarmLevelId != null" > alarm_level_id,</if>
<if test= "alarmTypeId != null" > alarm_type_id,</if>
<if test= "ruleType != null and ruleType != ''" > rule_type,</if>
<if test= "deviceId != null" > device_id,</if>
<if test= "deviceModeId != null" > device_mode_id,</if>
<if test= "modeFunctionId != null" > mode_function_id,</if>
<if test= "triggerCondition != null and triggerCondition != ''" > trigger_condition,</if>
<if test= "triggerDataA != null and triggerDataA != ''" > trigger_data_a,</if>
<if test= "triggerDataB != null" > trigger_data_b,</if>
<if test= "triggerDeadzone != null" > trigger_deadzone,</if>
<if test= "triggerNumber != null" > trigger_number,</if>
<if test= "triggerTimeFrame != null" > trigger_time_frame,</if>
<if test= "ruleDeviceId != null" > rule_device_id,</if>
<if test= "ruleFunctionTotal != null" > rule_function_total,</if>
<if test= "triggerExpression != null and triggerExpression != ''" > trigger_expression,</if>
<if test= "linkFlag != null and linkFlag != ''" > link_flag,</if>
<if test= "linkType != null" > link_type,</if>
<if test= "linkDeviceId != null" > link_device_id,</if>
<if test= "linkDeviceFunctionId != null" > link_device_function_id,</if>
<if test= "linkDeviceFunctionData != null" > link_device_function_data,</if>
<if test= "alarmRuleStatus != null and alarmRuleStatus != ''" > alarm_rule_status,</if>
<if test= "alarmPushFlag != null and alarmPushFlag != ''" > alarm_push_flag,</if>
<if test= "alarmPushContent != null" > alarm_push_content,</if>
@ -116,23 +129,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test= "alarmRuleName != null and alarmRuleName != ''" > #{alarmRuleName},</if>
<if test= "tenantId != null" > #{tenantId},</if>
<if test= "sceneId != null" > #{sceneId},</if>
<if test= "languageCode != null" > #{languageCode},</if>
<if test= "alarmLevelId != null" > #{alarmLevelId},</if>
<if test= "alarmTypeId != null" > #{alarmTypeId},</if>
<if test= "ruleType != null and ruleType != ''" > #{ruleType},</if>
<if test= "deviceId != null" > #{deviceId},</if>
<if test= "deviceModeId != null" > #{deviceModeId},</if>
<if test= "modeFunctionId != null" > #{modeFunctionId},</if>
<if test= "triggerCondition != null and triggerCondition != ''" > #{triggerCondition},</if>
<if test= "triggerDataA != null and triggerDataA != ''" > #{triggerDataA},</if>
<if test= "triggerDataB != null" > #{triggerDataB},</if>
<if test= "triggerDeadzone != null" > #{triggerDeadzone},</if>
<if test= "triggerNumber != null" > #{triggerNumber},</if>
<if test= "triggerTimeFrame != null" > #{triggerTimeFrame},</if>
<if test= "ruleDeviceId != null" > #{ruleDeviceId},</if>
<if test= "ruleFunctionTotal != null" > #{ruleFunctionTotal},</if>
<if test= "triggerExpression != null and triggerExpression != ''" > #{triggerExpression},</if>
<if test= "linkFlag != null and linkFlag != ''" > #{linkFlag},</if>
<if test= "linkType != null" > #{linkType},</if>
<if test= "linkDeviceId != null" > #{linkDeviceId},</if>
<if test= "linkDeviceFunctionId != null" > #{linkDeviceFunctionId},</if>
<if test= "linkDeviceFunctionData != null" > #{linkDeviceFunctionData},</if>
<if test= "alarmRuleStatus != null and alarmRuleStatus != ''" > #{alarmRuleStatus},</if>
<if test= "alarmPushFlag != null and alarmPushFlag != ''" > #{alarmPushFlag},</if>
<if test= "alarmPushContent != null" > #{alarmPushContent},</if>
@ -152,23 +156,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test= "alarmRuleName != null and alarmRuleName != ''" > alarm_rule_name = #{alarmRuleName},</if>
<if test= "tenantId != null" > tenant_id = #{tenantId},</if>
<if test= "sceneId != null" > scene_id = #{sceneId},</if>
<if test= "languageCode != null" > language_code = #{languageCode},</if>
<if test= "alarmLevelId != null" > alarm_level_id = #{alarmLevelId},</if>
<if test= "alarmTypeId != null" > alarm_type_id = #{alarmTypeId},</if>
<if test= "ruleType != null and ruleType != ''" > rule_type = #{ruleType},</if>
<if test= "deviceId != null" > device_id = #{deviceId},</if>
<if test= "deviceModeId != null" > device_mode_id = #{deviceModeId},</if>
<if test= "modeFunctionId != null" > mode_function_id = #{modeFunctionId},</if>
<if test= "triggerCondition != null and triggerCondition != ''" > trigger_condition = #{triggerCondition},</if>
<if test= "triggerDataA != null and triggerDataA != ''" > trigger_data_a = #{triggerDataA},</if>
<if test= "triggerDataB != null" > trigger_data_b = #{triggerDataB},</if>
<if test= "triggerDeadzone != null" > trigger_deadzone = #{triggerDeadzone},</if>
<if test= "triggerNumber != null" > trigger_number = #{triggerNumber},</if>
<if test= "triggerTimeFrame != null" > trigger_time_frame = #{triggerTimeFrame},</if>
<if test= "ruleDeviceId != null" > rule_device_id = #{ruleDeviceId},</if>
<if test= "ruleFunctionTotal != null" > rule_function_total = #{ruleFunctionTotal},</if>
<if test= "triggerExpression != null and triggerExpression != ''" > trigger_expression = #{triggerExpression},</if>
<if test= "linkFlag != null and linkFlag != ''" > link_flag = #{linkFlag},</if>
<if test= "linkType != null" > link_type = #{linkType},</if>
<if test= "linkDeviceId != null" > link_device_id = #{linkDeviceId},</if>
<if test= "linkDeviceFunctionId != null" > link_device_function_id = #{linkDeviceFunctionId},</if>
<if test= "linkDeviceFunctionData != null" > link_device_function_data = #{linkDeviceFunctionData},</if>
<if test= "alarmRuleStatus != null and alarmRuleStatus != ''" > alarm_rule_status = #{alarmRuleStatus},</if>
<if test= "alarmPushFlag != null and alarmPushFlag != ''" > alarm_push_flag = #{alarmPushFlag},</if>
<if test= "alarmPushContent != null" > alarm_push_content = #{alarmPushContent},</if>
@ -188,9 +183,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id= "deleteHwAlarmRuleByAlarmRuleIds" parameterType= "String" >
delete from hw_alarm_rule where alarm_rule_id in
update hw_alarm_rule set alarm_rule_status='9' where alarm_rule_id in
<foreach item= "alarmRuleId" collection= "array" open= "(" separator= "," close= ")" >
#{alarmRuleId}
</foreach>
</delete>
<delete id= "deleteHwAlarmRuleLinkByAlarmRuleIds" parameterType= "String" >
delete from hw_alarm_rule_link where alarm_rule_id in
<foreach item= "alarmRuleId" collection= "array" open= "(" separator= "," close= ")" >
#{alarmRuleId}
</foreach>
</delete>
<delete id= "deleteHwAlarmRuleLinkByAlarmRuleId" parameterType= "Long" >
delete from hw_alarm_rule_link where alarm_rule_id = #{alarmRuleId}
</delete>
<insert id= "batchHwAlarmRuleLink" >
insert into hw_alarm_rule_link( rule_link_id, alarm_rule_id, link_type, link_device_id, link_device_function_id, link_device_function_identifier, link_device_function_data) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.ruleLinkId}, #{item.alarmRuleId}, #{item.linkType}, #{item.linkDeviceId}, #{item.linkDeviceFunctionId}, #{item.linkDeviceFunctionIdentifier}, #{item.linkDeviceFunctionData})
</foreach>
</insert>
</mapper>