diff --git a/apps/enm/services.py b/apps/enm/services.py index 4d93dcf8..9656bb05 100644 --- a/apps/enm/services.py +++ b/apps/enm/services.py @@ -46,14 +46,13 @@ def transfer_mpoint_val_to_ep_running_state(current_val, base_val: float, expr_s matches = re.findall(pattern, expr_str) for match in matches: if match == "self": - expr_str = expr_str.replace(f"${{{match}}}", str(current_val)) + expr_str = expr_str.replace("{self}", str(current_val)) else: + match_val = 50 mpoint_data = MpointCache(match).data - if mpoint_data: - match_val = 50 - if mpoint_data.get("gather_state", -2) == 0: # 测点正常采集 - match_val = mpoint_data["last_data"]["last_mrs"] - expr_str = expr_str.replace(f"{{{match}}}", str(match_val)) + if mpoint_data and mpoint_data.get("gather_state", -2) == 0: # 测点正常采集 + match_val = mpoint_data["last_data"]["last_mrs"] + expr_str = expr_str.replace(f"{{{match}}}", str(match_val)) rval = eval(expr_str) return rval if isinstance(current_val, bool):