|
@@ -5,9 +5,10 @@ from django.http import JsonResponse
|
|
|
|
|
|
from Ansjer.config import SERVER_TYPE, LOGGER
|
|
|
from Model.models import Device_Info, UidSetModel, UID_Preview, VoicePromptModel, UID_Bucket, UidChannelSetModel, \
|
|
|
- AiService, CountryModel
|
|
|
+ AiService, CountryModel, CityInformation
|
|
|
from Object.ETkObject import ETkObject
|
|
|
from Service.CommonService import CommonService
|
|
|
+from Object.IPQueryObject import IPQuery
|
|
|
|
|
|
|
|
|
# 更新设备影子
|
|
@@ -31,9 +32,10 @@ def update_device_shadow(request):
|
|
|
'data': {}})
|
|
|
|
|
|
nowTime = int(time.time())
|
|
|
-
|
|
|
+ ip = CommonService.get_ip_address(request)
|
|
|
# 重置按钮
|
|
|
is_reset = request_dict.get('is_reset', None)
|
|
|
+
|
|
|
# 传1则重置设备信息
|
|
|
if is_reset == '1':
|
|
|
LOGGER.info('设备重置: {}'.format(uid))
|
|
@@ -69,12 +71,22 @@ def update_device_shadow(request):
|
|
|
AiService.objects.filter(uid=uid, use_status=1).update(detect_status=0, detect_group='')
|
|
|
LOGGER.info('{}重置成功'.format(uid))
|
|
|
|
|
|
+ # ip变化更新tb_city_information_id
|
|
|
+ uid_set_qs = UidSetModel.objects.filter(uid=uid).values('ip')
|
|
|
+ if uid_set_qs.exists():
|
|
|
+ if ip != uid_set_qs[0]['ip']:
|
|
|
+ ip_qs = IPQuery(ip)
|
|
|
+ district = ip_qs.district
|
|
|
+ city_information_qs = CityInformation.objects.filter(district=district).values('city_id')
|
|
|
+ if city_information_qs.exists():
|
|
|
+ city_id = city_information_qs[0]['city_id']
|
|
|
+ uid_set_qs.updete(tb_city_information_id=city_id)
|
|
|
+
|
|
|
ucode = request_dict.get('ucode', None)
|
|
|
version = request_dict.get('version', None)
|
|
|
p2p_region = request_dict.get('p2p_region', None)
|
|
|
tz = request_dict.get('tz', None)
|
|
|
video_code = request_dict.get('video_code', None)
|
|
|
- ip = CommonService.get_ip_address(request)
|
|
|
channel = request_dict.get('channel', None)
|
|
|
cloud_vod = request_dict.get('cloud_vod', None)
|
|
|
push_status = request_dict.get('push_status', None)
|
|
@@ -136,6 +148,13 @@ def update_device_shadow(request):
|
|
|
qs_dict['tb_country'] = country
|
|
|
LOGGER.info('{} qs_dict: {}'.format(uid, qs_dict))
|
|
|
|
|
|
+ ip_qs = IPQuery(ip)
|
|
|
+ district = ip_qs.district
|
|
|
+ city_information_qs = CityInformation.objects.filter(district=district).values('city_id')
|
|
|
+ if city_information_qs.exists():
|
|
|
+ city_id = city_information_qs[0]['city_id']
|
|
|
+ qs_dict['tb_city_information_id'] = city_id
|
|
|
+
|
|
|
us_qs = UidSetModel.objects.filter(uid=uid)
|
|
|
if us_qs.exists():
|
|
|
if is_alexa and us_qs[0].is_alexa == 0:
|