#7987467 Раздел РТК в ЕЦП

This commit is contained in:
ai.astrakhantsev 2022-12-05 12:39:25 +05:00
parent 2963d74f43
commit 9b4f14a036
27 changed files with 19827 additions and 1028 deletions

View File

@ -1,86 +0,0 @@
using System;
namespace AsbCloudApp.Data
{
/// <summary>
/// Ïàðàìåòðû êîðèäîðîâ áóðåíèÿ (äèàïàçîíû ïàðàìåòðîâ áóðåíèÿ)
/// </summary>
public class DrillFlowChartDto : IId, IWellRelated
{
/// <inheritdoc/>
public int Id { get; set; }
/// <inheritdoc/>
public int IdWell { get; set; }
/// <summary>
/// Id òèïà îïåðàöèè
/// </summary>
public int IdWellOperationCategory { get; set; }
/// <summary>
/// Äàòà ïîñëåäíåãî èçìåíåíèÿ
/// </summary>
public DateTime LastUpdate { get; set; }
/// <summary>
/// Ñòàðòîâàÿ ãëóáèíà
/// </summary>
public double DepthStart { get; set; }
/// <summary>
/// Ãëóáèíà îêîí÷àíèÿ èíòåðâàëà
/// </summary>
public double DepthEnd { get; set; }
/// <summary>
/// Ìèíèìàëüíàÿ íàãðóçêà
/// </summary>
public double AxialLoadMin { get; set; }
/// <summary>
/// Ìàêñèìàëüíàÿ íàãðóçêà
/// </summary>
public double AxialLoadMax { get; set; }
/// <summary>
/// Ìèíèìàëüíîå äàâëåíèå
/// </summary>
public double PressureMin { get; set; }
/// <summary>
/// Ìàêñèìàëüíîå äàâëåíèå
/// </summary>
public double PressureMax { get; set; }
/// <summary>
/// Ìèíèìàëüíûé ìîìåíò íà ÂÑÏ
/// </summary>
public double RotorTorqueMin { get; set; }
/// <summary>
/// Ìàêñèìàëüíûé ìîìåíò íà ÂÑÏ
/// </summary>
public double RotorTorqueMax { get; set; }
/// <summary>
/// Ìèíèìàëüíûå îáîðîòû íà ÂÑÏ
/// </summary>
public double RotorSpeedMin { get; set; }
/// <summary>
/// Ìàêñèìàëüíûå îáîðîòû íà ÂÑÏ
/// </summary>
public double RotorSpeedMax { get; set; }
/// <summary>
/// Ìèíèìàëüíûé ðàñõîä
/// </summary>
public double FlowMin { get; set; }
/// <summary>
/// Ìàêñèìàëüíûé ðàñõîä
/// </summary>
public double FlowMax { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsbCloudApp.Data
{
/// <summary>
/// Плановое и фактическое значения
/// </summary>
public class PlanFactDto
{
/// <summary>
/// План
/// </summary>
public double Plan { get; set; }
/// <summary>
/// Факт
/// </summary>
public double? Fact { get; set; }
}
}

View File

@ -0,0 +1,75 @@
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace AsbCloudApp.Data
{
#nullable enable
/// <summary>
/// Операции по скважине РТК
/// </summary>
public class ProcessMapDto : IId, IWellRelated
{
/// <summary>
/// <inheritdoc/>
/// </summary>
public int Id { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public int IdWell { get; set; }
/// <summary>
/// Секция
/// </summary>
public int Section { get; set; }
/// <summary>
/// Дата последнего изменения
/// </summary>
public DateTimeOffset LastUpdate { get; set; }
/// <summary>
/// Стартовая глубина
/// </summary>
public double DepthStart { get; set; }
/// <summary>
/// Глубина окончания интервала
/// </summary>
public double DepthEnd { get; set; }
/// <summary>
/// Нагрузка
/// </summary>
public PlanFactDto? AxialLoad { get; set; }
/// <summary>
/// Перепад давления
/// </summary>
public PlanFactDto? Pressure { get; set; }
/// <summary>
/// Момент на ВСП
/// </summary>
public PlanFactDto? RotorTorque { get; set; }
/// <summary>
/// Обороты на ВСП
/// </summary>
public PlanFactDto? RotorSpeed { get; set; }
/// <summary>
/// Расход
/// </summary>
public PlanFactDto? Flow { get; set; }
/// <summary>
/// Плановая механическая скорость, м/ч
/// </summary>
public double MechanicalSpeedPlan { get; set; }
}
#nullable disable
}

View File

@ -9,7 +9,7 @@ namespace AsbCloudApp.Services
/// <summary>
/// ÐÒÊ
/// </summary>
public interface IDrillFlowChartRepository : IRepositoryWellRelated<DrillFlowChartDto>
public interface IDrillFlowChartRepository : IRepositoryWellRelated<ProcessMapDto>
{
/// <summary>
/// Ïîëó÷èòü ïàðàìåòðû áóðåíèÿ íà÷èíàÿ ñ äàòû.
@ -18,7 +18,7 @@ namespace AsbCloudApp.Services
/// <param name="updateFrom"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<DrillFlowChartDto>> GetAllAsync(int idWell,
Task<IEnumerable<ProcessMapDto>> GetAllAsync(int idWell,
DateTime updateFrom, CancellationToken token = default);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,73 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class RemoveTable_t_drill_params : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_drill_params");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_drill_params",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
well_id = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
id_wellsection_type = table.Column<int>(type: "integer", nullable: false, comment: "Id с типом секции скважины"),
axial_load_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Средняя нагрузка"),
axial_load_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальная нагрузка"),
axial_load_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальная нагрузка"),
depth_end = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина окончания интервала"),
depth_start = table.Column<double>(type: "double precision", nullable: false, comment: "Стартовая глубина"),
flow_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Средний расход"),
flow_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный расход"),
flow_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный расход"),
pressure_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Среднее давление"),
pressure_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальное давление"),
pressure_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальное давление"),
rotor_speed_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Средние обороты на ВСП"),
rotor_speed_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальные обороты на ВСП"),
rotor_speed_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальные обороты на ВСП"),
rotor_torque_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Средний момент на ВСП"),
rotor_torque_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный момент на ВСП"),
rotor_torque_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный момент на ВСП")
},
constraints: table =>
{
table.PrimaryKey("PK_t_drill_params", x => x.id);
table.ForeignKey(
name: "FK_t_drill_params_t_well_well_id",
column: x => x.well_id,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "t_drill_params_t_well_section_type_id_fk",
column: x => x.id_wellsection_type,
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "Режим бурения в секции (диапазоны параметров бурения)");
migrationBuilder.CreateIndex(
name: "IX_t_drill_params_id_wellsection_type",
table: "t_drill_params",
column: "id_wellsection_type");
migrationBuilder.CreateIndex(
name: "IX_t_drill_params_well_id",
table: "t_drill_params",
column: "well_id");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,64 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class DeleteTable_t_drill_flow_chart : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_drill_flow_chart");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_drill_flow_chart",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
well_id = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
axial_load_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальная нагрузка"),
axial_load_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальная нагрузка"),
depth_end = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина окончания интервала"),
depth_start = table.Column<double>(type: "double precision", nullable: false, comment: "Стартовая глубина"),
flow_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный расход"),
flow_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный расход"),
id_operation_category = table.Column<int>(type: "integer", nullable: false, comment: "Id типа операции"),
last_update = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата последнего изменения"),
pressure_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальное давление"),
pressure_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальное давление"),
rotor_speed_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальные обороты на ВСП"),
rotor_speed_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальные обороты на ВСП"),
rotor_torque_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный момент на ВСП"),
rotor_torque_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный момент на ВСП")
},
constraints: table =>
{
table.PrimaryKey("PK_t_drill_flow_chart", x => x.id);
table.ForeignKey(
name: "FK_t_drill_flow_chart_t_well_well_id",
column: x => x.well_id,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "Параметры коридоров бурения (диапазоны параметров бурения)");
migrationBuilder.CreateIndex(
name: "IX_t_drill_flow_chart_id_operation_category",
table: "t_drill_flow_chart",
column: "id_operation_category");
migrationBuilder.CreateIndex(
name: "IX_t_drill_flow_chart_well_id",
table: "t_drill_flow_chart",
column: "well_id");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class AddTable_t_process_map : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_process_map",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
well_id = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
section = table.Column<int>(type: "integer", nullable: false, comment: "Секция"),
last_update = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата последнего изменения"),
depth_start = table.Column<double>(type: "double precision", nullable: false, comment: "Стартовая глубина"),
depth_end = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина окончания интервала"),
axial_load_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Нагрузка, план"),
axial_load_fact = table.Column<double>(type: "double precision", nullable: true, comment: "Нагрузка, факт"),
pressure_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, план"),
pressure_fact = table.Column<double>(type: "double precision", nullable: true, comment: "Перепад давления, факт"),
rotor_torque_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Момент на ВСП, план"),
rotor_torque_fact = table.Column<double>(type: "double precision", nullable: true, comment: "Момент на ВСП, факт"),
rotor_speed_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Обороты на ВСП, план"),
rotor_speed_fact = table.Column<double>(type: "double precision", nullable: true, comment: "Обороты на ВСП, факт"),
flow_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Расход, план"),
flow_fact = table.Column<double>(type: "double precision", nullable: true, comment: "Расход, факт"),
mechanical_speed_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Плановая механическая скорость, м/ч")
},
constraints: table =>
{
table.PrimaryKey("PK_t_process_map", x => x.id);
},
comment: "Операции по скважине РТК");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_process_map");
}
}
}

View File

@ -297,101 +297,6 @@ namespace AsbCloudDb.Migrations
b.HasComment("Бурильщик");
});
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChart", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("AxialLoadMax")
.HasColumnType("double precision")
.HasColumnName("axial_load_max")
.HasComment("Максимальная нагрузка");
b.Property<double>("AxialLoadMin")
.HasColumnType("double precision")
.HasColumnName("axial_load_min")
.HasComment("Минимальная нагрузка");
b.Property<double>("DepthEnd")
.HasColumnType("double precision")
.HasColumnName("depth_end")
.HasComment("Глубина окончания интервала");
b.Property<double>("DepthStart")
.HasColumnType("double precision")
.HasColumnName("depth_start")
.HasComment("Стартовая глубина");
b.Property<double>("FlowMax")
.HasColumnType("double precision")
.HasColumnName("flow_max")
.HasComment("Максимальный расход");
b.Property<double>("FlowMin")
.HasColumnType("double precision")
.HasColumnName("flow_min")
.HasComment("Минимальный расход");
b.Property<int>("IdWell")
.HasColumnType("integer")
.HasColumnName("well_id")
.HasComment("Id скважины");
b.Property<int>("IdWellOperationCategory")
.HasColumnType("integer")
.HasColumnName("id_operation_category")
.HasComment("Id типа операции");
b.Property<DateTimeOffset>("LastUpdate")
.HasColumnType("timestamp with time zone")
.HasColumnName("last_update")
.HasComment("Дата последнего изменения");
b.Property<double>("PressureMax")
.HasColumnType("double precision")
.HasColumnName("pressure_max")
.HasComment("Максимальное давление");
b.Property<double>("PressureMin")
.HasColumnType("double precision")
.HasColumnName("pressure_min")
.HasComment("Минимальное давление");
b.Property<double>("RotorSpeedMax")
.HasColumnType("double precision")
.HasColumnName("rotor_speed_max")
.HasComment("Максимальные обороты на ВСП");
b.Property<double>("RotorSpeedMin")
.HasColumnType("double precision")
.HasColumnName("rotor_speed_min")
.HasComment("Минимальные обороты на ВСП");
b.Property<double>("RotorTorqueMax")
.HasColumnType("double precision")
.HasColumnName("rotor_torque_max")
.HasComment("Максимальный момент на ВСП");
b.Property<double>("RotorTorqueMin")
.HasColumnType("double precision")
.HasColumnName("rotor_torque_min")
.HasComment("Минимальный момент на ВСП");
b.HasKey("Id");
b.HasIndex("IdWell");
b.HasIndex("IdWellOperationCategory");
b.ToTable("t_drill_flow_chart");
b.HasComment("Параметры коридоров бурения (диапазоны параметров бурения)");
});
modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b =>
{
b.Property<int>("Id")
@ -421,121 +326,6 @@ namespace AsbCloudDb.Migrations
b.HasComment("части программ бурения");
});
modelBuilder.Entity("AsbCloudDb.Model.DrillParams", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("AxialLoadAvg")
.HasColumnType("double precision")
.HasColumnName("axial_load_avg")
.HasComment("Средняя нагрузка");
b.Property<double>("AxialLoadMax")
.HasColumnType("double precision")
.HasColumnName("axial_load_max")
.HasComment("Максимальная нагрузка");
b.Property<double>("AxialLoadMin")
.HasColumnType("double precision")
.HasColumnName("axial_load_min")
.HasComment("Минимальная нагрузка");
b.Property<double>("DepthEnd")
.HasColumnType("double precision")
.HasColumnName("depth_end")
.HasComment("Глубина окончания интервала");
b.Property<double>("DepthStart")
.HasColumnType("double precision")
.HasColumnName("depth_start")
.HasComment("Стартовая глубина");
b.Property<double>("FlowAvg")
.HasColumnType("double precision")
.HasColumnName("flow_avg")
.HasComment("Средний расход");
b.Property<double>("FlowMax")
.HasColumnType("double precision")
.HasColumnName("flow_max")
.HasComment("Максимальный расход");
b.Property<double>("FlowMin")
.HasColumnType("double precision")
.HasColumnName("flow_min")
.HasComment("Минимальный расход");
b.Property<int>("IdWell")
.HasColumnType("integer")
.HasColumnName("well_id")
.HasComment("Id скважины");
b.Property<int>("IdWellSectionType")
.HasColumnType("integer")
.HasColumnName("id_wellsection_type")
.HasComment("Id с типом секции скважины");
b.Property<double>("PressureAvg")
.HasColumnType("double precision")
.HasColumnName("pressure_avg")
.HasComment("Среднее давление");
b.Property<double>("PressureMax")
.HasColumnType("double precision")
.HasColumnName("pressure_max")
.HasComment("Максимальное давление");
b.Property<double>("PressureMin")
.HasColumnType("double precision")
.HasColumnName("pressure_min")
.HasComment("Минимальное давление");
b.Property<double>("RotorSpeedAvg")
.HasColumnType("double precision")
.HasColumnName("rotor_speed_avg")
.HasComment("Средние обороты на ВСП");
b.Property<double>("RotorSpeedMax")
.HasColumnType("double precision")
.HasColumnName("rotor_speed_max")
.HasComment("Максимальные обороты на ВСП");
b.Property<double>("RotorSpeedMin")
.HasColumnType("double precision")
.HasColumnName("rotor_speed_min")
.HasComment("Минимальные обороты на ВСП");
b.Property<double>("RotorTorqueAvg")
.HasColumnType("double precision")
.HasColumnName("rotor_torque_avg")
.HasComment("Средний момент на ВСП");
b.Property<double>("RotorTorqueMax")
.HasColumnType("double precision")
.HasColumnName("rotor_torque_max")
.HasComment("Максимальный момент на ВСП");
b.Property<double>("RotorTorqueMin")
.HasColumnType("double precision")
.HasColumnName("rotor_torque_min")
.HasComment("Минимальный момент на ВСП");
b.HasKey("Id");
b.HasIndex("IdWell");
b.HasIndex("IdWellSectionType");
b.ToTable("t_drill_params");
b.HasComment("Режим бурения в секции (диапазоны параметров бурения)");
});
modelBuilder.Entity("AsbCloudDb.Model.FileCategory", b =>
{
b.Property<int>("Id")
@ -1972,6 +1762,102 @@ namespace AsbCloudDb.Migrations
});
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMap", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double?>("AxialLoadFact")
.HasColumnType("double precision")
.HasColumnName("axial_load_fact")
.HasComment("Нагрузка, факт");
b.Property<double>("AxialLoadPlan")
.HasColumnType("double precision")
.HasColumnName("axial_load_plan")
.HasComment("Нагрузка, план");
b.Property<double>("DepthEnd")
.HasColumnType("double precision")
.HasColumnName("depth_end")
.HasComment("Глубина окончания интервала");
b.Property<double>("DepthStart")
.HasColumnType("double precision")
.HasColumnName("depth_start")
.HasComment("Стартовая глубина");
b.Property<double?>("FlowFact")
.HasColumnType("double precision")
.HasColumnName("flow_fact")
.HasComment("Расход, факт");
b.Property<double>("FlowPlan")
.HasColumnType("double precision")
.HasColumnName("flow_plan")
.HasComment("Расход, план");
b.Property<int>("IdWell")
.HasColumnType("integer")
.HasColumnName("well_id")
.HasComment("Id скважины");
b.Property<DateTimeOffset>("LastUpdate")
.HasColumnType("timestamp with time zone")
.HasColumnName("last_update")
.HasComment("Дата последнего изменения");
b.Property<double>("MechanicalSpeedPlan")
.HasColumnType("double precision")
.HasColumnName("mechanical_speed_plan")
.HasComment("Плановая механическая скорость, м/ч");
b.Property<double?>("PressureFact")
.HasColumnType("double precision")
.HasColumnName("pressure_fact")
.HasComment("Перепад давления, факт");
b.Property<double>("PressurePlan")
.HasColumnType("double precision")
.HasColumnName("pressure_plan")
.HasComment("Перепад давления, план");
b.Property<double?>("RotorSpeedFact")
.HasColumnType("double precision")
.HasColumnName("rotor_speed_fact")
.HasComment("Обороты на ВСП, факт");
b.Property<double>("RotorSpeedPlan")
.HasColumnType("double precision")
.HasColumnName("rotor_speed_plan")
.HasComment("Обороты на ВСП, план");
b.Property<double?>("RotorTorqueFact")
.HasColumnType("double precision")
.HasColumnName("rotor_torque_fact")
.HasComment("Момент на ВСП, факт");
b.Property<double>("RotorTorquePlan")
.HasColumnType("double precision")
.HasColumnName("rotor_torque_plan")
.HasComment("Момент на ВСП, план");
b.Property<int>("Section")
.HasColumnType("integer")
.HasColumnName("section")
.HasComment("Секция");
b.HasKey("Id");
b.ToTable("t_process_map");
b.HasComment("Операции по скважине РТК");
});
modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b =>
{
b.Property<int>("IdCompany")
@ -5883,17 +5769,6 @@ namespace AsbCloudDb.Migrations
b.Navigation("Telemetry");
});
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChart", b =>
{
b.HasOne("AsbCloudDb.Model.Well", "Well")
.WithMany()
.HasForeignKey("IdWell")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Well");
});
modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b =>
{
b.HasOne("AsbCloudDb.Model.FileCategory", "FileCategory")
@ -5913,26 +5788,6 @@ namespace AsbCloudDb.Migrations
b.Navigation("Well");
});
modelBuilder.Entity("AsbCloudDb.Model.DrillParams", b =>
{
b.HasOne("AsbCloudDb.Model.Well", "Well")
.WithMany()
.HasForeignKey("IdWell")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
.WithMany("DrillParamsCollection")
.HasForeignKey("IdWellSectionType")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("t_drill_params_t_well_section_type_id_fk");
b.Navigation("Well");
b.Navigation("WellSectionType");
});
modelBuilder.Entity("AsbCloudDb.Model.FileInfo", b =>
{
b.HasOne("AsbCloudDb.Model.User", "Author")
@ -6577,8 +6432,6 @@ namespace AsbCloudDb.Migrations
modelBuilder.Entity("AsbCloudDb.Model.WellSectionType", b =>
{
b.Navigation("DrillParamsCollection");
b.Navigation("WellComposites");
b.Navigation("WellOperations");

View File

@ -13,9 +13,8 @@ namespace AsbCloudDb.Model
public virtual DbSet<DailyReport.DailyReport> DailyReports => Set <DailyReport.DailyReport >();
public virtual DbSet<Deposit> Deposits => Set<Deposit>();
public virtual DbSet<DetectedOperation> DetectedOperations => Set<DetectedOperation>();
public virtual DbSet<DrillFlowChart> DrillFlowChart => Set<DrillFlowChart>();
public virtual DbSet<ProcessMap> ProcessMap => Set<ProcessMap>();
public virtual DbSet<DrillingProgramPart> DrillingProgramParts => Set<DrillingProgramPart>();
public virtual DbSet<DrillParams> DrillParams => Set<DrillParams>();
public virtual DbSet<FileCategory> FileCategories => Set<FileCategory>();
public virtual DbSet<FileInfo> Files => Set<FileInfo>();
public virtual DbSet<FileMark> FileMarks => Set<FileMark>();
@ -248,19 +247,6 @@ namespace AsbCloudDb.Model
entity.HasIndex(d => d.DateStart);
});
modelBuilder.Entity<DrillParams>(entity =>
{
entity.HasOne(r => r.WellSectionType)
.WithMany(w => w.DrillParamsCollection)
.HasForeignKey(r => r.IdWellSectionType)
.HasConstraintName("t_drill_params_t_well_section_type_id_fk");
});
modelBuilder.Entity<DrillFlowChart>(entity =>
{
entity.HasIndex(d => d.IdWellOperationCategory);
});
modelBuilder.Entity<DrillingProgramPart>(entity =>
{
entity.HasIndex(x => new { x.IdWell, x.IdFileCategory })

View File

@ -1,66 +0,0 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
#nullable disable
[Table("t_drill_flow_chart"), Comment("Параметры коридоров бурения (диапазоны параметров бурения)")]
public class DrillFlowChart : IId, IWellRelated
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("well_id"), Comment("Id скважины")]
public int IdWell { get; set; }
[Column("id_operation_category"), Comment("Id типа операции")]
public int IdWellOperationCategory { get; set; }
[Column("last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего изменения")]
public DateTimeOffset LastUpdate { get; set; }
[Column("depth_start"), Comment("Стартовая глубина")]
public double DepthStart { get; set; }
[Column("depth_end"), Comment("Глубина окончания интервала")]
public double DepthEnd { get; set; }
[Column("axial_load_min"), Comment("Минимальная нагрузка")]
public double AxialLoadMin { get; set; }
[Column("axial_load_max"), Comment("Максимальная нагрузка")]
public double AxialLoadMax { get; set; }
[Column("pressure_min"), Comment("Минимальное давление")]
public double PressureMin { get; set; }
[Column("pressure_max"), Comment("Максимальное давление")]
public double PressureMax { get; set; }
[Column("rotor_torque_min"), Comment("Минимальный момент на ВСП")]
public double RotorTorqueMin { get; set; }
[Column("rotor_torque_max"), Comment("Максимальный момент на ВСП")]
public double RotorTorqueMax { get; set; }
[Column("rotor_speed_min"), Comment("Минимальные обороты на ВСП")]
public double RotorSpeedMin { get; set; }
[Column("rotor_speed_max"), Comment("Максимальные обороты на ВСП")]
public double RotorSpeedMax { get; set; }
[Column("flow_min"), Comment("Минимальный расход")]
public double FlowMin { get; set; }
[Column("flow_max"), Comment("Максимальный расход")]
public double FlowMax { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
}
}

View File

@ -1,81 +0,0 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
#nullable disable
[Table("t_drill_params"), Comment("Режим бурения в секции (диапазоны параметров бурения)")]
public class DrillParams : IId
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("well_id"), Comment("Id скважины")]
public int IdWell { get; set; }
[Column("depth_start"), Comment("Стартовая глубина")]
public double DepthStart { get; set; }
[Column("depth_end"), Comment("Глубина окончания интервала")]
public double DepthEnd { get; set; }
[Column("id_wellsection_type"), Comment("Id с типом секции скважины")]
public int IdWellSectionType { get; set; }
[Column("axial_load_min"), Comment("Минимальная нагрузка")]
public double AxialLoadMin { get; set; }
[Column("axial_load_avg"), Comment("Средняя нагрузка")]
public double AxialLoadAvg { get; set; }
[Column("axial_load_max"), Comment("Максимальная нагрузка")]
public double AxialLoadMax { get; set; }
[Column("pressure_min"), Comment("Минимальное давление")]
public double PressureMin { get; set; }
[Column("pressure_avg"), Comment("Среднее давление")]
public double PressureAvg { get; set; }
[Column("pressure_max"), Comment("Максимальное давление")]
public double PressureMax { get; set; }
[Column("rotor_torque_min"), Comment("Минимальный момент на ВСП")]
public double RotorTorqueMin { get; set; }
[Column("rotor_torque_avg"), Comment("Средний момент на ВСП")]
public double RotorTorqueAvg { get; set; }
[Column("rotor_torque_max"), Comment("Максимальный момент на ВСП")]
public double RotorTorqueMax { get; set; }
[Column("rotor_speed_min"), Comment("Минимальные обороты на ВСП")]
public double RotorSpeedMin { get; set; }
[Column("rotor_speed_avg"), Comment("Средние обороты на ВСП")]
public double RotorSpeedAvg { get; set; }
[Column("rotor_speed_max"), Comment("Максимальные обороты на ВСП")]
public double RotorSpeedMax { get; set; }
[Column("flow_min"), Comment("Минимальный расход")]
public double FlowMin { get; set; }
[Column("flow_avg"), Comment("Средний расход")]
public double FlowAvg { get; set; }
[Column("flow_max"), Comment("Максимальный расход")]
public double FlowMax { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdWellSectionType))]
public virtual WellSectionType WellSectionType { get; set; }
}
}

