refector: mgroup_on_change时创建stlog优化
This commit is contained in:
parent
d102f01c26
commit
592e34c07e
|
@ -127,9 +127,16 @@ def mgroup_run_change(mgroup: Mgroup, new_run: bool, last_timex: datetime):
|
||||||
last_stlog.save()
|
last_stlog.save()
|
||||||
cal_exp_duration_sec(last_stlog.id) # 触发时间分配
|
cal_exp_duration_sec(last_stlog.id) # 触发时间分配
|
||||||
elif last_stlog.end_time and new_run is False and last_timex > last_stlog.end_time: # 从开到停
|
elif last_stlog.end_time and new_run is False and last_timex > last_stlog.end_time: # 从开到停
|
||||||
has_same_stlog =StLog.objects.filter(mgroup=mgroup, is_shutdown=True, start_time=last_timex).exists()
|
StLog.objects.get_or_create(
|
||||||
if not has_same_stlog:
|
mgroup=mgroup,
|
||||||
StLog.objects.create(title="停机", is_shutdown=True, mgroup=mgroup, end_time=None, start_time=last_timex, sflog=get_sflog(mgroup, last_timex))
|
is_shutdown=True,
|
||||||
|
start_time=last_timex,
|
||||||
|
defaults={
|
||||||
|
'title': '停机',
|
||||||
|
'end_time': None,
|
||||||
|
'sflog': get_sflog(mgroup, last_timex)
|
||||||
|
}
|
||||||
|
)
|
||||||
elif new_run is False:
|
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))
|
StLog.objects.create(title="停机", is_shutdown=True, mgroup=mgroup, end_time=None, start_time=last_timex, sflog=get_sflog(mgroup, last_timex))
|
||||||
mgroup.is_running = False
|
mgroup.is_running = False
|
||||||
|
|
Loading…
Reference in New Issue