From cd652f3696e7668820303774c2d8f0a95c188e86 Mon Sep 17 00:00:00 2001 From: zty Date: Fri, 17 Jan 2025 16:08:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:enm/service=20=E4=BF=AE=E6=94=B9translate?= =?UTF-8?q?=5Feval=5Fformula?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/services.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/enm/services.py b/apps/enm/services.py index c5bf7711..bf08301c 100644 --- a/apps/enm/services.py +++ b/apps/enm/services.py @@ -42,11 +42,12 @@ def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour: # exp_str2 = exp_str2.replace(f"{{{match}}}", str(mpst.val)) # 为了校正计算测点 exp_str2 = exp_str2.replace(f"{{{match}}}", str(mpst.val if mpst.val_correct is None else mpst.val_correct)) + rval = 0 try: rval = eval(exp_str2) except Exception as e: myLogger.error(f"表达式计算错误: {e}, {exp_str}, --{exp_str2}") - + rval = 0 return rval def transfer_mpoint_val_to_ep_running_state(current_val, base_val: float, expr_str: str):