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

View File

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

View File

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

View File

@ -44,37 +44,37 @@ namespace AsbCloudInfrastructure.Services.SAUB
.Where(t => t.BlockPosition > 0.0001)
.Where(t => t.WellDepth > 0.0001)
.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)
.GroupBy(t => new {
t.DateTime.Hour,
WellDepthX10 = Math.Truncate(t.WellDepth!.Value * 10),
WellDepthX10 = Math.Truncate(t.WellDepth * 10),
t.Mode,
t.IdFeedRegulator})
.Select(g => new TelemetryDataSaubStatDto
{
Count = g.Count(),
IdMode = g.Key.Mode??0,
IdMode = g.Key.Mode,
IdFeedRegulator = g.Key.IdFeedRegulator,
DateMin = DateTime.SpecifyKind(g.Min(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),
WellDepthMax = g.Max(t => t.WellDepth!.Value),
WellDepthMin = g.Min(t => t.WellDepth),
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),
PressureIdle = g.Average(t => t.PressureIdle!.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),
AxialLoad = g.Average(t => t.AxialLoad!.Value),
AxialLoad = g.Average(t => t.AxialLoad),
AxialLoadSp = g.Average(t => t.AxialLoadSp!.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),
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.WellDepth != null)
.Where(d => d.WellDepth > 0)
.GroupBy(d => Math.Ceiling(d.WellDepth ?? 0 * 10))
.GroupBy(d => Math.Ceiling(d.WellDepth * 10))
.Select(g => new
{
DateMin = g.Min(d => d.DateTime),
DepthMin = g.Min(d => d.WellDepth) ?? 0,
DepthMin = g.Min(d => d.WellDepth),
})
.OrderBy(i => i.DateMin)
.ToArrayAsync(token);