View File

@ -15,9 +15,8 @@ namespace AsbCloudDb.Model
DbSet<DailyReport.DailyReport> DailyReports { get; }
DbSet<Deposit> Deposits { get; }
DbSet<DetectedOperation> DetectedOperations { get; }
DbSet<DrillFlowChart> DrillFlowChart { get; }
DbSet<ProcessMap> ProcessMap { get; }
DbSet<DrillingProgramPart> DrillingProgramParts { get; }
DbSet<DrillParams> DrillParams { get; }
DbSet<FileCategory> FileCategories { get; }
DbSet<FileInfo> Files { get; }
DbSet<FileMark> FileMarks { get; }

View File

@ -0,0 +1,65 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
#nullable enable
[Table("t_process_map"), Comment("Операции по скважине РТК")]
public class ProcessMap : IId, IWellRelated
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("well_id"), Comment("Id скважины")]
public int IdWell { get; set; }
[Column("section"), Comment("Секция")]
public int Section { get; set; }
[Column("last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего изменения")]
public DateTimeOffset LastUpdate { get; set; }
[Column("depth_start"), Comment("Стартовая глубина")]
public double DepthStart { get; set; }
[Column("depth_end"), Comment("Глубина окончания интервала")]
public double DepthEnd { get; set; }
[Column("axial_load_plan"), Comment("Нагрузка, план")]
public double AxialLoadPlan { get; set; }
[Column("axial_load_fact"), Comment("Нагрузка, факт")]
public double? AxialLoadFact { get; set; }
[Column("pressure_plan"), Comment("Перепад давления, план")]
public double PressurePlan { get; set; }
[Column("pressure_fact"), Comment("Перепад давления, факт")]
public double? PressureFact { get; set; }
[Column("rotor_torque_plan"), Comment("Момент на ВСП, план")]
public double RotorTorquePlan { get; set; }
[Column("rotor_torque_fact"), Comment("Момент на ВСП, факт")]
public double? RotorTorqueFact { get; set; }
[Column("rotor_speed_plan"), Comment("Обороты на ВСП, план")]
public double RotorSpeedPlan { get; set; }
[Column("rotor_speed_fact"), Comment("Обороты на ВСП, факт")]
public double? RotorSpeedFact { get; set; }
[Column("flow_plan"), Comment("Расход, план")]
public double FlowPlan { get; set; }
[Column("flow_fact"), Comment("Расход, факт")]
public double? FlowFact { get; set; }
[Column("mechanical_speed_plan"), Comment("Плановая механическая скорость, м/ч")]
public double MechanicalSpeedPlan { get; set; }
}
#nullable disable
}

