|
@@ -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
|
|
@@ -114,6 +114,8 @@ class AiView(View):
|
|
return self.deleteInfo(userID, request_dict, response)
|
|
return self.deleteInfo(userID, request_dict, response)
|
|
elif operation == 'queryorderlist': # 查询订单
|
|
elif operation == 'queryorderlist': # 查询订单
|
|
return self.do_querylist(userID, request_dict, response)
|
|
return self.do_querylist(userID, request_dict, response)
|
|
|
|
+ elif operation == 'updateJpushTime': # 查询订单
|
|
|
|
+ return self.update_jpush_time(userID, request_dict, response)
|
|
else:
|
|
else:
|
|
return response.json(414)
|
|
return response.json(414)
|
|
|
|
|
|
@@ -458,6 +460,11 @@ class AiView(View):
|
|
return response.json(0, {"orderID": orderID})
|
|
return response.json(0, {"orderID": orderID})
|
|
return response.json(10, 'generate_order_false')
|
|
return response.json(10, 'generate_order_false')
|
|
|
|
|
|
|
|
+ def update_jpush_time(self,userID, request_dict, response):
|
|
|
|
+ msg_id = request_dict.get('msg_id', None)
|
|
|
|
+ apns_push_time = request_dict.get('apns_push_time', None)
|
|
|
|
+ AiProcessTime.objects.filter(msg_id=msg_id).update(appPushTime=apns_push_time)
|
|
|
|
+ return response.json(0)
|
|
|
|
|
|
def do_ai_identification(self, request_dict,response):
|
|
def do_ai_identification(self, request_dict,response):
|
|
etk = request_dict.get('etk', None)
|
|
etk = request_dict.get('etk', None)
|
|
@@ -582,8 +589,8 @@ class AiView(View):
|
|
|
|
|
|
eq_list = []
|
|
eq_list = []
|
|
userID_ids = []
|
|
userID_ids = []
|
|
- jpush_start_time = 0
|
|
|
|
- jpush_end_time = 0
|
|
|
|
|
|
+ apns_start_time = 0
|
|
|
|
+ apns_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']
|
|
@@ -596,7 +603,8 @@ class AiView(View):
|
|
# 推送标题
|
|
# 推送标题
|
|
msg_title = self.get_msg_title(appBundleId=appBundleId, nickname=nickname)
|
|
msg_title = self.get_msg_title(appBundleId=appBundleId, nickname=nickname)
|
|
# 推送内容
|
|
# 推送内容
|
|
- msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz, label_list=label_list)
|
|
|
|
|
|
+ msg_id = CommonService.createOrderID()
|
|
|
|
+ msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz, label_list=label_list, msg_id = msg_id)
|
|
kwargs = {
|
|
kwargs = {
|
|
'uid': uid,
|
|
'uid': uid,
|
|
'channel': channel,
|
|
'channel': channel,
|
|
@@ -652,9 +660,9 @@ class AiView(View):
|
|
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
|
|
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)
|
|
|
|
|
|
+ AiProcessTime.objects.create(detectTime=n_time, receiveTime=receiveTime, aiTime=ai_start_time,
|
|
|
|
+ aiEndTime=ai_end_time, pushTime=apns_start_time,
|
|
|
|
+ pushEndTime=apns_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)
|
|
|
|
|
|
@@ -750,7 +758,7 @@ class AiView(View):
|
|
print(res)
|
|
print(res)
|
|
return res.status_code
|
|
return res.status_code
|
|
|
|
|
|
- def do_fcm(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title, msg_text):
|
|
|
|
|
|
+ def do_fcm(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title, msg_text, msg_id=0):
|
|
try:
|
|
try:
|
|
serverKey = FCM_CONFIG[appBundleId]
|
|
serverKey = FCM_CONFIG[appBundleId]
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -769,7 +777,7 @@ class AiView(View):
|
|
print(result)
|
|
print(result)
|
|
return result
|
|
return result
|
|
|
|
|
|
- def do_apns(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title, msg_text):
|
|
|
|
|
|
+ def do_apns(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title, msg_text, msg_id=0):
|
|
logger = logging.getLogger('info')
|
|
logger = logging.getLogger('info')
|
|
logger.info("进来do_apns函数了")
|
|
logger.info("进来do_apns函数了")
|
|
logger.info(token_val)
|
|
logger.info(token_val)
|
|
@@ -778,7 +786,7 @@ class AiView(View):
|
|
try:
|
|
try:
|
|
cli = apns2.APNSClient(mode=APNS_MODE, client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
|
|
cli = apns2.APNSClient(mode=APNS_MODE, client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
|
|
push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
|
|
push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
|
|
- "received_at": n_time, "sound": "", "uid": uid, "zpush": "1", "channel": channel}
|
|
|
|
|
|
+ "received_at": n_time, "sound": "", "uid": uid, "zpush": "1", "channel": channel, "msg_id": msg_id}
|
|
alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
|
|
alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
|
|
payload = apns2.Payload(alert=alert, custom=push_data, sound="default")
|
|
payload = apns2.Payload(alert=alert, custom=push_data, sound="default")
|
|
n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|
|
n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|