From ea5e0415757d8476e3aabc3d89bf8c1b526b1fdc Mon Sep 17 00:00:00 2001 From: zty Date: Thu, 27 Feb 2025 14:28:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20enm/task=20=E4=BF=AE=E6=94=B9=E7=8F=AD?= =?UTF-8?q?=E6=97=B6=E6=A0=A1=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/tasks.py | 1 + apps/enm/views.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index 9ca958b5..711f6d4a 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -492,6 +492,7 @@ def cal_mpointstat_manual(mpointId: str, sflogId: str, mgroupId: str, year: int, start_cal_type = 'month_s' elif year_s: start_cal_type = 'year_s' + myLogger.info('--------开始计算能源数据统计----') cal_enstat(start_cal_type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, day_s) diff --git a/apps/enm/views.py b/apps/enm/views.py index 8097c25c..77db0ebc 100644 --- a/apps/enm/views.py +++ b/apps/enm/views.py @@ -194,6 +194,7 @@ class MpointStatViewSet(BulkCreateModelMixin, BulkDestroyModelMixin, CustomListM sr = MpointStatCorrectSerializer(data=request.data) sr.is_valid(raise_exception=True) last_record = None + # 校正班月和月的统计值 if instance.type in ['month_s', 'month']: last_record = MpointStat.objects.filter(mpoint=instance.mpoint, type=instance.type, @@ -201,6 +202,7 @@ class MpointStatViewSet(BulkCreateModelMixin, BulkDestroyModelMixin, CustomListM year_s=instance.year_s, year = instance.year ).order_by(instance.type).values("id").last() + # 校正班天和天的统计值 elif instance.type in ['day_s', 'day']: last_record = MpointStat.objects.filter(mpoint=instance.mpoint, type=instance.type, @@ -218,7 +220,10 @@ class MpointStatViewSet(BulkCreateModelMixin, BulkDestroyModelMixin, CustomListM instance.val = val_correct instance.update_by = request.user instance.save() - mpoint, sflog, mgroup, year_s, month_s, day_s, year, month, day = instance.mpoint, instance.sflog, instance.mgroup, instance.year_s, instance.month_s, instance.day_s, instance.year, instance.month, instance.day + (mpoint, sflog, mgroup, year_s, month_s, day_s, year, month, day, hour) = ( + instance.mpoint, instance.sflog, instance.mgroup, + instance.year_s, instance.month_s, instance.day_s, instance.hour, + instance.year, instance.month, instance.day) # sflog 可能为None if sflog is None: sflogId = None @@ -228,7 +233,8 @@ class MpointStatViewSet(BulkCreateModelMixin, BulkDestroyModelMixin, CustomListM mgroupId = None else: mgroupId = mgroup.id - cal_mpointstat_manual.delay(mpoint.id, sflogId, mgroupId, year, month, day, None, year_s, month_s, day_s, next_cal=1) + myLogger.info(f'{mpoint.id}--{sflogId}--{mgroupId}--{year}--{month}--{day}--{hour}--{year_s}--{month_s}--{day_s}') + cal_mpointstat_manual.delay(mpoint.id, sflogId, mgroupId, year, month, day, hour, year_s, month_s, day_s, next_cal=1) return Response() @action(methods=["post"], detail=False, perms_map={"post": "mpointstat.correct"}, serializer_class=ReCalSerializer)