feat: sflog增加property以获取年月日
This commit is contained in:
parent
27fa035bea
commit
be9011f8f5
|
@ -2,6 +2,7 @@ from django.db import models
|
||||||
from apps.system.models import BaseModel
|
from apps.system.models import BaseModel
|
||||||
from apps.utils.models import CommonADModel, CommonBDModel
|
from apps.utils.models import CommonADModel, CommonBDModel
|
||||||
from apps.mtm.models import Mgroup, Team, Shift
|
from apps.mtm.models import Mgroup, Team, Shift
|
||||||
|
from django.utils.timezone import localtime
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
class StLog(CommonADModel):
|
class StLog(CommonADModel):
|
||||||
|
@ -29,6 +30,14 @@ class SfLog(CommonADModel):
|
||||||
work_hour = models.FloatField('运转时间', default=12)
|
work_hour = models.FloatField('运转时间', default=12)
|
||||||
shut_hour = models.FloatField('停机时间', default=0)
|
shut_hour = models.FloatField('停机时间', default=0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def get_ymd(self):
|
||||||
|
"""
|
||||||
|
返回值班记录所属年月日
|
||||||
|
"""
|
||||||
|
end_time_local = localtime(self.end_time)
|
||||||
|
return end_time_local.year, end_time_local.month, end_time_local.day
|
||||||
|
|
||||||
|
|
||||||
class StSfLog(BaseModel):
|
class StSfLog(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
@ -38,6 +47,7 @@ class StSfLog(BaseModel):
|
||||||
sflog = models.ForeignKey(SfLog, verbose_name='关联值班记录', on_delete=models.CASCADE)
|
sflog = models.ForeignKey(SfLog, verbose_name='关联值班记录', on_delete=models.CASCADE)
|
||||||
is_current_down = models.BooleanField('是否本班停机', default=False)
|
is_current_down = models.BooleanField('是否本班停机', default=False)
|
||||||
reason = models.TextField('停机原因', null=True, blank=True)
|
reason = models.TextField('停机原因', null=True, blank=True)
|
||||||
|
duration = models.FloatField('停机时长(h)', null=True, blank=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['sflog__start_time']
|
ordering = ['sflog__start_time']
|
||||||
|
|
Loading…
Reference in New Issue