124 lines
4.2 KiB
Python
124 lines
4.2 KiB
Python
from util.haikang_util import HaikangUtil
|
|
import asyncio
|
|
import base64
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 查询门禁点列表
|
|
async def get_door_list_service(pageNo: int = 1, pageSize: int = 10):
|
|
result = await HaikangUtil.get_door_list_v2(pageNo, pageSize)
|
|
print(result)
|
|
with open("get_door_list_service.json", "w", encoding="utf-8") as f:
|
|
f.write(json.dumps(result[1]))
|
|
|
|
# 查询门禁状态
|
|
async def get_door_status_service(door_index_codes):
|
|
result = await HaikangUtil.get_door_status(door_index_codes)
|
|
print(result)
|
|
with open("get_door_status_service.json", "w", encoding="utf-8") as f:
|
|
f.write(json.dumps(result[1]))
|
|
|
|
# 门禁控制
|
|
async def door_do_control_service(door_index_codes, control_type):
|
|
result = await HaikangUtil.door_do_control(door_index_codes, control_type)
|
|
print(result)
|
|
with open("door_do_control_service.json", "w", encoding="utf-8") as f:
|
|
f.write(json.dumps(result[1]))
|
|
|
|
# 查询门禁点事件
|
|
async def query_door_events_service(door_index_code,pageNo, pageSize, startTime, endTime):
|
|
result = await HaikangUtil.query_door_events_v2(door_index_code, pageNo=pageNo, pageSize=pageSize ,startTime=startTime, endTime=endTime)
|
|
print(result)
|
|
with open("query_door_events_service.json", "w", encoding="utf-8") as f:
|
|
f.write(json.dumps(result[1]))
|
|
|
|
# 查看门禁点在线状态
|
|
async def door_online_status_service(door_index_codes):
|
|
result = await HaikangUtil.door_online_status(door_index_codes)
|
|
print(result)
|
|
with open("door_online_status_service.json", "w", encoding="utf-8") as f:
|
|
f.write(json.dumps(result[1]))
|
|
|
|
# 按条件查询人脸分组, 很重要
|
|
async def get_face_group_service():
|
|
result = await HaikangUtil.get_face_group()
|
|
print(result)
|
|
with open("get_face_group_service.json", "w", encoding="utf-8") as f:
|
|
f.write(json.dumps(result[1]))
|
|
|
|
# 人脸分组1vN搜索
|
|
async def face_group_1vN_search_service(image_path):
|
|
|
|
with open(image_path, 'rb') as f:
|
|
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,
|
|
pageSize=10,
|
|
searchNum=99,
|
|
minSimilarity=50,
|
|
faceGroupIndexCodes=['70cd3fcdcdb444a0b92e75ff66b549e6']
|
|
)
|
|
print(result)
|
|
with open("face_group_1vN_search_service.json", "w", encoding="utf-8") as f:
|
|
f.write(json.dumps(result[1]))
|
|
|
|
# 人脸评分
|
|
async def face_picture_check(image_path):
|
|
|
|
with open(image_path, 'rb') as f:
|
|
image_data = f.read()
|
|
|
|
encoded_image = base64.b64encode(image_data).decode('utf-8')
|
|
|
|
# print(encoded_image)
|
|
result = await HaikangUtil.face_picture_check(
|
|
facePicBinaryData=encoded_image
|
|
)
|
|
print(result)
|
|
with open("face_picture_check.json", "w", encoding="utf-8") as f:
|
|
f.write(json.dumps(result[1]))
|
|
|
|
# 查询访客预约记录
|
|
async def query_visitor_record():
|
|
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)
|
|
# asyncio.run(get_door_status_service(['d4a610b6554d4544bc35dd3138f128b0']))
|
|
# print("*"*100)
|
|
|
|
# asyncio.run(door_do_control_service(['D01'], 1))
|
|
|
|
# asyncio.run(query_door_events_service('d4a610b6554d4544bc35dd3138f128b0',1,10,'20025-09-10T17:30:08+08:00','2004-09-15T17:30:08+08:00'))
|
|
|
|
#asyncio.run(get_face_group_service())
|
|
|
|
# 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(door_online_status_service(["d4a610b6554d4544bc35dd3138f128b0"]))
|
|
|