From 69db9db18021b70b68ca47870f312843428ac26d Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 30 Apr 2024 18:01:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=A8=E5=8E=82=E7=94=B5=E9=87=8F?= =?UTF-8?q?=E8=AE=A1=E7=AE=97enstat2.elec=5Fconsume=E6=8B=BF=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E9=BB=98=E8=AE=A40,3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/tasks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index fbe5a3ce..81946e20 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -619,9 +619,11 @@ def cal_enstat2(type: str, year_s: int, month_s: int, day_s: int, cascade=True): ) if use_mpoint_elec_val: if type == 'day_s': - enstat2.elec_consume = MpointStat.objects.filter(type='day', mpoint__in=mp_elecs, year=year_s, month=month_s, day=day_s).aggregate(sum=Sum("val")).get('sum', 0) + enstat2.elec_consume = MpointStat.objects.filter(type='day', mpoint__in=mp_elecs, year=year_s, month=month_s, day=day_s).aggregate(sum=Sum("val"))['sum'] elif type == 'month_s': - enstat2.elec_consume = MpointStat.objects.filter(type='month', mpoint__in=mp_elecs, year=year_s, month=month_s).aggregate(sum=Sum("val")).get('sum', 0) + enstat2.elec_consume = MpointStat.objects.filter(type='month', mpoint__in=mp_elecs, year=year_s, month=month_s).aggregate(sum=Sum("val"))['sum'] + if enstat2.elec_consume is None: + enstat2.elec_consume = 0 else: enstat2.elec_consume = res_elec_pcoal["sum1"] if res_elec_pcoal["sum1"] else 0