|
@@ -46,7 +46,7 @@ from Controller.CheckUserData import DataValid
|
|
from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket, StsCrdModel, \
|
|
from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket, StsCrdModel, \
|
|
ExperienceContextModel, Pay_Type, CDKcontextModel, Device_User, SysMassModel, SysMsgModel, UidPushModel, \
|
|
ExperienceContextModel, Pay_Type, CDKcontextModel, Device_User, SysMassModel, SysMsgModel, UidPushModel, \
|
|
Unused_Uid_Meal, UIDMainUser, UserModel, PromotionRuleModel, VideoPlaybackTimeModel, CloudLogModel, CouponModel, \
|
|
Unused_Uid_Meal, UIDMainUser, UserModel, PromotionRuleModel, VideoPlaybackTimeModel, CloudLogModel, CouponModel, \
|
|
- AiStoreMeal, AiService, UidSetModel, Ai_Push_Info, iotdeviceInfoModel
|
|
|
|
|
|
+ AiStoreMeal, AiService, UidSetModel, Ai_Push_Info, iotdeviceInfoModel, AiProcessTime
|
|
from Object.AWS.S3Email import S3Email
|
|
from Object.AWS.S3Email import S3Email
|
|
from Object.AliPayObject import AliPayObject
|
|
from Object.AliPayObject import AliPayObject
|
|
from Object.AliSmsObject import AliSmsObject
|
|
from Object.AliSmsObject import AliSmsObject
|
|
@@ -353,7 +353,6 @@ class AiView(View):
|
|
else:
|
|
else:
|
|
return response.json(0)
|
|
return response.json(0)
|
|
|
|
|
|
-
|
|
|
|
def do_querylist(self, userID, request_dict, response):
|
|
def do_querylist(self, userID, request_dict, response):
|
|
page = request_dict.get('page', None)
|
|
page = request_dict.get('page', None)
|
|
line = request_dict.get('line', None)
|
|
line = request_dict.get('line', None)
|
|
@@ -530,6 +529,7 @@ class AiView(View):
|
|
maxLabels = 50
|
|
maxLabels = 50
|
|
minConfidence = 96
|
|
minConfidence = 96
|
|
|
|
|
|
|
|
+ ai_start_time = int(time.time())
|
|
client = boto3.client(
|
|
client = boto3.client(
|
|
'rekognition',
|
|
'rekognition',
|
|
aws_access_key_id='AKIA2E67UIMD6JD6TN3J',
|
|
aws_access_key_id='AKIA2E67UIMD6JD6TN3J',
|
|
@@ -542,6 +542,7 @@ class AiView(View):
|
|
MinConfidence=minConfidence)
|
|
MinConfidence=minConfidence)
|
|
if rekognition_res['ResponseMetadata']['HTTPStatusCode'] != 200:
|
|
if rekognition_res['ResponseMetadata']['HTTPStatusCode'] != 200:
|
|
return response.json(173)
|
|
return response.json(173)
|
|
|
|
+ ai_end_time = int(time.time())
|
|
labels =rekognition_res['Labels']
|
|
labels =rekognition_res['Labels']
|
|
label_name = []
|
|
label_name = []
|
|
logger.info('--------识别到的标签-------')
|
|
logger.info('--------识别到的标签-------')
|
|
@@ -581,6 +582,8 @@ class AiView(View):
|
|
|
|
|
|
eq_list = []
|
|
eq_list = []
|
|
userID_ids = []
|
|
userID_ids = []
|
|
|
|
+ jpush_start_time = 0
|
|
|
|
+ jpush_end_time = 0
|
|
for up in uid_push_list:
|
|
for up in uid_push_list:
|
|
push_type = up['push_type']
|
|
push_type = up['push_type']
|
|
appBundleId = up['appBundleId']
|
|
appBundleId = up['appBundleId']
|
|
@@ -607,13 +610,17 @@ class AiView(View):
|
|
# 推送消息
|
|
# 推送消息
|
|
if push_type == 0: # ios apns
|
|
if push_type == 0: # ios apns
|
|
logger.info('into-------apns')
|
|
logger.info('into-------apns')
|
|
|
|
+ apns_start_time = int(time.time())
|
|
res = self.do_apns(**kwargs)
|
|
res = self.do_apns(**kwargs)
|
|
|
|
+ apns_end_time = int(time.time())
|
|
logger.info(res)
|
|
logger.info(res)
|
|
# elif push_type == 1: # android gcm
|
|
# elif push_type == 1: # android gcm
|
|
# self.do_fcm(**kwargs)
|
|
# self.do_fcm(**kwargs)
|
|
elif push_type == 2: # android jpush
|
|
elif push_type == 2: # android jpush
|
|
logger.info('into-------jpush')
|
|
logger.info('into-------jpush')
|
|
|
|
+ jpush_start_time = int(time.time())
|
|
res = self.do_jpush(**kwargs)
|
|
res = self.do_jpush(**kwargs)
|
|
|
|
+ jpush_end_time = int(time.time())
|
|
logger.info(res)
|
|
logger.info(res)
|
|
|
|
|
|
# 以下是存库
|
|
# 以下是存库
|
|
@@ -637,12 +644,17 @@ class AiView(View):
|
|
Ai_Push_Info.objects.bulk_create(eq_list)
|
|
Ai_Push_Info.objects.bulk_create(eq_list)
|
|
|
|
|
|
#上传缩略图到s3
|
|
#上传缩略图到s3
|
|
|
|
+ cover_start_time = int(time.time())
|
|
upload_cover_path = "{uid}/{channel}/cover{n_time}.jpg".format(uid=uid, channel=channel, n_time=n_time) #封面图
|
|
upload_cover_path = "{uid}/{channel}/cover{n_time}.jpg".format(uid=uid, channel=channel, n_time=n_time) #封面图
|
|
upload_desc_path = "{uid}/{channel}/desc{n_time}.jpg".format(uid=uid, channel=channel, n_time=n_time) #详情内容图
|
|
upload_desc_path = "{uid}/{channel}/desc{n_time}.jpg".format(uid=uid, channel=channel, n_time=n_time) #详情内容图
|
|
c_res = self.upload_s3(cover, upload_cover_path)
|
|
c_res = self.upload_s3(cover, upload_cover_path)
|
|
d_res = self.upload_s3(desc, upload_desc_path)
|
|
d_res = self.upload_s3(desc, upload_desc_path)
|
|
if c_res and d_res:
|
|
if c_res and d_res:
|
|
logger.info('upload-----S3----success')
|
|
logger.info('upload-----S3----success')
|
|
|
|
+ count_time = int(time.time()) - receiveTime
|
|
|
|
+ AiProcessTime.objects.create(detectTime=n_time, receiveTime=receiveTime, aiTime=ai_start_time,
|
|
|
|
+ aiEndTime=ai_end_time, pushTime=jpush_start_time,
|
|
|
|
+ pushEndTime=jpush_end_time, serverCountTime=count_time)
|
|
return JsonResponse(status=200, data='success', safe=False)
|
|
return JsonResponse(status=200, data='success', safe=False)
|
|
return JsonResponse(status=500, data='fail', safe=False)
|
|
return JsonResponse(status=500, data='fail', safe=False)
|
|
|
|
|