feat: 暂时先同步执行,后面再优化
This commit is contained in:
parent
25e49601a5
commit
d1d427927e
|
@ -152,33 +152,33 @@ def cal_mpointstats(is_now=1, year=None, month=None, day=None, hour=None):
|
||||||
|
|
||||||
# 先统计不带公式的测点
|
# 先统计不带公式的测点
|
||||||
mpoints_without_formula = Mpoint.objects.filter(is_auto=True, formula='')
|
mpoints_without_formula = Mpoint.objects.filter(is_auto=True, formula='')
|
||||||
mpoints_without_formula_group = []
|
# mpoints_without_formula_group = []
|
||||||
for item in mpoints_without_formula:
|
for item in mpoints_without_formula:
|
||||||
mpoints_without_formula_group.append(cal_mpointstat_hour.s(item.id, year, month, day, hour))
|
# mpoints_without_formula_group.append(cal_mpointstat_hour.s(item.id, year, month, day, hour))
|
||||||
# cal_mpointstat_hour(item.id, year, month, day, hour)
|
cal_mpointstat_hour(item.id, year, month, day, hour)
|
||||||
|
|
||||||
# 再统计其他测点
|
# 再统计其他测点
|
||||||
mpoints_other = Mpoint.objects.filter(is_auto=True).exclude(formula='')
|
mpoints_other = Mpoint.objects.filter(is_auto=True).exclude(formula='')
|
||||||
mpoints_other_group = []
|
# mpoints_other_group = []
|
||||||
for item in mpoints_other:
|
for item in mpoints_other:
|
||||||
mpoints_other_group.append(cal_mpointstat_hour.s(item.id, year, month, day, hour))
|
# mpoints_other_group.append(cal_mpointstat_hour.s(item.id, year, month, day, hour))
|
||||||
# cal_mpointstat_hour(item.id, year, month, day, hour)
|
cal_mpointstat_hour(item.id, year, month, day, hour)
|
||||||
|
|
||||||
# 开始计算enstat
|
# 开始计算enstat
|
||||||
mgroups = Mgroup.objects.all().order_by('sort')
|
mgroups = Mgroup.objects.all().order_by('sort')
|
||||||
mgroups_group = []
|
mgroups_group = []
|
||||||
for mgroup in mgroups:
|
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']))
|
# mgroups_group.append(cal_enstat.s('hour_s', None, mgroup.id, year, month, day, hour, None, None, None, True, ['material', 'run_hour']))
|
||||||
# cal_enstat('hour_s', None, mgroup.id, year, month, day, hour, None, None, None, True)
|
cal_enstat('hour_s', None, mgroup.id, year, month, day, hour, None, None, None, True)
|
||||||
|
|
||||||
mgroups_t = mgroups.filter(name__in=['回转窑', '水泥磨'])
|
# mgroups_t = mgroups.filter(name__in=['回转窑', '水泥磨'])
|
||||||
mgroups_t_group = []
|
# mgroups_t_group = []
|
||||||
for mgroup in mgroups_t:
|
# for mgroup in mgroups_t:
|
||||||
mgroups_t_group.append(cal_enstat.s('hour_s', None, mgroup.id, year, month, day, hour, None, None, None, True, ['pcoal']))
|
# mgroups_t_group.append(cal_enstat.s('hour_s', None, mgroup.id, year, month, day, hour, None, None, None, True, ['pcoal']))
|
||||||
# 最后计算enstat2
|
# 最后计算enstat2
|
||||||
|
cal_enstat2(year_s=year, month_s=month)
|
||||||
task_chain = chain(group(mpoints_without_formula_group), group(mpoints_other_group), group(mgroups_group), group(mgroups_t_group), group([cal_enstat2.s(year_s=year, month_s=month)]))
|
# task_chain = chain(group(mpoints_without_formula_group), group(mpoints_other_group), group(mgroups_group), group(mgroups_t_group), group([cal_enstat2.s(year_s=year, month_s=month)]))
|
||||||
task_chain.delay()
|
# task_chain.delay()
|
||||||
|
|
||||||
@shared_task(base=CustomTask)
|
@shared_task(base=CustomTask)
|
||||||
def cal_mpointstat_manual(mpointId: str, sflogId: str, mgroupId: str, year: int, month: int, day: int, hour: int, year_s: int, month_s: int, day_s: int, next_cal=0):
|
def cal_mpointstat_manual(mpointId: str, sflogId: str, mgroupId: str, year: int, month: int, day: int, hour: int, year_s: int, month_s: int, day_s: int, next_cal=0):
|
||||||
|
|
|
@ -265,7 +265,7 @@ AUTHENTICATION_BACKENDS = (
|
||||||
CACHES = {
|
CACHES = {
|
||||||
"default": {
|
"default": {
|
||||||
"BACKEND": "django_redis.cache.RedisCache",
|
"BACKEND": "django_redis.cache.RedisCache",
|
||||||
"LOCATION": "redis://localhost:6379/2",
|
"LOCATION": "redis://127.0.0.1:6379/2",
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ CACHES = {
|
||||||
}
|
}
|
||||||
|
|
||||||
# celery配置,celery正常运行必须安装redis
|
# celery配置,celery正常运行必须安装redis
|
||||||
CELERY_BROKER_URL = "redis://localhost:6379/2" # 任务存储
|
CELERY_BROKER_URL = "redis://127.0.0.1:6379/3" # 任务存储
|
||||||
CELERYD_MAX_TASKS_PER_CHILD = 100 # 每个worker最多执行100个任务就会被销毁,可防止内存泄露
|
CELERYD_MAX_TASKS_PER_CHILD = 100 # 每个worker最多执行100个任务就会被销毁,可防止内存泄露
|
||||||
CELERY_TIMEZONE = 'Asia/Shanghai' # 设置时区
|
CELERY_TIMEZONE = 'Asia/Shanghai' # 设置时区
|
||||||
CELERY_ENABLE_UTC = True # 启动时区设置
|
CELERY_ENABLE_UTC = True # 启动时区设置
|
||||||
|
|
Loading…
Reference in New Issue