init
This commit is contained in:
Binary file not shown.
BIN
hik_push/mapping/__pycache__/user_map.cpython-312.pyc
Normal file
BIN
hik_push/mapping/__pycache__/user_map.cpython-312.pyc
Normal file
Binary file not shown.
@ -88,18 +88,26 @@ async def read_event():
|
|||||||
event_type = event['eventType']
|
event_type = event['eventType']
|
||||||
event_type_str = mapping.get(event_type, "未知事件类型")
|
event_type_str = mapping.get(event_type, "未知事件类型")
|
||||||
event['eventType'] = event_type_str
|
event['eventType'] = event_type_str
|
||||||
# ip address
|
if "data" in event:
|
||||||
|
# 如果存在 data 属性
|
||||||
|
# ip_address
|
||||||
ip_address = event["data"]["ipAddress"]
|
ip_address = event["data"]["ipAddress"]
|
||||||
|
|
||||||
# 根据 ip_address 获取对应设备名称
|
# 根据 ip_address 获取对应设备名称
|
||||||
device_name = device_map.get(ip_address, "未知设备")
|
device_name = device_map.get(ip_address, "未知设备")
|
||||||
event['deviceName'] = device_name
|
event['data']['deviceName'] = device_name
|
||||||
# print(event['data'][event['data']['eventType']])
|
|
||||||
# TODO: 根据 ip_address 获取对应 userid
|
# 根据 ip_address 获取对应 userid 数组
|
||||||
user_ids = user_map.get(ip_address, [])
|
user_ids = user_map.get(ip_address, [])
|
||||||
event['userIds'] = user_ids
|
event['data']['userIds'] = user_ids
|
||||||
|
# 替换分析结果字段
|
||||||
|
if "eventType" in event['data']:
|
||||||
|
detection_field_name = event['data']['eventType']
|
||||||
|
if detection_field_name in event['data']:
|
||||||
|
event['data']["_detectionResult"] = event['data'].pop(detection_field_name)
|
||||||
# TODO: 请求推送 api
|
# TODO: 请求推送 api
|
||||||
#
|
#
|
||||||
print(event, device_name)
|
print(event)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("error: ", e)
|
print("error: ", e)
|
||||||
|
Reference in New Issue
Block a user