fix: 如果结束时间为0点则取开始时间来返回年月日2

This commit is contained in:
caoqianming 2024-04-30 19:00:19 +08:00
parent a6914413f7
commit 2263c0decb
2 changed files with 5 additions and 5 deletions

View File

@ -646,7 +646,7 @@ def cal_enstat2(type: str, year_s: int, month_s: int, day_s: int, cascade=True):
enstat2.save()
def cal_enstat_pcoal_change(enstat, new_pcoal_heat):
def cal_enstat_pcoal_change(enstat: EnStat, new_pcoal_heat):
type = enstat.type
if type in ["hour_s", "sflog", "day_s"]:
enstat.pcoal_heat = new_pcoal_heat

View File

@ -6,6 +6,7 @@ from apps.system.models import User
from django.utils.timezone import localtime
from apps.em.models import Equipment
from apps.system.models import Dept
from datetime import timedelta
# Create your models here.
@ -38,10 +39,9 @@ class SfLog(CommonADModel):
"""
返回值班记录所属年月日
"""
end_time = self.end_time
if end_time.minute == 0 and end_time.second == 0 and end_time.hour == 0: # 如果结束时间为00:00:00
end_time = self.start_time
end_time_local = localtime(end_time)
end_time_local = localtime(self.end_time)
if end_time_local.hour == 0 and end_time_local.minute == 0 and end_time_local.second == 0: # 如果结束时间为00:00:00
end_time_local = localtime(self.start_time)
return end_time_local.year, end_time_local.month, end_time_local.day