Browse Source

AI识别反馈增加识别来源字段

peng 1 year ago
parent
commit
8edb66301f
2 changed files with 17 additions and 5 deletions
  1. 15 5
      Controller/FeedBack.py
  2. 2 0
      Service/EquipmentInfoService.py

+ 15 - 5
Controller/FeedBack.py

@@ -1,4 +1,5 @@
 import json
+import threading
 import time
 
 import oss2
@@ -6,7 +7,7 @@ from django.db import transaction
 from django.views.generic.base import View
 
 from Ansjer.config import ACCESS_KEY_ID, SECRET_ACCESS_KEY, REGION_NAME, PUSH_BUCKET, PUSH_INACCURATE_BUCKET
-from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET
+from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, LOGGER
 from Model.models import FeedBackModel, StatResModel, PushInaccurateFeedback
 from Object.AWS.AmazonS3Util import AmazonS3Util
 from Object.ResponseObject import ResponseObject
@@ -343,11 +344,21 @@ class FeedBackView(View):
         tag = request_dict.get('tag', '')
         if not all([equipment_info_id, uid, is_st, event_type, event_time, channel]):
             return response.json(444)
+        try:
+            thread = threading.Thread(target=FeedBackView.asyn_push_inaccurate,
+                                      args=(
+                                          equipment_info_id, uid, channel, user_id, event_type, event_time, int(is_st),
+                                          tag,))
+            thread.start()
+            return response.json(0)
+        except Exception as e:
+            return response.json(500, repr(e))
 
-        now_time = int(time.time())
-        is_st = int(is_st)
+    @staticmethod
+    def asyn_push_inaccurate(equipment_info_id, uid, channel, user_id, event_type, event_time, is_st, tag):
         try:
             # 默认查询近七天内数据
+            now_time = int(time.time())
             start_time = LocalDateTimeUtil.get_before_days_timestamp(now_time, 7)
             uid_list = uid.split(',')
             equipment_info_qs, count = EquipmentInfoService. \
@@ -375,6 +386,5 @@ class FeedBackView(View):
                                                   event_type=event_type, uid=uid, channel=channel,
                                                   add_time=now_time, tag=tag, is_st=is_st, event_time=event_time,
                                                   identify_type=identify_type)
-            return response.json(0)
         except Exception as e:
-            return response.json(500, repr(e))
+            LOGGER.info('asyn_push_inaccurate, errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))

+ 2 - 0
Service/EquipmentInfoService.py

@@ -269,6 +269,8 @@ class EquipmentInfoService:
             if event_time:
                 kwargs['event_time'] = event_time
                 event_type_kwargs['event_time'] = event_time
+                del kwargs['event_tag__regex']
+                del event_type_kwargs['event_tag']
             if not event_type_list:
                 # 新增tab_val字段记录表的标识:表编号+10
                 equipment_info_1 = EquipmentInfo1.objects.filter(**kwargs).annotate(tab_val=Value('11', output_field=CharField()))