fix: get_total_hour_now_and_shut_hour查询条件用work_date替换
This commit is contained in:
parent
30974d90b0
commit
757c3f4ad8
|
@ -526,25 +526,24 @@ def get_total_hour_now_and_shut_hour(enstat: EnStat):
|
||||||
# shut_hour = 1 - run_hour
|
# shut_hour = 1 - run_hour
|
||||||
# shut_hour = shut_hour +
|
# shut_hour = shut_hour +
|
||||||
# return 1, 0
|
# return 1, 0
|
||||||
now = datetime.datetime.now().replace(tzinfo=tz.gettz(settings.TIME_ZONE))
|
|
||||||
if enstat.type == "sflog":
|
if enstat.type == "sflog":
|
||||||
sflog = enstat.sflog
|
sflog = enstat.sflog
|
||||||
return sflog.total_hour_now, sflog.shut_hour
|
return sflog.total_hour_now, sflog.shut_hour
|
||||||
elif enstat.type == "day_s":
|
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")
|
sum1=Sum("total_hour_now"), sum2=Sum("shut_hour")
|
||||||
)
|
)
|
||||||
return res["sum1"] if res["sum1"] else 0, res["sum2"] if res["sum2"] else 0
|
return res["sum1"] if res["sum1"] else 0, res["sum2"] if res["sum2"] else 0
|
||||||
elif enstat.type == "month_st":
|
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")
|
sum1=Sum("total_hour_now"), sum2=Sum("shut_hour")
|
||||||
)
|
)
|
||||||
return res["sum1"] if res["sum1"] else 0, res["sum2"] if res["sum2"] else 0
|
return res["sum1"] if res["sum1"] else 0, res["sum2"] if res["sum2"] else 0
|
||||||
elif enstat.type == "month_s":
|
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
|
return res["sum1"] if res["sum1"] else 0, res["sum2"] if res["sum2"] else 0
|
||||||
elif enstat.type == "year_s":
|
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
|
return res["sum1"] if res["sum1"] else 0, res["sum2"] if res["sum2"] else 0
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue