feat: cal_mpointstats可指定cal_attrs

This commit is contained in:
caoqianming 2024-05-10 13:17:02 +08:00
parent 4e4e923476
commit 7c087024c9
1 changed files with 5 additions and 4 deletions

View File

@ -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 = []