fix: enm/service 修改service
This commit is contained in:
parent
345588b611
commit
47acf9ceb4
|
@ -45,6 +45,9 @@ class MpointSerializer(CustomModelSerializer):
|
|||
attrs["cate"] = "material"
|
||||
if "mgroup" in attrs and attrs["mgroup"]:
|
||||
attrs["belong_dept"] = attrs["mgroup"].belong_dept
|
||||
formula = attrs.get("formula", "")
|
||||
if formula:
|
||||
pass
|
||||
return attrs
|
||||
|
||||
|
||||
|
|
|
@ -25,17 +25,20 @@ def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour:
|
|||
"""
|
||||
pattern = r"\{(.*?)}"
|
||||
matches = re.findall(pattern, exp_str)
|
||||
exp_str2 = exp_str
|
||||
for match in matches:
|
||||
if match in ["enm_lhxs"]:
|
||||
exp_str = exp_str.replace(f"{{{match}}}", str(get_sysconfig(f"enm.{match}")))
|
||||
exp_str2 = exp_str2.replace(f"{{{match}}}", str(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()
|
||||
mpst = MpointStat.objects.filter(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)
|
||||
exp_str2 = exp_str2.replace(f"{{{match}}}", str(mpst.val))
|
||||
try:
|
||||
rval = eval(exp_str2)
|
||||
except Exception as e:
|
||||
myLogger.error(f"表达式计算错误: {e}")
|
||||
return rval
|
||||
|
||||
|
||||
def transfer_mpoint_val_to_ep_running_state(current_val, base_val: float, expr_str: str):
|
||||
"""
|
||||
将测点值转换所监测设备的运行状态值
|
||||
|
|
Loading…
Reference in New Issue