diff --git a/apps/mtm/services.py b/apps/mtm/services.py index 9c4a4783..d935fc48 100644 --- a/apps/mtm/services.py +++ b/apps/mtm/services.py @@ -124,8 +124,8 @@ def mgroup_run_change(mgroup: Mgroup, new_run: bool, last_timex: datetime): last_stlog.save() cal_exp_duration_sec(last_stlog.id) # 触发时间分配 elif last_stlog.end_time and new_run is False and last_timex > last_stlog.end_time: # 从开到停 - last_stlog2 = StLog.objects.filter(mgroup=mgroup, is_shutdown=True).order_by("-start_time").first() - if not last_stlog2: + has_same_stlog =StLog.objects.filter(mgroup=mgroup, is_shutdown=True, start_time=last_timex).exists() + if not has_same_stlog: StLog.objects.create(title="停机", is_shutdown=True, mgroup=mgroup, end_time=None, start_time=last_timex, sflog=get_sflog(mgroup, last_timex)) elif new_run is False: StLog.objects.create(title="停机", is_shutdown=True, mgroup=mgroup, end_time=None, start_time=last_timex, sflog=get_sflog(mgroup, last_timex))