fix: 计算month_st时必须有sflog

This commit is contained in:
caoqianming 2024-05-16 12:34:26 +08:00
parent f836def404
commit 924c5d09b1
1 changed files with 2 additions and 1 deletions

View File

@ -365,6 +365,7 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
mytz = tz.gettz(settings.TIME_ZONE)
dt = datetime.datetime(year=year, month=month, day=day, hour=hour, tzinfo=mytz)
sflog = get_sflog(mgroup, dt)
team = None
if sflog:
year_s, month_s, day_s = sflog.get_ymd
team = sflog.team
@ -387,7 +388,7 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
enstat, _ = EnStat.objects.get_or_create(
type="day_s", mgroup=mgroup, year_s=year_s, month_s=month_s, day_s=day_s, defaults={"type": "day_s", "mgroup": mgroup, "year_s": year_s, "month_s": month_s, "day_s": day_s}
)
elif type == "month_st":
elif type == "month_st" and team:
enstat, _ = EnStat.objects.get_or_create(
type="month_st", mgroup=mgroup, team=team, year_s=year_s, month_s=month_s, defaults={"type": "month_st", "mgroup": mgroup, "year_s": year_s, "month_s": month_s, "team": team}
)