diff --git a/iti/applications/service/iot/alert.py b/iti/applications/service/iot/alert.py index ee94132..89099f8 100644 --- a/iti/applications/service/iot/alert.py +++ b/iti/applications/service/iot/alert.py @@ -64,7 +64,7 @@ def add_node_alert_log(node_id: int, alert_value: str): if not node: return "节点不存在" - alert_rule_list = db.session.scalars(select(IotAlertRule).filter_by(node_id=node_id)).all() + alert_rule_list = db.session.scalars(select(IotAlertRule).filter_by(node_id=node_id).order_by(desc(IotAlertRule.alert_level))).all() if len(alert_rule_list) > 0: for alert_rule in alert_rule_list: if alert_rule.status == 1: @@ -92,8 +92,7 @@ def add_node_alert_log(node_id: int, alert_value: str): alert_log = IotAlertLog(**dict_data) db.session.add(alert_log) db.session.commit() - else: - current_app.logger.info(f"节点{node.node_number}值{alert_value}未触发告警规则{alert_rule.alert_rule}") + break return ""