update
This commit is contained in:
54
config.yaml
54
config.yaml
@ -1,37 +1,37 @@
|
|||||||
user_ids:
|
user_ids:
|
||||||
T2变电所:
|
T2变电所:
|
||||||
- g78976das
|
- g78976das
|
||||||
A区北油库:
|
A区北油库: []
|
||||||
B区西~油库:
|
B区西~油库:
|
||||||
- fsdf34324
|
- fsdf34324
|
||||||
- dsffee879
|
- dsffee879
|
||||||
二厂平台~东:
|
二厂平台~东: []
|
||||||
T1变电所:
|
T1变电所: []
|
||||||
A区南~油库:
|
A区南~油库:
|
||||||
- ffe348244
|
- ffe348244
|
||||||
T3变电所:
|
T3变电所: []
|
||||||
T11变电所:
|
T11变电所: []
|
||||||
二厂平台~西:
|
二厂平台~西: []
|
||||||
二厂平台~中01:
|
二厂平台~中01: []
|
||||||
二厂平台~中02:
|
二厂平台~中02: []
|
||||||
T9变压器:
|
T9变压器: []
|
||||||
T6变压器:
|
T6变压器: []
|
||||||
B区西~油库(测温):
|
B区西~油库(测温): []
|
||||||
T2变电所 (测温):
|
T2变电所 (测温): []
|
||||||
二厂平台~西(测温):
|
二厂平台~西(测温): []
|
||||||
二厂平台~中01(测温):
|
二厂平台~中01(测温): []
|
||||||
T1变电所(测温):
|
T1变电所(测温): []
|
||||||
二厂平台~东(测温):
|
二厂平台~东(测温): []
|
||||||
二厂平台~中02(测温):
|
二厂平台~中02(测温): []
|
||||||
T3变电所(测温):
|
T3变电所(测温): []
|
||||||
T11变电所(测温):
|
T11变电所(测温): []
|
||||||
A区南~油库(测温):
|
A区南~油库(测温): []
|
||||||
T9变压器(测温):
|
T9变压器(测温): []
|
||||||
T6变压器(测温):
|
T6变压器(测温): []
|
||||||
A区北油库(测温):
|
A区北油库(测温): []
|
||||||
A区_北油库_气体探测器:
|
A区_北油库_气体探测器: []
|
||||||
A区_南油库_气体探测器:
|
A区_南油库_气体探测器: []
|
||||||
B区油库_气体探测器:
|
B区油库_气体探测器: []
|
||||||
|
|
||||||
|
|
||||||
event_type:
|
event_type:
|
||||||
@ -80,6 +80,8 @@ event_type:
|
|||||||
254235: 高限报警
|
254235: 高限报警
|
||||||
254011: 燃气报警
|
254011: 燃气报警
|
||||||
930335: 高空抛物
|
930335: 高空抛物
|
||||||
|
327681: 防区报警
|
||||||
|
327946: 防区布防
|
||||||
889196545: 监控点离线
|
889196545: 监控点离线
|
||||||
422400001: 有人打电话
|
422400001: 有人打电话
|
||||||
422400000: 有人抽烟
|
422400000: 有人抽烟
|
||||||
|
@ -16,9 +16,9 @@ async def read_event():
|
|||||||
if "user_ids" not in config:
|
if "user_ids" not in config:
|
||||||
logging.error("请配置user_ids")
|
logging.error("请配置user_ids")
|
||||||
return
|
return
|
||||||
# if "devices" not in config:
|
if "devices" not in config:
|
||||||
# logging.error("请配置devices")
|
logging.error("请配置devices")
|
||||||
# return
|
return
|
||||||
if "event_type" not in config:
|
if "event_type" not in config:
|
||||||
logging.error("请配置event_type")
|
logging.error("请配置event_type")
|
||||||
return
|
return
|
||||||
@ -38,31 +38,63 @@ async def read_event():
|
|||||||
sub_json = json.loads(data[1].decode('utf-8'))
|
sub_json = json.loads(data[1].decode('utf-8'))
|
||||||
events = sub_json["params"]["events"]
|
events = sub_json["params"]["events"]
|
||||||
for event in events:
|
for event in events:
|
||||||
# 将eventType ID 替换为中文字符串
|
# 如果是ai事件
|
||||||
event_type = event['eventType']
|
if event["srcType"] == "eventRule":
|
||||||
logging.info(event_type)
|
event_details = event["eventDetails"]
|
||||||
event_type_str = event_map.get(event_type, "未知事件类型")
|
for event_detail in event_details:
|
||||||
event['eventType'] = event_type_str
|
# 事件类型 id 替换为 str
|
||||||
#
|
event_type_str = event_map.get(event_detail['eventType'], "未知事件类型")
|
||||||
src_index = event["srcIndex"]
|
event_detail['eventType'] = event_type_str
|
||||||
device_name = device_map.get(src_index, "未知设备")
|
# 添加设备名称
|
||||||
user_ids = user_map.get(device_name, [])
|
src_index = event_detail["srcIndex"]
|
||||||
event['deviceName'] = device_name
|
device_name = device_map.get(src_index, "未知设备")
|
||||||
event['userIds'] = user_ids
|
event_detail['deviceName'] = device_name
|
||||||
if "data" in event:
|
# 根据设备名称获取 user_ids
|
||||||
# 如果存在 data 属性
|
user_ids = user_map.get(device_name, [])
|
||||||
# 替换分析结果字段
|
event_detail['userIds'] = user_ids
|
||||||
if "eventType" in event['data']:
|
# 添加其他字段
|
||||||
detection_field_name = event['data']['eventType']
|
event_detail["eventLvl"] = event['eventLvl']
|
||||||
if detection_field_name in event['data']:
|
event_detail["happenTime"] = event['happenTime']
|
||||||
event['data']["_detectionResult"] = event['data'].pop(detection_field_name)
|
# 如果存在 data 属性
|
||||||
# 请求推送 api
|
if "data" in event_detail:
|
||||||
logging.info(event)
|
# 替换分析结果字段
|
||||||
try:
|
if "eventType" in event_detail['data']:
|
||||||
push_resp = requests.post(push_url, json=event).content.decode('utf-8')
|
detection_field_name = event_detail['data']['eventType']
|
||||||
logging.info(push_resp)
|
if detection_field_name in event_detail['data']:
|
||||||
except Exception as e:
|
event_detail['data']["_detectionResult"] = event_detail['data'].pop(detection_field_name)
|
||||||
logging.error(f"网络错误推送失败: {e}")
|
logging.info(event_detail)
|
||||||
|
try:
|
||||||
|
push_resp = requests.post(push_url, json=event_detail).content.decode('utf-8')
|
||||||
|
logging.info(push_resp)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"网络错误推送失败: {e}")
|
||||||
|
else:
|
||||||
|
# 将 eventType ID 替换为中文字符串
|
||||||
|
event_type = event['eventType']
|
||||||
|
logging.info(event_type)
|
||||||
|
event_type_str = event_map.get(event_type, "未知事件类型")
|
||||||
|
event['eventType'] = event_type_str
|
||||||
|
# 添加设备名称
|
||||||
|
src_index = event["srcIndex"]
|
||||||
|
device_name = device_map.get(src_index, "未知设备")
|
||||||
|
# 根据设备名称获取 user_ids
|
||||||
|
user_ids = user_map.get(device_name, [])
|
||||||
|
event['deviceName'] = device_name
|
||||||
|
event['userIds'] = user_ids
|
||||||
|
if "data" in event:
|
||||||
|
# 如果存在 data 属性
|
||||||
|
# 替换分析结果字段
|
||||||
|
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)
|
||||||
|
# 请求推送 api
|
||||||
|
logging.info(event)
|
||||||
|
try:
|
||||||
|
push_resp = requests.post(push_url, json=event).content.decode('utf-8')
|
||||||
|
logging.info(push_resp)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"网络错误推送失败: {e}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("error: ", e)
|
logging.error("error: ", e)
|
||||||
|
@ -33,9 +33,12 @@
|
|||||||
192515,
|
192515,
|
||||||
192514,
|
192514,
|
||||||
192513,
|
192513,
|
||||||
|
254234,
|
||||||
|
254235,
|
||||||
|
254011,
|
||||||
930335,
|
930335,
|
||||||
20210724,
|
327681,
|
||||||
20210724
|
327946
|
||||||
],
|
],
|
||||||
"eventDest": "http://127.0.0.1:8000/eventRcv",
|
"eventDest": "http://127.0.0.1:8000/eventRcv",
|
||||||
"subType": 0
|
"subType": 0
|
||||||
|
121
hik_push/trd.json
Normal file
121
hik_push/trd.json
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
{
|
||||||
|
"eventDetails": [
|
||||||
|
{
|
||||||
|
"ability": "event_vss",
|
||||||
|
"data": {
|
||||||
|
"AIOPResultData": {
|
||||||
|
"confidence": 770,
|
||||||
|
"height": "1080",
|
||||||
|
"id": 10013,
|
||||||
|
"imageUrl": "http://192.168.1.250:6120/pic?0d44=de54ida-=o1018p02ea976d-63599cbbb*162s=**118==tp*7618=6201040*6020=7l1*0026=fo966-14*le1-od2620224252",
|
||||||
|
"modelID": "00012023050501005hms3classDet00",
|
||||||
|
"realArea": 0,
|
||||||
|
"realHeight": 0,
|
||||||
|
"realVolume": 0,
|
||||||
|
"realWidth": 0,
|
||||||
|
"rect": {
|
||||||
|
"h": "0.107890",
|
||||||
|
"w": "0.067804",
|
||||||
|
"x": "0.305665",
|
||||||
|
"y": "0.303932"
|
||||||
|
},
|
||||||
|
"region": {
|
||||||
|
"rect": {
|
||||||
|
"h": "0.107890",
|
||||||
|
"w": "0.067804",
|
||||||
|
"x": "0.305665",
|
||||||
|
"y": "0.303932"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ruleId": 2,
|
||||||
|
"ruleName": [
|
||||||
|
"打电话"
|
||||||
|
],
|
||||||
|
"targetAttrs": {
|
||||||
|
"cameraIndexCode": "f3e4a7ff9123414e8654735a6346c709",
|
||||||
|
"deviceIndexCode": "efa6aa29eaea4464aa5c3dd847f2c9c3",
|
||||||
|
"imageServerCode": "d74f089c-4888-4d36-b829-926e6f7c3c3c",
|
||||||
|
"picServerIndexCode": "d74f089c-4888-4d36-b829-926e6f7c3c3c"
|
||||||
|
},
|
||||||
|
"taskID": "86ff37c70e9e42f98f636ee866619e00",
|
||||||
|
"taskType": "AIOP_Video",
|
||||||
|
"triggerType": 1073758209,
|
||||||
|
"type": 3,
|
||||||
|
"typeName": "打电话",
|
||||||
|
"url": None,
|
||||||
|
"valid": 1,
|
||||||
|
"visible": 1,
|
||||||
|
"width": "1920"
|
||||||
|
},
|
||||||
|
"aiopMsgType": 2,
|
||||||
|
"channelID": 33,
|
||||||
|
"channelName": "T2变电所",
|
||||||
|
"dataProcInterval": "28",
|
||||||
|
"dataType": "AIOPDetection",
|
||||||
|
"dateTime": "2024-02-02T10:33:44.430+08:00",
|
||||||
|
"eventDescription": "AI Open Platform Video Detection",
|
||||||
|
"eventType": "AIOPResultData",
|
||||||
|
"ipAddress": "192.168.1.10",
|
||||||
|
"picUploadInterval": "13",
|
||||||
|
"portNo": 8000,
|
||||||
|
"presetIndex": 0,
|
||||||
|
"recvTime": "2024-02-02T10:34:20.589+08:00",
|
||||||
|
"sendTime": "2024-02-02T10:34:20.617+08:00",
|
||||||
|
"targetAttrs": {
|
||||||
|
"cameraIndexCode": "f3e4a7ff9123414e8654735a6346c709",
|
||||||
|
"deviceIndexCode": "efa6aa29eaea4464aa5c3dd847f2c9c3",
|
||||||
|
"imageServerCode": "d74f089c-4888-4d36-b829-926e6f7c3c3c",
|
||||||
|
"picServerIndexCode": "d74f089c-4888-4d36-b829-926e6f7c3c3c"
|
||||||
|
},
|
||||||
|
"taskID": "86ff37c70e9e42f98f636ee866619e00",
|
||||||
|
"url": "http://192.168.1.250:6120/pic?0d44=de54ida-=o1018p02ea976d-63599cbbb*162s=**118==tp*7618=6201040*6020=7l1*0026=fo966-14*le1-od2620224252"
|
||||||
|
},
|
||||||
|
"eventOriginalId": "578B384C-78AB-7743-A2E5-CDE3BD0E19E2",
|
||||||
|
"eventType": 422400002,
|
||||||
|
"locationIndexCode": ", "locationName": ",
|
||||||
|
"regionIndexCode": "2bc4f74e-4a96-4a67-b67f-4037724b0a46",
|
||||||
|
"regionName": "江淮 汽车发动机公司/行为分析监控",
|
||||||
|
"srcIndex": "f3e4a7ff9123414e8654735a6346c709",
|
||||||
|
"srcName": "T2变电所",
|
||||||
|
"srcType": "camera"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"eventId": "894A9D9761D84FAB96BD0D292DA219BC",
|
||||||
|
"eventLvl": 2,
|
||||||
|
"eventName": "有人抽烟或打电话",
|
||||||
|
"eventOldId": "578B384C-78AB-7743-A2E5-CDE3BD0E19E2",
|
||||||
|
"eventType": "未知事件类型",
|
||||||
|
"happenTime": "2024-02-02T10:33:44.430+08:00",
|
||||||
|
"linkageAcion": [
|
||||||
|
{
|
||||||
|
"content": "[{"cameraIndexCode":"f3e4a7ff9123414e8654735a6346c709","cameraName":"T2变电所","cameraType":"0","cascadeCode":"","decodeTag":"hikvision","recordType":"1","treatyType":"1"}]\n",
|
||||||
|
"linkageType": "popUpLiveViewOnClient"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "[{"cameraIndexCode":"f3e4a7ff9123414e8654735a6346c709","cameraName":"T2变电所","cameraType":"0","cascadeCode":"","decodeTag":"hikvision","recordType":"1","treatyType":"1"}]\n",
|
||||||
|
"linkageType": "popUpPlayBackOnClient"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "{"bPopupEventPicture":true}",
|
||||||
|
"linkageType": "popUpPictureOnClient"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "{"alertTimes":1,"soundText":"江淮 汽车发动机公司/行为分析监控,T2变电所发生有人抽烟或打电话事件"}\n",
|
||||||
|
"linkageType": "alertByEventInfo"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "{"wordsOverlayTxt":"江淮汽车发动机公司/行为分析监控,T2变电所发生有人抽烟或打电话事件"}\n",
|
||||||
|
"linkageType": "overlayTextOnPopUp"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"remark": ", "ruleDescription": ",
|
||||||
|
"srcIndex": "03c96cdd994d4fda9dbc935be58af195",
|
||||||
|
"srcName": "有人抽烟或打电 话",
|
||||||
|
"srcParentIndex": "efa6aa29eaea4464aa5c3dd847f2c9c3",
|
||||||
|
"srcType": "eventRule",
|
||||||
|
"status": 0,
|
||||||
|
"stopTime": "2024-02-02T10:33:44.430+08:00",
|
||||||
|
"timeout": 0,
|
||||||
|
"deviceName": "未知设备",
|
||||||
|
"userIds": []
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "hik-push"
|
name = "hik-push"
|
||||||
version = "0.2.4"
|
version = "0.3.1"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["quantulr <35954003+quantulr@users.noreply.github.com>"]
|
authors = ["quantulr <35954003+quantulr@users.noreply.github.com>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
Reference in New Issue
Block a user