Часть полей в таблице t_telemetry_data_saub

This commit is contained in:
Olga Nemt 2023-11-10 14:29:44 +05:00
parent 5459fbdd5c
commit bec1491192
7 changed files with 9177 additions and 41 deletions

View File

@ -0,0 +1,224 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class UpdateTable_t_telemetry_data_Set_ImportantColumns_NotNull : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DELETE FROM t_telemetry WHERE " +
"well_depth IS NULL OR " +
"rotor_torque IS NULL OR " +
"rotor_speed IS NULL OR " +
"pressure IS NULL OR " +
"mode IS NULL OR " +
"hook_weight IS NULL OR " +
"block_position IS NULL OR " +
"bit_depth IS NULL OR " +
"axial_load IS NULL;");
migrationBuilder.AlterColumn<float>(
name: "well_depth",
table: "t_telemetry_data_saub",
type: "real",
nullable: false,
defaultValue: 0f,
comment: "Глубина забоя",
oldClrType: typeof(float),
oldType: "real",
oldNullable: true,
oldComment: "Глубина забоя");
migrationBuilder.AlterColumn<float>(
name: "rotor_torque",
table: "t_telemetry_data_saub",
type: "real",
nullable: false,
defaultValue: 0f,
comment: "Момент на роторе",
oldClrType: typeof(float),
oldType: "real",
oldNullable: true,
oldComment: "Момент на роторе");
migrationBuilder.AlterColumn<float>(
name: "rotor_speed",
table: "t_telemetry_data_saub",
type: "real",
nullable: false,
defaultValue: 0f,
comment: "Обороты ротора",
oldClrType: typeof(float),
oldType: "real",
oldNullable: true,
oldComment: "Обороты ротора");
migrationBuilder.AlterColumn<float>(
name: "pressure",
table: "t_telemetry_data_saub",
type: "real",
nullable: false,
defaultValue: 0f,
comment: "Давление",
oldClrType: typeof(float),
oldType: "real",
oldNullable: true,
oldComment: "Давление");
migrationBuilder.AlterColumn<short>(
name: "mode",
table: "t_telemetry_data_saub",
type: "smallint",
nullable: false,
defaultValue: (short)0,
comment: "Режим САУБ",
oldClrType: typeof(short),
oldType: "smallint",
oldNullable: true,
oldComment: "Режим САУБ");
migrationBuilder.AlterColumn<float>(
name: "hook_weight",
table: "t_telemetry_data_saub",
type: "real",
nullable: false,
defaultValue: 0f,
comment: "Вес на крюке",
oldClrType: typeof(float),
oldType: "real",
oldNullable: true,
oldComment: "Вес на крюке");
migrationBuilder.AlterColumn<float>(
name: "block_position",
table: "t_telemetry_data_saub",
type: "real",
nullable: false,
defaultValue: 0f,
comment: "Высота талевого блока",
oldClrType: typeof(float),
oldType: "real",
oldNullable: true,
oldComment: "Высота талевого блока");
migrationBuilder.AlterColumn<float>(
name: "bit_depth",
table: "t_telemetry_data_saub",
type: "real",
nullable: false,
defaultValue: 0f,
comment: "Положение инструмента",
oldClrType: typeof(float),
oldType: "real",
oldNullable: true,
oldComment: "Положение инструмента");
migrationBuilder.AlterColumn<float>(
name: "axial_load",
table: "t_telemetry_data_saub",
type: "real",
nullable: false,
defaultValue: 0f,
comment: "Осевая нагрузка",
oldClrType: typeof(float),
oldType: "real",
oldNullable: true,
oldComment: "Осевая нагрузка");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<float>(
name: "well_depth",
table: "t_telemetry_data_saub",
type: "real",
nullable: true,
comment: "Глубина забоя",
oldClrType: typeof(float),
oldType: "real",
oldComment: "Глубина забоя");
migrationBuilder.AlterColumn<float>(
name: "rotor_torque",
table: "t_telemetry_data_saub",
type: "real",
nullable: true,
comment: "Момент на роторе",
oldClrType: typeof(float),
oldType: "real",
oldComment: "Момент на роторе");
migrationBuilder.AlterColumn<float>(
name: "rotor_speed",
table: "t_telemetry_data_saub",
type: "real",
nullable: true,
comment: "Обороты ротора",
oldClrType: typeof(float),
oldType: "real",
oldComment: "Обороты ротора");
migrationBuilder.AlterColumn<float>(
name: "pressure",
table: "t_telemetry_data_saub",
type: "real",
nullable: true,
comment: "Давление",
oldClrType: typeof(float),
oldType: "real",
oldComment: "Давление");
migrationBuilder.AlterColumn<short>(
name: "mode",
table: "t_telemetry_data_saub",
type: "smallint",
nullable: true,
comment: "Режим САУБ",
oldClrType: typeof(short),
oldType: "smallint",
oldComment: "Режим САУБ");
migrationBuilder.AlterColumn<float>(
name: "hook_weight",
table: "t_telemetry_data_saub",
type: "real",
nullable: true,
comment: "Вес на крюке",
oldClrType: typeof(float),
oldType: "real",
oldComment: "Вес на крюке");
migrationBuilder.AlterColumn<float>(
name: "block_position",
table: "t_telemetry_data_saub",
type: "real",
nullable: true,
comment: "Высота талевого блока",
oldClrType: typeof(float),
oldType: "real",
oldComment: "Высота талевого блока");
migrationBuilder.AlterColumn<float>(
name: "bit_depth",
table: "t_telemetry_data_saub",
type: "real",
nullable: true,
comment: "Положение инструмента",
oldClrType: typeof(float),
oldType: "real",
oldComment: "Положение инструмента");
migrationBuilder.AlterColumn<float>(
name: "axial_load",
table: "t_telemetry_data_saub",
type: "real",
nullable: true,
comment: "Осевая нагрузка",
oldClrType: typeof(float),
oldType: "real",
oldComment: "Осевая нагрузка");
}
}
}

