|
@@ -213,9 +213,23 @@ class EquipmentManagerV3(View):
|
|
|
us_qs = UidSetModel.objects.filter(uid=UID)
|
|
|
|
|
|
if us_qs.exists() and us_qs[0].is_alexa == 1:
|
|
|
- asy = threading.Thread(target=ModelService.notify_alexa_add,
|
|
|
- args=(UID, userID, NickName, encrypt_pass))
|
|
|
- asy.start()
|
|
|
+ if us_qs[0].channel > 1:
|
|
|
+ data_list = []
|
|
|
+ uid_channel_set_qs = UidChannelSetModel.objects.filter(uid_id=us_qs[0].id).\
|
|
|
+ values('channel', 'channel_name')
|
|
|
+ if uid_channel_set_qs.exists():
|
|
|
+ # 多通道设备名为 UidChannelSetModel 的 channel_name
|
|
|
+ for uid_channel_set in uid_channel_set_qs:
|
|
|
+ data_list.append({'userID': userID, 'UID': UID, 'uid_nick': uid_channel_set['channel_name'],
|
|
|
+ 'channel': uid_channel_set['channel'], 'password': encrypt_pass})
|
|
|
+ else:
|
|
|
+ data_list = [{'userID': userID, 'UID': UID, 'uid_nick': NickName, 'password': encrypt_pass}]
|
|
|
+
|
|
|
+ # 请求Alexa服务器更新事件网关
|
|
|
+ data_list = json.dumps(data_list)
|
|
|
+ data = {'data_list': data_list}
|
|
|
+ url = 'https://www.zositech.xyz/deviceStatus/addOrUpdateV2'
|
|
|
+ requests.post(url, data=data, timeout=2)
|
|
|
|
|
|
except Exception as e:
|
|
|
return response.json(10, repr(e))
|
|
@@ -241,7 +255,6 @@ class EquipmentManagerV3(View):
|
|
|
'endpoint': iotqs[0].endpoint,
|
|
|
'token_iot_number': iotqs[0].endpoint
|
|
|
}
|
|
|
-
|
|
|
return response.json(0, res)
|
|
|
|
|
|
|
|
@@ -258,10 +271,8 @@ class EquipmentManagerV3(View):
|
|
|
userID = tko.userID
|
|
|
if userID is None:
|
|
|
return response.json(309)
|
|
|
- deviceData = None
|
|
|
- dev_info_qs = None
|
|
|
+
|
|
|
try:
|
|
|
- # deviceData = json.loads(deviceContent)
|
|
|
deviceData = eval(deviceContent)
|
|
|
if deviceData.__contains__('userID_id'):
|
|
|
asy = threading.Thread(target=ModelService.update_log,
|
|
@@ -306,12 +317,16 @@ class EquipmentManagerV3(View):
|
|
|
UidSetModel.objects.create(**uid_set_create_dict)
|
|
|
di_qs = Device_Info.objects.filter(UID=uid)
|
|
|
di_qs.update(NickName=nickname)
|
|
|
+
|
|
|
if deviceData is not None and deviceData.__contains__('NickName') and us_qs[0].is_alexa == 1:
|
|
|
+ # 请求Alexa服务器更新事件网关
|
|
|
+ url = 'https://www.zositech.xyz/deviceStatus/addOrUpdateV2'
|
|
|
password = encrypt_pwd if deviceData.__contains__('View_Password') else ''
|
|
|
- asy = threading.Thread(target=ModelService.notify_alexa_add, args=(uid, userID, nickname, password))
|
|
|
- asy.start()
|
|
|
- # redisObj = RedisObject(db=8)
|
|
|
- # redisObj.del_data(key='uid_qs_' + userID)
|
|
|
+ data_list = [{'userID': userID, 'UID': uid, 'uid_nick': nickname, 'password': password}]
|
|
|
+ data_list = json.dumps(data_list)
|
|
|
+ data = {'data_list': data_list}
|
|
|
+ requests.post(url, data=data, timeout=2)
|
|
|
+
|
|
|
return response.json(0, res)
|
|
|
|
|
|
# 编辑通道名
|