diff --git a/apps/enm/services.py b/apps/enm/services.py index 9a68e374..52af8419 100644 --- a/apps/enm/services.py +++ b/apps/enm/services.py @@ -27,10 +27,8 @@ 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(Q(mpoint__id=match) | Q(mpoint__name=match) | Q(mpoint__code=match), type="hour", year=year, month=month, day=day, hour=hour).first() - val = 0 if mpst: - val = mpst.val - exp_str = exp_str.replace(f"${{{match}}}", str(val)) + exp_str = exp_str.replace(f"${{{match}}}", str(mpst.val)) rval = eval(exp_str) return rval