添加推送等级

This commit is contained in:
quantulr
2024-03-14 11:02:52 +08:00
parent 31b4ef217b
commit 91b25dab9e
6 changed files with 321 additions and 193 deletions

2
.idea/hik_push.iml generated
View File

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Poetry (hik_push) (2)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Poetry (hik_push) (3)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

2
.idea/misc.xml generated
View File

@ -3,5 +3,5 @@
<component name="Black"> <component name="Black">
<option name="sdkName" value="Poetry (hik_push)" /> <option name="sdkName" value="Poetry (hik_push)" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Poetry (hik_push) (2)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Poetry (hik_push) (3)" project-jdk-type="Python SDK" />
</project> </project>

View File

@ -1,154 +1,270 @@
# 推送 api 地址 # 推送 api 地址
push_url: http://192.168.1.233:8080/batch_msg push_url: http://192.168.20.115:8000/ipaasuat/engine_company/anycross/trigger/callback/MmRhZTE4OTRiYjVkZDQ5YWNmOGRmZDI0NjQ1MTBlODUw
# 推送用户表 # 推送用户表
user_ids: user_ids:
all: all:
- 1645 - id: "1645"
- 2088 level: 3
- 2110 - id: "2088"
level: 3
- id: "2110"
level: 1
T2变电所: T2变电所:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
A区北油库: A区北油库:
- 5791 - id: "5791"
- 35393 level: 1
- 26292 - id: "35393"
level: 2
- id: "26292"
level: 1
B区西~油库: B区西~油库:
- 1823 - id: "1823"
- 2164 level: 1
- 2166 - id: "2164"
- 30024 level: 1
- 2078 - id: "2166"
level: 2
- id: "30024"
level: 2
- id: "2078"
level: 1
二厂平台~东: 二厂平台~东:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
T1变电所: T1变电所:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
A区南~油库: A区南~油库:
- 2043 - id: "2043"
- 29246 level: 1
- 2090 - id: "29246"
level: 2
- id: "2090"
level: 1
T3变电所: T3变电所:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
T11变电所: T11变电所:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
二厂平台~西: 二厂平台~西:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
二厂平台~中01: 二厂平台~中01:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
二厂平台~中02: 二厂平台~中02:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
T9变压器: T9变压器:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
T6变压器: T6变压器:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
B区西~油库(测温): B区西~油库(测温):
- 1823 - id: "1823"
- 2164 level: 1
- 2166 - id: "2164"
- 30024 level: 1
- 2078 - id: "2166"
level: 2
- id: "30024"
level: 2
- id: "2078"
level: 1
T2变电所 (测温): T2变电所 (测温):
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
二厂平台~西(测温): 二厂平台~西(测温):
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
二厂平台~中01测温: 二厂平台~中01测温:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
T1变电所(测温): T1变电所(测温):
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
二厂平台~东(测温): 二厂平台~东(测温):
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
二厂平台~中02测温: 二厂平台~中02测温:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
T3变电所测温: T3变电所测温:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
T11变电所(测温): T11变电所(测温):
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
A区南~油库(测温): A区南~油库(测温):
- 2043 - id: "2043"
- 29246 level: 1
- 2090 - id: "29246"
level: 2
- id: "2090"
level: 1
T9变压器测温: T9变压器测温:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
T6变压器测温: T6变压器测温:
- 1815 - id: "1815"
- 1899 level: 1
- 1926 - id: "1899"
- 2097 level: 3
- id: "1926"
level: 2
- id: "2097"
level: 2
A区北油库(测温): A区北油库(测温):
- 5791 - id: "5791"
- 35393 level: 1
- 26292 - id: "35393"
level: 2
- id: "26292"
level: 1
A区_北油库_气体探测器: A区_北油库_气体探测器:
- 5791 - id: "5791"
- 35393 level: 1
- 26292 - id: "35393"
level: 2
- id: "26292"
level: 1
A区_南油库_气体探测器: A区_南油库_气体探测器:
- 2043 - id: "2043"
- 29246 level: 1
- 2090 - id: "29246"
level: 2
- id: "2090"
level: 1
B区油库_气体探测器: B区油库_气体探测器:
- 1823 - id: "1823"
- 2164 level: 1
- 2166 - id: "2164"
- 30024 level: 1
- 2078 - id: "2166"
level: 2
- id: "30024"
level: 2
- id: "2078"
level: 1
# srcIndex 与设备名称 map # srcIndex 与设备名称 map
devices: devices:
@ -246,107 +362,107 @@ event_type:
# 用户姓名部门科室 # 用户姓名部门科室
user_info: user_info:
1645: "1645":
name: 项贤忠 name: 项贤忠
work_no: GF20030242 work_no: GF20030242
depart: 安环机动部 depart: 安环机动部
section: section:
2088: "2088":
name: 宫春月 name: 宫春月
work_no: GF20020113 work_no: GF20020113
depart: 安环机动部 depart: 安环机动部
section: 安全环保管理业务 section: 安全环保管理业务
2110: "2110":
name: 程秋生 name: 程秋生
work_no: GF20061051 work_no: GF20061051
depart: 安环机动部 depart: 安环机动部
section: 安全环保管理业务 section: 安全环保管理业务
1815: "1815":
name: 刘方 name: 刘方
work_no: GF20060059 work_no: GF20060059
depart: 安环机动部 depart: 安环机动部
section: 设备能源管理业务 section: 设备能源管理业务
1899: "1899":
name: 何国飞 name: 何国飞
work_no: GF20082111 work_no: GF20082111
depart: 安环机动部 depart: 安环机动部
section: 设备能源管理业务 section: 设备能源管理业务
1926: "1926":
name: 朱江潮 name: 朱江潮
work_no: GF19920032 work_no: GF19920032
depart: 安环机动部 depart: 安环机动部
section: 设备能源管理业务 section: 设备能源管理业务
2097: "2097":
name: 董海波 name: 董海波
work_no: GF20072117 work_no: GF20072117
depart: 安环机动部 depart: 安环机动部
section: 设备能源管理业务 section: 设备能源管理业务
1823: "1823":
name: 朱政荣 name: 朱政荣
work_no: GF20060063 work_no: GF20060063
depart: 动力二厂 depart: 动力二厂
section: 装调车间 section: 装调车间
2164: "2164":
name: 罗运保 name: 罗运保
work_no: GF20082137 work_no: GF20082137
depart: 动力二厂 depart: 动力二厂
section: 装调车间 section: 装调车间
2166: "2166":
name: 王军 name: 王军
work_no: GF20082149 work_no: GF20082149
depart: 动力二厂 depart: 动力二厂
section: 装调车间 section: 装调车间
30024: "30024":
name: 王金宝 name: 王金宝
work_no: GF20160011 work_no: GF20160011
depart: 动力二厂 depart: 动力二厂
section: 装调车间 section: 装调车间
2078: "2078":
name: 陈飞 name: 陈飞
work_no: GF20072258 work_no: GF20072258
depart: 动力二厂 depart: 动力二厂
section: 专业管理 section: 专业管理
2043: "2043":
name: 赵东翔 name: 赵东翔
work_no: GF20115183 work_no: GF20115183
depart: 动力一厂 depart: 动力一厂
section: 装调一车间 section: 装调一车间
29246: "29246":
name: 莫磊磊 name: 莫磊磊
work_no: GF20140817 work_no: GF20140817
depart: 动力一厂 depart: 动力一厂
section: 装调一车间 section: 装调一车间
2090: "2090":
name: 陶新 name: 陶新
work_no: GF20082084 work_no: GF20082084
depart: 动力一厂 depart: 动力一厂
section: 装调一车间 section: 装调一车间
5791: "5791":
name: 陈健 name: 陈健
work_no: GF20050025 work_no: GF20050025
depart: 动力一厂 depart: 动力一厂
section: 装调二车间 section: 装调二车间
35393: "35393":
name: 范永辉 name: 范永辉
work_no: GF20161338 work_no: GF20161338
depart: 动力一厂 depart: 动力一厂
section: 装调二车间 section: 装调二车间
26292: "26292":
name: 杨晨 name: 杨晨
work_no: GF20140093 work_no: GF20140093
depart: 动力一厂 depart: 动力一厂
section: 装调二车间 section: 装调二车间
2152: "2152":
name: 鲁新峰 name: 鲁新峰
work_no: GF20030639 work_no: GF20030639
depart: 动力一厂 depart: 动力一厂
section: section:
2050: "2050":
name: 李建民 name: 李建民
work_no: GF20030097 work_no: GF20030097
depart: 动力一厂 depart: 动力一厂
section: section:
24857: "24857":
name: 李建民 name: 李建民
work_no: GF20090716 work_no: GF20090716
depart: 动力一厂 depart: 动力一厂

View File

@ -1,55 +1,58 @@
{ {
"eventId": "BE26E09F-0C6C-4EF9-BE2B-27007B261731", "eventId": "BE26E09F-0C6C-4EF9-BE2B-27007B261731",
"eventType": "区域入侵", "eventType": "区域入侵",
"deviceName": "A区北油料库", "deviceName": "A区北油料库",
"eventLvl": 1, "eventLvl": 1,
"userIds": [ "userIds": [
"gdsdfs" {
], "id": "4314",
"happenTime": "2019-01-02T15:17:24.000+08:00", "level": 1
"srcIndex": "da107dd1989e44978a5efebe73d6e979",
"srcName": "-",
"srcType": "camera",
"status": 0,
"timeout": 0,
"data": {
"channelName": "A区北油料库",
"dataType": "behavioralAnalysis",
"recvTime": "2017-04-22T15:39:01+08:00",
"sendTime": "2017-04-22T15:39:01+08:00",
"dateTime": "2017-04-22T15:39:01+08:00",
"ipAddress": "10.19.134.11",
"portNo": 80,
"channelID": 1,
"eventType": "fielddetection",
"eventDescription": "fielddetection",
"_detectionResult": [
{
"imageUrl": "http://10.3.1.12:8080/xxx",
"targetAttrs": {
"imageServerCode": "3212234",
"deviceIndexCode": "1568556",
"cameraIndexCode": "1235415",
"channelName": "tongdao1",
"cameraAddress": "杭州市西兴",
"longitude": 116.39737,
"latitude": 116.39737
},
"duration": 120,
"sensitivityLevel": 20,
"rate": 30,
"detectionTarget": 1,
"regionCoordinatesList": [
{
"positionX": 0.901,
"positionY": 0.536
},
{
"positionX": 0.901,
"positionY": 0.536
}
]
}
]
} }
],
"happenTime": "2019-01-02T15:17:24.000+08:00",
"srcIndex": "da107dd1989e44978a5efebe73d6e979",
"srcName": "-",
"srcType": "camera",
"status": 0,
"timeout": 0,
"data": {
"channelName": "A区北油料库",
"dataType": "behavioralAnalysis",
"recvTime": "2017-04-22T15:39:01+08:00",
"sendTime": "2017-04-22T15:39:01+08:00",
"dateTime": "2017-04-22T15:39:01+08:00",
"ipAddress": "10.19.134.11",
"portNo": 80,
"channelID": 1,
"eventType": "fielddetection",
"eventDescription": "fielddetection",
"_detectionResult": [
{
"imageUrl": "http://192.168.11.180:8080/xxx",
"targetAttrs": {
"imageServerCode": "3212234",
"deviceIndexCode": "1568556",
"cameraIndexCode": "1235415",
"channelName": "tongdao1",
"cameraAddress": "杭州市西兴",
"longitude": 116.39737,
"latitude": 116.39737
},
"duration": 120,
"sensitivityLevel": 20,
"rate": 30,
"detectionTarget": 1,
"regionCoordinatesList": [
{
"positionX": 0.901,
"positionY": 0.536
},
{
"positionX": 0.901,
"positionY": 0.536
}
]
}
]
}
} }

