From 7c087024c9f6d1f7e07e21643a267c9e2c7cc65a Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 10 May 2024 13:17:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20cal=5Fmpointstats=E5=8F=AF=E6=8C=87?= =?UTF-8?q?=E5=AE=9Acal=5Fattrs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/tasks.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index b2ce633c..4eeaa65a 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -82,7 +82,7 @@ def get_current_and_previous_time(): @shared_task(base=CustomTask) -def cal_mpointstats_duration(start_time: str, end_time: str, m_code_list=[]): +def cal_mpointstats_duration(start_time: str, end_time: str, m_code_list=[], cal_attrs=[]): """ 重跑某一段时间的任务 """ @@ -94,7 +94,7 @@ def cal_mpointstats_duration(start_time: str, end_time: str, m_code_list=[]): current_time = start_time while current_time <= end_time: year, month, day, hour = current_time.year, current_time.month, current_time.day, current_time.hour - cal_mpointstats(0, year, month, day, hour, m_code_list) + cal_mpointstats(0, year, month, day, hour, m_code_list, cal_attrs=[]) current_time += datetime.timedelta(hours=1) @@ -194,9 +194,10 @@ def cal_mpointstat_hour(mpointId: str, year: int, month: int, day: int, hour: in @shared_task(base=CustomTask) -def cal_mpointstats(is_now=1, year=None, month=None, day=None, hour=None, m_code_list=[]): +def cal_mpointstats(is_now=1, year=None, month=None, day=None, hour=None, m_code_list=[], cal_attrs=[]): """ 计算所有自动采集测点的统计值,默认当前小时, 可手动传入时间和测点编号集 + cal_attrs: 需要计算的属性,空列表默认计算所有属性["material", "pcoal", "run_hour"] """ if year and month and day and hour is not None: pass @@ -240,7 +241,7 @@ def cal_mpointstats(is_now=1, year=None, month=None, day=None, hour=None, m_code year_s, month_s, day_s = 0, 0, 0 for mgroup in mgroups: # mgroups_group.append(cal_enstat.s('hour_s', None, mgroup.id, year, month, day, hour, None, None, None, True, ['material', 'run_hour'])) - year_s, month_s, day_s = cal_enstat("hour_s", None, mgroup.id, year, month, day, hour, None, None, None, True) + year_s, month_s, day_s = cal_enstat("hour_s", None, mgroup.id, year, month, day, hour, None, None, None, True, cal_attrs) # mgroups_t = mgroups.filter(name__in=['回转窑', '水泥磨']) # mgroups_t_group = []