From 27a2a20cbe938257bbaada20ae14d8c965bf21b7 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 24 Jul 2023 11:19:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=80=BC=E7=8F=AD=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=90=E8=BD=AC=E6=97=B6=E9=97=B4=E5=92=8C?= =?UTF-8?q?=E5=81=9C=E6=9C=BA=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wpm/migrations/0005_auto_20230724_1118.py | 23 +++++++++++++++++++ apps/wpm/models.py | 2 ++ apps/wpm/services.py | 1 + 3 files changed, 26 insertions(+) create mode 100644 apps/wpm/migrations/0005_auto_20230724_1118.py diff --git a/apps/wpm/migrations/0005_auto_20230724_1118.py b/apps/wpm/migrations/0005_auto_20230724_1118.py new file mode 100644 index 00000000..8f9db271 --- /dev/null +++ b/apps/wpm/migrations/0005_auto_20230724_1118.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.12 on 2023-07-24 03:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wpm', '0004_sflog_last_test_time'), + ] + + operations = [ + migrations.AddField( + model_name='sflog', + name='shut_hour', + field=models.FloatField(default=0, verbose_name='停机时间'), + ), + migrations.AddField( + model_name='sflog', + name='work_hour', + field=models.FloatField(default=12, verbose_name='运转时间'), + ), + ] diff --git a/apps/wpm/models.py b/apps/wpm/models.py index 71661269..ee4d4232 100644 --- a/apps/wpm/models.py +++ b/apps/wpm/models.py @@ -26,6 +26,8 @@ class SfLog(CommonADModel): note = models.TextField('其他备注', null=True, blank=True) stlogs = models.ManyToManyField('wpm.stlog', verbose_name='关联停机记录', through='wpm.stsflog') last_test_time = models.DateTimeField('最后质检时间', null=True, blank=True) + work_hour = models.FloatField('运转时间', default=12) + shut_hour = models.FloatField('停机时间', default=0) class StSfLog(BaseModel): diff --git a/apps/wpm/services.py b/apps/wpm/services.py index 29343f11..49b9ebe3 100644 --- a/apps/wpm/services.py +++ b/apps/wpm/services.py @@ -17,5 +17,6 @@ def make_sflogs(mgroup: Mgroup, start_date: datetime.date, end_date: datetime.da "shift": shift, "start_time": start_time, "end_time": end_time, + "work_hour": round((end_time-start_time).total_seconds/3600) }) current_date = current_date + datetime.timedelta(days=1) \ No newline at end of file