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