|
@@ -105,7 +105,6 @@ class EquipmentManagerV3(View):
|
|
View_Account = request_dict.get('View_Account', None)
|
|
View_Account = request_dict.get('View_Account', None)
|
|
View_Password = request_dict.get('View_Password', '')
|
|
View_Password = request_dict.get('View_Password', '')
|
|
encrypt_pass = View_Password
|
|
encrypt_pass = View_Password
|
|
- print("准备解密")
|
|
|
|
Type = request_dict.get('Type', None)
|
|
Type = request_dict.get('Type', None)
|
|
ChannelIndex = request_dict.get('ChannelIndex', None)
|
|
ChannelIndex = request_dict.get('ChannelIndex', None)
|
|
version = request_dict.get('version', '')
|
|
version = request_dict.get('version', '')
|
|
@@ -215,16 +214,28 @@ class EquipmentManagerV3(View):
|
|
res['isMainUserExists'] = 1
|
|
res['isMainUserExists'] = 1
|
|
return response.json(0, res)
|
|
return response.json(0, res)
|
|
|
|
|
|
|
|
+ # 日志数据
|
|
|
|
+ nowTime = int(time.time())
|
|
|
|
+ ip = CommonService.get_ip_address(request)
|
|
|
|
+ content = json.loads(json.dumps(request_dict))
|
|
|
|
+ log = {
|
|
|
|
+ 'ip': ip,
|
|
|
|
+ 'user_id': 1,
|
|
|
|
+ 'status': 200,
|
|
|
|
+ 'time': nowTime,
|
|
|
|
+ 'content': json.dumps(content),
|
|
|
|
+ 'url': 'v3/equipment/add',
|
|
|
|
+ 'operation': '{}添加{}成功'.format(userID, UID)
|
|
|
|
+ }
|
|
|
|
+
|
|
try:
|
|
try:
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
# 判断是否有用户绑定
|
|
# 判断是否有用户绑定
|
|
- nowTime = int(time.time())
|
|
|
|
us_qs = UidSetModel.objects.filter(uid=UID)
|
|
us_qs = UidSetModel.objects.filter(uid=UID)
|
|
if us_qs.exists():
|
|
if us_qs.exists():
|
|
us_qs.update(nickname=NickName, device_type=Type)
|
|
us_qs.update(nickname=NickName, device_type=Type)
|
|
UidSet_id = us_qs.first().id
|
|
UidSet_id = us_qs.first().id
|
|
else:
|
|
else:
|
|
- ip = CommonService.get_ip_address(request)
|
|
|
|
ipInfo = CommonService.getIpIpInfo(ip, 'CN')
|
|
ipInfo = CommonService.getIpIpInfo(ip, 'CN')
|
|
country_qs = CountryModel.objects.filter(country_code=ipInfo['country_code']).values('id')
|
|
country_qs = CountryModel.objects.filter(country_code=ipInfo['country_code']).values('id')
|
|
country = country_qs.exists() if country_qs[0]['id'] else 0
|
|
country = country_qs.exists() if country_qs[0]['id'] else 0
|
|
@@ -234,7 +245,7 @@ class EquipmentManagerV3(View):
|
|
'uid': UID,
|
|
'uid': UID,
|
|
'addTime': nowTime,
|
|
'addTime': nowTime,
|
|
'updTime': nowTime,
|
|
'updTime': nowTime,
|
|
- 'ip': CommonService.get_ip_address(request_dict),
|
|
|
|
|
|
+ 'ip': ip,
|
|
'channel': ChannelIndex,
|
|
'channel': ChannelIndex,
|
|
'nickname': NickName,
|
|
'nickname': NickName,
|
|
'version': version,
|
|
'version': version,
|
|
@@ -329,19 +340,16 @@ class EquipmentManagerV3(View):
|
|
data = {'data_list': data_list}
|
|
data = {'data_list': data_list}
|
|
url = 'https://www.zositech.xyz/deviceStatus/addOrUpdateV2'
|
|
url = 'https://www.zositech.xyz/deviceStatus/addOrUpdateV2'
|
|
requests.post(url, data=data, timeout=2)
|
|
requests.post(url, data=data, timeout=2)
|
|
- content = json.loads(json.dumps(request_dict))
|
|
|
|
- log = {
|
|
|
|
- 'ip': ip,
|
|
|
|
- 'user_id': 1,
|
|
|
|
- 'status': 200,
|
|
|
|
- 'time': nowTime,
|
|
|
|
- 'content': json.dumps(content),
|
|
|
|
- 'url': 'v3/equipment/add',
|
|
|
|
- 'operation': '{}添加设备,uid:{}'.format(userID, UID),
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ # 记录添加日志
|
|
LogModel.objects.create(**log)
|
|
LogModel.objects.create(**log)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- return response.json(10, repr(e))
|
|
|
|
|
|
+ # 记录添加失败日志
|
|
|
|
+ error_msg = 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e))
|
|
|
|
+ operation = '{}添加{}失败:{}'.format(userID, UID, error_msg)
|
|
|
|
+ log['operation'] = operation
|
|
|
|
+ LogModel.objects.create(**log)
|
|
|
|
+ return response.json(10, error_msg)
|
|
else:
|
|
else:
|
|
dvqs = Device_Info.objects.filter(id=id).values('id', 'userID', 'NickName', 'UID',
|
|
dvqs = Device_Info.objects.filter(id=id).values('id', 'userID', 'NickName', 'UID',
|
|
'View_Account',
|
|
'View_Account',
|