Добавлен столбец "Фактический расход"

This commit is contained in:
Olga Nemt 2024-01-31 16:05:57 +05:00
parent d73fc5df43
commit 9c69adb10c
5 changed files with 22 additions and 3 deletions

View File

@ -13,7 +13,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace AsbCloudDb.Migrations namespace AsbCloudDb.Migrations
{ {
[DbContext(typeof(AsbCloudDbContext))] [DbContext(typeof(AsbCloudDbContext))]
[Migration("20240131074638_Add_Table_DataSaubStat")] [Migration("20240131104814_Add_Table_DataSaubStat")]
partial class Add_Table_DataSaubStat partial class Add_Table_DataSaubStat
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -378,6 +378,11 @@ namespace AsbCloudDb.Migrations
.HasColumnName("enabled_subsystems") .HasColumnName("enabled_subsystems")
.HasComment("Флаги подсистем"); .HasComment("Флаги подсистем");
b.Property<double>("Flow")
.HasColumnType("double precision")
.HasColumnName("flow")
.HasComment("Фактический расход");
b.Property<bool>("HasOscillation") b.Property<bool>("HasOscillation")
.HasColumnType("boolean") .HasColumnType("boolean")
.HasColumnName("has_oscillation") .HasColumnName("has_oscillation")

View File

@ -36,6 +36,7 @@ namespace AsbCloudDb.Migrations
detected_operation_category_id = table.Column<int>(type: "integer", nullable: false, comment: "Название автоопределённой операции"), detected_operation_category_id = table.Column<int>(type: "integer", nullable: false, comment: "Название автоопределённой операции"),
enabled_subsystems = table.Column<int>(type: "integer", nullable: false, comment: "Флаги подсистем"), enabled_subsystems = table.Column<int>(type: "integer", nullable: false, comment: "Флаги подсистем"),
has_oscillation = table.Column<bool>(type: "boolean", nullable: false, comment: "Наличие или отсутствие осцилляции"), has_oscillation = table.Column<bool>(type: "boolean", nullable: false, comment: "Наличие или отсутствие осцилляции"),
flow = table.Column<double>(type: "double precision", nullable: false, comment: "Фактический расход"),
id_telemetry = table.Column<int>(type: "integer", nullable: false, comment: "Ключ телеметрии") id_telemetry = table.Column<int>(type: "integer", nullable: false, comment: "Ключ телеметрии")
}, },
constraints: table => constraints: table =>

View File

@ -376,6 +376,11 @@ namespace AsbCloudDb.Migrations
.HasColumnName("enabled_subsystems") .HasColumnName("enabled_subsystems")
.HasComment("Флаги подсистем"); .HasComment("Флаги подсистем");
b.Property<double>("Flow")
.HasColumnType("double precision")
.HasColumnName("flow")
.HasComment("Фактический расход");
b.Property<bool>("HasOscillation") b.Property<bool>("HasOscillation")
.HasColumnType("boolean") .HasColumnType("boolean")
.HasColumnName("has_oscillation") .HasColumnName("has_oscillation")

View File

@ -73,6 +73,9 @@ namespace AsbCloudDb.Model
[Column("has_oscillation"), Comment("Наличие или отсутствие осцилляции")] [Column("has_oscillation"), Comment("Наличие или отсутствие осцилляции")]
public bool HasOscillation { get; set; } public bool HasOscillation { get; set; }
[Column("flow"), Comment("Фактический расход")]
public double Flow { get; set; }
[Column("id_telemetry"), Comment("Ключ телеметрии")] [Column("id_telemetry"), Comment("Ключ телеметрии")]
public int IdTelemetry { get; set; } public int IdTelemetry { get; set; }

View File

@ -128,6 +128,7 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
EnabledSubsystems = operation.EnabledSubsystems, EnabledSubsystems = operation.EnabledSubsystems,
HasOscillation = hasOscillation, HasOscillation = hasOscillation,
IdTelemetry = operation.IdTelemetry, IdTelemetry = operation.IdTelemetry,
Flow = wavg.Flow
}; };
return processMapDrillingCacheItem; return processMapDrillingCacheItem;
} }
@ -136,13 +137,15 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
double Pressure, double Pressure,
double AxialLoad, double AxialLoad,
double RotorTorque, double RotorTorque,
double RotorSpeed double RotorSpeed,
double Flow
) CalcWavg(Span<TelemetryDataSaub> span) ) CalcWavg(Span<TelemetryDataSaub> span)
{ {
var sumPressure = 0.0; var sumPressure = 0.0;
var sumAxialLoad = 0.0; var sumAxialLoad = 0.0;
var sumRotorTorque = 0.0; var sumRotorTorque = 0.0;
var sumRotorSpeed = 0.0; var sumRotorSpeed = 0.0;
var flow = span[0].Flow ?? 0.0;
var diffDepthTotal = span[^1].WellDepth - span[0].WellDepth; var diffDepthTotal = span[^1].WellDepth - span[0].WellDepth;
for (var i = 0; i < span.Length - 1; i++) for (var i = 0; i < span.Length - 1; i++)
{ {
@ -151,12 +154,14 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
sumAxialLoad += weigth * span[i].AxialLoad; sumAxialLoad += weigth * span[i].AxialLoad;
sumRotorTorque += weigth * span[i].RotorTorque; sumRotorTorque += weigth * span[i].RotorTorque;
sumRotorSpeed += weigth * span[i].RotorSpeed; sumRotorSpeed += weigth * span[i].RotorSpeed;
flow = span[i + 1].Flow > flow ? span[i + 1].Flow ?? 0.0 :flow;
} }
return ( return (
Pressure: sumPressure / diffDepthTotal, Pressure: sumPressure / diffDepthTotal,
AxialLoad: sumAxialLoad / diffDepthTotal, AxialLoad: sumAxialLoad / diffDepthTotal,
RotorTorque: sumRotorTorque / diffDepthTotal, RotorTorque: sumRotorTorque / diffDepthTotal,
RotorSpeed: sumRotorSpeed / diffDepthTotal RotorSpeed: sumRotorSpeed / diffDepthTotal,
Flow: flow
); );
} }