View File

@ -21,10 +21,6 @@ namespace AsbCloudDb.Model
[InverseProperty(nameof(WellOperation.WellSectionType))]
public virtual ICollection<WellOperation> WellOperations { get; set; } = null!;
[JsonIgnore]
[InverseProperty(nameof(DrillParams.WellSectionType))]
public virtual ICollection<DrillParams> DrillParamsCollection { get; set; } = null!;
[JsonIgnore]
[InverseProperty(nameof(WellComposite.WellSectionType))]
public virtual ICollection<WellComposite> WellComposites { get; set; } = null!;

View File

@ -111,9 +111,8 @@ namespace AsbCloudInfrastructure
services.AddTransient<IAuthService, AuthService>();
services.AddTransient<IClusterService, ClusterService>();
services.AddTransient<IDrillFlowChartRepository, DrillFlowChartRepository>();
services.AddTransient<IDrillFlowChartRepository, ProcessMapRepository>();
services.AddTransient<IDrillingProgramService, DrillingProgramService>();
services.AddTransient<IDrillParamsService, DrillParamsService>();
services.AddTransient<IEventService, EventService>();
services.AddTransient<FileService>();
services.AddTransient<IMeasureService, MeasureService>();
@ -144,7 +143,6 @@ namespace AsbCloudInfrastructure
s.GetService<IAsbCloudDbContext>(),
s.GetService<IMemoryCache>(),
dbSet => dbSet.Include(t => t.Well))); // может быть включен в сервис TelemetryService
services.AddTransient<ICrudService<DrillParamsDto>, DrillParamsService>();
services.AddTransient<ICrudService<DepositDto>, CrudCacheServiceBase<DepositDto, Deposit>>(s =>
new CrudCacheServiceBase<DepositDto, Deposit>(
s.GetService<IAsbCloudDbContext>(),

View File

@ -1,63 +0,0 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Mapster;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Repository
{
public class DrillFlowChartRepository : CrudWellRelatedServiceBase<DrillFlowChartDto, DrillFlowChart>,
IDrillFlowChartRepository
{
private readonly IWellService wellService;
public DrillFlowChartRepository(IAsbCloudDbContext context, IWellService wellService)
: base(context)
{
this.wellService = wellService;
}
public async Task<IEnumerable<DrillFlowChartDto>> GetAllAsync(int idWell,
DateTime updateFrom, CancellationToken token = default)
{
var timezone = wellService.GetTimezone(idWell);
var updateFromUtc = updateFrom.ToUtcDateTimeOffset(timezone.Hours);
var entities = await GetQuery()
.Where(e => e.IdWell == idWell)
.Where(e => e.LastUpdate == updateFromUtc)
.OrderBy(e => e.DepthStart)
.ThenBy(e => e.Id)
.ToListAsync(token)
.ConfigureAwait(false);
var dtos = entities.Select(entity =>
{
var dto = entity.Adapt<DrillFlowChartDto>();
dto.LastUpdate = entity.LastUpdate.ToRemoteDateTime(timezone.Hours);
return dto;
});
return dtos;
}
public override async Task<int> InsertAsync(DrillFlowChartDto dto,
CancellationToken token = default)
{
dto.LastUpdate = DateTime.UtcNow;
var result = await base.InsertAsync(dto, token);
return result;
}
public override async Task<int> UpdateAsync(DrillFlowChartDto dto,
CancellationToken token = default)
{
dto.LastUpdate = DateTime.UtcNow;
var result = await base.UpdateAsync(dto, token);
return result;
}
}
}

View File

@ -0,0 +1,96 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Mapster;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Repository
{
public class ProcessMapRepository : CrudWellRelatedServiceBase<ProcessMapDto, ProcessMap>,
IDrillFlowChartRepository
{
private readonly IWellService wellService;
public ProcessMapRepository(IAsbCloudDbContext context, IWellService wellService)
: base(context)
{
this.wellService = wellService;
}
public async Task<IEnumerable<ProcessMapDto>> GetAllAsync(int idWell,
DateTime updateFrom, CancellationToken token = default)
{
var timezone = wellService.GetTimezone(idWell);
var updateFromUtc = updateFrom.ToUtcDateTimeOffset(timezone.Hours);
var entities = await GetQuery()
.Where(e => e.IdWell == idWell)
.Where(e => e.LastUpdate == updateFromUtc)
.OrderBy(e => e.DepthStart)
.ThenBy(e => e.Id)
.ToListAsync(token)
.ConfigureAwait(false);
var dtos = entities.Select(entity =>
{
var dto = entity.Adapt<ProcessMapDto>();
dto.LastUpdate = entity.LastUpdate.ToRemoteDateTime(timezone.Hours);
return dto;
});
return dtos;
}
public override async Task<int> InsertAsync(ProcessMapDto dto,
CancellationToken token = default)
{
dto.LastUpdate = DateTime.UtcNow;
var result = await base.InsertAsync(dto, token);
return result;
}
public override async Task<int> UpdateAsync(ProcessMapDto dto,
CancellationToken token = default)
{
dto.LastUpdate = DateTime.UtcNow;
var result = await base.UpdateAsync(dto, token);
return result;
}
protected override ProcessMapDto Convert(ProcessMap entity)
{
return new ProcessMapDto {
Id = entity.Id,
IdWell = entity.IdWell,
LastUpdate = entity.LastUpdate,
Section = entity.Section,
DepthEnd = entity.DepthEnd,
DepthStart = entity.DepthStart,
AxialLoad = new PlanFactDto {
Fact = entity.AxialLoadFact,
Plan = entity.AxialLoadPlan
},
Flow = new PlanFactDto {
Fact = entity.FlowFact,
Plan = entity.FlowPlan
},
Pressure = new PlanFactDto {
Fact = entity.FlowFact,
Plan = entity.FlowPlan
},
RotorSpeed = new PlanFactDto {
Fact = entity.RotorSpeedFact,
Plan = entity.RotorSpeedPlan
},
RotorTorque = new PlanFactDto {
Fact= entity.RotorTorqueFact,
Plan = entity.RotorTorquePlan
},
MechanicalSpeedPlan = entity.MechanicalSpeedPlan
};
}
}
}

View File

@ -48,9 +48,7 @@ namespace AsbCloudInfrastructure.Services
.Include(w => w.WellType)
.Include(w => w.Cluster)
.ThenInclude(c => c.Deposit)
from p in db.DrillParams
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany) &&
well.Id == p.IdWell
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany)
select well).ToListAsync(token)
.ConfigureAwait(false);

