past_seven_days
This commit is contained in:
parent
6b7b44a1af
commit
4ba135f885
8
xumu.py
8
xumu.py
|
@ -24,7 +24,7 @@ class BaseResponse(BaseModel):
|
|||
async def video_query(username):
|
||||
return BaseResponse(data=get_video_url(username))
|
||||
|
||||
|
||||
# 报警数据接口
|
||||
@app.get("/api/xumu/warning")
|
||||
async def get_warning(deviceId):
|
||||
try:
|
||||
|
@ -34,6 +34,8 @@ async def get_warning(deviceId):
|
|||
"sql": sql
|
||||
}
|
||||
r = requests.post(baseHost + queryUri, headers=headers, json=send_json)
|
||||
data = r.json()
|
||||
|
||||
return BaseResponse(data=r.json())
|
||||
except Exception as e:
|
||||
return BaseResponse(code=500, msg=str(e))
|
||||
|
@ -327,14 +329,14 @@ async def process_data(request: Request):
|
|||
|
||||
|
||||
# 监测数据最近7天的数据
|
||||
@app.get("/api/xumu/data/past_seven_days")
|
||||
@app.get("/api/xumu/warning/past_seven_days")
|
||||
async def past_seven_days(deviceId):
|
||||
try:
|
||||
current_date = datetime.now().date()
|
||||
past_7_days_date = current_date - timedelta(days=7)
|
||||
if deviceId is None or deviceId == "" or len(deviceId) != 4:
|
||||
return BaseResponse(code=500, msg="参数错误")
|
||||
sql = f"select * from root.farm.{deviceId} where time >= {past_7_days_date} and time <= {current_date}"
|
||||
sql = f"select * from root.warning.{deviceId} where time >= {past_7_days_date} and time <= {current_date}"
|
||||
send_json = {
|
||||
"sql": sql
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue