From 15744998740b392fd8c1c07f19621729bf3a8fa7 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 16 May 2024 11:27:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mpoitstat=20correct=20=E6=97=B6=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E9=94=99=E8=AF=AF3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/tasks.py | 8 ++++---- apps/enm/views.py | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index 6910f5f2..912dcc7a 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -367,10 +367,10 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, sflog = get_sflog(mgroup, dt) if sflog: year_s, month_s, day_s = sflog.get_ymd - team = sflog.team - # 如果没有班组,那么month_st无需计算 - if team is None and type == "month_st": - return year_s, month_s, day_s + team = sflog.team + # 如果没有班组,那么month_st无需计算 + if team is None and type == "month_st": + return year_s, month_s, day_s if type == "hour_s": enstat, _ = EnStat.objects.get_or_create( type="hour_s", diff --git a/apps/enm/views.py b/apps/enm/views.py index 092f0184..dacd9b55 100644 --- a/apps/enm/views.py +++ b/apps/enm/views.py @@ -124,15 +124,14 @@ class MpointStatViewSet(BulkCreateModelMixin, BulkDestroyModelMixin, CustomListM 修正测点统计记录及统计值 """ - instance = self.get_object() + instance: MpointStat = self.get_object() sr = MpointStatCorrectSerializer(data=request.data) sr.is_valid(raise_exception=True) vdata = sr.validated_data val_correct = vdata["val_correct"] - if val_correct: - instance.val_correct = val_correct - instance.val = val_correct - instance.save() + instance.val_correct = val_correct + instance.val = val_correct + instance.save(update_by=request.user) mpoint, sflog, mgroup, year_s, month_s, day_s = instance.mpoint, instance.sflog, instance.mgroup, instance.year_s, instance.month_s, instance.day_s # sflog 可能为None if sflog is None: