diff --git a/apps/enm/migrations/0052_auto_20241225_1405.py b/apps/enm/migrations/0052_auto_20241225_1405.py new file mode 100644 index 00000000..71fb0294 --- /dev/null +++ b/apps/enm/migrations/0052_auto_20241225_1405.py @@ -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='采集系数'), + ), + ] diff --git a/apps/enm/models.py b/apps/enm/models.py index ff68de4c..7d0508cd 100644 --- a/apps/enm/models.py +++ b/apps/enm/models.py @@ -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") diff --git a/apps/enm/views.py b/apps/enm/views.py index d1cd25a1..59185504 100644 --- a/apps/enm/views.py +++ b/apps/enm/views.py @@ -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计算