From 31b4ef217b65dd131347ae5676c78d369795d779 Mon Sep 17 00:00:00 2001
From: quantulr <35954003+quantulr@users.noreply.github.com>
Date: Fri, 23 Feb 2024 10:11:42 +0800
Subject: [PATCH] update
---
.idea/hik_push.iml | 2 +-
.idea/misc.xml | 2 +-
config.yaml | 364 +++++++++++++++++++++++++++++++++--------
event.json | 14 +-
hik_push/read_event.py | 7 +-
hik_push/test.py | 14 --
6 files changed, 309 insertions(+), 94 deletions(-)
delete mode 100644 hik_push/test.py
diff --git a/.idea/hik_push.iml b/.idea/hik_push.iml
index d0876a7..7c232c8 100644
--- a/.idea/hik_push.iml
+++ b/.idea/hik_push.iml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 88178e4..5812083 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/config.yaml b/config.yaml
index e6f6b41..8fe1a01 100644
--- a/config.yaml
+++ b/config.yaml
@@ -1,39 +1,196 @@
+# 推送 api 地址
+push_url: http://192.168.1.233:8080/batch_msg
+
+# 推送用户表
user_ids:
+ all:
+ - 1645
+ - 2088
+ - 2110
T2变电所:
- - g78976das
- A区北油库: []
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ A区北油库:
+ - 5791
+ - 35393
+ - 26292
B区西~油库:
- - fsdf34324
- - dsffee879
- 二厂平台~东: []
- T1变电所: []
+ - 1823
+ - 2164
+ - 2166
+ - 30024
+ - 2078
+ 二厂平台~东:
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ T1变电所:
+ - 1815
+ - 1899
+ - 1926
+ - 2097
A区南~油库:
- - ffe348244
- T3变电所: []
- T11变电所: []
- 二厂平台~西: []
- 二厂平台~中01: []
- 二厂平台~中02: []
- T9变压器: []
- T6变压器: []
- B区西~油库(测温): []
- T2变电所 (测温): []
- 二厂平台~西(测温): []
- 二厂平台~中01(测温): []
- T1变电所(测温): []
- 二厂平台~东(测温): []
- 二厂平台~中02(测温): []
- T3变电所(测温): []
- T11变电所(测温): []
- A区南~油库(测温): []
- T9变压器(测温): []
- T6变压器(测温): []
- A区北油库(测温): []
- A区_北油库_气体探测器: []
- A区_南油库_气体探测器: []
- B区油库_气体探测器: []
+ - 2043
+ - 29246
+ - 2090
+ T3变电所:
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ T11变电所:
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ 二厂平台~西:
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ 二厂平台~中01:
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ 二厂平台~中02:
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ T9变压器:
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ T6变压器:
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ B区西~油库(测温):
+ - 1823
+ - 2164
+ - 2166
+ - 30024
+ - 2078
+ T2变电所 (测温):
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ 二厂平台~西(测温):
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ 二厂平台~中01(测温):
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ T1变电所(测温):
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ 二厂平台~东(测温):
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ 二厂平台~中02(测温):
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ T3变电所(测温):
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ T11变电所(测温):
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ A区南~油库(测温):
+ - 2043
+ - 29246
+ - 2090
+ T9变压器(测温):
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ T6变压器(测温):
+ - 1815
+ - 1899
+ - 1926
+ - 2097
+ A区北油库(测温):
+ - 5791
+ - 35393
+ - 26292
+ A区_北油库_气体探测器:
+ - 5791
+ - 35393
+ - 26292
+ A区_南油库_气体探测器:
+ - 2043
+ - 29246
+ - 2090
+ B区油库_气体探测器:
+ - 1823
+ - 2164
+ - 2166
+ - 30024
+ - 2078
+# srcIndex 与设备名称 map
+devices:
+ f3e4a7ff9123414e8654735a6346c709: T2变电所
+ fbd248070e194ee7a5d19bbebd04b416: A区北油库
+ 7b2e3262db0944f6aafb46e92662b5d0: B区西~油库
+ 2fea57a3fb0e4b1690a4c3f0ea104e5a: 二厂平台~东
+ 3a749d1152ed46c8ae5fb6498c93fd5c: T1变电所
+ 326798a515e34beebb192e310a083b6f: A区南~油库
+ 60755219aaac48d4b28330557f3195ab: T3变电所
+ f35c4c52e3a14d79bb7550add62e53c1: T11变电所
+ c08f3b8317a743069ac18fc1f9d3dfc3: B区西~油库
+ f56fe78367e5428ea86a0df60c65ce97: T2变电所
+ 0f13fc0d975744cc87020ec684ac567f: 二厂平台~西
+ c25ef7b22a014427b81450e9947a4900: 二厂平台~中01
+ 5241132804bc4190a9602de3eef52e67: T1变电所
+ 6408079965494092aa9098d4c40e5de1: 二厂平台~东
+ 98836b3470724ac286bcf13409680cd3: 二厂平台~中02
+ 17d6d40adab940d09c31fdc61eddbf0f: T3变电所
+ 870bd26f6c8e4d37aa66f055cf948ad2: T11变电所
+ daa37a58d3364f6ab195a7b7f37864f4: A区南~油库
+ ca89140d5deb448888aee8505f36e380: T9变压器
+ b61cc3688e41446f882e4ac17ff9de94: T6变压器
+ 96d676184b2c46ddaa58cc1959844649: A区北油库
+ 38a57cbc742a4ff7bedf84582ae12ceb: B区西~油库(测温)
+ c9558cebdc7b4bc3afff8e574c9980e5: T2变电所 (测温)
+ 6db35c44bd2749d99513e42bf0e807a3: 二厂平台~西(测温)
+ 600984a71b104b7f87f04166e6116120: 二厂平台~中01(测温)
+ 0167f324d14246dda04dc0d5cadd03d7: T1变电所(测温)
+ 6128d2a2ab5746279135c96c79f2561f: 二厂平台~东(测温)
+ cb82b9641aa54011abe92408cae86a3f: 二厂平台~中02(测温)
+ c914de0202544211822fee8ca293b5be: T3变电所(测温)
+ 2ecfd396c4d0454f99101d3b3de6e60f: T11变电所(测温)
+ f1e5e56900f847df8b982a6f5046f6ef: A区南~油库(测温
+ 4c3504b4122a4edf98befbcc5f8de8f4: T9变压器(测温)
+ 210062d2e12d4b56b31a8324b42e8af8: T6变压器(测温)
+ d16a70c6461c407a8f507013c29fce97: A区北油库(测温)
+ 4a1057f79b12483288e22d81a2f587f9: A区_北油库_气体探测器
+ c0f9b4d866af46d79d7ddb19c4f4a874: A区_南油库_气体探测器
+ 2b6d0f3694854ad393537ececed20704: B区油库_气体探测器
+# 事件类型 map
event_type:
131329: 视频丢失
131330: 视频遮挡
@@ -87,43 +244,110 @@ event_type:
422400000: 有人抽烟
422400002: 有人抽烟或打电话
-devices:
- f3e4a7ff9123414e8654735a6346c709: T2变电所
- fbd248070e194ee7a5d19bbebd04b416: A区北油库
- 7b2e3262db0944f6aafb46e92662b5d0: B区西~油库
- 2fea57a3fb0e4b1690a4c3f0ea104e5a: 二厂平台~东
- 3a749d1152ed46c8ae5fb6498c93fd5c: T1变电所
- 326798a515e34beebb192e310a083b6f: A区南~油库
- 60755219aaac48d4b28330557f3195ab: T3变电所
- f35c4c52e3a14d79bb7550add62e53c1: T11变电所
- c08f3b8317a743069ac18fc1f9d3dfc3: B区西~油库
- f56fe78367e5428ea86a0df60c65ce97: T2变电所
- 0f13fc0d975744cc87020ec684ac567f: 二厂平台~西
- c25ef7b22a014427b81450e9947a4900: 二厂平台~中01
- 5241132804bc4190a9602de3eef52e67: T1变电所
- 6408079965494092aa9098d4c40e5de1: 二厂平台~东
- 98836b3470724ac286bcf13409680cd3: 二厂平台~中02
- 17d6d40adab940d09c31fdc61eddbf0f: T3变电所
- 870bd26f6c8e4d37aa66f055cf948ad2: T11变电所
- daa37a58d3364f6ab195a7b7f37864f4: A区南~油库
- ca89140d5deb448888aee8505f36e380: T9变压器
- b61cc3688e41446f882e4ac17ff9de94: T6变压器
- 96d676184b2c46ddaa58cc1959844649: A区北油库
- 38a57cbc742a4ff7bedf84582ae12ceb: B区西~油库(测温)
- c9558cebdc7b4bc3afff8e574c9980e5: T2变电所 (测温)
- 6db35c44bd2749d99513e42bf0e807a3: 二厂平台~西(测温)
- 600984a71b104b7f87f04166e6116120: 二厂平台~中01(测温)
- 0167f324d14246dda04dc0d5cadd03d7: T1变电所(测温)
- 6128d2a2ab5746279135c96c79f2561f: 二厂平台~东(测温)
- cb82b9641aa54011abe92408cae86a3f: 二厂平台~中02(测温)
- c914de0202544211822fee8ca293b5be: T3变电所(测温)
- 2ecfd396c4d0454f99101d3b3de6e60f: T11变电所(测温)
- f1e5e56900f847df8b982a6f5046f6ef: A区南~油库(测温
- 4c3504b4122a4edf98befbcc5f8de8f4: T9变压器(测温)
- 210062d2e12d4b56b31a8324b42e8af8: T6变压器(测温)
- d16a70c6461c407a8f507013c29fce97: A区北油库(测温
- 4a1057f79b12483288e22d81a2f587f9: A区_北油库_气体探测器
- c0f9b4d866af46d79d7ddb19c4f4a874: A区_南油库_气体探测器
- 2b6d0f3694854ad393537ececed20704: B区油库_气体探测器
-
-push_url: http://192.168.1.233:8080/batch_msg
+# 用户姓名部门科室
+user_info:
+ 1645:
+ name: 项贤忠
+ work_no: GF20030242
+ depart: 安环机动部
+ section:
+ 2088:
+ name: 宫春月
+ work_no: GF20020113
+ depart: 安环机动部
+ section: 安全环保管理业务
+ 2110:
+ name: 程秋生
+ work_no: GF20061051
+ depart: 安环机动部
+ section: 安全环保管理业务
+ 1815:
+ name: 刘方
+ work_no: GF20060059
+ depart: 安环机动部
+ section: 设备能源管理业务
+ 1899:
+ name: 何国飞
+ work_no: GF20082111
+ depart: 安环机动部
+ section: 设备能源管理业务
+ 1926:
+ name: 朱江潮
+ work_no: GF19920032
+ depart: 安环机动部
+ section: 设备能源管理业务
+ 2097:
+ name: 董海波
+ work_no: GF20072117
+ depart: 安环机动部
+ section: 设备能源管理业务
+ 1823:
+ name: 朱政荣
+ work_no: GF20060063
+ depart: 动力二厂
+ section: 装调车间
+ 2164:
+ name: 罗运保
+ work_no: GF20082137
+ depart: 动力二厂
+ section: 装调车间
+ 2166:
+ name: 王军
+ work_no: GF20082149
+ depart: 动力二厂
+ section: 装调车间
+ 30024:
+ name: 王金宝
+ work_no: GF20160011
+ depart: 动力二厂
+ section: 装调车间
+ 2078:
+ name: 陈飞
+ work_no: GF20072258
+ depart: 动力二厂
+ section: 专业管理
+ 2043:
+ name: 赵东翔
+ work_no: GF20115183
+ depart: 动力一厂
+ section: 装调一车间
+ 29246:
+ name: 莫磊磊
+ work_no: GF20140817
+ depart: 动力一厂
+ section: 装调一车间
+ 2090:
+ name: 陶新
+ work_no: GF20082084
+ depart: 动力一厂
+ section: 装调一车间
+ 5791:
+ name: 陈健
+ work_no: GF20050025
+ depart: 动力一厂
+ section: 装调二车间
+ 35393:
+ name: 范永辉
+ work_no: GF20161338
+ depart: 动力一厂
+ section: 装调二车间
+ 26292:
+ name: 杨晨
+ work_no: GF20140093
+ depart: 动力一厂
+ section: 装调二车间
+ 2152:
+ name: 鲁新峰
+ work_no: GF20030639
+ depart: 动力一厂
+ section:
+ 2050:
+ name: 李建民
+ work_no: GF20030097
+ depart: 动力一厂
+ section:
+ 24857:
+ name: 李建民
+ work_no: GF20090716
+ depart: 动力一厂
+ section:
\ No newline at end of file
diff --git a/event.json b/event.json
index aed3913..a9fd3cb 100644
--- a/event.json
+++ b/event.json
@@ -1,19 +1,19 @@
{
"eventId": "BE26E09F-0C6C-4EF9-BE2B-27007B261731",
"eventType": "区域入侵",
+ "deviceName": "A区北油料库",
"eventLvl": 1,
- "happenTime": "2019-01-02T15:17:24.000+08:00",
- "srcIndex": "da107dd1989e44978a5efebe73d6e979",
- "srcName": "浙江杭州",
- "srcType": "camera",
- "status": 0,
- "timeout": 0,
"userIds": [
"gdsdfs"
],
+ "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",
diff --git a/hik_push/read_event.py b/hik_push/read_event.py
index 34386c4..68ff065 100644
--- a/hik_push/read_event.py
+++ b/hik_push/read_event.py
@@ -50,7 +50,9 @@ async def read_event():
device_name = device_map.get(src_index, "未知设备")
event_detail['deviceName'] = device_name
# 根据设备名称获取 user_ids
+ user_all = user_map.get("all", []) # 接受全部通知的用户
user_ids = user_map.get(device_name, [])
+ user_ids = user_ids + user_all
event_detail['userIds'] = user_ids
# 添加其他字段
event_detail["eventLvl"] = event['eventLvl']
@@ -61,7 +63,8 @@ async def read_event():
if "eventType" in event_detail['data']:
detection_field_name = event_detail['data']['eventType']
if detection_field_name in event_detail['data']:
- event_detail['data']["_detectionResult"] = event_detail['data'].pop(detection_field_name)
+ event_detail['data']["_detectionResult"] = event_detail['data'].pop(
+ detection_field_name)
logging.info(event_detail)
try:
push_resp = requests.post(push_url, json=event_detail).content.decode('utf-8')
@@ -78,7 +81,9 @@ async def read_event():
src_index = event["srcIndex"]
device_name = device_map.get(src_index, "未知设备")
# 根据设备名称获取 user_ids
+ user_all = user_map.get("all", []) # 接受全部通知的用户
user_ids = user_map.get(device_name, [])
+ user_ids = user_ids + user_all
event['deviceName'] = device_name
event['userIds'] = user_ids
if "data" in event:
diff --git a/hik_push/test.py b/hik_push/test.py
deleted file mode 100644
index 98d7cd1..0000000
--- a/hik_push/test.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import io
-import json
-
-import requests
-
-if __name__ == '__main__':
- image_content = requests.get(
- "http://47.102.206.10:8086/api/uploads/image/20231101/5bedf085-841a-48cc-bca2-9c9b2c751b48.jpeg").content
- image_bytes = io.BytesIO(image_content)
- # files = {"file": image_bytes}
- data = {"file": "67tgby6y67tg", "file_bytes": "fsfadfsdffadf"}
- resp = requests.post("http://localhost:8000/upload",
- files={"file": image_bytes}).content.decode('utf-8')
- print(resp)