feat: enm mpoint 添加计算系数字段
This commit is contained in:
parent
5a41aee253
commit
aae5c909c5
|
@ -0,0 +1,33 @@
|
|||
# Generated by Django 3.2.12 on 2024-12-25 06:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('enm', '0051_enstat_note'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='mpoint',
|
||||
name='cal_coefficient',
|
||||
field=models.FloatField(blank=True, null=True, verbose_name='计算系数'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='mpoint',
|
||||
name='need_change_cal_coefficient',
|
||||
field=models.BooleanField(default=False, verbose_name='是否需要变更计算系数'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='mpointstat',
|
||||
name='current_cal_coefficient',
|
||||
field=models.FloatField(blank=True, null=True, verbose_name='采用计算系数'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='mpoint',
|
||||
name='coefficient',
|
||||
field=models.FloatField(default=1.0, verbose_name='采集系数'),
|
||||
),
|
||||
]
|
|
@ -50,11 +50,16 @@ class Mpoint(CommonBModel):
|
|||
|
||||
need_display = models.BooleanField("是否需要展示", default=False)
|
||||
report_sortstr = models.CharField('在报告中的排序', max_length=50, default='', blank=True)
|
||||
coefficient = models.FloatField("系数", default=1.0)
|
||||
|
||||
coefficient = models.FloatField("采集系数", default=1.0)
|
||||
|
||||
need_change_cal_coefficient = models.BooleanField("是否需要变更计算系数", default=False)
|
||||
cal_coefficient = models.FloatField("计算系数", null=True, blank=True)
|
||||
|
||||
@classmethod
|
||||
def cache_key(cls, code: str):
|
||||
return f"mpoint_{code}"
|
||||
|
||||
class MpLogx(models.Model):
|
||||
"""
|
||||
测点记录超表
|
||||
|
@ -103,6 +108,7 @@ class MpointStat(CommonADModel):
|
|||
val = models.FloatField("统计值", default=0)
|
||||
val_level = models.CharField("峰谷平", max_length=50, null=True, blank=True, help_text="peak/high/flat/low/deep")
|
||||
val_origin = models.FloatField("统计原始值", default=0)
|
||||
current_cal_coefficient = models.FloatField("采用计算系数", null=True, blank=True)
|
||||
val_correct = models.FloatField("统计矫正值", null=True, blank=True)
|
||||
total_production = models.FloatField("总产量", default=0, help_text="t")
|
||||
elec_consume_unit = models.FloatField("单位产品电耗", default=0, help_text="kw·h/t")
|
||||
|
|
|
@ -45,6 +45,7 @@ class MpointViewSet(CustomModelViewSet):
|
|||
"material": ["exact", "isnull"],
|
||||
"material__code": ["exact", "in"],
|
||||
"code": ["exact", "contains", "in"],
|
||||
"need_change_cal_coefficient": ["exact"],
|
||||
}
|
||||
|
||||
search_fields = ["name", "code", "nickname", "material__code", "material__name"]
|
||||
|
@ -198,7 +199,7 @@ class MpointStatViewSet(BulkCreateModelMixin, BulkDestroyModelMixin, CustomListM
|
|||
cal_mpointstat_manual.delay(mpoint.id, sflogId, mgroup.id, None, None, None, None, year_s, month_s, day_s, next_cal=1)
|
||||
return Response()
|
||||
|
||||
@action(methods=["post"], detail=False, perms_map={"post": "mpointstat.create"}, serializer_class=ReCalSerializer)
|
||||
@action(methods=["post"], detail=False, perms_map={"post": "mpointstat.correct"}, serializer_class=ReCalSerializer)
|
||||
def recal(self, request, *args, **kwargs):
|
||||
"""重新运行某段时间的enm计算
|
||||
|
||||
|
|
Loading…
Reference in New Issue