|
@@ -36,7 +36,6 @@ from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
|
|
|
from Service.PushService import PushObject
|
|
|
from django.db import close_old_connections
|
|
|
|
|
|
-
|
|
|
LOGGING = logging.getLogger('info')
|
|
|
TIME_LOGGER = logging.getLogger('time')
|
|
|
ERROR_INFO_LOGGER = logging.getLogger('error_info')
|
|
@@ -127,6 +126,21 @@ class DevicePushService:
|
|
|
'uid_set__msg_notify', 'jg_token_val')
|
|
|
return uid_push_qs
|
|
|
|
|
|
+ @classmethod
|
|
|
+ def get_uid_push_by_uid(cls, uid):
|
|
|
+ """
|
|
|
+ 根据uid获取设备推送(目前仅用在OZI定制客户)
|
|
|
+ """
|
|
|
+ device_info_qs = Device_Info.objects.filter(UID=uid).values('vodPrimaryUserID')
|
|
|
+ primary_user_id = device_info_qs[0]['vodPrimaryUserID']
|
|
|
+ uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, userID_id=primary_user_id) \
|
|
|
+ .exclude(token_val='0'). \
|
|
|
+ values('token_val', 'app_type', 'appBundleId', 'm_code', 'push_type', 'userID_id', 'userID__NickName',
|
|
|
+ 'lang', 'm_code', 'tz', 'uid_set__nickname', 'uid_set__detect_interval', 'uid_set__detect_group',
|
|
|
+ 'uid_set__channel', 'uid_set__ai_type', 'uid_set__device_type', 'uid_set__new_detect_interval',
|
|
|
+ 'uid_set__msg_notify', 'jg_token_val')
|
|
|
+ return uid_push_qs
|
|
|
+
|
|
|
@staticmethod
|
|
|
def qs_to_list(qs):
|
|
|
"""
|
|
@@ -170,8 +184,9 @@ class DevicePushService:
|
|
|
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
|
|
|
+ # 低功耗产品推送,休眠702,低电量704提醒,1023 ozi, 并且detection=0,0标识单事件类型,1标识多事件类型
|
|
|
+ is_app_push = True if params['event_type'] in [702, 704, 1022, 1023] and params[
|
|
|
+ 'detection'] == 0 else is_app_push
|
|
|
redis_obj = params['redis_obj']
|
|
|
# 推送
|
|
|
if is_app_push:
|
|
@@ -557,6 +572,10 @@ class DevicePushService:
|
|
|
msg_type = '有人徘徊'
|
|
|
elif event_type == 65:
|
|
|
msg_type = '长时间无人出现'
|
|
|
+ elif event_type == 1022:
|
|
|
+ msg_type = '有人按下门铃'
|
|
|
+ elif event_type == 1023:
|
|
|
+ msg_type = '儿童保护模式开启'
|
|
|
|
|
|
elif event_type == 704:
|
|
|
msg_type = '电量低'
|
|
@@ -566,7 +585,7 @@ class DevicePushService:
|
|
|
msg_type = '摄像头唤醒'
|
|
|
elif event_type in [606, 607]:
|
|
|
msg_type = '有人呼叫,请点击查看'
|
|
|
- if event_type not in [606, 607] and ai_type > 0 and event_list:
|
|
|
+ if event_type not in [606, 607, 1022] and ai_type > 0 and event_list:
|
|
|
msg_type = ''.join([DevicePushService.get_event_type_text(lang, item, dealings_type)
|
|
|
for item in event_list])
|
|
|
if is_sys:
|
|
@@ -610,6 +629,10 @@ class DevicePushService:
|
|
|
msg_type = 'Loitering detected'
|
|
|
elif event_type == 65:
|
|
|
msg_type = 'No appearance for a long time'
|
|
|
+ elif event_type == 1022:
|
|
|
+ msg_type = 'Someone rang the doorbell'
|
|
|
+ elif event_type == 1023:
|
|
|
+ msg_type = 'Child protection mode is enabled'
|
|
|
|
|
|
elif event_type == 704:
|
|
|
msg_type = 'low battery'
|
|
@@ -619,7 +642,7 @@ class DevicePushService:
|
|
|
msg_type = 'Camera wake'
|
|
|
elif event_type in [606, 607]:
|
|
|
msg_type = 'Someone is calling, please click to view'
|
|
|
- if event_type not in [606, 607] and ai_type > 0 and event_list:
|
|
|
+ if event_type not in [606, 607, 1022] and ai_type > 0 and event_list:
|
|
|
msg_type = ''.join([DevicePushService.get_event_type_text(lang, item, dealings_type)
|
|
|
for item in event_list])
|
|
|
if is_sys:
|
|
@@ -734,9 +757,11 @@ class DevicePushService:
|
|
|
|
|
|
response = requests.post(push_url, data=push_data, headers=headers)
|
|
|
if response.status_code == 200:
|
|
|
- LOGGING.info("oppo推送返回值:{},uid:{},time:{},event:{}".format(response.json(), uid, now_time, event_type))
|
|
|
+ LOGGING.info(
|
|
|
+ "oppo推送返回值:{},uid:{},time:{},event:{}".format(response.json(), uid, now_time, event_type))
|
|
|
if event_type in [606, 607]:
|
|
|
- PushObject.jpush_transparent_transmission(msg_title, msg_text, appBundleId, jg_token_val, extra_data)
|
|
|
+ PushObject.jpush_transparent_transmission(msg_title, msg_text, appBundleId, jg_token_val,
|
|
|
+ extra_data)
|
|
|
return True
|
|
|
return False
|
|
|
except Exception as e:
|
|
@@ -996,7 +1021,8 @@ class DevicePushService:
|
|
|
LOGGING.info('{}APP推送消息类型提醒是否执行:{}'.format(uid, push_result))
|
|
|
return push_result
|
|
|
except Exception as e:
|
|
|
- LOGGING.info('{}判断是否执行APP推送异常,errLine:{}, errMsg:{}'.format(uid, e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ LOGGING.info(
|
|
|
+ '{}判断是否执行APP推送异常,errLine:{}, errMsg:{}'.format(uid, e.__traceback__.tb_lineno, repr(e)))
|
|
|
return True
|
|
|
|
|
|
@staticmethod
|
|
@@ -1025,7 +1051,8 @@ class DevicePushService:
|
|
|
|
|
|
except Exception as e:
|
|
|
# 记录异常信息并返回 False
|
|
|
- ERROR_INFO_LOGGER.error('NVRAPP推送异常, errLine: {}, errMsg: {}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ ERROR_INFO_LOGGER.error(
|
|
|
+ 'NVRAPP推送异常, errLine: {}, errMsg: {}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
return False
|
|
|
|
|
|
@staticmethod
|