Browse Source

Merge branch 'test' of http://192.168.136.99:3000/servers/ASJPush into locky

 Conflicts:
	Controller/DetectControllerV2.py
locky 2 năm trước cách đây
mục cha
commit
442d285009

+ 1 - 1
Controller/DetectController.py

@@ -127,7 +127,7 @@ class NotificationView(View):
             params = {'nickname': nickname, 'uid': uid, 'kwag_args': kwag_args, 'is_st': is_st,
                       'is_sys_msg': is_sys_msg, 'channel': channel, 'event_type': event_type, 'n_time': n_time,
                       'electricity': '', 'bucket': bucket, 'app_push': '', 'storage_location': 1, 'ai_type': 0,
-                      'dealings_type': 0}
+                      'dealings_type': 0, 'detection': 0}
             #  推送以及报警消息存库
             result = DevicePushService.save_msg_push(uid_set_push_list=uid_push_list, **params)
             if result['code_date'] is None:

+ 3 - 1
Controller/DetectControllerV2.py

@@ -56,6 +56,8 @@ class NotificationV2View(View):
         uid = request_dict.get('uid', None)
         # 往来检测 1:来,2:离开
         dealings_type = request_dict.get('dealingsType', 0)
+        # 检测类型 0:普通,1:算法
+        detection = int(request_dict.get('detection', 0))
 
         if not all([channel, n_time]):
             return JsonResponse(status=200, data={
@@ -125,7 +127,7 @@ class NotificationV2View(View):
                       'is_sys_msg': is_sys_msg, 'channel': channel, 'event_type': event_type, 'n_time': n_time,
                       'electricity': electricity, 'bucket': bucket, 'aws_s3_client': aws_s3_client,
                       'app_push': cache_app_push, 'storage_location': 2, 'ai_type': ai_type, 'device_type': device_type,
-                      'dealings_type': int(dealings_type)}
+                      'dealings_type': int(dealings_type), 'detection': detection}
             logger.info('推送数据参数:{}'.format(params))
             # 推送消息,生成推送数据列表
             result = DevicePushService.save_msg_push(uid_set_push_list, **params)

+ 20 - 13
Service/DevicePushService.py

@@ -110,9 +110,9 @@ class DevicePushService:
         kwag_args = params['kwag_args']
         code_data = {'do_apns_code': '', 'do_fcm_code': '', 'do_jpush_code': ''}
         local_date_time = ''
-        push_permission = True
+        # push_permission = True
         try:
-            params['event_tag'] = cls.get_event_tag(params['ai_type'], params['event_type'])
+            params['event_tag'] = cls.get_event_tag(params['ai_type'], params['event_type'], params['detection'])
             for up in uid_set_push_list:
                 appBundleId = up['appBundleId']
                 token_val = up['token_val']
@@ -169,19 +169,24 @@ class DevicePushService:
             LOGGING.info('推送消息或存表异常: errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
 
     @classmethod
-    def get_event_tag(cls, ai_type, event_type):
+    def get_event_tag(cls, ai_type, event_type, detection=0):
         """
         获取事件标签
         """
-        if ai_type > 0:
-            event_res = DEVICE_EVENT_TYPE.get(event_type, 0)
-            if event_res > 0:
-                return ',' + str(event_res) + ','
-            event_type = cls.dec_to_bin(event_type)
-            types = cls.get_combo_types(event_type)
-            res = ','.join(types) + ','
-            return ',' + res
-        return ',' + str(event_type) + ','
+        algorithm = False
+        if ai_type > 0 and detection == 1:
+            algorithm = True
+        elif (ai_type == 7 and event_type <= 7) or (ai_type == 47 and event_type <= 47) or (detection == 1):
+            algorithm = True
+        if not algorithm:
+            return ',' + str(event_type) + ','
+        event_res = DEVICE_EVENT_TYPE.get(event_type, 0)
+        if event_res > 0:
+            return ',' + str(event_res) + ','
+        event_type = cls.dec_to_bin(event_type)
+        types = cls.get_combo_types(event_type)
+        res = ','.join(types) + ','
+        return ',' + res
 
     @classmethod
     def get_combo_types(cls, event_type):
@@ -196,13 +201,15 @@ class DevicePushService:
         """
         try:
             types = []
-            combo_types = list(DEVICE_EVENT_TYPE.values())
+            combo_types = [51, 57, 58, 60, 59, 61,
+                           62, 63, 64, 65, 66]
             event_type = str(event_type)
             len_type = len(event_type)
             for i in range(0, len_type):
                 e_type = int(event_type[len_type - 1 - i])
                 if e_type == 1:
                     types.append(str(combo_types[i]))
+            LOGGING.info('算法对照打印:{}'.format(combo_types))
             return types
         except Exception as e:
             print('推送错误异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))

+ 2 - 1
Service/HuaweiPushService/HuaweiPushService.py

@@ -105,7 +105,8 @@ class HuaweiPushObject:
             default_sound=True,
             click_action=messaging.AndroidClickAction(
                 action_type=1,
-                intent='intent://com.huawei.codelabpush/deeplink?#Intent;scheme=pushscheme;launchFlags=0x4000000;i.age=180;S.name=abc;end'),
+                intent='intent://com.huawei.codelabpush/deeplink?#Intent;scheme=pushscheme;launchFlags=0x4000000;i.age=180;S.name=abc;end',
+                action='android.intent.action.VIEW'),
             body_loc_key='M.String.body',
             body_loc_args=('boy', 'dog'),
             title_loc_key='M.String.title',