fix: transfer_mpoint_val_to_ep_running_state 对expr_str的replace
This commit is contained in:
parent
52fc0c6bd3
commit
25965c7072
|
@ -46,7 +46,10 @@ def transfer_mpoint_val_to_ep_running_state(current_val, base_val: float, expr_s
|
||||||
else:
|
else:
|
||||||
mpoint_data = MpointCache(match).data
|
mpoint_data = MpointCache(match).data
|
||||||
if mpoint_data:
|
if mpoint_data:
|
||||||
expr_str = expr_str.replace(f"{{{match}}}", str(mpoint_data['last_data']['last_val'])) # 这个last_val可能不存在
|
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))
|
||||||
rval = eval(expr_str)
|
rval = eval(expr_str)
|
||||||
return rval
|
return rval
|
||||||
if isinstance(current_val, bool):
|
if isinstance(current_val, bool):
|
||||||
|
@ -136,7 +139,7 @@ class MpointCache:
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
mpoint_data = MpointSerializer(instance=mpoint).data
|
mpoint_data = MpointSerializer(instance=mpoint).data
|
||||||
mpoint_data['last_data'] = {'last_val': None, 'last_timex': None}
|
mpoint_data['last_data'] = {'last_val': None, 'last_timex': None, 'last_mrs': None} # 初始化
|
||||||
if update_mplogx:
|
if update_mplogx:
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
last_mplogx = MpLogx.objects.filter(mpoint=mpoint, timex__gte=now - timedelta(minutes=5)).order_by("-timex").first()
|
last_mplogx = MpLogx.objects.filter(mpoint=mpoint, timex__gte=now - timedelta(minutes=5)).order_by("-timex").first()
|
||||||
|
|
Loading…
Reference in New Issue