From 7e1c63b4ec27bf39b36c7036803c483cc6ec1a3b Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Tue, 20 Feb 2024 14:34:31 +0800 Subject: [PATCH] statistics --- config.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index da37a5c..97918ef 100644 --- a/config.py +++ b/config.py @@ -70,11 +70,20 @@ def warning_sql(deviceId, type): template = "warning" match type: case 0: - return RFID_template(template, deviceId) + rfid = RFID_template(template, deviceId) + rfid.append(f"CREATE TIMESERIES root.{template}.{deviceId}.reason(rs) WITH datatype=TEXT,ENCODING=PLAIN") + rfid.append(f"CREATE TIMESERIES root.{template}.{deviceId}.solve(s) WITH datatype=TEXT,ENCODING=PLAIN") + return rfid case 1: - return air_template(template, deviceId) + air = air_template(template, deviceId) + air.append(f"CREATE TIMESERIES root.{template}.{deviceId}.reason(rs) WITH datatype=TEXT,ENCODING=PLAIN") + air.append(f"CREATE TIMESERIES root.{template}.{deviceId}.solve(s) WITH datatype=TEXT,ENCODING=PLAIN") + return air case _: - return common_template(template, deviceId) + common = common_template(template, deviceId) + common.append(f"CREATE TIMESERIES root.{template}.{deviceId}.reason(rs) WITH datatype=TEXT,ENCODING=PLAIN") + common.append(f"CREATE TIMESERIES root.{template}.{deviceId}.solve(s) WITH datatype=TEXT,ENCODING=PLAIN") + return common def rfid_deviceId(rfid, deviceId): @@ -125,6 +134,12 @@ def is_warning(deviceId, v, t): def insert_to_warning_sql(deviceId, v, t): + measurements[t].append("reason") + measurements[t].append("solve") + dataTypes[t].append("TEXT") + dataTypes[t].append("TEXT") + v.append("无") + v.append("无") return { "devices": ["root.warning." + deviceId], "timestamps": [int(time.time() * 1000)],