feat: 添加计算系数后的enm task修改

This commit is contained in:
caoqianming 2024-12-25 15:24:26 +08:00
parent 4b5308b0cc
commit 1e4e80879f
2 changed files with 21 additions and 10 deletions

View File

@ -33,9 +33,6 @@ def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour:
matches = re.findall(pattern, exp_str)
exp_str2 = exp_str
for match in matches:
if match in ["enm_lhxs"]:
exp_str2 = exp_str2.replace(f"{{{match}}}", str(get_sysconfig(f"enm.{match}")))
else:
mpst = MpointStat.objects.filter(mpoint__code=match, type="hour", year=year, month=month, day=day, hour=hour).first()
if mpst is None:
mpoint = Mpoint.objects.get(code=match)

View File

@ -208,6 +208,20 @@ def cal_mpointstat_hour(mpointId: str, year: int, month: int, day: int, hour: in
else:
return
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
if material_code == 'elec':
val_level = get_elec_level(month, hour)