Browse Source

修改时间点任务

peng 1 year ago
parent
commit
8ab6d93d65
1 changed files with 4 additions and 3 deletions
  1. 4 3
      Controller/SensorGateway/SmartSwitchController.py

+ 4 - 3
Controller/SensorGateway/SmartSwitchController.py

@@ -232,6 +232,7 @@ class SmartSwitchView(View):
         if time_type_radio == 1:  # 时间点
             if not all([time_point]):
                 return response.json(444, {'param': 'timePoint'})
+            time_point = int(time_point)
             scheduler_data = {
                 'device_id': device_id,
                 'time_type_radio': time_type_radio,
@@ -299,9 +300,9 @@ class SmartSwitchView(View):
                     else:
                         return response.json(444, {'param': 'actionsType'})
 
-                    time_str = datetime.datetime.fromtimestamp(int(time_point))
-                    celery_obj.creat_crontab_task(tz, task_id, MQTT_TASK, time_str.minute,
-                                                  time_str.hour, repeat,
+                    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,
                                                   args=[serial_number, topic_name, msg, task_id, 1, device_id,
                                                         json.dumps(scheduler_data)])
                 else:  # 时间段任务