|
@@ -8,10 +8,11 @@ import time
|
|
|
from django.views.generic.base import View
|
|
|
|
|
|
from AnsjerPush.config import BASE_DIR
|
|
|
-from Model.models import UidPushModel, AiService, Device_Info
|
|
|
+from Model.models import UidPushModel, AiService, Device_Info, VodHlsTag, VodHlsTagType
|
|
|
from Object.AiImageObject import ImageProcessingObject
|
|
|
from Object.ETkObject import ETkObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
+from Object.enums.MessageTypeEnum import MessageTypeEnum
|
|
|
from Object.utils import LocalDateTimeUtil
|
|
|
from Object.utils.AmazonRekognitionUtil import AmazonRekognitionUtil
|
|
|
from Service.CommonService import CommonService
|
|
@@ -199,7 +200,7 @@ class AiView(View):
|
|
|
except Exception as e:
|
|
|
logger.info('ai推送消息异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
continue
|
|
|
-
|
|
|
+ AiView.save_cloud_ai_tag(uid, int(n_time), event_type)
|
|
|
week = LocalDateTimeUtil.date_to_week(local_date_time)
|
|
|
EquipmentInfoService.equipment_info_bulk_create(week, eq_list)
|
|
|
return response.json(0)
|
|
@@ -211,3 +212,32 @@ class AiView(View):
|
|
|
'errMsg': repr(e)
|
|
|
}
|
|
|
return response.json(48, data)
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def save_cloud_ai_tag(cls, uid, event_time, types):
|
|
|
+ """
|
|
|
+ 保存云存AI标签
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ types = str(types)
|
|
|
+ if not types:
|
|
|
+ return False
|
|
|
+ n_time = int(time.time())
|
|
|
+ vod_hls_tag = {"uid": uid, "ai_event_time": event_time, "created_time": n_time}
|
|
|
+ vod_tag_vo = VodHlsTag.objects.create(**vod_hls_tag)
|
|
|
+ tag_list = []
|
|
|
+ if len(types) > 1:
|
|
|
+ for i in range(1, len(types) + 1):
|
|
|
+ ai_type = MessageTypeEnum(int(types[i - 1:i]))
|
|
|
+ vod_tag_type_vo = VodHlsTagType(tag_id=vod_tag_vo.id, created_time=n_time, type=ai_type.value)
|
|
|
+ tag_list.append(vod_tag_type_vo)
|
|
|
+ else:
|
|
|
+ ai_type = MessageTypeEnum(int(types))
|
|
|
+ vod_tag_type_vo = {"tag_id": vod_tag_vo.id, "created_time": n_time, "type": ai_type.value}
|
|
|
+ VodHlsTagType.objects.create(**vod_tag_type_vo)
|
|
|
+ if tag_list:
|
|
|
+ VodHlsTagType.objects.bulk_create(tag_list)
|
|
|
+ return True
|
|
|
+ except Exception as e:
|
|
|
+ print('AI标签存储异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return False
|