feat: 添加计算系数后的enm task修改
This commit is contained in:
parent
4b5308b0cc
commit
1e4e80879f
|
@ -33,16 +33,13 @@ def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour:
|
||||||
matches = re.findall(pattern, exp_str)
|
matches = re.findall(pattern, exp_str)
|
||||||
exp_str2 = exp_str
|
exp_str2 = exp_str
|
||||||
for match in matches:
|
for match in matches:
|
||||||
if match in ["enm_lhxs"]:
|
mpst = MpointStat.objects.filter(mpoint__code=match, type="hour", year=year, month=month, day=day, hour=hour).first()
|
||||||
exp_str2 = exp_str2.replace(f"{{{match}}}", str(get_sysconfig(f"enm.{match}")))
|
if mpst is None:
|
||||||
else:
|
mpoint = Mpoint.objects.get(code=match)
|
||||||
mpst = MpointStat.objects.filter(mpoint__code=match, type="hour", year=year, month=month, day=day, hour=hour).first()
|
mpst, _ = MpointStat.objects.get_or_create(mpoint=mpoint, type="hour", year=year, month=month, day=day, hour=hour, defaults={"val": 0})
|
||||||
if mpst is None:
|
myLogger.error(f"找不到该测点的时间线数据: {match}, {year}, {month}, {day}, {hour}, 赋予0值")
|
||||||
mpoint = Mpoint.objects.get(code=match)
|
if mpst:
|
||||||
mpst, _ = MpointStat.objects.get_or_create(mpoint=mpoint, type="hour", year=year, month=month, day=day, hour=hour, defaults={"val": 0})
|
exp_str2 = exp_str2.replace(f"{{{match}}}", str(mpst.val))
|
||||||
myLogger.error(f"找不到该测点的时间线数据: {match}, {year}, {month}, {day}, {hour}, 赋予0值")
|
|
||||||
if mpst:
|
|
||||||
exp_str2 = exp_str2.replace(f"{{{match}}}", str(mpst.val))
|
|
||||||
try:
|
try:
|
||||||
rval = eval(exp_str2)
|
rval = eval(exp_str2)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -208,6 +208,20 @@ def cal_mpointstat_hour(mpointId: str, year: int, month: int, day: int, hour: in
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
ms, _ = MpointStat.safe_get_or_create(**params)
|
ms, _ = MpointStat.safe_get_or_create(**params)
|
||||||
|
ms.val_origin = val
|
||||||
|
need_cal_co = False
|
||||||
|
if ms.current_cal_coefficient is None and mpoint.cal_coefficient is not None:
|
||||||
|
ms.current_cal_coefficient = mpoint.cal_coefficient
|
||||||
|
need_cal_co = True
|
||||||
|
elif ms.current_cal_coefficient is not None:
|
||||||
|
need_cal_co = True
|
||||||
|
|
||||||
|
if need_cal_co:
|
||||||
|
if mpoint.cal_coefficient_method == 1:
|
||||||
|
val = val * ms.current_cal_coefficient
|
||||||
|
elif mpoint.cal_coefficient_method == 2:
|
||||||
|
val = val / ms.current_cal_coefficient
|
||||||
|
# 如果有correct直接用correct代替
|
||||||
ms.val = ms.val_correct if ms.val_correct is not None else val
|
ms.val = ms.val_correct if ms.val_correct is not None else val
|
||||||
if material_code == 'elec':
|
if material_code == 'elec':
|
||||||
val_level = get_elec_level(month, hour)
|
val_level = get_elec_level(month, hour)
|
||||||
|
|
Loading…
Reference in New Issue