fix: 计算month_st时必须有sflog
This commit is contained in:
parent
f836def404
commit
924c5d09b1
|
@ -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}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue