|
@@ -46,6 +46,9 @@ class GatewayFamilyRoomView(View):
|
|
|
# 房间删除
|
|
|
elif operation == 'del':
|
|
|
return self.room_del(request_dict, response)
|
|
|
+ # 房间详情
|
|
|
+ elif operation == 'details':
|
|
|
+ return self.get_room_details(app_user_id, request_dict, response)
|
|
|
|
|
|
@classmethod
|
|
|
def room_device_save(cls, app_user_id, request_dict, response):
|
|
@@ -119,3 +122,53 @@ class GatewayFamilyRoomView(View):
|
|
|
if family_room.exists():
|
|
|
family_room.update(sort=int(sort))
|
|
|
return response.json(0)
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def get_room_details(cls, app_user_id, request_dict, response):
|
|
|
+ """
|
|
|
+ 房间设备详情
|
|
|
+ @param app_user_id:
|
|
|
+ @param request_dict:
|
|
|
+ @param response:
|
|
|
+ @return:
|
|
|
+ """
|
|
|
+ family_id = request_dict.get('familyId', None)
|
|
|
+ room_id = request_dict.get('roomId', None)
|
|
|
+ page_no = request_dict.get('pageNo', None)
|
|
|
+ page_size = request_dict.get('pageSize', None)
|
|
|
+ if not all([family_id, room_id, page_no, page_size]):
|
|
|
+ return response.json(444)
|
|
|
+ room_count = FamilyRoomDevice.objects.filter(family_id=int(family_id), room_id=int(room_id)).count()
|
|
|
+ device_room = []
|
|
|
+ # 房间设备列表
|
|
|
+ if room_count > 0:
|
|
|
+ device_room_list = EquipmentFamilyView.get_family_device_list(user_id=app_user_id, page_no=1,
|
|
|
+ page_size=room_count,
|
|
|
+ family_id=int(family_id),
|
|
|
+ room_id=int(room_id))
|
|
|
+
|
|
|
+ if device_room_list:
|
|
|
+ room_name = FamilyRoom.objects.get(id=room_id).name
|
|
|
+
|
|
|
+ for item in device_room_list:
|
|
|
+ device_room.append({
|
|
|
+ 'deviceId': item['id'],
|
|
|
+ 'deviceType': item['Type'],
|
|
|
+ 'nickName': item['NickName'],
|
|
|
+ 'roomName': room_name,
|
|
|
+ })
|
|
|
+ device_not_room = []
|
|
|
+ device_not_room_count = FamilyRoomDevice.objects.filter(family_id=int(family_id), room_id=0).count()
|
|
|
+ if device_not_room_count > 0:
|
|
|
+ not_room_device_list = EquipmentFamilyView.get_family_device_list(user_id=app_user_id, page_no=int(page_no),
|
|
|
+ page_size=int(page_size),
|
|
|
+ family_id=int(family_id), room_id=0,
|
|
|
+ is_room_other=True)
|
|
|
+ if not_room_device_list:
|
|
|
+ for item in not_room_device_list:
|
|
|
+ device_not_room.append({
|
|
|
+ 'deviceId': item['id'],
|
|
|
+ 'deviceType': item['Type'],
|
|
|
+ 'nickName': item['NickName'],
|
|
|
+ })
|
|
|
+ return response.json(0, {'deviceRooms': device_room, 'deviceNotRooms': device_not_room})
|