|
@@ -151,9 +151,8 @@ class AiView(View):
|
|
# 关闭推送
|
|
# 关闭推送
|
|
if not all([appBundleId, app_type, token_val, uid, m_code]):
|
|
if not all([appBundleId, app_type, token_val, uid, m_code]):
|
|
return response.json(444, 'appBundleId,app_type,token_val,uid,m_code')
|
|
return response.json(444, 'appBundleId,app_type,token_val,uid,m_code')
|
|
- # 判断推送类型对应key是否存在
|
|
|
|
- print('push_type:', push_type)
|
|
|
|
|
|
|
|
|
|
+ # 判断推送类型对应key是否存在
|
|
if push_type == '0':
|
|
if push_type == '0':
|
|
if appBundleId not in APNS_CONFIG.keys():
|
|
if appBundleId not in APNS_CONFIG.keys():
|
|
return response.json(904)
|
|
return response.json(904)
|
|
@@ -165,27 +164,26 @@ class AiView(View):
|
|
return response.json(904)
|
|
return response.json(904)
|
|
else:
|
|
else:
|
|
return response.json(173)
|
|
return response.json(173)
|
|
- hasAiService = AiService.objects.filter(uid=uid,use_status=1)
|
|
|
|
- if not hasAiService.exists():
|
|
|
|
- return response.json(10053)
|
|
|
|
- nowTime = int(time.time())
|
|
|
|
- endTime = hasAiService.values('endTime')[0]['endTime']
|
|
|
|
- if nowTime >endTime:
|
|
|
|
- return response.json(10054)
|
|
|
|
- dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
|
|
|
|
- status = int(status)
|
|
|
|
- nowTime = int(time.time())
|
|
|
|
- if dvqs.exists():
|
|
|
|
- # 修改状态
|
|
|
|
- # dvqs.update(NotificationMode=status)
|
|
|
|
- uid_set_qs = UidSetModel.objects.filter(uid=uid)
|
|
|
|
- # uid配置信息是否存在
|
|
|
|
|
|
|
|
|
|
+ try:
|
|
|
|
+ hasAiService = AiService.objects.filter(uid=uid, use_status=1)
|
|
|
|
+ if not hasAiService.exists():
|
|
|
|
+ return response.json(10053)
|
|
|
|
+ nowTime = int(time.time())
|
|
|
|
+ endTime = hasAiService.values('endTime')[0]['endTime']
|
|
|
|
+ if nowTime > endTime:
|
|
|
|
+ return response.json(10054)
|
|
|
|
+
|
|
|
|
+ dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
|
|
|
|
+ status = int(status)
|
|
|
|
+ nowTime = int(time.time())
|
|
|
|
+ if not dvqs.exists():
|
|
|
|
+ return response.json(14)
|
|
|
|
+ uid_set_qs = UidSetModel.objects.filter(uid=uid)
|
|
if uid_set_qs.exists():
|
|
if uid_set_qs.exists():
|
|
uid_set_id = uid_set_qs[0].id
|
|
uid_set_id = uid_set_qs[0].id
|
|
qs_data = {
|
|
qs_data = {
|
|
'updTime': nowTime,
|
|
'updTime': nowTime,
|
|
-
|
|
|
|
}
|
|
}
|
|
if interval:
|
|
if interval:
|
|
qs_data['detect_interval'] = int(interval)
|
|
qs_data['detect_interval'] = int(interval)
|
|
@@ -248,19 +246,9 @@ class AiView(View):
|
|
# 绑定设备推送
|
|
# 绑定设备推送
|
|
UidPushModel.objects.create(**uid_push_create_dict)
|
|
UidPushModel.objects.create(**uid_push_create_dict)
|
|
|
|
|
|
- # if interval:
|
|
|
|
- # self.do_delete_redis(uid, int(interval))
|
|
|
|
- # else:
|
|
|
|
- # self.do_delete_redis(uid)
|
|
|
|
- # utko = UidTokenObject()
|
|
|
|
- # # right
|
|
|
|
- # utko.generate(data={'uid': uid})
|
|
|
|
etkObj = ETkObject(etk='')
|
|
etkObj = ETkObject(etk='')
|
|
etk = etkObj.encrypt(uid)
|
|
etk = etkObj.encrypt(uid)
|
|
|
|
|
|
- #只返回一个接口就行
|
|
|
|
- # detectUrl = "{DETECT_PUSH_DOMAIN}AiService/push?etk={etk}&endTime={endTime}". \
|
|
|
|
- # format(etk=etk, DETECT_PUSH_DOMAIN=SERVER_DOMAIN_SSL, endTime=endTime)
|
|
|
|
aiIdentificationUrl = "{DETECT_PUSH_DOMAIN}AiService/identification".format(DETECT_PUSH_DOMAIN=SERVER_DOMAIN_SSL)
|
|
aiIdentificationUrl = "{DETECT_PUSH_DOMAIN}AiService/identification".format(DETECT_PUSH_DOMAIN=SERVER_DOMAIN_SSL)
|
|
|
|
|
|
# mqtt通知设备开启AI识别功能
|
|
# mqtt通知设备开启AI识别功能
|
|
@@ -276,8 +264,9 @@ class AiView(View):
|
|
if not req_success:
|
|
if not req_success:
|
|
return response.json(10044)
|
|
return response.json(10044)
|
|
return response.json(0, {'aiIdentificationUrl': aiIdentificationUrl, 'endTime': endTime, 'etk': etk})
|
|
return response.json(0, {'aiIdentificationUrl': aiIdentificationUrl, 'endTime': endTime, 'etk': etk})
|
|
- else:
|
|
|
|
- return response.json(14)
|
|
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
|
|
+ return response.json(500, repr(e))
|
|
|
|
|
|
def getAiStatus(self, userID, request_dict, response):
|
|
def getAiStatus(self, userID, request_dict, response):
|
|
uid = request_dict.get('uid', None)
|
|
uid = request_dict.get('uid', None)
|