fix: mpoitstat correct 时除0错误

This commit is contained in:
caoqianming 2024-05-16 11:34:06 +08:00
parent f10cf8d67d
commit f836def404
1 changed files with 5 additions and 1 deletions

View File

@ -494,8 +494,12 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
).exclude(mpoint__ep_monitored=None).update(total_production=total_production, elec_consume_unit=elec_consume_unit)
# 更新余热发电的production_elec_unit
if mgroup.name == "回转窑":
if enstat.total_production == 0:
production_elec_unit_yr = 0
else:
production_elec_unit_yr = F("total_production") / enstat.total_production
EnStat.objects.filter(type=enstat.type, year_s=enstat.year_s, month_s=enstat.month_s, day_s=enstat.day_s, hour=enstat.hour, mgroup__name="余热发电").update(
production_elec_unit=F("total_production") / enstat.total_production
production_elec_unit=production_elec_unit_yr
)
# 其他一些触发计算