ソースを参照

修改时间点任务

peng 1 年間 前
コミット
3814a18033
1 ファイル変更5 行追加3 行削除
  1. 5 3
      Controller/SensorGateway/SmartSwitchController.py

+ 5 - 3
Controller/SensorGateway/SmartSwitchController.py

@@ -233,6 +233,8 @@ class SmartSwitchView(View):
             if not all([time_point]):
                 return response.json(444, {'param': 'timePoint'})
             time_point = int(time_point)
+            if time_point > 86400:
+                return response.json(444, {'param': 'timePoint'})
             scheduler_data = {
                 'device_id': device_id,
                 'time_type_radio': time_type_radio,
@@ -300,9 +302,9 @@ class SmartSwitchView(View):
                     else:
                         return response.json(444, {'param': 'actionsType'})
 
-                    time_str_hour = int(time_point / 60 // 60)
-                    time_str_minute = int(time_point / 60 % 60)
-                    celery_obj.creat_crontab_task(tz, task_id, MQTT_TASK, time_str_minute, time_str_hour, repeat,
+                    time_point_hour = int(time_point / 60 // 60)
+                    time_point_minute = int(time_point / 60 % 60)
+                    celery_obj.creat_crontab_task(tz, task_id, MQTT_TASK, time_point_minute, time_point_hour, repeat,
                                                   args=[serial_number, topic_name, msg, task_id, 1, device_id,
                                                         json.dumps(scheduler_data)])
                 else:  # 时间段任务