From 7c144a33be16e6ea7f49049d04a06a560e69ba45 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1JS6RSM\\Admin" Date: Wed, 4 Mar 2026 16:27:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E9=9B=86=E7=AB=AF=E6=B7=BB=E5=8A=A0op?= =?UTF-8?q?c=E8=AF=B7=E6=B1=82=E5=9C=B0=E5=9D=80=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iti/applications/models/iot/iot_endpoint.py | 2 ++ iti/applications/routes/iot/alert_log_ctl.py | 11 ++++---- .../routes/iot/schemas/alert_log.py | 27 ++++++++++++++++--- .../routes/iot/schemas/endpoint.py | 10 ++++++- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/iti/applications/models/iot/iot_endpoint.py b/iti/applications/models/iot/iot_endpoint.py index 51cdc9b..518d81b 100644 --- a/iti/applications/models/iot/iot_endpoint.py +++ b/iti/applications/models/iot/iot_endpoint.py @@ -21,6 +21,7 @@ class IotEndpoint(db.Model, TimeModelMixin): description = db.Column(db.Text, nullable=True, comment="采集端描述") ip = db.Column(db.String(255), nullable=False, comment="采集端IP") port = db.Column(db.String(255), nullable=False, comment="采集端端口") + opc_url_temp = db.Column(db.String(1024), nullable=False, comment="OPC URL模板") brand_name = db.Column(db.String(255), nullable=False, comment="品牌名称") specification_model = db.Column(db.String(255), nullable=False, comment="规格型号") is_online = db.Column(db.Integer, nullable=False, default=0, comment="在线状态 0:离线 1:在线") @@ -40,6 +41,7 @@ class IotEndpointSchema(BaseSchema): description = String() ip = String() port = String() + opc_url_temp = String() brand_name = String() specification_model = String() is_online = Integer() diff --git a/iti/applications/routes/iot/alert_log_ctl.py b/iti/applications/routes/iot/alert_log_ctl.py index 75c9031..bd93a79 100644 --- a/iti/applications/routes/iot/alert_log_ctl.py +++ b/iti/applications/routes/iot/alert_log_ctl.py @@ -76,11 +76,12 @@ def add_node_alert(json_data: dict): """ 添加节点值异常告警日志 """ - node_id = json_data["node_id"] - alert_value = json_data["alert_value"] - result = add_node_alert_log(node_id, alert_value) - if len(result) > 0: - raise BizException(result) + for node_data in json_data["node_data_list"]: + node_id = node_data["node_id"] + alert_value = node_data["alert_value"] + result = add_node_alert_log(node_id, alert_value) + if len(result) > 0: + raise BizException(result) return success(); diff --git a/iti/applications/routes/iot/schemas/alert_log.py b/iti/applications/routes/iot/schemas/alert_log.py index 09d1ff7..430c418 100644 --- a/iti/applications/routes/iot/schemas/alert_log.py +++ b/iti/applications/routes/iot/schemas/alert_log.py @@ -121,10 +121,9 @@ class AlertLogUpdateRequest(BaseSchema): }, ) - -class NodeAlertLogAddRequest(BaseSchema): +class NodeCollectData(BaseSchema): """ - 节点值异常告警日志信息添加请求 + 节点收集数据 """ node_id = fields.Integer( required=True, @@ -139,4 +138,26 @@ class NodeAlertLogAddRequest(BaseSchema): "example": "-2.1", "description": "告警值", }, + ) + +class NodeAlertLogAddRequest(BaseSchema): + """ + 节点值异常告警日志信息添加请求 + """ + node_data_list = fields.List( + fields.Nested(NodeCollectData), + required=True, + metadata={ + "example": [ + { + "node_id": 1, + "alert_value": "-2.1", + }, + { + "node_id": 2, + "alert_value": "100", + }, + ], + "description": "节点收集数据列表", + }, ) \ No newline at end of file diff --git a/iti/applications/routes/iot/schemas/endpoint.py b/iti/applications/routes/iot/schemas/endpoint.py index a679c1c..8eb6720 100644 --- a/iti/applications/routes/iot/schemas/endpoint.py +++ b/iti/applications/routes/iot/schemas/endpoint.py @@ -38,7 +38,7 @@ class EndpointAddRequest(BaseSchema): endpoint_name = fields.String( required=True, - metadata={"example": "采集端名称", "descriptrion": "采集端名称"}, + metadata={"example": "采集端名称", "description": "采集端名称"}, ) endpoint_number = fields.String( required=True, @@ -57,6 +57,10 @@ class EndpointAddRequest(BaseSchema): required=True, metadata={"example": "采集端端口", "description": "采集端端口"}, ) + opc_url_temp = fields.String( + required=True, + metadata={"example": "{_ip_}:{_port_}", "description": "OPC URL模板"}, + ) brand_name = fields.String( required=False, metadata={"example": "品牌名称", "description": "品牌名称"}, @@ -95,6 +99,10 @@ class EndpointUpdateRequest(BaseSchema): required=True, metadata={"example": "采集端端口", "description": "采集端端口"}, ) + opc_url_temp = fields.String( + required=True, + metadata={"example": "{_ip_}:{_port_}", "description": "OPC URL模板"}, + ) brand_name = fields.String( required=False, metadata={"example": "品牌名称", "description": "品牌名称"},