|
@@ -982,7 +982,7 @@ class DevicePushService:
|
|
|
return True if c else False
|
|
|
|
|
|
@staticmethod
|
|
|
- def is_send_app_push(event_type, event_tag, app_push_config, msg_interval=None, uid=None):
|
|
|
+ def is_send_app_push(event_type, event_tag, app_push_config, msg_interval=None, uid=None, channel=1):
|
|
|
"""
|
|
|
是否进行APP消息提醒
|
|
|
@return: True|False
|
|
@@ -999,6 +999,12 @@ class DevicePushService:
|
|
|
return False
|
|
|
if msg_interval: # 存在消息间隔数据缓存 不推送APP消息
|
|
|
return False
|
|
|
+
|
|
|
+ if 'nvr' in app_push_config:
|
|
|
+ push = DevicePushService.is_msg_push_nvr(event_type, int(channel), app_push_config)
|
|
|
+ TIME_LOGGER.info(f'uid:{uid}NVR推送结果:{push}')
|
|
|
+ return push
|
|
|
+
|
|
|
all_day = app_push_config['pushTime']['allDay']
|
|
|
# 允许设备类型APP提醒列表
|
|
|
app_event_types = app_push_config['eventTypes']['device']
|
|
@@ -1017,6 +1023,35 @@ class DevicePushService:
|
|
|
LOGGING.info('{}判断是否执行APP推送异常,errLine:{}, errMsg:{}'.format(uid, e.__traceback__.tb_lineno, repr(e)))
|
|
|
return True
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def is_msg_push_nvr(event_type, channel, config):
|
|
|
+ try:
|
|
|
+ # 获取 NVR 配置中记录,默认为空列表
|
|
|
+ nvr_entries = config.get('nvr', [])
|
|
|
+ # 构建通道键,例如 'channel1' 或 'channel2'
|
|
|
+ channel_key = f'channel{channel}'
|
|
|
+
|
|
|
+ if not nvr_entries:
|
|
|
+ return True
|
|
|
+
|
|
|
+ # 查找给定通道
|
|
|
+ matching_entry = next((entry for entry in nvr_entries if channel_key in entry), None)
|
|
|
+
|
|
|
+ # 如果没有找到匹配项,返回 True,表示可以推送
|
|
|
+ if not matching_entry:
|
|
|
+ return True
|
|
|
+
|
|
|
+ # 获取与 channel_key 对应的 event_types
|
|
|
+ event_types = matching_entry[channel_key] if channel_key in matching_entry else []
|
|
|
+
|
|
|
+ # 调用 is_type_push 方法检查事件类型是否可以推送
|
|
|
+ return DevicePushService.is_type_push(event_type, None, event_types)
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ # 记录异常信息并返回 False
|
|
|
+ ERROR_INFO_LOGGER.error('NVRAPP推送异常, errLine: {}, errMsg: {}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return False
|
|
|
+
|
|
|
@staticmethod
|
|
|
def is_type_push(event_type, event_tag, app_event_types):
|
|
|
# 检查事件标签和应用事件类型是否都存在
|