|
@@ -1,9 +1,9 @@
|
|
|
-import logging
|
|
|
+import json
|
|
|
import time
|
|
|
|
|
|
from django.http import JsonResponse
|
|
|
|
|
|
-from Ansjer.config import SERVER_TYPE
|
|
|
+from Ansjer.config import SERVER_TYPE, LOGGER
|
|
|
from Model.models import Device_Info, UidSetModel, UID_Preview, VoicePromptModel, UID_Bucket, UidChannelSetModel, \
|
|
|
AiService, CountryModel
|
|
|
from Object.ETkObject import ETkObject
|
|
@@ -19,16 +19,16 @@ def update_device_shadow(request):
|
|
|
request_dict = request.GET
|
|
|
else:
|
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
|
|
|
-
|
|
|
- logger = logging.getLogger('info')
|
|
|
- logger.info('---更新设备影子---, 使用配置:{}, 参数:{}'.format(SERVER_TYPE, request_dict.dict()))
|
|
|
+ LOGGER.info('---更新设备影子---,使用配置:{}, 参数:{}'.format(SERVER_TYPE,
|
|
|
+ json.dumps(request_dict.dict())))
|
|
|
|
|
|
try:
|
|
|
etk = request_dict.get('etk', None)
|
|
|
eto = ETkObject(etk)
|
|
|
uid = eto.uid
|
|
|
if not uid:
|
|
|
- return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
|
|
|
+ return JsonResponse(status=200, data={'code': 400001, 'msg': 'The UID length or format is incorrect.',
|
|
|
+ 'data': {}})
|
|
|
|
|
|
nowTime = int(time.time())
|
|
|
|
|
@@ -36,7 +36,7 @@ def update_device_shadow(request):
|
|
|
is_reset = request_dict.get('is_reset', None)
|
|
|
# 传1则重置设备信息
|
|
|
if is_reset == '1':
|
|
|
- logger.info('设备重置: {}'.format(uid))
|
|
|
+ LOGGER.info('设备重置: {}'.format(uid))
|
|
|
|
|
|
# 重置语音提示
|
|
|
uid_channel_qs = UidChannelSetModel.objects.filter(uid__uid=uid)
|
|
@@ -67,7 +67,7 @@ def update_device_shadow(request):
|
|
|
|
|
|
# 关闭AI
|
|
|
AiService.objects.filter(uid=uid, use_status=1).update(detect_status=0, detect_group='')
|
|
|
- logger.info('{}重置成功'.format(uid))
|
|
|
+ LOGGER.info('{}重置成功'.format(uid))
|
|
|
|
|
|
ucode = request_dict.get('ucode', None)
|
|
|
version = request_dict.get('version', None)
|
|
@@ -134,7 +134,7 @@ def update_device_shadow(request):
|
|
|
if country_qs.exists():
|
|
|
country = country_qs[0]['id']
|
|
|
qs_dict['tb_country'] = country
|
|
|
- logger.info('{} qs_dict: {}'.format(uid, qs_dict))
|
|
|
+ LOGGER.info('{} qs_dict: {}'.format(uid, qs_dict))
|
|
|
|
|
|
us_qs = UidSetModel.objects.filter(uid=uid)
|
|
|
if us_qs.exists():
|
|
@@ -148,8 +148,8 @@ def update_device_shadow(request):
|
|
|
qs_dict['uid'] = uid
|
|
|
qs_dict['addTime'] = nowTime
|
|
|
UidSetModel.objects.create(**qs_dict)
|
|
|
- logger.info('***设备影子保存成功{}'.format(uid))
|
|
|
+ LOGGER.info('***设备影子保存成功{}'.format(uid))
|
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
|
|
|
except Exception as e:
|
|
|
- logger.info('更新设备影子异常: {}'.format(repr(e)))
|
|
|
- return JsonResponse(status=200, data={'code': 0, 'update_shadow_error': repr(e)})
|
|
|
+ LOGGER.info('更新设备影子异常: {}'.format(repr(e)))
|
|
|
+ return JsonResponse(status=200, data={'code': 1000001, 'update_shadow_error': repr(e)})
|