|
@@ -167,7 +167,8 @@ class DevicePushService:
|
|
|
params['event_tag'] = cls.get_event_tag(params['ai_type'], params['event_type'], params['detection'])
|
|
|
is_app_push = True if params['event_type'] in [606, 607] else \
|
|
|
cls.is_send_app_push(
|
|
|
- params['event_type'], params['event_tag'], params['app_push_config'], params['app_push'], uid)
|
|
|
+ params['event_type'], params['event_tag'], params['app_push_config'], params['app_push'],
|
|
|
+ uid, params['channel'])
|
|
|
|
|
|
# 低功耗产品推送,休眠702、低电量704提醒,并且detection=0,0标识单事件类型,1标识多事件类型
|
|
|
is_app_push = True if params['event_type'] in [702, 704] and params['detection'] == 0 else is_app_push
|
|
@@ -957,12 +958,15 @@ 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
|
|
|
"""
|
|
|
try:
|
|
|
+ LOGGING.info(
|
|
|
+ 'is_send_app_push函数参数打印:uid:{},event_type:{},event_tag:{},msg_interval:{}'.format(
|
|
|
+ uid, event_type, event_tag, msg_interval))
|
|
|
if not app_push_config:
|
|
|
return True
|
|
|
|
|
@@ -971,6 +975,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']
|
|
@@ -989,6 +999,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):
|
|
|
# 检查事件标签和应用事件类型是否都存在
|