|
@@ -136,10 +136,9 @@ class GatewayDeviceView(View):
|
|
|
if uid_set_qs.exists():
|
|
|
uid_set_qs.update(nickname=device_name)
|
|
|
if device_info_qs[0].Type == 201:
|
|
|
- device_info_qs = device_info_qs.values('userID__region_country', 'serial_number')
|
|
|
- region = device_info_qs[0]['userID__region_country']
|
|
|
+ device_info_qs = device_info_qs.values('serial_number')
|
|
|
cls.update_socket(serial_number=device_info_qs[0]['serial_number'], device_name=device_name,
|
|
|
- user_id=user_id, region=region)
|
|
|
+ user_id=user_id)
|
|
|
return response.json(0)
|
|
|
|
|
|
@classmethod
|
|
@@ -587,16 +586,21 @@ class GatewayDeviceView(View):
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
@classmethod
|
|
|
- def update_socket(cls, serial_number, device_name, user_id, region):
|
|
|
+ def update_socket(cls, serial_number, device_name, user_id):
|
|
|
url = 'https://www.zositech.xyz/deviceStatus/addOrUpdateSwitch'
|
|
|
try:
|
|
|
- country_qs = CountryModel.objects.filter(id=region).values('region__continent_code')
|
|
|
+ region_id = CommonService.confirm_region_id()
|
|
|
data = {
|
|
|
'nick_name': device_name,
|
|
|
'serial_number': serial_number,
|
|
|
'user_id': user_id,
|
|
|
- 'region': country_qs[0]['region__continent_code'] if country_qs.exists() else 'EN'
|
|
|
}
|
|
|
+ if region_id == 3:
|
|
|
+ data['region'] = 'US'
|
|
|
+ elif region_id == 4:
|
|
|
+ data['region'] = 'EU'
|
|
|
+ elif region_id == 5:
|
|
|
+ data['region'] = 'CN'
|
|
|
requests.post(url=url, data=data, timeout=5)
|
|
|
except Exception as e:
|
|
|
print(repr(e))
|