This commit is contained in:
xyj 2024-02-20 15:50:18 +08:00
parent 7d78859fd6
commit fe712cc09c
1 changed files with 2 additions and 4 deletions

View File

@ -337,11 +337,9 @@ async def process_data(request: Request):
async def past_seven_days(deviceId): async def past_seven_days(deviceId):
try: try:
current_date = datetime.now().date() current_date = datetime.now().date()
past_7_days_date = current_date - timedelta(days=7)
tomorrow = current_date + timedelta(days=1) tomorrow = current_date + timedelta(days=1)
if deviceId is None or deviceId == "" or len(deviceId) != 4: past_6_days_date = current_date - timedelta(days=6)
return BaseResponse(code=500, msg="参数错误") sql = f"select MAX_VALUE(value) from root.warning.{deviceId} group by ([{past_6_days_date}, {tomorrow}), 1d)"
sql = f"select * from root.warning.{deviceId} where time >= {past_7_days_date} and time <= {tomorrow}"
send_json = { send_json = {
"sql": sql "sql": sql
} }