From ac0908dc112527d2bbf161999b4206cad6453367 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 3 Aug 2023 11:16:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20month=5Fst=E6=97=B6equip=5Fdata=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=A4=B1=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/tasks.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index 2947b33a..d18e7f97 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -255,7 +255,7 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, elif type == 'day_s': enstat, _ = EnStat.objects.get_or_create(type="day_s", mgroup=mgroup, year_s=year_s, month_s=month_s, day_s=day_s, defaults={'type': 'day_s', 'mgroup': mgroup, 'year_s': year_s, 'month_s': month_s, 'day_s': day_s}) - elif type == 'month_st' and team: + elif type == 'month_st': enstat, _ = EnStat.objects.get_or_create(type="month_st", mgroup=mgroup, team=team, year_s=year_s, month_s=month_s, defaults={'type': 'month_st', 'mgroup': mgroup, 'year_s': year_s, 'month_s': month_s, 'team': team}) elif type == 'month_s': @@ -352,9 +352,9 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, pass enstat.save() # 计算一些其他数据 - if type == 'month_st' and 'material' in cal_attrs: # 如果计算的是班月,把主要设备电耗数据拉过来 - 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).annotate( - equipment=F('mpoint__ep_monitored__id', equipment_name=F('mpoint__ep_monitored__name')), consume=F('val')).values('equipment', 'equipment_name', 'consume') + if type == 'month_st' and 'material' in this_cal_attrs: # 如果计算的是班月,把主要设备电耗数据拉过来 + 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'), consume=F('val')) res = list(res) for item in res: try: @@ -430,7 +430,7 @@ def get_total_hour_now_and_shut_hour(enstat: EnStat): # shut_hour = 1 - run_hour # shut_hour = shut_hour + # return 1, 0 - now = datetime.datetime.now() + now = datetime.datetime.now().replace(tzinfo=tz.gettz(settings.TIME_ZONE)) if enstat.type == 'sflog': sflog = enstat.sflog return sflog.total_hour_now, sflog.shut_hour