Jelajahi Sumber

Merge branch 'test' of http://192.168.136.99:3000/servers/ASJServer into ming

zhangdongming 2 tahun lalu
induk
melakukan
137cf0c4a0

+ 6 - 2
AdminController/DeviceManagementController.py

@@ -494,7 +494,8 @@ class DeviceManagement(View):
                 sort=F('app_device_type__devicenamelanguage__sort')).values('id', 'app_device_type__id', 'model',
                                                                             'type', 'icon',
                                                                             'app_device_type__devicenamelanguage__id',
-                                                                            'lang', 'name', 'sort').order_by(
+                                                                            'lang', 'name', 'sort',
+                                                                            'app_device_type__app_version_number_id').order_by(
                 'app_device_type__devicenamelanguage__sort')
             if not app_bundle_qs.exists():
                 return response.json(0)
@@ -507,7 +508,10 @@ class DeviceManagement(View):
                 app_bundle_qs = app_bundle_qs.filter(type=type)
             total = app_bundle_qs.count()
             app_bundle_qs = app_bundle_qs[(page - 1) * line:page * line]
-            app_device_type_list = [app_bundle for app_bundle in app_bundle_qs]
+            app_device_type_list = []
+            for app_bundle in app_bundle_qs:
+                app_bundle['version_number'] = app_bundle.pop('app_device_type__app_version_number_id')
+                app_device_type_list.append(app_bundle)
             return response.json(0, {'list': app_device_type_list, 'total': total})
         except Exception as e:
             print(e)

+ 28 - 28
Controller/SensorGateway/SmartSceneController.py

@@ -981,35 +981,35 @@ class SmartSceneView(View):
         @param tasks_list: app任务列表
         @return: task_list
         """
-        # 只下发最后一个任务
-        last_task = tasks_list.pop()
-        sensor_type = int(last_task['device_type'])
-        task_temp = {
-            'sensor_type': sensor_type,
-            'sensor_delay': 0
-        }
-
-        # 延时
-        if 'delay_time' in last_task and last_task['delay_time'] != 0:
-            task_temp['sensor_delay'] = last_task['delay_time']
-
-        if sensor_type != -1:  # 不为-1时需要其他数据
-            task_temp['sensor_action'] = int(last_task['event_type'])
+        task_list = []
+        for task in tasks_list:
+            sensor_type = int(task['device_type'])
+            task_temp = {
+                'sensor_type': sensor_type,
+                'sensor_delay': 0
+            }
 
-            # 子设备返回长地址
-            sub_device_id = last_task.get('subDeviceId', None)
-            if sub_device_id:
-                sub_device_qs = GatewaySubDevice.objects.filter(id=sub_device_id).values('ieee_addr').first()
-                task_temp['sensor_ieee_addr'] = sub_device_qs['ieee_addr']
-            # 网关添加报警类型数据
-            else:
-                task_temp['voice_type'] = last_task.get('voice_type')
-                task_temp['voice_id'] = last_task.get('voice_id')
-                task_temp['count'] = last_task.get('count')
-                task_temp['delay_time'] = last_task.get('delay_time')
-                task_temp['duration'] = last_task.get('duration')
-                task_temp['value_type'] = last_task.get('value_type')
-        task_list = [task_temp]
+            # 延时
+            if 'delay_time' in task and task['delay_time'] != 0:
+                task_temp['sensor_delay'] = task['delay_time']
+
+            # 不为-1时需要其他数据
+            if sensor_type != -1:
+                task_temp['sensor_action'] = int(task['event_type'])
+                # 子设备返回长地址
+                sub_device_id = task.get('subDeviceId', None)
+                if sub_device_id:
+                    sub_device_qs = GatewaySubDevice.objects.filter(id=sub_device_id).values('ieee_addr').first()
+                    task_temp['sensor_ieee_addr'] = sub_device_qs['ieee_addr']
+                # 网关添加报警类型数据
+                else:
+                    task_temp['voice_type'] = task.get('voice_type')
+                    task_temp['voice_id'] = task.get('voice_id')
+                    task_temp['count'] = task.get('count')
+                    task_temp['delay_time'] = task.get('delay_time')
+                    task_temp['duration'] = task.get('duration')
+                    task_temp['value_type'] = task.get('value_type')
+            task_list.append(task_temp)
         return task_list
 
 

+ 2 - 2
Controller/SensorGateway/SubDeviceController.py

@@ -633,10 +633,10 @@ class GatewaySubDeviceView(View):
         online = int(online)
         try:
             if online == 2:     # 复位删除设备
-                gateway_sub_device_qs = GatewaySubDevice.objects.filter(ieee_addr=ieee_addr).values('id')
+                gateway_sub_device_qs = GatewaySubDevice.objects.filter(ieee_addr=ieee_addr)
                 if not gateway_sub_device_qs.exists():
                     return response.json(0)
-                sub_device_id = gateway_sub_device_qs[0]['id']
+                sub_device_id = gateway_sub_device_qs.values('id')[0]['id']
                 # 删除设备信息,场景信息,场景日志
                 with transaction.atomic():
                     gateway_sub_device_qs.delete()