diff --git a/apps/wpm/tasks.py b/apps/wpm/tasks.py index ac966b18..b28c2e07 100644 --- a/apps/wpm/tasks.py +++ b/apps/wpm/tasks.py @@ -79,11 +79,12 @@ def cal_shut_hour(stlogId: str): sflogexp, _ = SfLogExp.objects.get_or_create(stlog=stlog, sflog=sflog, defaults={'stlog': stlog, 'sflog': sflog, 'is_current_down': is_current_down, 'title': '停机'}) # 计算duration sf_end, sf_start = sflog.end_time, sflog.start_time - duration_item = min(sf_end, st_end) - min(sf_start, st_start) - if duration_item < 0: + duration_item_delta = min(sf_end, st_end) - min(sf_start, st_start) + total_seconds = duration_item_delta.total_seconds() + if total_seconds < 0: duration_item = 0 else: - duration_item = duration_item.total_seconds()/3600 + duration_item = total_seconds/3600 sflogexp.duration = duration_item sflogexp.save() # 计算每班的总停机时间