Browse Source

告警规则功能,屏蔽空调和报警主机传感器 设备类型

humingshi-7@163.com 1 năm trước cách đây
mục cha
commit
0018e4ce87

+ 18 - 0
project_data/sql/0.1.1/soc/soc.sql

@@ -1077,6 +1077,24 @@ INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_fie
 INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (500, '微波(报警主机)', 'AlarmHostInput_Microwave', '微波', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
 INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (500, '紧急按钮(报警主机)', 'AlarmHostInput_EmergencyButton', '紧急按钮', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
 
+DELIMITER ??
+DROP PROCEDURE IF EXISTS schema_change??
+CREATE PROCEDURE schema_change()
+BEGIN
+    IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema = DATABASE()  AND table_name = 'iot_alarm_system_field' AND column_name = 'alarm_rule_property') THEN
+        ALTER TABLE `iot_alarm_system_field`
+            ADD COLUMN `alarm_rule_property` int NOT NULL DEFAULT '1' COMMENT '是否告警规则属性:0 否,1 是';
+    ELSE
+        ALTER TABLE `iot_alarm_system_field`
+            MODIFY COLUMN `alarm_rule_property` int NOT NULL DEFAULT '1' COMMENT '是否告警规则属性:0 否,1 是';
+    END IF;
+END??
+DELIMITER ;
+CALL schema_change();
+update iot_alarm_system_field set alarm_rule_property = 0 where source_type in (415,500);
+
+
+
 delete from sys_dict_data where dict_type = 'sensor_alarm_status' and dict_value='2';
 insert into sys_dict_data (dict_sort, dict_label, dict_value, dict_type, list_class, status, create_by, create_time) values (2, '未配置告警规则', '2', 'sensor_alarm_status', 'default', '0', '', sysdate());
 

+ 4 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmSystemField.java

@@ -76,6 +76,10 @@ public class IotAlarmSystemField implements Serializable {
     @TableField("enable")
     private Integer enable;
 
+    @ApiModelProperty(value = "是否告警规则属性:0 否,1 是")
+    @TableField("alarm_rule_property")
+    private Integer alarmRuleProperty;
+
     @ApiModelProperty(value = "创建人")
     @TableField("create_by")
     private String createBy;

+ 1 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmRuleServiceImpl.java

@@ -47,7 +47,7 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
     public IotInitAlarmRuleVo getAddInitAlarmRuleData() throws Exception {
 
         IotInitAlarmRuleVo ruleVo = new IotInitAlarmRuleVo();
-        LambdaQueryWrapper<IotAlarmSystemField> lqw = new LambdaQueryWrapper<IotAlarmSystemField>().eq(IotAlarmSystemField::getEnable, 1).orderByDesc(IotAlarmSystemField::getId);
+        LambdaQueryWrapper<IotAlarmSystemField> lqw = new LambdaQueryWrapper<IotAlarmSystemField>().eq(IotAlarmSystemField::getEnable, 1).eq(IotAlarmSystemField::getAlarmRuleProperty,1).orderByDesc(IotAlarmSystemField::getId);
         List<IotAlarmSystemField> systemFieldList = iotAlarmSystemFieldMapper.selectList(lqw);
         //
         List<IotAlarmSystemFieldVo> appAlarmSystemFieldVoList = new ArrayList<>();

+ 1 - 1
soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmRuleSourceMapper.xml

@@ -97,7 +97,7 @@
             a.source_type_des AS source_name,
             IFNULL( b.source_size, 0 ) AS source_size
         FROM
-            ( SELECT source_type, source_type_des FROM iot_alarm_system_field GROUP BY source_type, source_type_des ) a
+            ( SELECT source_type, source_type_des FROM iot_alarm_system_field where enable = 1 and alarm_rule_property = 1 GROUP BY source_type, source_type_des ) a
                 LEFT JOIN ( SELECT rule_id, source_type, count(*) source_size FROM iot_alarm_rule_source WHERE rule_id = #{ruleId} GROUP BY rule_id, source_type ) b ON a.source_type = b.source_type
     </select>
 </mapper>