diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index a3835dde..71ebede4 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -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