statistics

This commit is contained in:
xyj 2024-02-20 14:34:31 +08:00
parent 265f197042
commit 7e1c63b4ec
1 changed files with 18 additions and 3 deletions

View File

@ -70,11 +70,20 @@ def warning_sql(deviceId, type):
template = "warning" template = "warning"
match type: match type:
case 0: 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: 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 _: 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): def rfid_deviceId(rfid, deviceId):
@ -125,6 +134,12 @@ def is_warning(deviceId, v, t):
def insert_to_warning_sql(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 { return {
"devices": ["root.warning." + deviceId], "devices": ["root.warning." + deviceId],
"timestamps": [int(time.time() * 1000)], "timestamps": [int(time.time() * 1000)],