View File

@ -1,222 +0,0 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Repository;
using Mapster;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services
{
#nullable enable
public class DrillParamsService : CrudServiceBase<DrillParamsDto, DrillParams>, IDrillParamsService
{
private readonly IAsbCloudDbContext db;
private readonly ITelemetryService telemetryService;
public DrillParamsService(IAsbCloudDbContext context, ITelemetryService telemetryService)
: base(context)
{
this.db = context;
this.telemetryService = telemetryService;
}
public async Task<DrillParamsDto?> GetDefaultDrillParamsAsync(int idWell,
double startDepth, double endDepth, CancellationToken token = default)
{
var idTelemetry = telemetryService.GetOrDefaultIdTelemetryByIdWell(idWell);
if (idTelemetry is null)
return null;
var drillParamsDto = await (from telemetry in db.TelemetryDataSaub
where telemetry.IdTelemetry == idTelemetry &&
telemetry.WellDepth >= startDepth &&
telemetry.WellDepth <= endDepth
group telemetry by telemetry.IdTelemetry into g
select new DrillParamsDto()
{
IdWell = idWell,
Depth = new MinMaxDto<double>
{
Min = endDepth,
Max = startDepth
},
IdWellSectionType = 0,
AxialLoad = new MinMaxExtendedViewDto
{
Min = g.Min(t => t.AxialLoad) ?? double.NaN,
Avg = g.Average(t => t.AxialLoad) ?? double.NaN,
Max = g.Max(t => t.AxialLoad) ?? double.NaN
},
Pressure = new MinMaxExtendedViewDto
{
Min = g.Min(t => t.Pressure) ?? double.NaN,
Avg = g.Average(t => t.Pressure) ?? double.NaN,
Max = g.Max(t => t.Pressure) ?? double.NaN
},
RotorTorque = new MinMaxExtendedViewDto
{
Min = g.Min(t => t.RotorTorque) ?? double.NaN,
Avg = g.Average(t => t.RotorTorque) ?? double.NaN,
Max = g.Max(t => t.RotorTorque) ?? double.NaN
},
RotorSpeed = new MinMaxExtendedViewDto
{
Min = g.Min(t => t.RotorSpeed) ?? double.NaN,
Avg = g.Average(t => t.RotorSpeed) ?? double.NaN,
Max = g.Max(t => t.RotorSpeed) ?? double.NaN
},
Flow = new MinMaxExtendedViewDto
{
Min = g.Min(t => t.Flow) ?? double.NaN,
Avg = g.Min(t => t.Flow) ?? double.NaN,
Max = g.Min(t => t.Flow) ?? double.NaN
}
})
.AsNoTracking()
.DefaultIfEmpty()
.OrderBy(t => t.AxialLoad.Min)
.FirstOrDefaultAsync(token)
.ConfigureAwait(false);
return drillParamsDto;
}
public async Task<IEnumerable<DrillParamsDto>> GetAllAsync(int idWell,
CancellationToken token = default)
{
var entities = await db.DrillParams
.Where(p => p.IdWell == idWell)
.OrderBy(p=> p.Id)
.AsNoTracking()
.ToArrayAsync(token)
.ConfigureAwait(false);
var dtos = entities.Select(p =>
{
var dto = new DrillParamsDto
{
IdWell = p.IdWell,
Id = p.Id,
IdWellSectionType = p.IdWellSectionType,
Depth = new MinMaxDto<double> { Max = p.PressureMax, Min = p.PressureMin },
Pressure = MakeMinMaxExtended(p.PressureAvg, p.PressureMax, p.PressureMin),
AxialLoad = MakeMinMaxExtended(p.AxialLoadAvg, p.AxialLoadMax, p.AxialLoadMin),
Flow = MakeMinMaxExtended(p.FlowAvg, p.FlowMax, p.FlowMin),
RotorSpeed = MakeMinMaxExtended(p.RotorSpeedAvg, p.RotorSpeedMax, p.RotorSpeedMin),
RotorTorque = MakeMinMaxExtended(p.RotorTorqueAvg, p.RotorTorqueMax, p.RotorTorqueMin)
};
return dto;
});
return dtos;
}
public async Task<IEnumerable<DrillParamsDto>> GetCompositeAllAsync(int idWell,
CancellationToken token = default)
{
var allDrillParamsQuery = db.WellComposites
.Where(c => c.IdWell == idWell)
.Join(db.DrillParams,
c => c.IdWellSrc,
p => p.IdWell,
(c, p) => p);
var allDrillParams = await allDrillParamsQuery
.AsNoTracking()
.ToListAsync(token)
.ConfigureAwait(false);
var compositeWellDrillParamsQuery = db.WellComposites
.Where(c => c.IdWell == idWell)
.Join(db.DrillParams,
c => new { IdWell = c.IdWellSrc, IdSection = c.IdWellSectionType },
p => new { IdWell = p.IdWell, IdSection = p.IdWellSectionType },
(c, p) => p);
var compositeWellDrillParams = await compositeWellDrillParamsQuery
.AsNoTracking()
.ToListAsync(token)
.ConfigureAwait(false);
var result = compositeWellDrillParams.Select(x => Convert(x, allDrillParams));
return result;
}
public async Task<int> InsertAsync(int idWell, DrillParamsDto dto,
CancellationToken token = default)
{
dto.IdWell = idWell;
var result = await base.InsertAsync(dto, token).ConfigureAwait(false);
return result;
}
public async Task<int> InsertRangeAsync(int idWell, IEnumerable<DrillParamsDto> dtos,
CancellationToken token = default)
{
foreach (var dto in dtos)
dto.IdWell = idWell;
var result = await base.InsertRangeAsync(dtos, token).ConfigureAwait(false);
return result;
}
public async Task<int> SaveAsync(int idWell, IEnumerable<DrillParamsDto> dtos,
CancellationToken token = default)
{
db.DrillParams.RemoveRange(db.DrillParams.Where(d => d.IdWell == idWell));
foreach (var dto in dtos)
dto.IdWell = idWell;
var result = await base.InsertRangeAsync(dtos, token).ConfigureAwait(false);
return result;
}
public async Task<int> UpdateAsync(int idWell, int dtoId, DrillParamsDto dto,
CancellationToken token = default)
{
dto.IdWell = idWell;
var result = await base.UpdateAsync(dto, token).ConfigureAwait(false);
return result;
}
private static DrillParamsDto Convert(DrillParams entity, IEnumerable<DrillParams> drillParams)
{
return new DrillParamsDto
{
Id = entity.Id,
IdWellSectionType = entity.IdWellSectionType,
AxialLoad = MakeMinMaxExtended(entity.AxialLoadAvg, entity.AxialLoadMax, entity.AxialLoadMin, drillParams.Select(x => (x.AxialLoadMin, x.AxialLoadMax))),
Depth = new MinMaxDto<double> {
Min = entity.DepthEnd,
Max = entity.DepthStart
},
Flow = MakeMinMaxExtended(entity.FlowAvg, entity.FlowMax, entity.FlowMin, drillParams.Select(x => (x.FlowMin, x.FlowMax))),
IdWell = entity.IdWell,
Pressure = MakeMinMaxExtended(entity.PressureAvg, entity.PressureMax, entity.PressureMin, drillParams.Select(x => (x.PressureMin, x.PressureMax))),
RotorSpeed = MakeMinMaxExtended(entity.RotorSpeedAvg, entity.RotorSpeedMax, entity.RotorSpeedMin, drillParams.Select(x => (x.RotorSpeedMin, x.RotorSpeedMax))),
RotorTorque = MakeMinMaxExtended(entity.RotorTorqueAvg, entity.RotorTorqueMax, entity.RotorTorqueMin, drillParams.Select(x => (x.RotorTorqueMin, x.RotorTorqueMax)))
};
}
private static MinMaxExtendedViewDto MakeMinMaxExtended(double avg, double max, double min, IEnumerable<(double min, double max)>? allDrillParams = null)
=> new MinMaxExtendedViewDto {
Avg = avg,
Max = max,
Min = min,
IsMax = (! allDrillParams?.Any (mx => mx.max > max)) ?? false,
IsMin = (! allDrillParams?.Any (mn => mn.min < min)) ?? false
};
}
#nullable disable
}

