feat: cal_mpointstats支持传入指定测点集
This commit is contained in:
parent
10024f0d05
commit
4e4e923476
|
@ -82,7 +82,7 @@ def get_current_and_previous_time():
|
|||
|
||||
|
||||
@shared_task(base=CustomTask)
|
||||
def cal_mpointstats_duration(start_time: str, end_time: str):
|
||||
def cal_mpointstats_duration(start_time: str, end_time: str, m_code_list=[]):
|
||||
"""
|
||||
重跑某一段时间的任务
|
||||
"""
|
||||
|
@ -94,7 +94,7 @@ def cal_mpointstats_duration(start_time: str, end_time: str):
|
|||
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)
|
||||
cal_mpointstats(0, year, month, day, hour, m_code_list)
|
||||
current_time += datetime.timedelta(hours=1)
|
||||
|
||||
|
||||
|
@ -194,9 +194,9 @@ 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):
|
||||
def cal_mpointstats(is_now=1, year=None, month=None, day=None, hour=None, m_code_list=[]):
|
||||
"""
|
||||
计算所有自动采集测点的统计值,默认当前小时, 可手动传入时间
|
||||
计算所有自动采集测点的统计值,默认当前小时, 可手动传入时间和测点编号集
|
||||
"""
|
||||
if year and month and day and hour is not None:
|
||||
pass
|
||||
|
@ -206,20 +206,29 @@ def cal_mpointstats(is_now=1, year=None, month=None, day=None, hour=None):
|
|||
year, month, day, hour = now.year, now.month, now.day, now.hour
|
||||
else:
|
||||
year, month, day, hour = pre.year, pre.month, pre.day, pre.hour
|
||||
if m_code_list:
|
||||
mpoints1 = Mpoint.objects.filter(code__in=m_code_list)
|
||||
mpoints_related = Mpoint.objects.none()
|
||||
for item in mpoints1:
|
||||
cal_mpointstat_hour(item.id, year, month, day, hour)
|
||||
mpoints_related = mpoints_related | Mpoint.objects.filter(type=Mpoint.MT_COMPUTE, enabled=True, material__isnull=False, formula__contains='{' + item.code + '}')
|
||||
mpoints_related = mpoints_related.order_by('report_sortstr', 'create_time')
|
||||
for item in mpoints_related:
|
||||
cal_mpointstat_hour(item.id, year, month, day, hour)
|
||||
else:
|
||||
# 先统计自动采集的测点
|
||||
mpoints_auto = Mpoint.objects.filter(type=Mpoint.MT_AUTO, enabled=True)
|
||||
# mpoints_without_formula_group = []
|
||||
for item in mpoints_auto:
|
||||
# mpoints_without_formula_group.append(cal_mpointstat_hour.s(item.id, year, month, day, hour))
|
||||
cal_mpointstat_hour(item.id, year, month, day, hour)
|
||||
|
||||
# 先统计自动采集的测点
|
||||
mpoints_auto = Mpoint.objects.filter(type=Mpoint.MT_AUTO, enabled=True)
|
||||
# mpoints_without_formula_group = []
|
||||
for item in mpoints_auto:
|
||||
# mpoints_without_formula_group.append(cal_mpointstat_hour.s(item.id, year, month, day, hour))
|
||||
cal_mpointstat_hour(item.id, year, month, day, hour)
|
||||
|
||||
# 再统计计算测点
|
||||
mpoints_compute = Mpoint.objects.filter(type=Mpoint.MT_COMPUTE, enabled=True, material__isnull=False).exclude(formula="").order_by('report_sortstr', 'create_time')
|
||||
# mpoints_other_group = []
|
||||
for item in mpoints_compute:
|
||||
# mpoints_other_group.append(cal_mpointstat_hour.s(item.id, year, month, day, hour))
|
||||
cal_mpointstat_hour(item.id, year, month, day, hour)
|
||||
# 再统计计算测点
|
||||
mpoints_compute = Mpoint.objects.filter(type=Mpoint.MT_COMPUTE, enabled=True, material__isnull=False).exclude(formula="").order_by('report_sortstr', 'create_time')
|
||||
# mpoints_other_group = []
|
||||
for item in mpoints_compute:
|
||||
# mpoints_other_group.append(cal_mpointstat_hour.s(item.id, year, month, day, hour))
|
||||
cal_mpointstat_hour(item.id, year, month, day, hour)
|
||||
|
||||
# 先调整一下班时间,以防计算错误
|
||||
get_total_hour_now() # 先处理total_hour_now
|
||||
|
|
Loading…
Reference in New Issue