feat: 添加计算系数后的enm task修改
This commit is contained in:
parent
4b5308b0cc
commit
1e4e80879f
|
@ -33,9 +33,6 @@ 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"]:
|
|
||||||
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()
|
mpst = MpointStat.objects.filter(mpoint__code=match, type="hour", year=year, month=month, day=day, hour=hour).first()
|
||||||
if mpst is None:
|
if mpst is None:
|
||||||
mpoint = Mpoint.objects.get(code=match)
|
mpoint = Mpoint.objects.get(code=match)
|
||||||
|
|
|
@ -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