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