瀏覽代碼

修复查询不到子设备逻辑

peng 3 年之前
父節點
當前提交
a20614d62c

+ 1 - 4
Controller/SensorGateway/EquipmentFamilyController.py

@@ -748,10 +748,7 @@ class EquipmentFamilyView(View):
             'created_time': now_time
         }
 
-        if device_type == 200:
-            category = 0
-        else:
-            category = 1
+        category = 0 if device_type == 200 else 1
         data['category'] = category
         # 查询类别排序
         family_room_device_qs = FamilyRoomDevice.objects.filter(family_id=int(family_id), category=category).values(

+ 3 - 1
Controller/SensorGateway/GatewayFamilyRoomController.py

@@ -260,7 +260,7 @@ class GatewayFamilyRoomView(View):
                 device_type = device['device__Type']
                 category = device['category']
                 room_name = FamilyRoom.objects.filter(id=room_id)
-                if category == 0:  # 网关设备
+                if category == 0:  # 网关设备
                     if not device['sub_device']:
                         device_dict = {
                             'deviceId': device['device_id'],
@@ -271,6 +271,8 @@ class GatewayFamilyRoomView(View):
                     else:
                         sub_device_qs = GatewaySubDevice.objects.filter(id=device['sub_device']).values('device_type',
                                                                                                         'nickname')
+                        if not sub_device_qs.exists():
+                            continue
                         device_dict = {
                             'deviceId': device['sub_device'],
                             'deviceType': sub_device_qs[0]['device_type'],