feat: enm/model 增加碳排放强度 和 碳排放量字段与 task 计算逻辑
This commit is contained in:
parent
4927afa9b7
commit
bec6600089
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.2.12 on 2025-01-20 05:18
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('enm', '0054_mpoint_up_down'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='enstat',
|
||||
name='carbon_emission',
|
||||
field=models.FloatField(default=0, help_text='t', verbose_name='碳排放'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='enstat',
|
||||
name='carbon_emission_unit',
|
||||
field=models.FloatField(default=0, help_text='t/t', verbose_name='碳排放强度'),
|
||||
),
|
||||
]
|
|
@ -165,6 +165,8 @@ class EnStat(BaseModel):
|
|||
shut_sec = models.PositiveIntegerField("停机时长", default=0, help_text="s")
|
||||
run_rate = models.FloatField("运转率", default=0, help_text="%")
|
||||
ammonia_consume = models.FloatField("氨水消耗", default=0, help_text="t")
|
||||
carbon_emission = models.FloatField("碳排放", default=0, help_text="t")
|
||||
carbon_emission_unit = models.FloatField("碳排放强度", default=0, help_text="t/t")
|
||||
note = models.TextField("备注", default="", blank=True)
|
||||
|
||||
|
||||
|
|
|
@ -564,6 +564,12 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
|
|||
enstat.elec_consume_unit = enstat.elec_consume / enstat.total_production
|
||||
except ZeroDivisionError:
|
||||
enstat.elec_consume_unit = 0
|
||||
elif material.code == "carbon":
|
||||
enstat.carbon_emission = amount_consume
|
||||
try:
|
||||
enstat.carbon_emission_unit = enstat.carbon_emission / enstat.total_production
|
||||
except ZeroDivisionError:
|
||||
enstat.carbon_emission_unit = 0
|
||||
elif material.code == "water":
|
||||
enstat.water_consume = amount_consume
|
||||
elif material.code == "pcoal":
|
||||
|
|
Loading…
Reference in New Issue