fix: cal_mpointstat_hour对于is_unit的计算错误

This commit is contained in:
zty 2024-08-06 17:52:21 +08:00
parent 91e9ac38f6
commit f97c99bf8a
1 changed files with 1 additions and 1 deletions

View File

@ -143,7 +143,7 @@ def cal_mpointstat_hour(mpointId: str, year: int, month: int, day: int, hour: in
val_type = mpoint.val_type
if mpoint.type == Mpoint.MT_AUTO:
if mpoint.is_unit:
val = MpLogx.objects.filter(mpoint=mpoint, timex__gte=dt, timex__lt=dt_hour_n).aggregate(Sum("val"))["val__sum"] or 0
val = MpLogx.objects.filter(mpoint=mpoint, timex__gte=dt, timex__lt=dt_hour_n).aggregate(sum=Sum(f'val_{mpoint.val_type}'))["sum"] or 0
else:
mrs0 = MpLogx.objects.filter(mpoint=mpoint, timex__gte=dt_hour_p, timex__lte=dt).order_by("timex")
mrs = MpLogx.objects.filter(mpoint=mpoint, timex__gte=dt, timex__lte=dt_hour_n).order_by("timex")