diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index b3cc3886..c1a480eb 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -526,25 +526,24 @@ def get_total_hour_now_and_shut_hour(enstat: EnStat): # shut_hour = 1 - run_hour # shut_hour = shut_hour + # return 1, 0 - now = datetime.datetime.now().replace(tzinfo=tz.gettz(settings.TIME_ZONE)) if enstat.type == "sflog": sflog = enstat.sflog return sflog.total_hour_now, sflog.shut_hour elif enstat.type == "day_s": - res = SfLog.objects.filter(end_time__year=enstat.year_s, end_time__month=enstat.month_s, end_time__day=enstat.day_s, mgroup=enstat.mgroup, end_time__lt=now).aggregate( + res = SfLog.objects.filter(work_date__year=enstat.year_s, work_date__month=enstat.month_s, work_date__day=enstat.day_s, mgroup=enstat.mgroup).aggregate( sum1=Sum("total_hour_now"), sum2=Sum("shut_hour") ) return res["sum1"] if res["sum1"] else 0, res["sum2"] if res["sum2"] else 0 elif enstat.type == "month_st": - res = SfLog.objects.filter(end_time__year=enstat.year_s, end_time__month=enstat.month_s, mgroup=enstat.mgroup, team=enstat.team, end_time__lt=now).aggregate( + res = SfLog.objects.filter(work_date__year=enstat.year_s, work_date__month=enstat.month_s, mgroup=enstat.mgroup, team=enstat.team).aggregate( sum1=Sum("total_hour_now"), sum2=Sum("shut_hour") ) return res["sum1"] if res["sum1"] else 0, res["sum2"] if res["sum2"] else 0 elif enstat.type == "month_s": - res = SfLog.objects.filter(end_time__year=enstat.year_s, end_time__month=enstat.month_s, mgroup=enstat.mgroup, end_time__lt=now).aggregate(sum1=Sum("total_hour_now"), sum2=Sum("shut_hour")) + res = SfLog.objects.filter(work_date__year=enstat.year_s, work_date__month=enstat.month_s, mgroup=enstat.mgroup).aggregate(sum1=Sum("total_hour_now"), sum2=Sum("shut_hour")) return res["sum1"] if res["sum1"] else 0, res["sum2"] if res["sum2"] else 0 elif enstat.type == "year_s": - res = SfLog.objects.filter(end_time__year=enstat.year_s, mgroup=enstat.mgroup, end_time__lt=now).aggregate(sum1=Sum("total_hour_now"), sum2=Sum("shut_hour")) + res = SfLog.objects.filter(work_date__year=enstat.year_s, mgroup=enstat.mgroup).aggregate(sum1=Sum("total_hour_now"), sum2=Sum("shut_hour")) return res["sum1"] if res["sum1"] else 0, res["sum2"] if res["sum2"] else 0