|
@@ -38,29 +38,29 @@ class EquipmentManagerV3(View):
|
|
token = request_dict.get('token', None)
|
|
token = request_dict.get('token', None)
|
|
# 设备主键uid
|
|
# 设备主键uid
|
|
tko = TokenObject(token)
|
|
tko = TokenObject(token)
|
|
- if tko.code == 0:
|
|
|
|
- response.lang = tko.lang
|
|
|
|
- userID = tko.userID
|
|
|
|
- # 手机端添加设备,查询,修改
|
|
|
|
- if operation == 'add':
|
|
|
|
- return self.do_add(userID, request_dict, response, request)
|
|
|
|
- elif operation == 'query':
|
|
|
|
- return self.do_query(userID, request_dict, response)
|
|
|
|
- elif operation == 'modify':
|
|
|
|
- return self.do_modify(userID, request_dict, response, request)
|
|
|
|
- elif operation == 'fuzzyQuery':
|
|
|
|
- return self.do_fuzzy_query(userID, request_dict, response)
|
|
|
|
- elif operation == 'mainUserDevice':
|
|
|
|
- return self.do_mainUserDevice( request_dict, response)
|
|
|
|
- elif operation == 'getDeviceFeatures':
|
|
|
|
- return self.do_get_device_features(request_dict, response)
|
|
|
|
- else:
|
|
|
|
- return response.json(414)
|
|
|
|
- else:
|
|
|
|
|
|
+ if tko.code != 0:
|
|
return response.json(tko.code)
|
|
return response.json(tko.code)
|
|
|
|
+ response.lang = tko.lang
|
|
|
|
+ userID = tko.userID
|
|
|
|
+ # 手机端添加设备,查询,修改
|
|
|
|
+ if operation == 'add':
|
|
|
|
+ return self.do_add(userID, request_dict, response, request)
|
|
|
|
+ elif operation == 'query':
|
|
|
|
+ return self.do_query(userID, request_dict, response)
|
|
|
|
+ elif operation == 'modify':
|
|
|
|
+ return self.do_modify(userID, request_dict, response, request)
|
|
|
|
+ elif operation == 'modifyChannelName':
|
|
|
|
+ return self.do_modify_channel_name(userID, request_dict, response, request)
|
|
|
|
+ elif operation == 'fuzzyQuery':
|
|
|
|
+ return self.do_fuzzy_query(userID, request_dict, response)
|
|
|
|
+ elif operation == 'mainUserDevice':
|
|
|
|
+ return self.do_mainUserDevice( request_dict, response)
|
|
|
|
+ elif operation == 'getDeviceFeatures':
|
|
|
|
+ return self.do_get_device_features(request_dict, response)
|
|
|
|
+ else:
|
|
|
|
+ return response.json(414)
|
|
|
|
|
|
def do_add(self, userID, request_dict, response, request):
|
|
def do_add(self, userID, request_dict, response, request):
|
|
- token = request_dict.get('token', None)
|
|
|
|
UID = request_dict.get('UID', None)
|
|
UID = request_dict.get('UID', None)
|
|
NickName = request_dict.get('NickName', None)
|
|
NickName = request_dict.get('NickName', None)
|
|
View_Account = request_dict.get('View_Account', None)
|
|
View_Account = request_dict.get('View_Account', None)
|
|
@@ -68,196 +68,174 @@ class EquipmentManagerV3(View):
|
|
encrypt_pass = View_Password
|
|
encrypt_pass = View_Password
|
|
print("准备解密")
|
|
print("准备解密")
|
|
View_Password = self.decode_pwd(View_Password)
|
|
View_Password = self.decode_pwd(View_Password)
|
|
- Type = request_dict.get('Type', None)
|
|
|
|
- ChannelIndex = request_dict.get('ChannelIndex', None)
|
|
|
|
|
|
+ Type = int(request_dict.get('Type', None))
|
|
|
|
+ ChannelIndex = int(request_dict.get('ChannelIndex', None))
|
|
version = request_dict.get('version', '')
|
|
version = request_dict.get('version', '')
|
|
isCheckMainUser = request_dict.get('isCheckMainUser', None)
|
|
isCheckMainUser = request_dict.get('isCheckMainUser', None)
|
|
isMainUserExists = False
|
|
isMainUserExists = False
|
|
- if all([UID, NickName, View_Account, Type, ChannelIndex]):
|
|
|
|
- tko = TokenObject(token)
|
|
|
|
- response.lang = tko.lang
|
|
|
|
- if tko.code == 0:
|
|
|
|
- userID = tko.userID
|
|
|
|
- re_uid = re.compile(r'^[A-Za-z0-9]{14,20}$')
|
|
|
|
- if re_uid.match(UID):
|
|
|
|
- is_exist = Device_Info.objects.filter(UID=UID, userID_id=userID)
|
|
|
|
- if is_exist:
|
|
|
|
- # 判断设备是否已存在
|
|
|
|
- if is_exist[0].isExist == 1:
|
|
|
|
- return response.json(174)
|
|
|
|
- else:
|
|
|
|
- is_exist.delete()
|
|
|
|
- if UID == '98UXAA8BRPA35VAL111A':
|
|
|
|
- asy = threading.Thread(target=ModelService.add_log,
|
|
|
|
- args=(CommonService.get_ip_address(request), userID, 'addV3'))
|
|
|
|
- asy.start()
|
|
|
|
- return response.json(10, 'illegal uid: {uid}'.format(uid=UID))
|
|
|
|
-
|
|
|
|
- pk = CommonService.getUserID(getUser=False)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- userName = Device_User.objects.get(userID=userID).username
|
|
|
|
- main_exist = Device_Info.objects.filter(UID=UID)
|
|
|
|
- main_exist = main_exist.filter(~Q(vodPrimaryUserID='')).values('vodPrimaryUserID', 'vodPrimaryMaster')
|
|
|
|
- vodPrimaryUserID = userID
|
|
|
|
- vodPrimaryMaster = userName
|
|
|
|
- if main_exist.exists():
|
|
|
|
- vodPrimaryUserID = main_exist[0]['vodPrimaryUserID']
|
|
|
|
- vodPrimaryMaster = main_exist[0]['vodPrimaryMaster']
|
|
|
|
-
|
|
|
|
- is_bind = Device_Info.objects.filter(UID=UID, isShare=False).values('userID__userID', 'vodPrimaryUserID')
|
|
|
|
- isvodPrimaryUserID = ''
|
|
|
|
-
|
|
|
|
- for forbind in is_bind:
|
|
|
|
- if forbind['vodPrimaryUserID'] != '':
|
|
|
|
- isvodPrimaryUserID = forbind['vodPrimaryUserID']
|
|
|
|
-
|
|
|
|
- if isCheckMainUser != '1' :
|
|
|
|
- if main_exist.exists():
|
|
|
|
- vodPrimaryUserID = main_exist[0]['vodPrimaryUserID']
|
|
|
|
- vodPrimaryMaster = main_exist[0]['vodPrimaryMaster']
|
|
|
|
- else:
|
|
|
|
- vodPrimaryUserID = ''
|
|
|
|
- vodPrimaryMaster = ''
|
|
|
|
-
|
|
|
|
- isusermain = False
|
|
|
|
- if is_bind and isvodPrimaryUserID != userID and isvodPrimaryUserID != '':
|
|
|
|
- isusermain = True
|
|
|
|
-
|
|
|
|
- # uid_main_exist = UIDMainUser.objects.filter(UID=UID).values('UID', 'user_id')
|
|
|
|
- # if uid_main_exist.exists():
|
|
|
|
- # vodPrimaryUserID = uid_main_exist[0]['user_id']
|
|
|
|
- # vodPrimaryMaster = Device_User.objects.get(userID=vodPrimaryUserID).username
|
|
|
|
- #
|
|
|
|
- # if vodPrimaryUserID != userID:
|
|
|
|
- # isusermain = True
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- # 判断是否有已绑定用户
|
|
|
|
- if isCheckMainUser == '1' and isusermain:
|
|
|
|
- res = {
|
|
|
|
- 'id': pk,
|
|
|
|
- 'userID': userID,
|
|
|
|
- 'NickName': NickName,
|
|
|
|
- 'UID': UID,
|
|
|
|
- 'View_Account': View_Account,
|
|
|
|
- 'View_Password': View_Password,
|
|
|
|
- 'ChannelIndex': ChannelIndex,
|
|
|
|
- 'Type': Type,
|
|
|
|
- 'isShare': False,
|
|
|
|
- 'primaryUserID': '',
|
|
|
|
- 'primaryMaster': '',
|
|
|
|
- 'vodPrimaryUserID': vodPrimaryUserID,
|
|
|
|
- 'vodPrimaryMaster': vodPrimaryMaster,
|
|
|
|
- 'data_joined': '',
|
|
|
|
- 'version': version,
|
|
|
|
- 'isVod': 0,
|
|
|
|
- 'isExist': 1,
|
|
|
|
- 'userID__userEmail': ''
|
|
|
|
- }
|
|
|
|
- res['vod'] = [
|
|
|
|
- {
|
|
|
|
- "status": 1,
|
|
|
|
- "channel": ChannelIndex,
|
|
|
|
- "endTime": '',
|
|
|
|
- "bucket__content": '',
|
|
|
|
- "uid": UID
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- res['isMainUserExists'] = 1
|
|
|
|
- return response.json(0, res)
|
|
|
|
-
|
|
|
|
- try:
|
|
|
|
- # 判断是否有用户绑定
|
|
|
|
- nowTime = int(time.time())
|
|
|
|
- us_qs = UidSetModel.objects.filter(uid=UID)
|
|
|
|
- if not us_qs.exists():
|
|
|
|
- uid_set_create_dict = {
|
|
|
|
- 'uid': UID,
|
|
|
|
- 'addTime': nowTime,
|
|
|
|
- 'updTime': nowTime,
|
|
|
|
- 'ip': CommonService.get_ip_address(request_dict),
|
|
|
|
- 'channel': ChannelIndex,
|
|
|
|
- 'nickname': NickName,
|
|
|
|
- 'version': version,
|
|
|
|
- }
|
|
|
|
- UidSetModel.objects.create(**uid_set_create_dict)
|
|
|
|
- else:
|
|
|
|
- us_qs.update(nickname=NickName)
|
|
|
|
-
|
|
|
|
- userDevice = Device_Info(id=pk, userID_id=userID, UID=UID,
|
|
|
|
- NickName=NickName, View_Account=View_Account,
|
|
|
|
- View_Password=View_Password, Type=Type, ChannelIndex=ChannelIndex,
|
|
|
|
- version=version,
|
|
|
|
- vodPrimaryUserID=vodPrimaryUserID, vodPrimaryMaster=vodPrimaryMaster)
|
|
|
|
- userDevice.save()
|
|
|
|
- uid_serial_qs = UIDCompanySerialModel.objects.filter(
|
|
|
|
- uid__uid=UID)
|
|
|
|
- if uid_serial_qs.exists():
|
|
|
|
- uid_serial = uid_serial_qs[0]
|
|
|
|
- Device_Info.objects.filter(UID=UID).update(vodPrimaryUserID=vodPrimaryUserID,
|
|
|
|
- vodPrimaryMaster=vodPrimaryMaster,
|
|
|
|
- serial_number=uid_serial.company_serial.serial_number + uid_serial.company_serial.company.mark)
|
|
|
|
- else:
|
|
|
|
- Device_Info.objects.filter(UID=UID).update(vodPrimaryUserID=vodPrimaryUserID,
|
|
|
|
- vodPrimaryMaster=vodPrimaryMaster)
|
|
|
|
-
|
|
|
|
- # if isCheckMainUser == '1':
|
|
|
|
- # uid_main_dict = {
|
|
|
|
- # 'UID': UID,
|
|
|
|
- # 'user_id': vodPrimaryUserID
|
|
|
|
- # }
|
|
|
|
- # UIDMainUser.objects.create(**uid_main_dict)
|
|
|
|
-
|
|
|
|
- if not us_qs.exists():
|
|
|
|
- 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()
|
|
|
|
-
|
|
|
|
- # redisObj = RedisObject(db=8)
|
|
|
|
- # redisObj.del_data(key='uid_qs_' + userID)
|
|
|
|
- except Exception as e:
|
|
|
|
- return response.json(10, repr(e))
|
|
|
|
- else:
|
|
|
|
- dvqs = Device_Info.objects.filter(id=pk).values('id', 'userID', 'NickName', 'UID',
|
|
|
|
- 'View_Account',
|
|
|
|
- 'View_Password', 'ChannelIndex', 'Type',
|
|
|
|
- 'isShare',
|
|
|
|
- 'primaryUserID', 'primaryMaster',
|
|
|
|
- 'vodPrimaryUserID', 'vodPrimaryMaster',
|
|
|
|
- 'userID__userEmail',
|
|
|
|
- 'data_joined', 'version',
|
|
|
|
- 'isVod', 'isExist', 'isCameraOpenCloud', 'serial_number')
|
|
|
|
- dvql = CommonService.qs_to_list(dvqs)
|
|
|
|
- ubqs = UID_Bucket.objects.filter(uid=UID). \
|
|
|
|
- values('bucket__content', 'status', 'channel', 'endTime', 'uid')
|
|
|
|
- res = dvql[0]
|
|
|
|
- res['vod'] = list(ubqs)
|
|
|
|
-
|
|
|
|
- iotqs = iotdeviceInfoModel.objects.filter(serial_number=dvql[0]['serial_number'])
|
|
|
|
- if iotqs.exists():
|
|
|
|
- res['iot'].append(
|
|
|
|
- {
|
|
|
|
- 'endpoint': iotqs[0].endpoint,
|
|
|
|
- 'token_iot_number': iotqs[0].endpoint
|
|
|
|
|
|
+ if not all([UID, NickName, View_Account, Type, ChannelIndex]):
|
|
|
|
+ return response.json(444, {'param': 'UID,NickName,View_Account,View_Password,Type,ChannelIndex,version'})
|
|
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
|
|
+ re_uid = re.compile(r'^[A-Za-z0-9]{14,20}$')
|
|
|
|
+ if not re_uid.match(UID):
|
|
|
|
+ return response.json(444, {'param': 'UID'})
|
|
|
|
|
|
- return response.json(0, res)
|
|
|
|
|
|
+ device_info_qs = Device_Info.objects.filter(UID=UID, userID_id=userID)
|
|
|
|
+ if device_info_qs:
|
|
|
|
+ # 判断设备是否已存在
|
|
|
|
+ if device_info_qs[0].isExist == 1:
|
|
|
|
+ return response.json(174)
|
|
|
|
+ else:
|
|
|
|
+ device_info_qs.delete()
|
|
|
|
+
|
|
|
|
+ id = CommonService.getUserID(getUser=False)
|
|
|
|
+ userName = Device_User.objects.get(userID=userID).username
|
|
|
|
+ main_exist = Device_Info.objects.filter(UID=UID)
|
|
|
|
+ main_exist = main_exist.filter(~Q(vodPrimaryUserID='')).values('vodPrimaryUserID', 'vodPrimaryMaster')
|
|
|
|
+ vodPrimaryUserID = userID
|
|
|
|
+ vodPrimaryMaster = userName
|
|
|
|
+ if main_exist.exists():
|
|
|
|
+ vodPrimaryUserID = main_exist[0]['vodPrimaryUserID']
|
|
|
|
+ vodPrimaryMaster = main_exist[0]['vodPrimaryMaster']
|
|
|
|
+
|
|
|
|
+ is_bind = Device_Info.objects.filter(UID=UID, isShare=False).values('userID__userID', 'vodPrimaryUserID')
|
|
|
|
+ isvodPrimaryUserID = ''
|
|
|
|
+
|
|
|
|
+ for forbind in is_bind:
|
|
|
|
+ if forbind['vodPrimaryUserID'] != '':
|
|
|
|
+ isvodPrimaryUserID = forbind['vodPrimaryUserID']
|
|
|
|
+
|
|
|
|
+ if isCheckMainUser != '1' :
|
|
|
|
+ if main_exist.exists():
|
|
|
|
+ vodPrimaryUserID = main_exist[0]['vodPrimaryUserID']
|
|
|
|
+ vodPrimaryMaster = main_exist[0]['vodPrimaryMaster']
|
|
|
|
+ else:
|
|
|
|
+ vodPrimaryUserID = ''
|
|
|
|
+ vodPrimaryMaster = ''
|
|
|
|
+
|
|
|
|
+ isusermain = False
|
|
|
|
+ if is_bind and isvodPrimaryUserID != userID and isvodPrimaryUserID != '':
|
|
|
|
+ isusermain = True
|
|
|
|
+
|
|
|
|
+ # 判断是否有已绑定用户
|
|
|
|
+ if isCheckMainUser == '1' and isusermain:
|
|
|
|
+ res = {
|
|
|
|
+ 'id': id,
|
|
|
|
+ 'userID': userID,
|
|
|
|
+ 'NickName': NickName,
|
|
|
|
+ 'UID': UID,
|
|
|
|
+ 'View_Account': View_Account,
|
|
|
|
+ 'View_Password': View_Password,
|
|
|
|
+ 'ChannelIndex': ChannelIndex,
|
|
|
|
+ 'Type': Type,
|
|
|
|
+ 'isShare': False,
|
|
|
|
+ 'primaryUserID': '',
|
|
|
|
+ 'primaryMaster': '',
|
|
|
|
+ 'vodPrimaryUserID': vodPrimaryUserID,
|
|
|
|
+ 'vodPrimaryMaster': vodPrimaryMaster,
|
|
|
|
+ 'data_joined': '',
|
|
|
|
+ 'version': version,
|
|
|
|
+ 'isVod': 0,
|
|
|
|
+ 'isExist': 1,
|
|
|
|
+ 'userID__userEmail': ''
|
|
|
|
+ }
|
|
|
|
+ res['vod'] = [
|
|
|
|
+ {
|
|
|
|
+ "status": 1,
|
|
|
|
+ "channel": ChannelIndex,
|
|
|
|
+ "endTime": '',
|
|
|
|
+ "bucket__content": '',
|
|
|
|
+ "uid": UID
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ res['isMainUserExists'] = 1
|
|
|
|
+ return response.json(0, res)
|
|
|
|
|
|
- else:
|
|
|
|
- return response.json(444, {'param': 'UID'})
|
|
|
|
|
|
+ try:
|
|
|
|
+ # 判断是否有用户绑定
|
|
|
|
+ nowTime = int(time.time())
|
|
|
|
+ us_qs = UidSetModel.objects.filter(uid=UID)
|
|
|
|
+ if us_qs.exists():
|
|
|
|
+ us_qs.update(nickname=NickName)
|
|
|
|
+ UidSet_id = us_qs.first().id
|
|
else:
|
|
else:
|
|
- return response.json(tko.code)
|
|
|
|
|
|
+ uid_set_create_dict = {
|
|
|
|
+ 'uid': UID,
|
|
|
|
+ 'addTime': nowTime,
|
|
|
|
+ 'updTime': nowTime,
|
|
|
|
+ 'ip': CommonService.get_ip_address(request_dict),
|
|
|
|
+ 'channel': ChannelIndex,
|
|
|
|
+ 'nickname': NickName,
|
|
|
|
+ 'version': version,
|
|
|
|
+ }
|
|
|
|
+ UidSet = UidSetModel.objects.create(**uid_set_create_dict)
|
|
|
|
+ UidSet_id = UidSet.id
|
|
|
|
+
|
|
|
|
+ # 查询uid_channel表有无该uid的数据
|
|
|
|
+ uid_channel_set = UidChannelSetModel.objects.filter(uid_id=UidSet_id)
|
|
|
|
+ if not uid_channel_set.exists():
|
|
|
|
+ # 多通道设备设置通道名
|
|
|
|
+ multi_channel_list = [1, 2, 3, 4, 10001]
|
|
|
|
+ if Type in multi_channel_list:
|
|
|
|
+ UidChannelSet_bulk = []
|
|
|
|
+ for i in range(1, ChannelIndex+1):
|
|
|
|
+ channel_name = 'channel'+str(i) # channel1,channel2...
|
|
|
|
+ UidChannelSet = UidChannelSetModel(uid_id=UidSet_id, channel=i, channel_name=channel_name)
|
|
|
|
+ UidChannelSet_bulk.append(UidChannelSet)
|
|
|
|
+ UidChannelSetModel.objects.bulk_create(UidChannelSet_bulk)
|
|
|
|
+
|
|
|
|
+ userDevice = Device_Info(id=id, userID_id=userID, UID=UID, NickName=NickName, View_Account=View_Account,
|
|
|
|
+ View_Password=View_Password, Type=Type, ChannelIndex=ChannelIndex, version=version,
|
|
|
|
+ vodPrimaryUserID=vodPrimaryUserID, vodPrimaryMaster=vodPrimaryMaster)
|
|
|
|
+ userDevice.save()
|
|
|
|
+ uid_serial_qs = UIDCompanySerialModel.objects.filter(uid__uid=UID)
|
|
|
|
+ if uid_serial_qs.exists():
|
|
|
|
+ uid_serial = uid_serial_qs[0]
|
|
|
|
+ Device_Info.objects.filter(UID=UID).update(vodPrimaryUserID=vodPrimaryUserID,
|
|
|
|
+ vodPrimaryMaster=vodPrimaryMaster,
|
|
|
|
+ serial_number=uid_serial.company_serial.serial_number.serial_number + uid_serial.company_serial.company.mark)
|
|
|
|
+ else:
|
|
|
|
+ Device_Info.objects.filter(UID=UID).update(vodPrimaryUserID=vodPrimaryUserID,
|
|
|
|
+ vodPrimaryMaster=vodPrimaryMaster)
|
|
|
|
+
|
|
|
|
+ if not us_qs.exists():
|
|
|
|
+ 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()
|
|
|
|
+
|
|
|
|
+ except Exception as e:
|
|
|
|
+ return response.json(10, repr(e))
|
|
else:
|
|
else:
|
|
- return response.json(444, {'param': 'UID,NickName,View_Account,View_Password,Type,ChannelIndex,version'})
|
|
|
|
|
|
+ dvqs = Device_Info.objects.filter(id=id).values('id', 'userID', 'NickName', 'UID',
|
|
|
|
+ 'View_Account',
|
|
|
|
+ 'View_Password', 'ChannelIndex', 'Type',
|
|
|
|
+ 'isShare',
|
|
|
|
+ 'primaryUserID', 'primaryMaster',
|
|
|
|
+ 'vodPrimaryUserID', 'vodPrimaryMaster',
|
|
|
|
+ 'userID__userEmail',
|
|
|
|
+ 'data_joined', 'version',
|
|
|
|
+ 'isVod', 'isExist', 'isCameraOpenCloud', 'serial_number')
|
|
|
|
+ dvql = CommonService.qs_to_list(dvqs)
|
|
|
|
+ ubqs = UID_Bucket.objects.filter(uid=UID). \
|
|
|
|
+ values('bucket__content', 'status', 'channel', 'endTime', 'uid')
|
|
|
|
+ res = dvql[0]
|
|
|
|
+ res['vod'] = list(ubqs)
|
|
|
|
+
|
|
|
|
+ iotqs = iotdeviceInfoModel.objects.filter(serial_number__serial_number=dvql[0]['serial_number'])
|
|
|
|
+ if iotqs.exists():
|
|
|
|
+ res['iot'].append(
|
|
|
|
+ {
|
|
|
|
+ 'endpoint': iotqs[0].endpoint,
|
|
|
|
+ 'token_iot_number': iotqs[0].endpoint
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ return response.json(0, res)
|
|
|
|
+
|
|
|
|
|
|
def do_modify(self, userID, request_dict, response, request):
|
|
def do_modify(self, userID, request_dict, response, request):
|
|
token = request_dict.get('token', None)
|
|
token = request_dict.get('token', None)
|
|
@@ -328,6 +306,17 @@ class EquipmentManagerV3(View):
|
|
# redisObj.del_data(key='uid_qs_' + userID)
|
|
# redisObj.del_data(key='uid_qs_' + userID)
|
|
return response.json(0, res)
|
|
return response.json(0, res)
|
|
|
|
|
|
|
|
+ # 编辑通道名
|
|
|
|
+ def do_modify_channel_name(self, userID, request_dict, response):
|
|
|
|
+ uid = request_dict.get('uid', None)
|
|
|
|
+ channel = request_dict.get('channel', None)
|
|
|
|
+ channel_name = request_dict.get('channel_name', None)
|
|
|
|
+ if not all([uid, channel, channel_name]):
|
|
|
|
+ return response.json(444)
|
|
|
|
+ # 更新通道名
|
|
|
|
+ UidChannelSetModel.objects.filter(uid__uid=uid).update(channel_name=channel_name)
|
|
|
|
+ return response.json(0)
|
|
|
|
+
|
|
# 新查询设备字段
|
|
# 新查询设备字段
|
|
def do_query(self, userID, request_dict, response):
|
|
def do_query(self, userID, request_dict, response):
|
|
token = request_dict.get('token', None)
|
|
token = request_dict.get('token', None)
|
|
@@ -367,7 +356,7 @@ class EquipmentManagerV3(View):
|
|
serial_number_list.append(dvl['serial_number'][0:6])
|
|
serial_number_list.append(dvl['serial_number'][0:6])
|
|
|
|
|
|
# 新增获取IOT证书内容
|
|
# 新增获取IOT证书内容
|
|
- iotqs = iotdeviceInfoModel.objects.filter(serial_number__in=serial_number_list)
|
|
|
|
|
|
+ iotqs = iotdeviceInfoModel.objects.filter(serial_number__serial_number__in=serial_number_list)
|
|
|
|
|
|
ubqs = UID_Bucket.objects.filter(uid__in=uid_list). \
|
|
ubqs = UID_Bucket.objects.filter(uid__in=uid_list). \
|
|
values('bucket__content', 'status', 'channel', 'endTime', 'uid')
|
|
values('bucket__content', 'status', 'channel', 'endTime', 'uid')
|
|
@@ -411,7 +400,8 @@ class EquipmentManagerV3(View):
|
|
'is_custom_voice': us['is_custom_voice']
|
|
'is_custom_voice': us['is_custom_voice']
|
|
}
|
|
}
|
|
# 从uid_channel里面取出通道配置信息
|
|
# 从uid_channel里面取出通道配置信息
|
|
- ucs_qs = UidChannelSetModel.objects.filter(uid__id=us['id']).values('channel', 'pir_audio', 'mic_audio',
|
|
|
|
|
|
+ ucs_qs = UidChannelSetModel.objects.filter(uid__id=us['id']).values('channel', 'channel_name',
|
|
|
|
+ 'pir_audio', 'mic_audio',
|
|
'battery_status', 'battery_level',
|
|
'battery_status', 'battery_level',
|
|
'sleep_status', 'sleep_time',
|
|
'sleep_status', 'sleep_time',
|
|
'light_night_model',
|
|
'light_night_model',
|
|
@@ -425,6 +415,7 @@ class EquipmentManagerV3(View):
|
|
for ucs in ucs_qs:
|
|
for ucs in ucs_qs:
|
|
channels_dict = {
|
|
channels_dict = {
|
|
'channel': ucs['channel'],
|
|
'channel': ucs['channel'],
|
|
|
|
+ 'channel_name': ucs['channel_name'],
|
|
'pir_audio': ucs['pir_audio'],
|
|
'pir_audio': ucs['pir_audio'],
|
|
'mic_audio': ucs['mic_audio'],
|
|
'mic_audio': ucs['mic_audio'],
|
|
'battery_status': ucs['battery_status'],
|
|
'battery_status': ucs['battery_status'],
|
|
@@ -445,7 +436,7 @@ class EquipmentManagerV3(View):
|
|
# 新增IOT
|
|
# 新增IOT
|
|
p['iot'] = []
|
|
p['iot'] = []
|
|
for iot in iotqs:
|
|
for iot in iotqs:
|
|
- if p['serial_number'][0:6] == iot.serial_number:
|
|
|
|
|
|
+ if p['serial_number'][0:6] == iot.serial_number.serial_number:
|
|
p['iot'].append(
|
|
p['iot'].append(
|
|
{
|
|
{
|
|
'endpoint': iot.endpoint,
|
|
'endpoint': iot.endpoint,
|
|
@@ -559,7 +550,7 @@ class EquipmentManagerV3(View):
|
|
serial_number_list.append(dvl['serial_number'][0:6])
|
|
serial_number_list.append(dvl['serial_number'][0:6])
|
|
|
|
|
|
# 新增获取IOT证书内容
|
|
# 新增获取IOT证书内容
|
|
- iotqs = iotdeviceInfoModel.objects.filter(serial_number__in=serial_number_list)
|
|
|
|
|
|
+ iotqs = iotdeviceInfoModel.objects.filter(serial_number__serial_number__in=serial_number_list)
|
|
|
|
|
|
ubqs = UID_Bucket.objects.filter(uid__in=uid_list). \
|
|
ubqs = UID_Bucket.objects.filter(uid__in=uid_list). \
|
|
values('bucket__content', 'status', 'channel', 'endTime', 'uid')
|
|
values('bucket__content', 'status', 'channel', 'endTime', 'uid')
|
|
@@ -606,6 +597,7 @@ class EquipmentManagerV3(View):
|
|
for ucs in ucs_qs:
|
|
for ucs in ucs_qs:
|
|
channel = {
|
|
channel = {
|
|
'channel': ucs['channel'],
|
|
'channel': ucs['channel'],
|
|
|
|
+ 'channel_name': ucs['channel_name'],
|
|
'pir_audio': ucs['pir_audio'],
|
|
'pir_audio': ucs['pir_audio'],
|
|
'mic_audio': ucs['mic_audio'],
|
|
'mic_audio': ucs['mic_audio'],
|
|
'battery_status': ucs['battery_status'],
|
|
'battery_status': ucs['battery_status'],
|
|
@@ -626,7 +618,7 @@ class EquipmentManagerV3(View):
|
|
# 新增IOT
|
|
# 新增IOT
|
|
p['iot'] = []
|
|
p['iot'] = []
|
|
for iot in iotqs:
|
|
for iot in iotqs:
|
|
- if p['serial_number'][0:6] == iot.serial_number:
|
|
|
|
|
|
+ if p['serial_number'][0:6] == iot.serial_number.serial_number:
|
|
p['iot'].append(
|
|
p['iot'].append(
|
|
{
|
|
{
|
|
'endpoint': iot.endpoint,
|
|
'endpoint': iot.endpoint,
|