From dd5b88e30029e745f6e582e13388794f5c7db30f Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 21 May 2024 18:17:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=90=A8=E7=86=9F?= =?UTF-8?q?=E6=96=99=E7=94=B5=E8=80=97=E8=AE=A1=E7=AE=97=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enm/migrations/0038_auto_20240521_1532.py | 23 +++++++++++++++++++ apps/enm/models.py | 3 ++- apps/enm/tasks.py | 11 +++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 apps/enm/migrations/0038_auto_20240521_1532.py diff --git a/apps/enm/migrations/0038_auto_20240521_1532.py b/apps/enm/migrations/0038_auto_20240521_1532.py new file mode 100644 index 00000000..06ac0367 --- /dev/null +++ b/apps/enm/migrations/0038_auto_20240521_1532.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.12 on 2024-05-21 07:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('enm', '0037_auto_20240516_1016'), + ] + + operations = [ + migrations.AddField( + model_name='enstat', + name='production_elec_consume_unit', + field=models.FloatField(default=0, help_text='kw·h/t', verbose_name='吨熟料电耗'), + ), + migrations.AlterField( + model_name='enstat', + name='production_hour', + field=models.FloatField(default=0, help_text='t/h', verbose_name='台时产量/发电功率'), + ), + ] diff --git a/apps/enm/models.py b/apps/enm/models.py index 79c76e7b..dcad6c46 100644 --- a/apps/enm/models.py +++ b/apps/enm/models.py @@ -135,8 +135,9 @@ class EnStat(BaseModel): coal_consume_unit = models.FloatField("单位产品标煤耗", default=0, help_text="kgce/t") en_consume_unit = models.FloatField("单位产品能耗", default=0, help_text="tce/t") cen_consume_unit = models.FloatField("单位产品综合能耗", default=0, help_text="kgce/t") - production_hour = models.FloatField("台时产量", default=0, help_text="t/h") + production_hour = models.FloatField("台时产量/发电功率", default=0, help_text="t/h") production_elec_unit = models.FloatField("吨熟料发电量", default=0, help_text="kw·h/t") + production_elec_consume_unit = models.FloatField("吨熟料电耗", default=0, help_text="kw·h/t") total_sec_now = models.PositiveIntegerField("动态总时长", default=0, help_text="s") run_sec = models.PositiveIntegerField("运转时长", default=0, help_text="s") shut_sec = models.PositiveIntegerField("停机时长", default=0, help_text="s") diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index a34f0616..cdec7fc8 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -522,10 +522,17 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, # 综合电耗 if enstat.type in ["hour_s", "day_s", "year_s", "month_s"]: pre_enstat = EnStat.objects.filter(type=enstat.type, year_s=enstat.year_s, month_s=enstat.month_s, day_s=enstat.day_s, hour=enstat.hour, mgroup__name="原料磨").first() + pre_enstat2 = EnStat.objects.filter(type=enstat.type, year_s=enstat.year_s, month_s=enstat.month_s, day_s=enstat.day_s, hour=enstat.hour, mgroup__name="煤磨").first() if pre_enstat: enstat.celec_consume_unit = enstat.elec_consume_unit + get_sysconfig('enm.enm_lhxs') * pre_enstat.elec_consume_unit - enstat.save() - + if pre_enstat2: + try: + pre_enstat2.production_elec_consume_unit = enstat.elec_consume / enstat.total_production + except ZeroDivisionError: + pre_enstat2.production_elec_consume_unit = 0 + pre_enstat2.save(update_fields=["production_elec_consume_unit"]) + enstat.celec_consume_unit += enstat.production_elec_consume_unit + enstat.save() # 算总煤耗 if "pcoal" in this_cal_attrs: if type in ["hour_s", "sflog", "day_s"]: