fix: mgroup_run_change bug

This commit is contained in:
caoqianming 2024-07-31 15:34:50 +08:00
parent bea83f93d5
commit 19167887d5
1 changed files with 2 additions and 2 deletions

View File

@ -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))