Преглед на файлове

优化算法事件与普通事件类型冲突问题

zhangdongming преди 2 години
родител
ревизия
01825b62d2
променени са 3 файла, в които са добавени 21 реда и са изтрити 14 реда
  1. 1 1
      Controller/DetectController.py
  2. 3 1
      Controller/DetectControllerV2.py
  3. 17 12
      Service/DevicePushService.py

+ 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,
-                      'dealings_type': int(dealings_type)}
+                      'dealings_type': int(dealings_type), 'detection': detection}
             logger.info('已创建s3对象,推送数据为:{}'.format(params))
             # APP消息推送与获取报警消息数据列表
             result = DevicePushService.save_msg_push(uid_set_push_list, **params)

+ 17 - 12
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']
@@ -168,19 +168,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 or event_type == 47:
+            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):