From d73cc1af5b6a4117c73541e843e242c0fd478e12 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 6 May 2024 16:14:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=99=E8=80=97=E7=B3=BB=E6=95=B0?= =?UTF-8?q?=E5=8F=AF=E7=94=A8=E4=BA=8E=E6=B5=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/filters.py | 1 - apps/enm/services.py | 10 +++++++--- apps/enm/tasks.py | 5 +---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/enm/filters.py b/apps/enm/filters.py index d7c67f68..458fa419 100644 --- a/apps/enm/filters.py +++ b/apps/enm/filters.py @@ -98,7 +98,6 @@ class EnStatFilter(filters.FilterSet): "year_s": ["exact"], "year": ["exact"], "month": ["exact"], - "day_s": ["exact"], "day": ["exact"], "hour": ["exact"], } diff --git a/apps/enm/services.py b/apps/enm/services.py index 6f822176..49839e7f 100644 --- a/apps/enm/services.py +++ b/apps/enm/services.py @@ -11,6 +11,7 @@ from .serializers import MpointSerializer from apps.enp.models import EnvData from apps.em.models import Equipment from apps.em.services import set_eq_rs +from server.settings import get_sysconfig myLogger = logging.getLogger("log") @@ -22,9 +23,12 @@ def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour: pattern = r"\{(.*?)}" matches = re.findall(pattern, exp_str) for match in matches: - mpst = MpointStat.objects.filter(Q(mpoint__id=match) | Q(mpoint__name=match) | Q(mpoint__code=match), type="hour", year=year, month=month, day=day, hour=hour).first() - if mpst: - exp_str = exp_str.replace(f"{{{match}}}", str(mpst.val)) + if match in ['enm_lhxs']: + exp_str = exp_str.replace(f"{{{match}}}", get_sysconfig(f'enm.{match}')) + else: + mpst = MpointStat.objects.filter(Q(mpoint__id=match) | Q(mpoint__name=match) | Q(mpoint__code=match), type="hour", year=year, month=month, day=day, hour=hour).first() + if mpst: + exp_str = exp_str.replace(f"{{{match}}}", str(mpst.val)) rval = eval(exp_str) return rval diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index 18c7fa5c..f82db7b8 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -365,9 +365,6 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, if amount_consume is None: amount_consume = 0 if ind == 0 and has_product: # 如果是产量 - # 料耗系数 - if mgroup.name == '回转窑': - amount_consume = amount_consume / get_sysconfig('enm.enm_lhxs') enstat.total_production = amount_consume else: if material.code in ["pcoal", "cair", "steam"]: @@ -737,7 +734,7 @@ def king_insert_mplogx(): @shared_task(base=CustomTask) -def check_mpoint_offline(seconds=300): +def check_mpoint_offline(seconds=100): """监测测点采集掉线""" now = localtime() for mpoint in Mpoint.objects.filter(enabled=True, type=Mpoint.MT_AUTO):