Ver código fonte

SD卡异常推送

locky 4 meses atrás
pai
commit
2513691d63

+ 1 - 1
AnsjerPush/MessageConfig.py

@@ -322,7 +322,7 @@ MSG_CONFIG = {
         'ko': '배터리 부족',
         'ar': 'بطارية منخفضة'
     },
-    705: {
+    706: {
         'default': {
             'cn': '存储卡异常,请重新插拔或格式化存储卡',
             'en': 'Storage card error, please reinsert or format the card ',

+ 1 - 1
AnsjerPush/config.py

@@ -147,7 +147,7 @@ APP_BUNDLE_DICT = {
     'com.ansjer.customizedc_a': 'PatrolSecure',
 }
 
-SYS_EVENT_TYPE_LIST = [702, 703, 704]
+SYS_EVENT_TYPE_LIST = [702, 703, 704, 706]
 MULTI_CHANNEL_TYPE_LIST = [1, 2, 3, 4, 10001]
 
 # AI识别标签

+ 10 - 7
Controller/DetectControllerV2.py

@@ -8,6 +8,7 @@ from django.views.generic.base import View
 from AnsjerPush.config import CONFIG_EUR, CONFIG_INFO, CONFIG_US
 from Object.RedisObject import RedisObject
 from Service.DevicePushService import DevicePushService
+from Object.enums.EventTypeEnum import EventTypeEnumObj
 
 TIME_LOGGER = logging.getLogger('time')
 ERROR_INFO_LOGGER = logging.getLogger('error_info')
@@ -53,7 +54,7 @@ class NotificationV2View(View):
         detection = int(request_dict.get('detection', 0))
         button = request_dict.get('button', '1')
         storage_location = request_dict.get('storage_location', None)
-        uid = ""
+        uid = request_dict.get('uid', None)
         # 参数校验
         if not all([channel, n_time]):
             return JsonResponse(status=200, data={'code': 444, 'msg': 'param is wrong'})
@@ -65,7 +66,8 @@ class NotificationV2View(View):
         event_type = int(event_type)
         redis_obj = RedisObject()
         try:
-            uid = DevicePushService.decode_uid(etk, uidToken)
+            if uid is None:
+                uid = DevicePushService.decode_uid(etk, uidToken)
             if len(uid) != 20 and len(uid) != 14:
                 return JsonResponse(status=200, data={'code': 404, 'msg': 'wrong uid'})
             TIME_LOGGER.info('开始推送,uid:{},参数:{}'.format(uid, request_dict))
@@ -79,7 +81,7 @@ class NotificationV2View(View):
             req_limiting = '{}_{}_{}_ptl'.format(uid, channel, event_type)
             cache_req_limiting = redis_obj.get_data(key=req_limiting)  # 获取请求限流缓存数据
             cache_app_push = redis_obj.get_data(key=push_interval)  # 获取APP推送消息时间间隔缓存数据
-            if event_type not in [606, 607, 1022, 1023]:
+            if event_type not in EventTypeEnumObj.UNRESTRICTED_FREQUENCY_PUSH_EVENT_TYPE_LIST.value:
                 if cache_req_limiting:  # 限流存在则直接返回
                     return JsonResponse(status=200, data={'code': 0, 'msg': 'Push again in one minute'})
             redis_obj.set_data(key=req_limiting, val=1, expire=60)  # 当缓存不存在限流数据 重新设置一分钟请求一次
@@ -91,10 +93,11 @@ class NotificationV2View(View):
                 uid_push_qs = DevicePushService.get_uid_push_by_uid(uid)  # 查主用户
             else:
                 uid_push_qs = DevicePushService.query_uid_push(uid, event_type, button)
-
+            if uid_push_qs is None:
+                return JsonResponse(status=200, data={'code': 175, 'msg': 'device_info数据不存在'})
             if not uid_push_qs.exists():
                 TIME_LOGGER.info('推送响应,uid:{},uid_push数据不存在!'.format(uid))
-                return JsonResponse(status=200, data={'code': 176, 'msg': 'no uid_push data'})
+                return JsonResponse(status=200, data={'code': 176, 'msg': 'uid_push数据不存在'})
 
             ai_type = 0 if child_protection else uid_push_qs.first()['uid_set__ai_type']
             device_type = uid_push_qs.first()['uid_set__device_type']
@@ -106,7 +109,7 @@ class NotificationV2View(View):
 
             # APP消息提醒推送间隔
             detect_interval = uid_set_push_list[0]['uid_set__detect_interval']
-            if event_type not in [606, 607, 1022, 1023]:
+            if event_type not in EventTypeEnumObj.UNRESTRICTED_FREQUENCY_PUSH_EVENT_TYPE_LIST.value:
                 if not cache_app_push:
                     # 缓存APP提醒推送间隔 默认1分钟提醒一次
                     DevicePushService.cache_push_detect_interval(redis_obj, push_interval, detect_interval,
@@ -159,7 +162,7 @@ class NotificationV2View(View):
             push_thread.start()
 
             # 视频通话不返回图片链接
-            if event_type == 607:
+            if event_type in [607, 1022]:
                 TIME_LOGGER.info('推送响应,uid:{},n_time:{},事件类型:{}'.format(uid, n_time, event_type))
                 return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
 

+ 14 - 1
Object/enums/EventTypeEnum.py

@@ -8,18 +8,31 @@ from enum import Enum, unique
 class EventTypeEnumObj(Enum):
     ONE_CLICK_CALL = 606                # 一键通话
     VIDEO_CALL = 607                    # 视频通话
+    SD_CARD_ABNORMALITY = 706           # SD卡异常
     PRESS_THE_DOORBELL = 1022           # 按下门铃
     CHILD_PROTECTION_MODE = 1023        # 儿童保护模式
     # 不限频推送事件类型列表
     UNRESTRICTED_FREQUENCY_PUSH_EVENT_TYPE_LIST = [
         ONE_CLICK_CALL,
         VIDEO_CALL,
+        SD_CARD_ABNORMALITY,
         PRESS_THE_DOORBELL,
         CHILD_PROTECTION_MODE
     ]
-    # 透传推送事件类型列表
+    # 透传推送事件类型列表(音视频通话)
     DATA_PUSH_EVENT_TYPE_LIST = [
         ONE_CLICK_CALL,
         VIDEO_CALL,
         PRESS_THE_DOORBELL
     ]
+    # 主用户推送事件类型列表
+    PRIMARY_USERS_PUSH_EVENT_TYPE_LIST = [
+        ONE_CLICK_CALL,
+        VIDEO_CALL,
+        PRESS_THE_DOORBELL,
+        SD_CARD_ABNORMALITY
+    ]
+    # 系统消息事件类型
+    SYS_MSG_EVENT_TYPE_LIST = [
+        SD_CARD_ABNORMALITY
+    ]

+ 17 - 3
Service/CommonService.py

@@ -14,6 +14,7 @@ from django.utils import timezone
 from pyipip import IPIPDatabase
 
 from AnsjerPush.config import BASE_DIR, ACCESS_KEY_ID, SECRET_ACCESS_KEY, REGION_NAME, PUSH_BUCKET
+from Object.enums.EventTypeEnum import EventTypeEnumObj
 
 
 # 复用性且公用较高封装代码在这
@@ -110,10 +111,7 @@ class CommonService:
         ipbd_dir = BASE_DIR + "/DB/mydata4vipday2.ipdb"
         db = ipdb.City(ipbd_dir)
         if update:
-            from var_dump import var_dump
-            var_dump('is_update')
             rr = db.reload(ipbd_dir)
-            var_dump(rr)
         info = db.find_map(ip, lang)
         return info
 
@@ -328,3 +326,19 @@ class CommonService:
         struct_time = time.localtime(timestamp)
         time_str = time.strftime("%Y-%m-%d %H:%M:%S", struct_time)
         return time_str
+
+    @staticmethod
+    def get_jump_type(event_type):
+        """
+        获取跳转类型
+        @param event_type: 事件类型
+        @return event_type: 跳转类型,1:推送消息,2:系统消息,3:音视频通话消息
+        """
+        # 跳转类型,1:推送消息,2:系统消息,3:音视频通话消息
+        jump_type = 1
+        event_type = int(event_type)
+        if event_type in EventTypeEnumObj.SYS_MSG_EVENT_TYPE_LIST.value:
+            jump_type = 2
+        elif event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
+            jump_type = 3
+        return jump_type

+ 58 - 38
Service/DevicePushService.py

@@ -108,7 +108,7 @@ class DevicePushService:
         @param button: 按钮
         @return: uid_push_qs
         """
-        if event_type not in [606, 607]:
+        if event_type not in EventTypeEnumObj.PRIMARY_USERS_PUSH_EVENT_TYPE_LIST.value:
             uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1) \
                 .exclude(token_val='0'). \
                 values('token_val', 'app_type', 'appBundleId', 'm_code', 'push_type', 'userID_id', 'userID__NickName',
@@ -116,8 +116,10 @@ class DevicePushService:
                        'uid_set__channel', 'uid_set__ai_type', 'uid_set__device_type', 'uid_set__new_detect_interval',
                        'uid_set__msg_notify')
         else:
-            # 一键通话只推主用户
+            # 一键通话,视频通话,按下门铃,SD卡异常 只推主用户
             device_info_qs = Device_Info.objects.filter(UID=uid).values('vodPrimaryUserID')
+            if not device_info_qs.exists():
+                return None
             primary_user_id = device_info_qs[0]['vodPrimaryUserID']
             if event_type == 607:  # 音视频通话根据用户按钮来推送
                 button_qs = UserAudioVideoPush.objects.filter(uid=uid).values('buttonUser1', 'buttonUser2')
@@ -137,6 +139,8 @@ class DevicePushService:
         根据uid获取设备推送(目前仅用在OZI定制客户)
         """
         device_info_qs = Device_Info.objects.filter(UID=uid).values('vodPrimaryUserID')
+        if not device_info_qs.exists():
+            return None
         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'). \
@@ -184,10 +188,10 @@ class DevicePushService:
         try:
             uid = params['uid']
             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['channel'])
+            is_app_push = True if params['event_type'] in EventTypeEnumObj.PRIMARY_USERS_PUSH_EVENT_TYPE_LIST.value \
+                else cls.is_send_app_push(
+                params['event_type'], params['event_tag'], params['app_push_config'], params['app_push'],
+                uid, params['channel'])
 
             # 低功耗产品推送,休眠702,低电量704提醒,1023 ozi, 并且detection=0,0标识单事件类型,1标识多事件类型
             is_app_push = True if params['event_type'] in [702, 704, 1022, 1023] and params[
@@ -208,7 +212,7 @@ class DevicePushService:
                     tz = up['tz']
                     if tz is None or tz == '':
                         tz = 0
-                    if params['event_type'] in [606, 607] and push_type in [5, 6]:
+                    if params['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value and push_type in [5, 6]:
                         process_token = up['jg_token_val']
                         push_kwargs['jg_token_val'] = up['jg_token_val']
                     else:
@@ -288,7 +292,7 @@ class DevicePushService:
                         sys_msg_text = cls.get_msg_text(channel=params['channel'], n_time=params['n_time'], lang=lang,
                                                         tz=tz, is_sys=1, device_type=params['device_type'],
                                                         event_type=params['event_type'],
-                                                        electricity=params['electricity'])
+                                                        electricity=params['electricity'], is_save_msg=1)
                         sys_msg_list.append(SysMsgModel(userID_id=user_id, msg=sys_msg_text, addTime=now_time,
                                                         updTime=now_time, uid=uid, eventType=params['event_type']))
                     # 保存推送消息
@@ -304,7 +308,7 @@ class DevicePushService:
                             'device_uid': params['uid'],
                             'device_nick_name': params['nickname'],
                             'channel': params['channel'],
-                            'alarm': 'Motion \tChannel:{}'.format(params['channel']),
+                            'alarm': '',
                             'is_st': params['is_st'],
                             'add_time': int(time.time()),
                             'storage_location': params['storage_location'],
@@ -325,7 +329,8 @@ class DevicePushService:
 
                 # 一键通话和视频通话需要实时写入数据
                 # 正式服通过定时任务批量写入数据
-                if params['event_type'] in [606, 607] or CONFIG_INFO == CONFIG_TEST:
+                if params['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value or \
+                        CONFIG_INFO == CONFIG_TEST:
                     end = 0
                     # 缓存数据多于100条,批量保存前100条,否则保存全部
                     equipment_info_len = redis_obj.llen(equipment_info_key)
@@ -429,8 +434,7 @@ class DevicePushService:
                 # thread_pool.submit(cls.async_send_picture_push, (
                 #     push_type, kwargs['aws_s3_client'], kwargs['bucket'], key,
                 #     kwargs['uid'], kwargs['appBundleId'], kwargs['token_val'], kwargs['event_type'], kwargs['n_time'],
-                #     push_kwargs['msg_title'], push_kwargs['msg_text'], kwargs['channel'], kwargs['storage_location']))
-
+                #     push_kwargs['msg_title'], push_kwargs['msg_text'], kwargs['channel'], kwargs['storage_location'])
                 push_thread = threading.Thread(target=cls.async_send_picture_push, args=(
                     push_type, kwargs['aws_s3_client'], kwargs['bucket'], key,
                     kwargs['uid'], kwargs['appBundleId'], kwargs['token_val'], kwargs['event_type'], kwargs['n_time'],
@@ -490,7 +494,7 @@ class DevicePushService:
                 elif push_type == 8:  # android honorpush
                     push_result = PushObject.android_honorpush(**push_kwargs)
 
-            if kwargs['event_type'] in [606, 607]:
+            if kwargs['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 close_old_connections()
                 # 写入日志表
                 PushLog.objects.create(uid=uid, event_type=kwargs['event_type'], created_time=int(time.time()),
@@ -534,7 +538,7 @@ class DevicePushService:
 
     @staticmethod
     def get_msg_text(channel, n_time, lang, tz, event_type, electricity='', is_sys=0, dealings_type=0, ai_type=0,
-                     device_type=0, event_tag=''):
+                     device_type=0, event_tag='', is_save_msg=0):
         """
         获取消息文本
         @param: channel 通道号
@@ -548,18 +552,20 @@ class DevicePushService:
         @param: ai_type 设备本地AI只能算法 事件类型
         @param: device_type 设备类型
         @param: event_tag 设备算法事件标签
+        @parm: is_save_msg 保存消息
         """
         msg_type = ''
         event_type = int(event_type)
         device_type = int(device_type)
         event_list = []
         if event_tag:
+            # 移除非组合推送类型
             event_list = [int(event) for event in event_tag.split(',') if event]
-
-            events_to_remove = [702, 703, 704]
+            events_to_remove = SYS_EVENT_TYPE_LIST
             for event in events_to_remove:
                 if event in event_list:
                     event_list.remove(event)
+
         if lang == 'cn':
             if event_type == 51:
                 msg_type = '检测到画面变化'
@@ -591,20 +597,26 @@ 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 = '电量低'
             elif event_type == 702:
                 msg_type = '摄像头休眠'
             elif event_type == 703:
                 msg_type = '摄像头唤醒'
-            elif event_type in [606, 607]:
+            elif event_type == 704:
+                msg_type = '电量低'
+            elif event_type == 706:
+                msg_type = 'SD卡异常,请重新插拔或格式化SD卡。'
+                if is_save_msg:
+                    msg_type = 'SD卡异常,请重新插拔或格式化SD卡。如问题仍未解决,请联系在线客服。'
+
+            elif event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 msg_type = '有人呼叫,请点击查看'
-            if event_type not in [606, 607, 1022] and ai_type > 0 and event_list:
+            if event_type not in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value 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:
@@ -648,20 +660,27 @@ 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'
             elif event_type == 702:
                 msg_type = 'Camera sleep'
             elif event_type == 703:
                 msg_type = 'Camera wake'
-            elif event_type in [606, 607]:
+            elif event_type == 704:
+                msg_type = 'low battery'
+            elif event_type == 706:
+                msg_type = 'SD card is abnormal. Please re-insert or format the SD card.'
+                if is_save_msg:
+                    msg_type = 'SD card is abnormal, please re-insert or format the SD card. ' \
+                               'If the problem is still not solved, please contact online customer service.'
+
+            elif event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 msg_type = 'Someone is calling, please click to view'
-            if event_type not in [606, 607, 1022] and ai_type > 0 and event_list:
+            elif event_type not in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value 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:
@@ -697,7 +716,7 @@ class DevicePushService:
                         event_list.remove(event)
 
             # 简体中文、英文、西班牙语、法语、德语、繁体中文、葡萄牙语、俄语、日语、意大利语、波兰语、韩语、阿拉伯语
-            SUPPORTED_LANGS = {'cn', 'en', 'es', 'fr', 'de', 'cn_tw', 'pt', 'ru', 'ja', 'it', 'pl', 'nl', 'ko', 'ar'}
+            SUPPORTED_LANGS = {'cn', 'en', 'es', 'fr', 'de', 'cn_tw', 'pt', 'ru', 'ja', 'it', 'pl', 'nl', 'kr', 'ar'}
             MIN_EVENT_TYPE, MAX_EVENT_TYPE = 51, 65
             # 根据语言获取对应单个事件文案
             if lang in SUPPORTED_LANGS and MIN_EVENT_TYPE <= event_type <= MAX_EVENT_TYPE:
@@ -714,11 +733,11 @@ class DevicePushService:
                 msg_type = MSG_CONFIG[703].get(lang, '')
             elif event_type == 704:
                 msg_type = MSG_CONFIG[704].get(lang, '')
-            elif event_type == 705:
+            elif event_type == 706:
                 if is_save_msg:
-                    msg_type = MSG_CONFIG[705]['save'].get(lang, '')
+                    msg_type = MSG_CONFIG[706]['save'].get(lang, '')
                 else:
-                    msg_type = MSG_CONFIG[705]['default'].get(lang, '')
+                    msg_type = MSG_CONFIG[706]['default'].get(lang, '')
 
             elif event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 msg_type = MSG_CONFIG['data_push'].get(lang, '')
@@ -771,10 +790,8 @@ class DevicePushService:
         try:
             url = 'https://api.xmpush.xiaomi.com/v3/message/regid'
             app_secret = XMPUSH_CONFIG[appBundleId]
-            # payload = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
-            #            'received_at': n_time, 'event_time': n_time, 'event_type': event_type,
-            #            'uid': uid, 'channel': channel
-            #            }
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
             data = {
                 'title': msg_title,
                 'description': msg_text,
@@ -782,7 +799,7 @@ class DevicePushService:
                 'restricted_package_name': appBundleId,
                 'registration_id': token_val,
                 'extra.channel_id': channel_id,
-                'extra.alert': 'Motion',
+                'extra.alert': msg_text,
                 'extra.msg': '',
                 'extra.sound': 'sound.aif',
                 'extra.zpush': '1',
@@ -791,8 +808,9 @@ class DevicePushService:
                 'extra.event_type': event_type,
                 'extra.uid': uid,
                 'extra.channel': channel,
+                'extra.jump_type': jump_type
             }
-            if event_type in [606, 607]:
+            if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 data['extra.sound_uri'] = 'android.resource://com.ansjer.zccloud_ab/raw/phone_call'
             headers = {
                 'Authorization': 'key={}'.format(app_secret)
@@ -817,7 +835,7 @@ class DevicePushService:
         android 国内oppo APP消息提醒推送
         """
         try:
-            if event_type in [606, 607]:
+            if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 channel_id = XM_PUSH_CHANNEL_ID['push_to_talk']
             app_key = OPPOPUSH_CONFIG[appBundleId]['Key']
             master_secret = OPPOPUSH_CONFIG[appBundleId]['Secret']
@@ -841,9 +859,11 @@ class DevicePushService:
             result = response.json()
             # 发送推送
             push_url = url + 'server/v1/message/notification/unicast'
-            extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
+            extra_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                           'received_at': n_time, 'event_time': n_time, 'event_type': event_type,
-                          'uid': uid, 'channel': channel}
+                          'uid': uid, 'channel': channel, 'jump_type': jump_type}
             message = {
                 "target_type": 2,
                 "target_value": token_val,
@@ -863,7 +883,7 @@ class DevicePushService:
 
             response = requests.post(push_url, data=push_data, headers=headers)
             if response.status_code == 200:
-                if event_type in [606, 607]:
+                if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                     PushObject.jpush_transparent_transmission(msg_title, msg_text, appBundleId, jg_token_val,
                                                               extra_data)
                 return True

+ 5 - 1
Service/HuaweiPushService/HuaweiPushService.py

@@ -2,6 +2,7 @@ import json
 
 from AnsjerPush.config import LOGGER
 from Object.enums.EventTypeEnum import EventTypeEnumObj
+from Service.CommonService import CommonService
 from Service.HuaweiPushService import push_admin
 from Service.HuaweiPushService.push_admin import messaging
 
@@ -70,10 +71,13 @@ class HuaweiPushObject:
             image=image_url
         )
 
+        # 跳转类型
+        jump_type = CommonService.get_jump_type(event_type)
         # 自定义键值对
         data = {
             'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': uid, 'nickname': nickname,
-            'event_type': event_type, 'received_at': n_time, 'event_time': n_time, 'channel': channel
+            'event_type': event_type, 'received_at': n_time, 'event_time': n_time, 'channel': channel,
+            'jump_type': jump_type
         }
         data = json.dumps(data)
         # 推送通知内容配置

+ 42 - 31
Service/PushService.py

@@ -127,11 +127,13 @@ class PushObject:
         try:
             cli = apns2.APNSClient(mode=APNS_MODE, client_cert=pem_path)
             alert = apns2.PayloadAlert(title=msg_title, body=msg_text, launch_image=launch_image)
-            push_data = {'alert': 'Motion', 'msg': '', 'sound': '', 'zpush': '1', 'uid': uid, 'channel': channel,
+            # 跳转类型,1:推送消息,2:系统消息,3:音视频通话消息
+            jump_type = CommonService.get_jump_type(event_type)
+            push_data = {'alert': msg_text, 'msg': '', 'sound': '', 'zpush': '1', 'uid': uid, 'channel': channel,
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
-                         'image_url': launch_image
+                         'image_url': launch_image, 'jump_type': jump_type
                          }
-            sound = 'call_phone.mp3' if event_type in [606, 607] else 'default'
+            sound = 'call_phone.mp3' if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value else 'default'
             payload = apns2.Payload(alert=alert, custom=push_data, sound=sound, category='myCategory',
                                     mutable_content=True)
             n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
@@ -162,11 +164,11 @@ class PushObject:
         try:
             serverKey = FCM_CONFIG[app_bundle_id]
             push_service = FCMNotification(api_key=serverKey)
-            push_data = {'alert': 'Motion', 'msg': '', 'zpush': '1', 'image': image,
+            push_data = {'alert': msg_text, 'msg': '', 'zpush': '1', 'image': image,
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                          'uid': uid, 'channel': channel
                          }
-            if event_type in [606, 607]:
+            if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 push_data['priority'] = 'high'
                 push_data['content_available'] = True
                 push_data['direct_boot_ok'] = True
@@ -215,11 +217,13 @@ class PushObject:
         try:
             event_type = str(event_type)
             n_time = str(n_time)
-            push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
+            push_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
-                         'uid': uid, 'channel': channel
+                         'uid': uid, 'channel': channel, 'jump_type': jump_type
                          }
-            if event_type in [606, 607]:
+            if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 push_data['priority'] = 'high'
                 push_data['content_available'] = True
                 push_data['direct_boot_ok'] = True
@@ -235,10 +239,10 @@ class PushObject:
             # Send a message to the device corresponding to the provided
             # registration token.
             result = messaging.send(message)
-            TIME_LOGGER.info('uid:{}fcm推送结果:{}'.format(uid, result))
+            LOGGER.info('fcm推送结果:{}'.format(result))
             return True
         except Exception as e:
-            TIME_LOGGER.error('uid:{}fcm推送异常:{}'.format(uid, repr(e)))
+            LOGGER.info('fcm推送异常:{}'.format(repr(e)))
             return False
 
     @staticmethod
@@ -262,11 +266,11 @@ class PushObject:
             # _jpush = jpush.JPush(app_key, master_secret)
             # push = _jpush.create_push()
             # push.audience = jpush.registration_id(token_val)
-            # if event_type in [606, 607]:
+            # if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
             #     channel_id = '111934'
             # else:
             #     channel_id = '1'
-            # push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': nickname,
+            # push_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': nickname,
             #              'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
             #              'channel': channel
             #              }
@@ -276,7 +280,6 @@ class PushObject:
             # push.notification = jpush.notification(android=android)
             # push.platform = jpush.all_
             # res = push.send()
-            # LOGGER.info("uid:{},time:{},极光推送返回值:{}".format(nickname, n_time, res))
             # assert res.status_code == 200
             return True
         except Exception as e:
@@ -308,9 +311,11 @@ class PushObject:
                 channel_id = '111934'
             else:
                 channel_id = '1'
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
             push_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': nickname,
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
-                         'channel': channel
+                         'channel': channel, 'jump_type': jump_type
                          }
             android = jpush.android(title=msg_title, big_text=msg_text, alert=msg_text, extras=push_data,
                                     priority=1, style=1, alert_type=7, channel_id=channel_id
@@ -346,10 +351,8 @@ class PushObject:
         try:
             url = 'https://api.xmpush.xiaomi.com/v3/message/regid'
             app_secret = XMPUSH_CONFIG[app_bundle_id]
-            # payload = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
-            #            'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
-            #            'uid': uid, 'channel': channel
-            #            }
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
             data = {
                 'title': msg_title,
                 'description': msg_text,
@@ -357,7 +360,7 @@ class PushObject:
                 'restricted_package_name': app_bundle_id,
                 'registration_id': token_val,
                 'extra.channel_id': channel_id,
-                'extra.alert': 'Motion',
+                'extra.alert': msg_text,
                 'extra.msg': '',
                 'extra.sound': 'sound.aif',
                 'extra.zpush': '1',
@@ -367,6 +370,7 @@ class PushObject:
                 'extra.nickname': nickname,
                 'extra.uid': uid,
                 'extra.channel': channel,
+                'extra.jump_type': jump_type
             }
             # if image:
             #     data['extra.notification_style_type'] = 2
@@ -414,9 +418,11 @@ class PushObject:
             # 鉴权接口调用获得authToken
             sender_send = APISender(app_secret)
             sender_send.set_token(rec['authToken'])
-            push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'image': image,
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
+            push_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'image': image,
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
-                         'uid': uid, 'channel': channel
+                         'uid': uid, 'channel': channel, 'jump_type': jump_type
                          }
             #  获取唯一标识符
             uid_push_qs = UidPushModel.objects.filter(token_val=token_val).values('m_code')
@@ -439,11 +445,12 @@ class PushObject:
                 .message_dict()
             rec = sender_send.send(message)
             LOGGER.info('vivo推送结果:{}, 设备uid:{}'.format(rec, uid))
-            if rec['result'] == 0 and event_type in [606, 607]:
+            if rec['result'] == 0 and event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 PushObject.jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, jg_token_val, push_data)
             return True
         except Exception as e:
-            LOGGER.info('vivo推送异常:{}'.format(e))
+            LOGGER.error('vivo推送异常,uid:{},error_line:{},error_msg:{}'.
+                         format(uid, e.__traceback__.tb_lineno, repr(e)))
             return False
 
     @staticmethod
@@ -491,7 +498,7 @@ class PushObject:
             result = response.json()
             # 发送推送
             push_url = url + 'server/v1/message/notification/unicast'
-            extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            extra_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                           'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                           'uid': uid, 'channel': channel
                           }
@@ -514,7 +521,7 @@ class PushObject:
 
             response = requests.post(push_url, data=push_data, headers=headers)
             LOGGER.info("oppo推送返回值:{}".format(response.json()))
-            if response.status_code == 200 and event_type in [606, 607]:
+            if response.status_code == 200 and event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 PushObject.jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, jg_token_val, extra_data)
             return True
         except Exception as e:
@@ -545,9 +552,11 @@ class PushObject:
             appId = MEIZUPUSH_CONFIG[app_bundle_id]['ID']
             appSecret = MEIZUPUSH_CONFIG[app_bundle_id]['AppSecret']
             url = 'https://server-api-push.meizu.com/garcia/api/server/push/varnished/pushByPushId'
-            extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
+            extra_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                           'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
-                          'uid': uid, 'channel': channel
+                          'uid': uid, 'channel': channel, 'jump_type': jump_type
                           }
             # 转换为json格式
             extra_data = json.dumps(extra_data)
@@ -621,10 +630,12 @@ class PushObject:
             push_url = 'https://push-api.cloud.hihonor.com/api/v1/{}/sendMessage'.format(app_id)
             headers = {'Content-Type': 'application/json', 'Authorization': authorization_token,
                        'timestamp': str(int(time.time()) * 1000)}
-            extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
+            extra_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                           'received_at': n_time, 'event_time': n_time, 'event_type': str(event_type),
-                          'nickname': nickname,
-                          'uid': uid, 'channel': channel, 'title': msg_title, 'body': msg_text
+                          'nickname': nickname, 'uid': uid, 'channel': channel, 'title': msg_title, 'body': msg_text,
+                          'jump_type': jump_type
                           }
             # 通知推送
             push_data = {
@@ -645,7 +656,7 @@ class PushObject:
             response = requests.post(push_url, json=push_data, headers=headers)
             LOGGER.info("uid:{},时间:{},荣耀推送通知返回值:{}".format(uid, n_time, response.json()))
             # 一键通话透传推送
-            if int(event_type) in [606, 607]:
+            if int(event_type) in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 push_data = {
                     "data": json.dumps(extra_data),
                     "token": [token_val]

+ 5 - 1
Service/VSeesHuaweiPushService/VseesHuaweiPushObject.py

@@ -2,6 +2,7 @@ import json
 
 from AnsjerPush.config import LOGGER
 from Object.enums.EventTypeEnum import EventTypeEnumObj
+from Service.CommonService import CommonService
 from Service.VSeesHuaweiPushService import push_admin
 from Service.VSeesHuaweiPushService.push_admin import messaging
 
@@ -70,10 +71,13 @@ class VseesHuaweiPushObject:
             image=image_url
         )
 
+        # 跳转类型
+        jump_type = CommonService.get_jump_type(event_type)
         # 自定义键值对
         data = {
             'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': uid, 'nickname': nickname,
-            'event_type': event_type, 'received_at': n_time, 'event_time': n_time, 'channel': channel
+            'event_type': event_type, 'received_at': n_time, 'event_time': n_time, 'channel': channel,
+            'jump_type': jump_type
         }
         data = json.dumps(data)
         # 推送通知内容配置