locky 1 жил өмнө
parent
commit
10d4305260

+ 3 - 4
Controller/SensorGateway/SmartSceneController.py

@@ -1176,7 +1176,7 @@ class SmartSceneView(View):
         @return: task_id, time_dict
         """
         task_id = serial_number + '_'
-        apscheduler_obj = ApschedulerObject()
+        apscheduler_obj = ApschedulerObject(tz)
         # 一次性任务
         if repeat == 0:
             # 根据时间戳和时区获取年月日,拼接由分钟转换出来的时间
@@ -1234,9 +1234,8 @@ class SmartSceneView(View):
         @param is_next_day: 是否隔天
         @return: weeks
         """
-        # 十进制转为7位的二进制,低六位倒序
-        bin_str = bin(repeat)[2:].zfill(7)
-        bin_str = bin_str[:1] + bin_str[-6:][::-1]
+        # 十进制转为7位的二进制并倒序
+        bin_str = bin(repeat)[2:].zfill(7)[::-1]
         # 生成星期周期字符串
         weeks = ''
         next_day = 1 if is_next_day else 0

+ 4 - 5
Object/ApschedulerObject.py

@@ -21,11 +21,10 @@ class ApschedulerObject:
         print('hello world: {} {}'.format(x, now_time))
 
     def create_cron_job(self, func, task_id, day_of_week, hour, minute, args, second=0):  # 周期任务
-        job = self.scheduler.add_job(func=func, trigger='cron', day_of_week=day_of_week, hour=hour, minute=minute,
-                                     second=second,
-                                     replace_existing=True, id=task_id, max_instances=1, coalesce=False, args=args,
-                                     misfire_grace_time=300)
-        print(job)
+        # day_of_week: 0,1,2,3,4,5,6对应周一到周日,也可写mon,tue,wed,thu,fri,sat,sun
+        self.scheduler.add_job(func=func, trigger='cron', day_of_week=day_of_week, hour=hour, minute=minute,
+                               second=second, replace_existing=True, id=task_id, max_instances=1, coalesce=False,
+                               args=args, misfire_grace_time=300)
 
     def create_interval_job(self, func, task_id, minutes, start_time, end_time, args):  # 间隔任务
         self.scheduler.add_job(func=func, trigger='interval', minutes=minutes,

+ 1 - 0
Service/CommonService.py

@@ -863,3 +863,4 @@ GCqvlyw5dfxNA+EtxNE2wCW/LW7ENJlACgcfgPlBZtpLheWoZB/maw4=
         else:
             # 截掉.00然后转为浮点型
             tz = float(gateway_push_qs.tz[:-3])
+        return tz