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