浏览代码

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

peng 1 年之前
父节点
当前提交
8f7a5d01a1
共有 3 个文件被更改,包括 18 次插入5 次删除
  1. 12 3
      Controller/FeedBack.py
  2. 1 0
      Model/models.py
  3. 5 2
      Service/EquipmentInfoService.py

+ 12 - 3
Controller/FeedBack.py

@@ -6,13 +6,15 @@ 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, LOGGER
+from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET
 from Model.models import FeedBackModel, StatResModel, PushInaccurateFeedback
 from Object.AWS.AmazonS3Util import AmazonS3Util
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
+from Object.utils import LocalDateTimeUtil
 from Service.CommonService import CommonService
 from Service.ModelService import ModelService
+from Service.EquipmentInfoService import EquipmentInfoService
 
 
 class FeedBackView(View):
@@ -341,10 +343,16 @@ 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)
-        LOGGER.info('push_inaccurate参数:{}'.format(request_dict))
+
         now_time = int(time.time())
         is_st = int(is_st)
         try:
+            # 默认查询近七天内数据
+            start_time = LocalDateTimeUtil.get_before_days_timestamp(now_time, 7)
+            uid_list = uid.split(',')
+            equipment_info_qs, count = EquipmentInfoService. \
+                union_equipment_info(user_id, uid_list, event_type, start_time, now_time, 1, 10, event_time)
+            identify_type = 1 if equipment_info_qs[0]['event_tag'] else 0
             s3 = AmazonS3Util(
                 aws_access_key_id=ACCESS_KEY_ID,
                 secret_access_key=SECRET_ACCESS_KEY,
@@ -365,7 +373,8 @@ class FeedBackView(View):
                         s3.copy_obj(PUSH_BUCKET, PUSH_INACCURATE_BUCKET, file_path)
             PushInaccurateFeedback.objects.create(equipment_info_id=equipment_info_id, user_id=user_id,
                                                   event_type=event_type, uid=uid, channel=channel,
-                                                  add_time=now_time, tag=tag, is_st=is_st, event_time=event_time)
+                                                  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))

+ 1 - 0
Model/models.py

@@ -925,6 +925,7 @@ class PushInaccurateFeedback(models.Model):
     event_type = models.IntegerField(default=0, verbose_name='事件类型')
     event_time = models.CharField(default='', max_length=16, verbose_name='事件时间')
     is_st = models.SmallIntegerField(default=0, verbose_name='是否多图')  # 1:单图, 3:多图
+    identify_type = models.SmallIntegerField(default=0, verbose_name='AI识别类型')  # 0:云端检测, 1:本地检测
     add_time = models.IntegerField(default=0, verbose_name='添加时间')
     tag = models.CharField(default='', max_length=128, verbose_name='标签')
 

+ 5 - 2
Service/EquipmentInfoService.py

@@ -229,7 +229,7 @@ class EquipmentInfoService:
             return ',' + str(event_type) + ','
 
     @classmethod
-    def union_equipment_info(cls, user_id, uid_list, event_type, start_time, end_time, page, line):
+    def union_equipment_info(cls, user_id, uid_list, event_type, start_time, end_time, page, line, event_time=None):
         """
         联表查询推送数据
         @param user_id:
@@ -239,6 +239,7 @@ class EquipmentInfoService:
         @param end_time:
         @param page:
         @param line:
+        @param event_time:
         @return:
         """
         try:
@@ -265,7 +266,9 @@ class EquipmentInfoService:
                     kwargs['event_tag__regex'] = tags
                 elif tags:
                     kwargs['event_tag__regex'] = tags
-
+            if event_time:
+                kwargs['event_time'] = event_time
+                event_type_kwargs['event_time'] = event_time
             if not event_type_list:
                 # 新增tab_val字段记录表的标识:表编号+10
                 equipment_info_1 = EquipmentInfo1.objects.filter(**kwargs).annotate(tab_val=Value('11', output_field=CharField()))