fix: month_st计算bug
This commit is contained in:
parent
fef37ebcd7
commit
cdc53fd14f
|
@ -227,7 +227,6 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
|
|||
for type in new_types_list:
|
||||
cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, day_s, False)
|
||||
return
|
||||
|
||||
if not cal_attrs:
|
||||
this_cal_attrs = ['material', 'pcoal', 'run_hour']
|
||||
else:
|
||||
|
@ -354,14 +353,14 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
|
|||
enstat.save()
|
||||
# 计算一些其他数据
|
||||
if type == 'month_st' and 'material' in this_cal_attrs: # 如果计算的是班月,把主要设备电耗数据拉过来
|
||||
res = MpointStat.objects.filter(type='month_s', 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 = 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')).annotate(consume=Sum('val'))
|
||||
res = list(res)
|
||||
for item in res:
|
||||
try:
|
||||
item['consume_unit'] = item['consume'] / enstat.total_production
|
||||
except ZeroDivisionError:
|
||||
pass
|
||||
item['consume_unit'] = None
|
||||
enstat.equip_elec_data = res
|
||||
enstat.save()
|
||||
if enstat.mgroup.name == '回转窑': # 算单位产品(综合电耗/标煤耗/综合能耗)
|
||||
|
|
Loading…
Reference in New Issue