|
@@ -89,6 +89,7 @@ class DetectControllerViewV2(View):
|
|
tz = request_dict.get('tz', '0')
|
|
tz = request_dict.get('tz', '0')
|
|
company_secrete = request_dict.get('company_secrete', None)
|
|
company_secrete = request_dict.get('company_secrete', None)
|
|
region = request_dict.get('region', None) # app必须传:2:国内 1:国外
|
|
region = request_dict.get('region', None) # app必须传:2:国内 1:国外
|
|
|
|
+ electricity_status = request_dict.get('electricity_status', None)
|
|
if not region:
|
|
if not region:
|
|
return response.json(444, 'region')
|
|
return response.json(444, 'region')
|
|
region = int(region)
|
|
region = int(region)
|
|
@@ -101,8 +102,8 @@ class DetectControllerViewV2(View):
|
|
tz = tz.replace("GMT", "")
|
|
tz = tz.replace("GMT", "")
|
|
detect_group = request_dict.get('detect_group', None)
|
|
detect_group = request_dict.get('detect_group', None)
|
|
interval = request_dict.get('interval', None)
|
|
interval = request_dict.get('interval', None)
|
|
- if not status:
|
|
|
|
- return response.json(444, 'status')
|
|
|
|
|
|
+ if not status and not electricity_status:
|
|
|
|
+ return response.json(444, 'status and electricity_status')
|
|
if not company_secrete:
|
|
if not company_secrete:
|
|
return response.json(444, 'company_secrete')
|
|
return response.json(444, 'company_secrete')
|
|
company = CompanyModel.objects.filter(secret=company_secrete)
|
|
company = CompanyModel.objects.filter(secret=company_secrete)
|
|
@@ -126,7 +127,6 @@ class DetectControllerViewV2(View):
|
|
else:
|
|
else:
|
|
return response.json(173)
|
|
return response.json(173)
|
|
dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
|
|
dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
|
|
- status = int(status)
|
|
|
|
# 获取用户区域
|
|
# 获取用户区域
|
|
# ip = self.ip
|
|
# ip = self.ip
|
|
# ipInfo = CommonService.getIpIpInfo(ip=ip, lang='EN')
|
|
# ipInfo = CommonService.getIpIpInfo(ip=ip, lang='EN')
|
|
@@ -139,16 +139,18 @@ class DetectControllerViewV2(View):
|
|
nowTime = int(time.time())
|
|
nowTime = int(time.time())
|
|
if dvqs.exists():
|
|
if dvqs.exists():
|
|
# 修改状态
|
|
# 修改状态
|
|
- dvqs.update(NotificationMode=status)
|
|
|
|
|
|
+ if status:
|
|
|
|
+ dvqs.update(NotificationMode=int(status))
|
|
uid_set_qs = UidSetModel.objects.filter(uid=uid)
|
|
uid_set_qs = UidSetModel.objects.filter(uid=uid)
|
|
# 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 = {
|
|
- 'detect_status': status,
|
|
|
|
'updTime': nowTime,
|
|
'updTime': nowTime,
|
|
}
|
|
}
|
|
|
|
+ if status:
|
|
|
|
+ qs_data['detect_status'] = int(status)
|
|
if interval:
|
|
if interval:
|
|
qs_data['detect_interval'] = int(interval)
|
|
qs_data['detect_interval'] = int(interval)
|
|
if detect_group:
|
|
if detect_group:
|
|
@@ -161,8 +163,9 @@ class DetectControllerViewV2(View):
|
|
'uid': uid,
|
|
'uid': uid,
|
|
'addTime': nowTime,
|
|
'addTime': nowTime,
|
|
'updTime': nowTime,
|
|
'updTime': nowTime,
|
|
- 'detect_status': status,
|
|
|
|
}
|
|
}
|
|
|
|
+ if status:
|
|
|
|
+ qs_data['detect_status'] = int(status)
|
|
if interval:
|
|
if interval:
|
|
qs_data['detect_interval'] = int(interval)
|
|
qs_data['detect_interval'] = int(interval)
|
|
if detect_group:
|
|
if detect_group:
|
|
@@ -172,6 +175,25 @@ class DetectControllerViewV2(View):
|
|
|
|
|
|
uid_set_id = uid_set_qs.id
|
|
uid_set_id = uid_set_qs.id
|
|
|
|
|
|
|
|
+ # 初始化UidPushModel推送表
|
|
|
|
+ if electricity_status:
|
|
|
|
+ uid_push_create_dict = {
|
|
|
|
+ 'uid_set_id': uid_set_id,
|
|
|
|
+ 'userID_id': userID,
|
|
|
|
+ 'appBundleId': appBundleId,
|
|
|
|
+ 'app_type': app_type,
|
|
|
|
+ 'push_type': push_type,
|
|
|
|
+ 'token_val': token_val,
|
|
|
|
+ 'm_code': m_code,
|
|
|
|
+ 'addTime': nowTime,
|
|
|
|
+ 'updTime': nowTime,
|
|
|
|
+ 'lang': lang,
|
|
|
|
+ 'tz': tz
|
|
|
|
+ }
|
|
|
|
+ # 绑定设备推送
|
|
|
|
+ UidPushModel.objects.create(**uid_push_create_dict)
|
|
|
|
+ return response.json(0)
|
|
|
|
+
|
|
if status == 0:
|
|
if status == 0:
|
|
# 状态为0的时候删除redis缓存数据
|
|
# 状态为0的时候删除redis缓存数据
|
|
self.do_delete_redis(uid)
|
|
self.do_delete_redis(uid)
|