From 7fd10f3e51e4b3d838a75fce25462dfaa7019ed8 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 3 Aug 2023 13:58:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20pcoal=5Fcoal=5Fconsume=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=B8=BANone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/tasks.py | 5 +++++ 1 file changed, 5 insertions(+) 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