diff --git a/apps/wpm/models.py b/apps/wpm/models.py index ee4d4232..868ae2ad 100644 --- a/apps/wpm/models.py +++ b/apps/wpm/models.py @@ -2,6 +2,7 @@ from django.db import models from apps.system.models import BaseModel from apps.utils.models import CommonADModel, CommonBDModel from apps.mtm.models import Mgroup, Team, Shift +from django.utils.timezone import localtime # Create your models here. class StLog(CommonADModel): @@ -29,6 +30,14 @@ class SfLog(CommonADModel): work_hour = models.FloatField('运转时间', default=12) 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): """ @@ -38,6 +47,7 @@ class StSfLog(BaseModel): sflog = models.ForeignKey(SfLog, verbose_name='关联值班记录', on_delete=models.CASCADE) is_current_down = models.BooleanField('是否本班停机', default=False) reason = models.TextField('停机原因', null=True, blank=True) + duration = models.FloatField('停机时长(h)', null=True, blank=True) class Meta: ordering = ['sflog__start_time']