View File

@ -65,6 +65,7 @@ async def read_event():
if detection_field_name in event_detail['data']: if detection_field_name in event_detail['data']:
event_detail['data']["_detectionResult"] = event_detail['data'].pop( event_detail['data']["_detectionResult"] = event_detail['data'].pop(
detection_field_name) detection_field_name)
replace_image_host(event_detail['data']["_detectionResult"])
logging.info(event_detail) logging.info(event_detail)
try: try:
push_resp = requests.post(push_url, json=event_detail).content.decode('utf-8') push_resp = requests.post(push_url, json=event_detail).content.decode('utf-8')
@ -93,6 +94,7 @@ async def read_event():
detection_field_name = event['data']['eventType'] detection_field_name = event['data']['eventType']
if detection_field_name in event['data']: if detection_field_name in event['data']:
event['data']["_detectionResult"] = event['data'].pop(detection_field_name) event['data']["_detectionResult"] = event['data'].pop(detection_field_name)
replace_image_host(event['data']["_detectionResult"])
# 请求推送 api # 请求推送 api
logging.info(event) logging.info(event)
try: try:
@ -108,6 +110,13 @@ async def read_event():
await asyncio.sleep(0.5) await asyncio.sleep(0.5)
def replace_image_host(detection_data):
if "imageUrl" in detection_data:
detection_data["imageUrl"] = detection_data["imageUrl"].replace("192.168.1.250", "192.168.11.180")
if "visiblePicUrl" in detection_data:
detection_data["visiblePicUrl"] = detection_data["visiblePicUrl"].replace("192.168.1.250", "192.168.11.180")
def run_app(): def run_app():
asyncio.run(read_event()) asyncio.run(read_event())

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "hik-push" name = "hik-push"
version = "0.3.1" version = "0.3.2"
description = "" description = ""
authors = ["quantulr <35954003+quantulr@users.noreply.github.com>"] authors = ["quantulr <35954003+quantulr@users.noreply.github.com>"]
readme = "README.md" readme = "README.md"