feat: enm/task 修改班时校正
This commit is contained in:
parent
bf35064f6e
commit
ea5e041575
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue