修改接口
This commit is contained in:
parent
960d5237da
commit
1f7dd0393c
@ -57,7 +57,10 @@ async def face_group_1vN_search_service(image_path):
|
||||
image_data = f.read()
|
||||
|
||||
encoded_image = base64.b64encode(image_data).decode('utf-8')
|
||||
|
||||
|
||||
with open("image_base64.txt", "w", encoding="utf-8") as f:
|
||||
f.write(encoded_image)
|
||||
|
||||
result = await HaikangUtil.face_group_1vN_search(
|
||||
facePicBinaryData=encoded_image,
|
||||
pageNo=1,
|
||||
@ -88,11 +91,16 @@ async def face_picture_check(image_path):
|
||||
|
||||
# 查询访客预约记录
|
||||
async def query_visitor_record():
|
||||
result = await HaikangUtil.query_visitor_record(pageNo=1, pageSize = 10)
|
||||
result = await HaikangUtil.query_visitor_record(pageNo=1, pageSize=10, visitorStatus=1)
|
||||
print(result)
|
||||
with open("query_visitor_record.json", "w", encoding="utf-8") as f:
|
||||
f.write(json.dumps(result[1]))
|
||||
|
||||
|
||||
# 查询访客预约记录图片
|
||||
async def query_visitor_record_pictures_service(svrIndexCode, picUri):
|
||||
await HaikangUtil.query_visitor_record_pictures(svrIndexCode, picUri)
|
||||
|
||||
if __name__ == '__main__':
|
||||
#asyncio.run(get_door_list_service())
|
||||
# print("*"*100)
|
||||
@ -105,11 +113,11 @@ if __name__ == '__main__':
|
||||
|
||||
#asyncio.run(get_face_group_service())
|
||||
|
||||
image_path = "./a7b3c794281902041c9b823df7667ce7.jpg"
|
||||
asyncio.run(face_group_1vN_search_service(image_path))
|
||||
# image_path = "./a7b3c794281902041c9b823df7667ce7.jpg"
|
||||
# asyncio.run(face_group_1vN_search_service(image_path))
|
||||
#asyncio.run(face_picture_check(image_path))
|
||||
|
||||
# asyncio.run(query_visitor_record())
|
||||
asyncio.run(query_visitor_record())
|
||||
|
||||
#asyncio.run(door_online_status_service(["d4a610b6554d4544bc35dd3138f128b0"]))
|
||||
|
||||
|
||||
Binary file not shown.
@ -33,6 +33,7 @@ class HaiKangSettings:
|
||||
HAIKANG_FACE_GROUP_URL = '/api/frs/v1/face/group'
|
||||
|
||||
HAIKANG_VISITOR_RECORD_SEARCH = '/api/visitor/v2/appointment/records'
|
||||
HAIKANG_VISITOR_RECORD_PICTURES = '/api/visitor/v1/record/pictures'
|
||||
|
||||
|
||||
class GetConfig:
|
||||
|
||||
@ -90,7 +90,7 @@ class HaikangUtil:
|
||||
|
||||
# 发送请求
|
||||
@classmethod
|
||||
async def send_request(cls, method: str, url: str, headers: dict, body: str | None):
|
||||
async def send_request(cls, method: str, url: str, headers: dict, body: str | None, json=True):
|
||||
|
||||
|
||||
|
||||
@ -102,7 +102,9 @@ class HaikangUtil:
|
||||
# if response.status_code >= 400:
|
||||
# logger.error(f"发送请求失败: {url} , {response.status_code} {response.text}")
|
||||
# raise HTTPException(status_code=response.status_code, detail=response.text)
|
||||
return response.json()
|
||||
if json:
|
||||
return response.json()
|
||||
return response
|
||||
|
||||
# 获取access_token
|
||||
@classmethod
|
||||
@ -455,3 +457,34 @@ class HaikangUtil:
|
||||
else:
|
||||
# logger.error(f"查询访客预约记录失败 ", back["code"], back["msg"])
|
||||
return [False, back["code"], back["msg"]]
|
||||
|
||||
# 获取访客记录中的图片
|
||||
@classmethod
|
||||
async def query_visitor_record_pictures(cls, svrIndexCode: str, picUri: str):
|
||||
"""获取访客记录中的图片
|
||||
|
||||
Args:
|
||||
visitorRecordIndexCode (str): 访客记录索引码
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
url = f"{HaiKangConfig.HAIKANG_URL}:{HaiKangConfig.HAIKANG_PORT}/artemis{HaiKangConfig.HAIKANG_VISITOR_RECORD_PICTURES}"
|
||||
|
||||
body_dict = {
|
||||
"svrIndexCode": svrIndexCode,
|
||||
"picUri": picUri,
|
||||
}
|
||||
|
||||
body_json = json.dumps(body_dict, separators=(",", ":"))
|
||||
|
||||
headers = cls.build_signed_headers(
|
||||
"POST", url, body_json, HaiKangConfig.HAIKANG_AK, HaiKangConfig.HAIKANG_SK
|
||||
)
|
||||
|
||||
back = await cls.send_request("POST", url, headers, body_json)
|
||||
|
||||
with open("person.jpg", 'wb') as f:
|
||||
for chunk in back.iter_content(chunk_size=8192):
|
||||
if chunk: # 忽略 keep-alive 的空 chunk
|
||||
f.write(chunk)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user