From d1d427927ee30b5f80ccb160529cd5c90c28e3d5 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 2 Aug 2023 15:09:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9A=82=E6=97=B6=E5=85=88=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=89=A7=E8=A1=8C,=E5=90=8E=E9=9D=A2=E5=86=8D?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/tasks.py | 30 +++++++++++++++--------------- server/settings.py | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index a80b5011..aac00bc1 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -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_group = [] + # mpoints_without_formula_group = [] for item in mpoints_without_formula: - 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_without_formula_group.append(cal_mpointstat_hour.s(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_group = [] + # mpoints_other_group = [] for item in mpoints_other: - mpoints_other_group.append(cal_mpointstat_hour.s(item.id, year, month, day, hour)) - # cal_mpointstat_hour(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) # 开始计算enstat mgroups = Mgroup.objects.all().order_by('sort') mgroups_group = [] 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'])) - # cal_enstat('hour_s', None, mgroup.id, year, month, day, hour, None, None, None, True) + # 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) - mgroups_t = mgroups.filter(name__in=['回转窑', '水泥磨']) - mgroups_t_group = [] - 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 = mgroups.filter(name__in=['回转窑', '水泥磨']) + # mgroups_t_group = [] + # 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'])) # 最后计算enstat2 - - 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() + 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.delay() @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): diff --git a/server/settings.py b/server/settings.py index ab3de955..eb0168dc 100755 --- a/server/settings.py +++ b/server/settings.py @@ -265,7 +265,7 @@ AUTHENTICATION_BACKENDS = ( CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": "redis://localhost:6379/2", + "LOCATION": "redis://127.0.0.1:6379/2", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", } @@ -273,7 +273,7 @@ CACHES = { } # 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个任务就会被销毁,可防止内存泄露 CELERY_TIMEZONE = 'Asia/Shanghai' # 设置时区 CELERY_ENABLE_UTC = True # 启动时区设置