From cdc53fd14f9df77f83762981b81cca62151cff77 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 9 Aug 2023 15:07:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20month=5Fst=E8=AE=A1=E7=AE=97bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/tasks.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index 4e53e653..fc0a1731 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -227,7 +227,6 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, for type in new_types_list: cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, day_s, False) return - if not cal_attrs: this_cal_attrs = ['material', 'pcoal', 'run_hour'] else: @@ -354,14 +353,14 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, enstat.save() # 计算一些其他数据 if type == 'month_st' and 'material' in this_cal_attrs: # 如果计算的是班月,把主要设备电耗数据拉过来 - res = MpointStat.objects.filter(type='month_s', year_s=year_s, month_s=month_s, sflog__team=enstat.team, mpoint__ep_monitored__power_kw__gte=100).values( - equipment=F('mpoint__ep_monitored__id'), equipment_name=F('mpoint__ep_monitored__name'), consume=F('val')) + res = MpointStat.objects.filter(type='sflog', year_s=year_s, month_s=month_s, sflog__team=enstat.team, mpoint__ep_monitored__power_kw__gte=100).values( + equipment=F('mpoint__ep_monitored__id'), equipment_name=F('mpoint__ep_monitored__name')).annotate(consume=Sum('val')) res = list(res) for item in res: try: item['consume_unit'] = item['consume'] / enstat.total_production except ZeroDivisionError: - pass + item['consume_unit'] = None enstat.equip_elec_data = res enstat.save() if enstat.mgroup.name == '回转窑': # 算单位产品(综合电耗/标煤耗/综合能耗)