fix: month_st时equip_data计算失误
This commit is contained in:
parent
60ac9e6ac2
commit
ac0908dc11
|
@ -255,7 +255,7 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
|
|||
elif type == 'day_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' and team:
|
||||
elif type == 'month_st':
|
||||
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})
|
||||
elif type == 'month_s':
|
||||
|
@ -352,9 +352,9 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
|
|||
pass
|
||||
enstat.save()
|
||||
# 计算一些其他数据
|
||||
if type == 'month_st' and 'material' in cal_attrs: # 如果计算的是班月,把主要设备电耗数据拉过来
|
||||
res = MpointStat.objects.filter(type='sflog', year_s=year_s, month_s=month_s, sflog__team=enstat.team, mpoint__ep_monitored__power_kw__gte=100).annotate(
|
||||
equipment=F('mpoint__ep_monitored__id', equipment_name=F('mpoint__ep_monitored__name')), consume=F('val')).values('equipment', 'equipment_name', 'consume')
|
||||
if type == 'month_st' and 'material' in this_cal_attrs: # 如果计算的是班月,把主要设备电耗数据拉过来
|
||||
res = MpointStat.objects.filter(type='sflog', year_s=year_s, month_s=month_s, sflog__team=enstat.team, mpoint__ep_monitored__power_kw__gte=100).values(
|
||||
equipment=F('mpoint__ep_monitored__id'), equipment_name=F('mpoint__ep_monitored__name'), consume=F('val'))
|
||||
res = list(res)
|
||||
for item in res:
|
||||
try:
|
||||
|
@ -430,7 +430,7 @@ def get_total_hour_now_and_shut_hour(enstat: EnStat):
|
|||
# shut_hour = 1 - run_hour
|
||||
# shut_hour = shut_hour +
|
||||
# return 1, 0
|
||||
now = datetime.datetime.now()
|
||||
now = datetime.datetime.now().replace(tzinfo=tz.gettz(settings.TIME_ZONE))
|
||||
if enstat.type == 'sflog':
|
||||
sflog = enstat.sflog
|
||||
return sflog.total_hour_now, sflog.shut_hour
|
||||
|
|
Loading…
Reference in New Issue