fix: 如果结束时间为0点则取开始时间来返回年月日2
This commit is contained in:
parent
a6914413f7
commit
2263c0decb
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue