fix: pcoal_coal_consume可能为None

This commit is contained in:
caoqianming 2023-08-03 13:58:15 +08:00
parent cb60fe2728
commit 7fd10f3e51
1 changed files with 5 additions and 0 deletions

View File

@ -386,6 +386,9 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
elif type == 'year_s':
enstat.pcoal_coal_consume = EnStat.objects.filter(type='sflog', mgroup=enstat.mgroup, year_s=year_s).aggregate(sum=Sum('pcoal_coal_consume'))['sum']
if enstat.pcoal_coal_consume is None:
enstat.pcoal_coal_consume = 0
# 算单位产品标煤耗
try:
enstat.coal_consume_unit = enstat.pcoal_coal_consume /enstat.total_production
@ -522,6 +525,8 @@ def cal_enstat_pcoal_change(enstat, new_pcoal_heat):
elif type == 'year_s':
enstat.pcoal_coal_consume = EnStat.objects.filter(type='sflog', mgroup=enstat.mgroup, year_s=enstat.year_s).aggregate(sum=Sum('pcoal_coal_consume'))['sum']
if enstat.pcoal_coal_consume is None:
enstat.pcoal_coal_consume = 0
# 算单位产品标煤耗
try:
enstat.coal_consume_unit = enstat.pcoal_coal_consume /enstat.total_production