|
@@ -1007,99 +1007,55 @@ class EquipmentFamilyView(View):
|
|
|
item['category_name'] = '网关子设备类'
|
|
|
else:
|
|
|
item['category_name'] = '摄像头类'
|
|
|
+ device_dict['sort'] = list(category_sort)
|
|
|
if room_id:
|
|
|
family_room = FamilyRoom.objects.filter(id=room_id)
|
|
|
if not family_room.exists():
|
|
|
return response.json(173)
|
|
|
family_room_device_qs = family_room_device_qs.filter(room_id=room_id)
|
|
|
- family_room_device_qs = family_room_device_qs[(page - 1) * line:page * line]
|
|
|
- for item in family_room_device_qs:
|
|
|
- if not item['sub_device']: # 查询网关、摄像头
|
|
|
- device_qs = Device_Info.objects.filter(id=item['device_id']).values(
|
|
|
- 'id', 'userID', 'NickName', 'UID', 'View_Account', 'View_Password',
|
|
|
- 'ChannelIndex',
|
|
|
- 'Type', 'isShare', 'primaryUserID', 'primaryMaster', 'data_joined',
|
|
|
- 'vodPrimaryUserID',
|
|
|
- 'vodPrimaryMaster', 'userID__userEmail', 'version', 'isVod',
|
|
|
- 'isExist', 'NotificationMode',
|
|
|
- 'isCameraOpenCloud', 'serial_number'
|
|
|
- ).first()
|
|
|
- if device_qs:
|
|
|
- device_qs['sensorStatus'] = 0
|
|
|
- if device_qs['primaryUserID'] and device_qs['id'] == device_qs['primaryUserID']:
|
|
|
- device_qs['isPrimaryUser'] = 1
|
|
|
- else:
|
|
|
- device_qs['isPrimaryUser'] = 0
|
|
|
- if 'data_joined' in device_qs:
|
|
|
- if device_qs['data_joined']:
|
|
|
- device_qs['data_joined'] = device_qs['data_joined'].strftime("%Y-%m-%d %H:%M:%S")
|
|
|
- else:
|
|
|
- device_qs['data_joined'] = ''
|
|
|
- if device_qs['Type'] == 200:
|
|
|
- gateways.append(device_qs)
|
|
|
+ # 处理网关摄像头
|
|
|
+ gateways_or_cameras_qs = family_room_device_qs.filter(sub_device=0)[(page - 1) * line:page * line]
|
|
|
+ for item in gateways_or_cameras_qs:
|
|
|
+ room_qs = FamilyRoom.objects.filter(id=item['room_id']).values('name')
|
|
|
+ room_name = room_qs[0]['name'] if room_qs.exists() else ''
|
|
|
+ device_qs = Device_Info.objects.filter(id=item['device_id']).values(
|
|
|
+ 'id', 'userID', 'NickName', 'UID', 'View_Account', 'View_Password',
|
|
|
+ 'ChannelIndex',
|
|
|
+ 'Type', 'isShare', 'primaryUserID', 'primaryMaster', 'data_joined',
|
|
|
+ 'vodPrimaryUserID',
|
|
|
+ 'vodPrimaryMaster', 'userID__userEmail', 'version', 'isVod',
|
|
|
+ 'isExist', 'NotificationMode',
|
|
|
+ 'isCameraOpenCloud', 'serial_number'
|
|
|
+ ).first()
|
|
|
+ if device_qs:
|
|
|
+ device_qs['sensorStatus'] = 0
|
|
|
+ device_qs['roomName'] = room_name
|
|
|
+ if device_qs['primaryUserID'] and device_qs['id'] == device_qs['primaryUserID']:
|
|
|
+ device_qs['isPrimaryUser'] = 1
|
|
|
+ else:
|
|
|
+ device_qs['isPrimaryUser'] = 0
|
|
|
+ if 'data_joined' in device_qs:
|
|
|
+ if device_qs['data_joined']:
|
|
|
+ device_qs['data_joined'] = device_qs['data_joined'].strftime("%Y-%m-%d %H:%M:%S")
|
|
|
else:
|
|
|
- cameras.append(device_qs)
|
|
|
- else: # 查询传感器
|
|
|
- sub_device_qs = GatewaySubDevice.objects.filter(id=item['sub_device']).values()
|
|
|
- if sub_device_qs.exists():
|
|
|
- created_time = time.localtime(sub_device_qs[0]['created_time'])
|
|
|
- created_time = time.strftime('%Y-%m-%d %H:%M:%S', created_time)
|
|
|
- sub_device_dict = {
|
|
|
- "id": sub_device_qs[0]['id'],
|
|
|
- "userID": user_id,
|
|
|
- "NickName": sub_device_qs[0]['nickname'],
|
|
|
- "UID": "",
|
|
|
- "View_Account": "",
|
|
|
- "View_Password": "",
|
|
|
- "ChannelIndex": 0,
|
|
|
- "Type": sub_device_qs[0]['device_type'],
|
|
|
- 'sensorStatus': sub_device_qs[0]['status'],
|
|
|
- "isShare": False,
|
|
|
- "primaryUserID": "",
|
|
|
- "primaryMaster": "",
|
|
|
- "data_joined": created_time,
|
|
|
- "vodPrimaryUserID": "",
|
|
|
- "vodPrimaryMaster": "",
|
|
|
- "userID__userEmail": "",
|
|
|
- "version": "",
|
|
|
- "isVod": 0,
|
|
|
- "isExist": 0,
|
|
|
- "NotificationMode": 0,
|
|
|
- "isCameraOpenCloud": 0,
|
|
|
- "serial_number": sub_device_qs[0]['sensor_serial'],
|
|
|
- "isPrimaryUser": 0,
|
|
|
- "iot": [],
|
|
|
- "vod": [],
|
|
|
- "preview": [],
|
|
|
- "platform": "",
|
|
|
- "initString": "",
|
|
|
- "initStringApp": "",
|
|
|
- "uid_version": "",
|
|
|
- "ucode": "",
|
|
|
- "detect_interval": 0,
|
|
|
- "detect_status": 0,
|
|
|
- "detect_group": "",
|
|
|
- "region_alexa": "",
|
|
|
- "is_alexa": 0,
|
|
|
- "deviceModel": "",
|
|
|
- "TimeZone": "",
|
|
|
- "TimeStatus": 0,
|
|
|
- "SpaceUsable": "",
|
|
|
- "SpaceSum": "",
|
|
|
- "MirrorType": 0,
|
|
|
- "RecordType": 0,
|
|
|
- "OutdoorModel": 0,
|
|
|
- "WIFIName": "",
|
|
|
- "isDetector": 0,
|
|
|
- "DetectorRank": 0,
|
|
|
- "is_human": 0,
|
|
|
- "is_custom_voice": 0,
|
|
|
- "is_ptz": 0,
|
|
|
- "channels": [],
|
|
|
- "double_wifi": 0,
|
|
|
- "is_ai": 0
|
|
|
- }
|
|
|
- sensors.append(sub_device_dict)
|
|
|
+ device_qs['data_joined'] = ''
|
|
|
+ if device_qs['Type'] == 200:
|
|
|
+ gateways.append(device_qs)
|
|
|
+ else:
|
|
|
+ cameras.append(device_qs)
|
|
|
+ # 处理传感器
|
|
|
+ sensors_qs = family_room_device_qs.filter(~Q(sub_device=0))
|
|
|
+ for item in sensors_qs: # 查询传感器
|
|
|
+ sub_device_qs = GatewaySubDevice.objects.filter(id=item['sub_device']).values()
|
|
|
+ if sub_device_qs.exists():
|
|
|
+ sub_device_dict = {
|
|
|
+ "id": sub_device_qs[0]['id'],
|
|
|
+ "NickName": sub_device_qs[0]['nickname'],
|
|
|
+ "Type": sub_device_qs[0]['device_type'],
|
|
|
+ 'sensorStatus': sub_device_qs[0]['status'],
|
|
|
+ }
|
|
|
+ sensors.append(sub_device_dict)
|
|
|
+ device_dict['sensors'] = sensors
|
|
|
|
|
|
device_list = [gateways, cameras]
|
|
|
for item in device_list:
|
|
@@ -1117,9 +1073,6 @@ class EquipmentFamilyView(View):
|
|
|
else:
|
|
|
device_dict['cameras'] = result
|
|
|
|
|
|
- device_dict['sort'] = list(category_sort)
|
|
|
- device_dict['gateways'].extend(sensors)
|
|
|
-
|
|
|
return response.json(0, device_dict)
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|