View File

@ -10,7 +10,7 @@ namespace AsbCloudInfrastructure.Validators
// services.AddTransient<IValidator<ClusterDto>, ClusterDtoValidator>();
// services.AddTransient<IValidator<CompanyDto>, CompanyDtoValidator>();
// services.AddTransient<IValidator<DepositDto>, DepositDtoValidator>();
// services.AddTransient<IValidator<DrillFlowChartDto>, DrillFlowChartDtoValidator>();
// services.AddTransient<IValidator<DrillFlowChartDto>, ProcessMapValidator>();
// services.AddTransient<IValidator<EventDto>, EventDtoValidator>();
// services.AddTransient<IValidator<FileInfoDto>, FileInfoDtoValidator>();
// services.AddTransient<IValidator<FileMarkDto>, FileMarkDtoValidator>();

View File

@ -3,14 +3,12 @@ using FluentValidation;
namespace AsbCloudInfrastructure.Validators
{
public class DrillFlowChartDtoValidator : AbstractValidator<DrillFlowChartDto>
public class ProcessMapValidator : AbstractValidator<ProcessMapDto>
{
public DrillFlowChartDtoValidator()
public ProcessMapValidator()
{
RuleFor(x => x.IdWell).GreaterThan(0)
.WithMessage("Id скважины не может быть меньше 1");
RuleFor(x => x.IdWellOperationCategory).GreaterThan(0)
.WithMessage("Id категории операции не может быть меньше 1");
RuleFor(x => x.DepthStart).GreaterThan(-1)
.WithMessage("Глубина не может быть отрицательной");
RuleFor(x => x.DepthEnd).GreaterThan(-1)

View File

@ -61,12 +61,6 @@ public class ClusterServiceTest
new WellSectionType { Id = 1, Caption = "Test well section type 1" }
};
private readonly List<DrillParams> drillParams = new()
{
new DrillParams {Id = 1, IdWell = 1, IdWellSectionType = 1},
new DrillParams {Id = 2, IdWell = 2, IdWellSectionType = 1}
};
public ClusterServiceTest()
{
context = TestHelpter.MakeRealTestContext();
@ -78,7 +72,6 @@ public class ClusterServiceTest
context.Companies.RemoveRange(context.Companies);
context.RelationCompaniesWells.RemoveRange(context.RelationCompaniesWells);
context.WellSectionTypes.RemoveRange(context.WellSectionTypes);
context.DrillParams.RemoveRange(context.DrillParams);
if (context.ChangeTracker.HasChanges())
context.SaveChanges();
context.Deposits.AddRange(deposits);
@ -88,7 +81,6 @@ public class ClusterServiceTest
context.Companies.AddRange(companies);
context.RelationCompaniesWells.AddRange(relations);
context.WellSectionTypes.AddRange(wellSectionTypes);
context.DrillParams.AddRange(drillParams);
context.SaveChanges();
}

View File

@ -1,222 +0,0 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers
{
/// <summary>
/// Режимы бурения
/// </summary>
[Route("api/well/{idWell}/drillParams/")]
[ApiController]
public class DrillParamsController : ControllerBase
{
private readonly IDrillParamsService drillParamsService;
private readonly IWellService wellService;
public DrillParamsController(IDrillParamsService drillParamsService,
IWellService wellService)
{
this.drillParamsService = drillParamsService;
this.wellService = wellService;
}
/// <summary>
/// Возвращает автоматически рассчитанные значения для режимов бурения
/// </summary>
/// <param name="idWell"> id скважины </param>
/// <param name="startDepth"> Стартовая глубина </param>
/// <param name="endDepth"> Конечная глубина </param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns> Значения по умолчанию для режимов бурения </returns>
[HttpGet("autoParams")]
[Permission]
[ProducesResponseType(typeof(DrillParamsDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetDefaultAsync(int idWell,
double startDepth, double endDepth, CancellationToken token = default)
{
var idCompany = User.GetCompanyId();
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false))
return Forbid();
var drillParamsDo = await drillParamsService.GetDefaultDrillParamsAsync(idWell,
startDepth, endDepth, token);
return Ok(drillParamsDo);
}
/// <summary>
/// Возвращает все значения для режимов бурения на скважине
/// </summary>
/// <param name="idWell"> id скважины </param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns> Список параметров для режимов бурения на скважине </returns>
[HttpGet]
[Permission]
[ProducesResponseType(typeof(IEnumerable<DrillParamsDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAllAsync(int idWell,
CancellationToken token = default)
{
var idCompany = User.GetCompanyId();
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false))
return Forbid();
var dto = await drillParamsService.GetAllAsync(idWell, token);
return Ok(dto);
}
/// <summary>
/// Сохраняет значения для режимов бурения по секции на скважине
/// </summary>
/// <param name="idWell"> id скважины </param>
/// <param name="drillParamsDto"> Параметры режимов бурений для секции</param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns></returns>
[HttpPost]
[Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> InsertAsync(int idWell,
DrillParamsDto drillParamsDto, CancellationToken token = default)
{
var idCompany = User.GetCompanyId();
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false))
return Forbid();
var result = await drillParamsService.InsertAsync(idWell, drillParamsDto, token);
return Ok(result);
}
/// <summary>
/// Добавляет массив объектов режимов бурений
/// </summary>
/// <param name="idWell"> id скважины </param>
/// <param name="drillParams"> Массив объектов параметров режима бурений для секции</param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns></returns>
[HttpPost("range")]
[Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> InsertRangeAsync(int idWell,
IEnumerable<DrillParamsDto> drillParams, CancellationToken token = default)
{
var idCompany = User.GetCompanyId();
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false))
return Forbid();
var result = await drillParamsService.InsertRangeAsync(idWell, drillParams,
token);
return Ok(result);
}
/// <summary>
/// Удаляет старые режимы бурения по скважине и добавляет новые
/// </summary>
/// <param name="idWell">Id скважины для добавления</param>
/// <param name="drillParams">Новые режимы бурения </param>
/// <param name="token"></param>
/// <returns>кол-во затронутых изменениями записей</returns>
[HttpPost("save")]
[Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> SaveAsync(int idWell, IEnumerable<DrillParamsDto> drillParams, CancellationToken token = default)
{
var idCompany = User.GetCompanyId();
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false))
return Forbid();
var result = await drillParamsService.SaveAsync(idWell, drillParams,
token);
return Ok(result);
}
/// <summary>
/// Изменяет значения выбранного режима бурения
/// </summary>
/// <param name="idWell"> id скважины </param>
/// <param name="dtoId"> id dto для изменения </param>
/// <param name="drillParamsDto"> Параметры режимов бурений для секции</param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns></returns>
[HttpPut]
[Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> UpdateAsync(int idWell, int dtoId,
DrillParamsDto drillParamsDto, CancellationToken token = default)
{
var idCompany = User.GetCompanyId();
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false))
return Forbid();
var result = await drillParamsService.UpdateAsync(idWell, dtoId,
drillParamsDto, token);
return Ok(result);
}
/// <summary>
/// Удаляет объект значений выбранного режима бурения
/// </summary>
/// <param name="idWell"> id скважины </param>
/// <param name="drillParamsId"> Id объекта параметров режима бурений для секции</param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns></returns>
[HttpDelete]
[Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> DeleteAsync(int idWell,
int drillParamsId, CancellationToken token = default)
{
var idCompany = User.GetCompanyId();
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false))
return Forbid();
var result = await drillParamsService.DeleteAsync(drillParamsId,
token);
return Ok(result);
}
/// <summary>
/// Возвращает значения для режимов бурения на композитной скважине
/// </summary>
/// <param name="idWell"> id скважины </param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns> Список параметров для режимов бурения на композитной скважине </returns>
[HttpGet("composite")]
[Permission]
[ProducesResponseType(typeof(IEnumerable<DrillParamsDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetCompositeAllAsync(int idWell, CancellationToken token = default)
{
var idCompany = User.GetCompanyId();
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false))
return Forbid();
var dto = await drillParamsService.GetCompositeAllAsync(idWell, token);
return Ok(dto);
}
}
}

