diff --git a/apps/enm/services.py b/apps/enm/services.py index 9ddc595f..4c2d33de 100644 --- a/apps/enm/services.py +++ b/apps/enm/services.py @@ -2,6 +2,7 @@ from apps.enm.models import Mpoint, MpointStat, EnStat import re import traceback from apps.mtm.services import get_mgroup_goals +from django.db.models import Q def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour: int): @@ -12,7 +13,7 @@ def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour: matches = re.findall(pattern, exp_str) for match in matches: - mpst = MpointStat.objects.filter(type='hour', mpoint__id=match, year=year, month=month, day=day).first() + 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}}}", mpst.val)