Browse Source

优化项目

peng 1 year ago
parent
commit
cef89594e2
1 changed files with 11 additions and 10 deletions
  1. 11 10
      Controller/SensorGateway/SmartSwitchController.py

+ 11 - 10
Controller/SensorGateway/SmartSwitchController.py

@@ -515,22 +515,23 @@ class SmartSwitchView(View):
         if not device_qs.exists():
             return response.json(173)
         device_id = device_qs[0]['id']
-        scheduler_qs = SwitchScheduler.objects.filter(device_id=device_id, id=scheduler_id).values('time_type_radio',
-                                                                                                   'time_point',
-                                                                                                   'start_time',
-                                                                                                   'end_time',
-                                                                                                   'actions',
-                                                                                                   'actions_type',
-                                                                                                   'slow_speed',
-                                                                                                   'repeat')
-        if not scheduler_qs.exists():
-            return response.json(173)
         try:
             scene_log = {
                 'status': operate_status,
                 'created_time': implement_time,
             }
             if event_type == '1':  # 排程任务
+                scheduler_qs = SwitchScheduler.objects.filter(device_id=device_id, id=scheduler_id).values(
+                    'time_type_radio',
+                    'time_point',
+                    'start_time',
+                    'end_time',
+                    'actions',
+                    'actions_type',
+                    'slow_speed',
+                    'repeat')
+                if not scheduler_qs.exists():
+                    return response.json(173)
                 scene_qs = SceneLog.objects.filter(created_time=send_time, device_id=device_id, scene_id=scheduler_id)
                 tasks = json.dumps(scheduler_qs[0])
                 scene_id = scheduler_id