View File

@ -19,7 +19,7 @@ namespace AsbCloudDb.Migrations
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.UseCollation("Russian_Russia.1251") .UseCollation("Russian_Russia.1251")
.HasAnnotation("ProductVersion", "6.0.22") .HasAnnotation("ProductVersion", "6.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63); .HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack");
@ -136,21 +136,21 @@ namespace AsbCloudDb.Migrations
{ {
Id = 1, Id = 1,
Caption = "Недропользователь", Caption = "Недропользователь",
IsContact = false, IsContact = true,
Order = 3 Order = 3
}, },
new new
{ {
Id = 2, Id = 2,
Caption = "Буровой подрядчик", Caption = "Буровой подрядчик",
IsContact = false, IsContact = true,
Order = 2 Order = 2
}, },
new new
{ {
Id = 3, Id = 3,
Caption = "Сервис автоматизации бурения", Caption = "Сервис автоматизации бурения",
IsContact = false, IsContact = true,
Order = 0 Order = 0
}, },
new new
@ -178,7 +178,7 @@ namespace AsbCloudDb.Migrations
{ {
Id = 7, Id = 7,
Caption = "Служба супервайзинга", Caption = "Служба супервайзинга",
IsContact = true, IsContact = false,
Order = 1 Order = 1
}, },
new new
@ -189,11 +189,18 @@ namespace AsbCloudDb.Migrations
Order = 7 Order = 7
}, },
new new
{
Id = 11,
Caption = "Дизельный сервис",
IsContact = false,
Order = 9
},
new
{ {
Id = 12, Id = 12,
Caption = "Сервис по обслуживанию верхних силовых приводов", Caption = "Сервис по обслуживанию верхних силовых приводов",
IsContact = true, IsContact = true,
Order = 7 Order = 8
}); });
}); });
@ -2415,6 +2422,12 @@ namespace AsbCloudDb.Migrations
Id = 528, Id = 528,
Description = "Разрешение на удаление контакта", Description = "Разрешение на удаление контакта",
Name = "WellContact.delete" Name = "WellContact.delete"
},
new
{
Id = 529,
Description = "Разрешение на получение отчетов drill test",
Name = "DrillTestReport.get"
}); });
}); });
@ -4081,6 +4094,11 @@ namespace AsbCloudDb.Migrations
{ {
IdUserRole = 1, IdUserRole = 1,
IdPermission = 528 IdPermission = 528
},
new
{
IdUserRole = 1,
IdPermission = 529
}); });
}); });
@ -4718,7 +4736,7 @@ namespace AsbCloudDb.Migrations
.HasColumnName("date") .HasColumnName("date")
.HasComment("'2021-10-19 18:23:54+05'"); .HasComment("'2021-10-19 18:23:54+05'");
b.Property<float?>("AxialLoad") b.Property<float>("AxialLoad")
.HasColumnType("real") .HasColumnType("real")
.HasColumnName("axial_load") .HasColumnName("axial_load")
.HasComment("Осевая нагрузка"); .HasComment("Осевая нагрузка");
@ -4733,12 +4751,12 @@ namespace AsbCloudDb.Migrations
.HasColumnName("axial_load_sp") .HasColumnName("axial_load_sp")
.HasComment("Осевая нагрузка. Задание"); .HasComment("Осевая нагрузка. Задание");
b.Property<float?>("BitDepth") b.Property<float>("BitDepth")
.HasColumnType("real") .HasColumnType("real")
.HasColumnName("bit_depth") .HasColumnName("bit_depth")
.HasComment("Положение инструмента"); .HasComment("Положение инструмента");
b.Property<float?>("BlockPosition") b.Property<float>("BlockPosition")
.HasColumnType("real") .HasColumnType("real")
.HasColumnName("block_position") .HasColumnName("block_position")
.HasComment("Высота талевого блока"); .HasComment("Высота талевого блока");
@ -4793,7 +4811,7 @@ namespace AsbCloudDb.Migrations
.HasColumnName("flow_idle") .HasColumnName("flow_idle")
.HasComment("Расход. Холостой ход"); .HasComment("Расход. Холостой ход");
b.Property<float?>("HookWeight") b.Property<float>("HookWeight")
.HasColumnType("real") .HasColumnType("real")
.HasColumnName("hook_weight") .HasColumnName("hook_weight")
.HasComment("Вес на крюке"); .HasComment("Вес на крюке");
@ -4823,7 +4841,7 @@ namespace AsbCloudDb.Migrations
.HasColumnName("id_user") .HasColumnName("id_user")
.HasComment("Пользователь САУБ"); .HasComment("Пользователь САУБ");
b.Property<short?>("Mode") b.Property<short>("Mode")
.HasColumnType("smallint") .HasColumnType("smallint")
.HasColumnName("mode") .HasColumnName("mode")
.HasComment("Режим САУБ"); .HasComment("Режим САУБ");
@ -4838,7 +4856,7 @@ namespace AsbCloudDb.Migrations
.HasColumnName("mse_state") .HasColumnName("mse_state")
.HasComment("Текущее состояние работы MSE"); .HasComment("Текущее состояние работы MSE");
b.Property<float?>("Pressure") b.Property<float>("Pressure")
.HasColumnType("real") .HasColumnType("real")
.HasColumnName("pressure") .HasColumnName("pressure")
.HasComment("Давление"); .HasComment("Давление");
@ -4888,12 +4906,12 @@ namespace AsbCloudDb.Migrations
.HasColumnName("pump2_flow") .HasColumnName("pump2_flow")
.HasComment("Расход. Буровой насос 3"); .HasComment("Расход. Буровой насос 3");
b.Property<float?>("RotorSpeed") b.Property<float>("RotorSpeed")
.HasColumnType("real") .HasColumnType("real")
.HasColumnName("rotor_speed") .HasColumnName("rotor_speed")
.HasComment("Обороты ротора"); .HasComment("Обороты ротора");
b.Property<float?>("RotorTorque") b.Property<float>("RotorTorque")
.HasColumnType("real") .HasColumnType("real")
.HasColumnName("rotor_torque") .HasColumnName("rotor_torque")
.HasComment("Момент на роторе"); .HasComment("Момент на роторе");
@ -4913,7 +4931,7 @@ namespace AsbCloudDb.Migrations
.HasColumnName("rotor_torque_sp") .HasColumnName("rotor_torque_sp")
.HasComment("Момент на роторе. Задание"); .HasComment("Момент на роторе. Задание");
b.Property<float?>("WellDepth") b.Property<float>("WellDepth")
.HasColumnType("real") .HasColumnType("real")
.HasColumnName("well_depth") .HasColumnName("well_depth")
.HasComment("Глубина забоя"); .HasComment("Глубина забоя");

View File

@ -18,7 +18,7 @@ namespace AsbCloudDb.Model
public DateTimeOffset DateTime { get; set; } public DateTimeOffset DateTime { get; set; }
[Column("mode"), Comment("Режим САУБ")] [Column("mode"), Comment("Режим САУБ")]
public short? Mode { get; set; } public short Mode { get; set; }
[Column("id_feed_regulator"), Comment("Текущий критерий бурения")] [Column("id_feed_regulator"), Comment("Текущий критерий бурения")]
public short? IdFeedRegulator { get; set; } public short? IdFeedRegulator { get; set; }
@ -27,13 +27,13 @@ namespace AsbCloudDb.Model
public short? MseState { get; set; } public short? MseState { get; set; }
[Column("well_depth"), Comment("Глубина забоя")] [Column("well_depth"), Comment("Глубина забоя")]
public float? WellDepth { get; set; } public float WellDepth { get; set; }
[Column("bit_depth"), Comment("Положение инструмента")] [Column("bit_depth"), Comment("Положение инструмента")]
public float? BitDepth { get; set; } public float BitDepth { get; set; }
[Column("block_position"), Comment("Высота талевого блока")] [Column("block_position"), Comment("Высота талевого блока")]
public float? BlockPosition { get; set; } public float BlockPosition { get; set; }
[Column("block_position_min"), Comment("Талевый блок. Мин положение")] [Column("block_position_min"), Comment("Талевый блок. Мин положение")]
public float? BlockPositionMin { get; set; } public float? BlockPositionMin { get; set; }
@ -57,7 +57,7 @@ namespace AsbCloudDb.Model
public float? BlockSpeedSpDevelop { get; set; } public float? BlockSpeedSpDevelop { get; set; }
[Column("pressure"), Comment("Давление")] [Column("pressure"), Comment("Давление")]
public float? Pressure { get; set; } public float Pressure { get; set; }
[Column("pressure_idle"), Comment("Давление. Холостой ход")] [Column("pressure_idle"), Comment("Давление. Холостой ход")]
public float? PressureIdle { get; set; } public float? PressureIdle { get; set; }
@ -78,7 +78,7 @@ namespace AsbCloudDb.Model
public float? PressureDeltaLimitMax { get; set; } public float? PressureDeltaLimitMax { get; set; }
[Column("axial_load"), Comment("Осевая нагрузка")] [Column("axial_load"), Comment("Осевая нагрузка")]
public float? AxialLoad { get; set; } public float AxialLoad { get; set; }
[Column("axial_load_sp"), Comment("Осевая нагрузка. Задание")] [Column("axial_load_sp"), Comment("Осевая нагрузка. Задание")]
public float? AxialLoadSp { get; set; } public float? AxialLoadSp { get; set; }
@ -87,7 +87,7 @@ namespace AsbCloudDb.Model
public float? AxialLoadLimitMax { get; set; } public float? AxialLoadLimitMax { get; set; }
[Column("hook_weight"), Comment("Вес на крюке")] [Column("hook_weight"), Comment("Вес на крюке")]
public float? HookWeight { get; set; } public float HookWeight { get; set; }
[Column("hook_weight_idle"), Comment("Вес на крюке. Холостой ход")] [Column("hook_weight_idle"), Comment("Вес на крюке. Холостой ход")]
public float? HookWeightIdle { get; set; } public float? HookWeightIdle { get; set; }
@ -99,7 +99,7 @@ namespace AsbCloudDb.Model
public float? HookWeightLimitMax { get; set; } public float? HookWeightLimitMax { get; set; }
[Column("rotor_torque"), Comment("Момент на роторе")] [Column("rotor_torque"), Comment("Момент на роторе")]
public float? RotorTorque { get; set; } public float RotorTorque { get; set; }
[Column("rotor_torque_idle"), Comment("Момент на роторе. Холостой ход")] [Column("rotor_torque_idle"), Comment("Момент на роторе. Холостой ход")]
public float? RotorTorqueIdle { get; set; } public float? RotorTorqueIdle { get; set; }
@ -111,7 +111,7 @@ namespace AsbCloudDb.Model
public float? RotorTorqueLimitMax { get; set; } public float? RotorTorqueLimitMax { get; set; }
[Column("rotor_speed"), Comment("Обороты ротора")] [Column("rotor_speed"), Comment("Обороты ротора")]
public float? RotorSpeed { get; set; } public float RotorSpeed { get; set; }
[Column("flow"), Comment("Расход")] [Column("flow"), Comment("Расход")]
public float? Flow { get; set; } public float? Flow { get; set; }

View File

@ -95,12 +95,12 @@ public class WorkOperationDetection: Work
{ {
DateTime = d.DateTime, DateTime = d.DateTime,
IdUser = d.IdUser, IdUser = d.IdUser,
WellDepth = d.WellDepth ?? float.NaN, WellDepth = d.WellDepth,
Pressure = d.Pressure ?? float.NaN, Pressure = d.Pressure,
HookWeight = d.HookWeight ?? float.NaN, HookWeight = d.HookWeight,
BlockPosition = d.BlockPosition ?? float.NaN, BlockPosition = d.BlockPosition,
BitDepth = d.BitDepth ?? float.NaN, BitDepth = d.BitDepth,
RotorSpeed = d.RotorSpeed ?? float.NaN, RotorSpeed = d.RotorSpeed,
}) })
.OrderBy(d => d.DateTime); .OrderBy(d => d.DateTime);

View File

@ -44,37 +44,37 @@ namespace AsbCloudInfrastructure.Services.SAUB
.Where(t => t.BlockPosition > 0.0001) .Where(t => t.BlockPosition > 0.0001)
.Where(t => t.WellDepth > 0.0001) .Where(t => t.WellDepth > 0.0001)
.Where(t => t.Mode != null) .Where(t => t.Mode != null)
.Where(t => modes.Contains(t.Mode!.Value)) .Where(t => modes.Contains(t.Mode))
.Where(t => t.WellDepth - t.BitDepth < 0.01) .Where(t => t.WellDepth - t.BitDepth < 0.01)
.GroupBy(t => new { .GroupBy(t => new {
t.DateTime.Hour, t.DateTime.Hour,
WellDepthX10 = Math.Truncate(t.WellDepth!.Value * 10), WellDepthX10 = Math.Truncate(t.WellDepth * 10),
t.Mode, t.Mode,
t.IdFeedRegulator}) t.IdFeedRegulator})
.Select(g => new TelemetryDataSaubStatDto .Select(g => new TelemetryDataSaubStatDto
{ {
Count = g.Count(), Count = g.Count(),
IdMode = g.Key.Mode??0, IdMode = g.Key.Mode,
IdFeedRegulator = g.Key.IdFeedRegulator, IdFeedRegulator = g.Key.IdFeedRegulator,
DateMin = DateTime.SpecifyKind(g.Min(t => t.DateTime.UtcDateTime) + timezoneOffset, DateTimeKind.Unspecified), DateMin = DateTime.SpecifyKind(g.Min(t => t.DateTime.UtcDateTime) + timezoneOffset, DateTimeKind.Unspecified),
DateMax = DateTime.SpecifyKind(g.Max(t => t.DateTime.UtcDateTime) + timezoneOffset, DateTimeKind.Unspecified), DateMax = DateTime.SpecifyKind(g.Max(t => t.DateTime.UtcDateTime) + timezoneOffset, DateTimeKind.Unspecified),
WellDepthMin = g.Min(t => t.WellDepth!.Value), WellDepthMin = g.Min(t => t.WellDepth),
WellDepthMax = g.Max(t => t.WellDepth!.Value), WellDepthMax = g.Max(t => t.WellDepth),
Pressure = g.Average(t => t.Pressure!.Value), Pressure = g.Average(t => t.Pressure),
PressureSp = g.Average(t => t.PressureSp!.Value), PressureSp = g.Average(t => t.PressureSp!.Value),
PressureIdle = g.Average(t => t.PressureIdle!.Value), PressureIdle = g.Average(t => t.PressureIdle!.Value),
PressureDeltaLimitMax = g.Average(t => t.PressureDeltaLimitMax!.Value), PressureDeltaLimitMax = g.Average(t => t.PressureDeltaLimitMax!.Value),
PressureDelta = g.Average(t => t.Pressure!.Value - t.PressureIdle!.Value), PressureDelta = g.Average(t => t.Pressure - t.PressureIdle!.Value),
PressureSpDelta = g.Average(t => t.PressureSp!.Value - t.PressureIdle!.Value), PressureSpDelta = g.Average(t => t.PressureSp!.Value - t.PressureIdle!.Value),
AxialLoad = g.Average(t => t.AxialLoad!.Value), AxialLoad = g.Average(t => t.AxialLoad),
AxialLoadSp = g.Average(t => t.AxialLoadSp!.Value), AxialLoadSp = g.Average(t => t.AxialLoadSp!.Value),
AxialLoadLimitMax = g.Average(t => t.AxialLoadLimitMax!.Value), AxialLoadLimitMax = g.Average(t => t.AxialLoadLimitMax!.Value),
RotorTorque = g.Average(t => t.RotorTorque!.Value), RotorTorque = g.Average(t => t.RotorTorque),
RotorTorqueSp = g.Average(t => t.RotorTorqueSp!.Value), RotorTorqueSp = g.Average(t => t.RotorTorqueSp!.Value),
RotorTorqueLimitMax = g.Average(t => t.RotorTorqueLimitMax!.Value), RotorTorqueLimitMax = g.Average(t => t.RotorTorqueLimitMax!.Value),

View File

@ -279,11 +279,11 @@ public class WorkSubsystemOperationTimeCalc : Work
.Where(d => d.DateTime <= dateEnd) .Where(d => d.DateTime <= dateEnd)
.Where(d => d.WellDepth != null) .Where(d => d.WellDepth != null)
.Where(d => d.WellDepth > 0) .Where(d => d.WellDepth > 0)
.GroupBy(d => Math.Ceiling(d.WellDepth ?? 0 * 10)) .GroupBy(d => Math.Ceiling(d.WellDepth * 10))
.Select(g => new .Select(g => new
{ {
DateMin = g.Min(d => d.DateTime), DateMin = g.Min(d => d.DateTime),
DepthMin = g.Min(d => d.WellDepth) ?? 0, DepthMin = g.Min(d => d.WellDepth),
}) })
.OrderBy(i => i.DateMin) .OrderBy(i => i.DateMin)
.ToArrayAsync(token); .ToArrayAsync(token);