فهرست منبع

SD卡异常推送

locky 5 ماه پیش
والد
کامیت
4a16e8d9ca
4فایلهای تغییر یافته به همراه41 افزوده شده و 19 حذف شده
  1. 1 1
      AnsjerPush/config.py
  2. 3 2
      Controller/DetectControllerV2.py
  3. 8 0
      Object/enums/EventTypeEnum.py
  4. 29 16
      Service/DevicePushService.py

+ 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, 705]
 MULTI_CHANNEL_TYPE_LIST = [1, 2, 3, 4, 10001]
 
 # AI识别标签

+ 3 - 2
Controller/DetectControllerV2.py

@@ -54,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'})
@@ -66,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))

+ 8 - 0
Object/enums/EventTypeEnum.py

@@ -8,6 +8,7 @@ from enum import Enum, unique
 class EventTypeEnumObj(Enum):
     ONE_CLICK_CALL = 606                # 一键通话
     VIDEO_CALL = 607                    # 视频通话
+    SD_CARD_ABNORMALITY = 705           # SD卡异常
     PRESS_THE_DOORBELL = 1022           # 按下门铃
     CHILD_PROTECTION_MODE = 1023        # 儿童保护模式
     # 不限频推送事件类型列表
@@ -23,3 +24,10 @@ class EventTypeEnumObj(Enum):
         VIDEO_CALL,
         PRESS_THE_DOORBELL
     ]
+    # 主用户推送事件类型列表
+    PRIMARY_USERS_PUSH_EVENT_TYPE_LIST = [
+        ONE_CLICK_CALL,
+        VIDEO_CALL,
+        PRESS_THE_DOORBELL,
+        SD_CARD_ABNORMALITY
+    ]

+ 29 - 16
Service/DevicePushService.py

@@ -107,7 +107,7 @@ class DevicePushService:
         @param button: 按钮
         @return: uid_push_qs
         """
-        if event_type not in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
+        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',
@@ -115,7 +115,7 @@ 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')
             primary_user_id = device_info_qs[0]['vodPrimaryUserID']
             if event_type == 607:  # 音视频通话根据用户按钮来推送
@@ -183,10 +183,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 EventTypeEnumObj.DATA_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'])
+            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[
@@ -287,7 +287,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']))
                     # 保存推送消息
@@ -535,7 +535,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 通道号
@@ -549,18 +549,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 = '检测到画面变化'
@@ -598,15 +600,20 @@ class DevicePushService:
             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 == 705:
+                msg_type = '录像异常,请重新插拔或格式化 SD 卡。'
+                if is_save_msg:
+                    msg_type = '录像异常,请重新插拔或格式化 SD 卡。如问题仍未解决,请联系在线客服。'
+
+            elif event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 msg_type = '有人呼叫,请点击查看'
-            if event_type not in [606, 607] 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:
@@ -656,12 +663,18 @@ class DevicePushService:
             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 == 704:
+                msg_type = 'low battery'
+            elif event_type == 705:
+                msg_type = 'Abnormal recording, please re-insert or format the SD card.'
+                if is_save_msg:
+                    msg_type = 'Abnormal recording, 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'
             elif event_type not in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value and ai_type > 0 and event_list: