feat: 增加吨熟料电耗计算功能

This commit is contained in:
caoqianming 2024-05-21 18:17:51 +08:00
parent 138d202a28
commit dd5b88e300
3 changed files with 34 additions and 3 deletions

View File

@ -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='台时产量/发电功率'),
),
]

View File

@ -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")

View File

@ -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"]: