feat: mpointstat safe_get_or_create

This commit is contained in:
caoqianming 2024-12-24 21:59:41 +08:00
parent a8f9583f7f
commit 43509aa25a
1 changed files with 1 additions and 1 deletions

View File

@ -207,7 +207,7 @@ def cal_mpointstat_hour(mpointId: str, year: int, month: int, day: int, hour: in
val = translate_eval_formula(formula, year, month, day, hour) val = translate_eval_formula(formula, year, month, day, hour)
else: else:
return return
ms, _ = MpointStat.objects.get_or_create(**params, defaults=params) ms, _ = MpointStat.objects.safe_get_or_create(**params)
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)