diff --git a/xumu.py b/xumu.py index 995937c..41d7a63 100644 --- a/xumu.py +++ b/xumu.py @@ -22,7 +22,7 @@ class BaseResponse(BaseModel): # 监控视频接口 @app.get("/api/xumu/video") -async def data_query(username): +async def video_query(username): return BaseResponse(data=get_video_url(username)) @@ -61,6 +61,20 @@ async def data_query(deviceId): return BaseResponse(code=500, msg=str(e)) +async def rfid_last_query(rfid, deviceId): + try: + if deviceId is None or deviceId == "" or len(deviceId) != 4: + return BaseResponse(code=500, msg="参数错误") + sql = f"select * from root.farm.{deviceId} where RFID='{rfid}' order by time desc limit 1" + send_json = { + "sql": sql + } + r = requests.post(baseHost + queryUri, headers=headers, json=send_json) + return BaseResponse(data=r.json()) + except Exception as e: + return BaseResponse(code=500, msg=str(e)) + + # 原生查询接口 @app.post("/api/xumu/rest/v2/query") async def rest_query(request: Request): @@ -85,7 +99,7 @@ async def rfid_query(rfid): if len(values) == 0: return BaseResponse(msg="No Such RFID", code=500) deviceId = values[0][0] - return await data_query(deviceId) + return await rfid_last_query(rfid, deviceId) except Exception as e: return BaseResponse(code=500, msg=str(e))