View File

@ -15,11 +15,11 @@ namespace AsbCloudWebApi.Controllers
[ApiController]
[Route("api/[controller]")]
[Authorize]
public class DrillFlowChartController : CrudWellRelatedController<DrillFlowChartDto, IDrillFlowChartRepository>
public class ProcessMapController : CrudWellRelatedController<ProcessMapDto, IDrillFlowChartRepository>
{
private readonly ITelemetryService telemetryService;
public DrillFlowChartController(IWellService wellService, IDrillFlowChartRepository service,
public ProcessMapController(IWellService wellService, IDrillFlowChartRepository service,
ITelemetryService telemetryService)
: base(wellService, service)
{
@ -36,7 +36,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet]
[Route("/api/telemetry/{uid}/drillFlowChart")]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable<DrillFlowChartDto>), (int)System.Net.HttpStatusCode.OK)]
[ProducesResponseType(typeof(IEnumerable<ProcessMapDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetByTelemetryAsync(string uid, DateTime updateFrom = default, CancellationToken token = default)
{
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
@ -49,5 +49,17 @@ namespace AsbCloudWebApi.Controllers
return Ok(dto);
}
/// <summary>
/// Выгрузка расширенной РТК
/// </summary>
/// <param name="wellId"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
[HttpGet]
[Route("{wellId}")]
public IActionResult GetExtendedRTCAsync(int wellId)
{
throw new NotImplementedException();
}
}
}