Merge pull request 'Разделить существующую таблицу БД РТК/План/Бурение на РТК/План/Слайд' (#284) from feature/#34164218-process-map-plan-drilling-rotor-and-slide into dev

Reviewed-on: https://test.digitaldrilling.ru:8443/DDrilling/AsbCloudServer/pulls/284
Reviewed-by: Никита Фролов <ng.frolov@digitaldrilling.ru>
This commit is contained in:
Никита Фролов 2024-06-24 09:17:47 +05:00
commit 07be69a368
45 changed files with 12158 additions and 1258 deletions

View File

@ -1,103 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data.ProcessMaps;
/// <summary>
/// РТК план бурение скважины
/// </summary>
public class ProcessMapPlanDrillingDto : ProcessMapPlanBaseDto
{
/// <summary>
/// Id режима 1-ротор, 2 - слайд
/// </summary>
[Range(1, 2, ErrorMessage = "Id режима должен быть либо 1-ротор либо 2-слайд")]
public int IdMode { get; set; }
/// <summary>
/// Название режима бурения
/// </summary>
public string? Mode { get; set; }
/// <summary>
/// Осевая нагрузка, т план
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Осевая нагрузка, т должна быть в пределах от 0 до 99999.9")]
public double AxialLoadPlan { get; set; }
/// <summary>
/// Осевая нагрузка, т ограничение
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Осевая нагрузка, т должна быть в пределах от 0 до 99999.9")]
public double AxialLoadLimitMax { get; set; }
/// <summary>
/// Перепад давления, атм план
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Перепад давления, атм должна быть в пределах от 0 до 99999.9")]
public double DeltaPressurePlan { get; set; }
/// <summary>
/// Перепад давления, атм ограничение
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Перепад давления, атм должна быть в пределах от 0 до 99999.9")]
public double DeltaPressureLimitMax { get; set; }
/// <summary>
/// Момент на ВСП, кН*м план
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Момент на ВСП, кН*м должна быть в пределах от 0 до 99999.9")]
public double TopDriveTorquePlan { get; set; }
/// <summary>
/// Момент на ВСП, кН*м ограничение
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Момент на ВСП, кН*м должна быть в пределах от 0 до 99999.9")]
public double TopDriveTorqueLimitMax { get; set; }
/// <summary>
/// Обороты на ВСП, об/мин план
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Обороты на ВСП, об/мин должна быть в пределах от 0 до 99999.9")]
public double TopDriveSpeedPlan { get; set; }
/// <summary>
/// Обороты на ВСП, об/мин ограничение
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Обороты на ВСП, об/мин должна быть в пределах от 0 до 99999.9")]
public double TopDriveSpeedLimitMax { get; set; }
/// <summary>
/// Расход, л/с план
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Расход, л/с должна быть в пределах от 0 до 99999.9")]
public double FlowPlan { get; set; }
/// <summary>
/// Расход, л/с ограничение
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Расход, л/с должна быть в пределах от 0 до 99999.9")]
public double FlowLimitMax { get; set; }
/// <summary>
/// Плановая механическая скорость, м/ч
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Плановая механическая скорость, м/ч должно быть в пределах от 0 до 99999.9")]
public double RopPlan { get; set; }
/// <summary>
/// Плановый процент использования АКБ
/// </summary>
[Range(0, 100, ErrorMessage = "Процент использования АКБ должен быть в пределах от 0 до 100")]
public double UsageSaub { get; set; }
/// <summary>
/// Плановый процент использования spin master
/// </summary>
[Range(0, 100, ErrorMessage = "Процент использования spin master должен быть в пределах от 0 до 100")]
public double UsageSpin { get; set; }
/// <summary>
/// Комментарий
/// </summary>
public string Comment { get; set; } = string.Empty;
}

View File

@ -0,0 +1,88 @@
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data.ProcessMaps;
/// <summary>
/// РТК план бурение скважины в роторе
/// </summary>
public class ProcessMapPlanRotorDto : ProcessMapPlanBaseDto
{
/// <summary>
/// Максимально допустимая скорость, м/ч
/// </summary>
[Range(0, 800.0, ErrorMessage = "Максимально допустимая скорость, м/ч., должно быть в пределах от 0 до 800.0")]
public double RopLimitMax { get; set; }
/// <summary>
/// Максимально допустимое давление, атм
/// </summary>
[Range(0.0, 400.0, ErrorMessage = "Максимально допустимое давление, атм., должно быть в пределах от 0 до 400.0")]
public double PressureLimitMax { get; set; }
/// <summary>
/// Перепад давления, атм. Уставка
/// </summary>
[Range(0.0, 60.0, ErrorMessage = "Перепад давления, атм., уставка, должно быть в пределах от 0 до 60.0")]
public double DifferentialPressure { get; set; }
/// <summary>
/// Перепад давления, атм. Ограничение
/// </summary>
[Range(0.0, 60.0, ErrorMessage = "Перепад давления, атм., ограничение, должно быть в пределах от 0 до 60.0")]
public double DifferentialPressureLimitMax { get; set; }
/// <summary>
/// Нагрузка, т. Уставка
/// </summary>
[Range(0.0, 99.0, ErrorMessage = "Нагрузка, т., уставка, должно быть в пределах от 0 до 99.0")]
public double WeightOnBit { get; set; }
/// <summary>
/// Нагрузка, т. Ограничение
/// </summary>
[Range(0.0, 99.0, ErrorMessage = "Нагрузка, т., ограничение, должно быть в пределах от 0 до 99.0")]
public double WeightOnBitLimitMax { get; set; }
/// <summary>
/// Момент на ВСП, кН*м. Уставка
/// </summary>
[Range(0.0, 35.0, ErrorMessage = "Момент на ВСП, кН*м., уставка, должно быть в пределах от 0 до 35.0")]
public double TopDriveTorque { get; set; }
/// <summary>
/// Момент на ВСП, кН*м. Ограничение
/// </summary>
[Range(0.0, 35.0, ErrorMessage = "Момент на ВСП, кН*м., ограничение, должно быть в пределах от 0 до 35.0")]
public double TopDriveTorqueLimit { get; set; }
/// <summary>
/// Обороты на ВСП, об/мин. Уставка
/// </summary>
[Range(0.0, 270.0, ErrorMessage = "Обороты на ВСП, об/мин., уставка, должно быть в пределах от 0 до 270.0")]
public double RevolutionsPerMinute { get; set; }
/// <summary>
/// Обороты на ВСП, об/мин. Ограничение
/// </summary>
[Range(0.0, 270.0, ErrorMessage = "Обороты на ВСП, об/мин., ограничение, должно быть в пределах от 0 до 270.0")]
public double RevolutionsPerMinuteLimitMax { get; set; }
/// <summary>
/// Расход л/с. Уставка
/// </summary>
[Range(0.0, 100.0, ErrorMessage = "Расход л/с., уставка, должно быть в пределах от 0 до 100.0")]
public double FlowRate { get; set; }
/// <summary>
/// Расход л/с. Ограничение
/// </summary>
[Range(0.0, 100.0, ErrorMessage = "Расход л/с., ограничение, должно быть в пределах от 0 до 100.0")]
public double FlowRateLimitMax { get; set; }
/// <summary>
/// Примечание
/// </summary>
[StringLength(1024, ErrorMessage = "Примечание, не должно превышать 1024 символов")]
public string Note { get; set; } = string.Empty;
}

View File

@ -0,0 +1,75 @@
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data.ProcessMaps;
/// <summary>
/// РТК план бурение скважины в слайде
/// </summary>
public class ProcessMapPlanSlideDto : ProcessMapPlanBaseDto
{
/// <summary>
/// Максимально допустимая скорость, м/ч
/// </summary>
[Range(0, 800.0, ErrorMessage = "Максимально допустимая скорость, м/ч., должно быть в пределах от 0 до 800.0")]
public double RopLimitMax { get; set; }
/// <summary>
/// Максимально допустимое давление, атм
/// </summary>
[Range(0, 400.0, ErrorMessage = "Максимально допустимое давление, атм., должно быть в пределах от 0 до 400.0")]
public double PressureLimitMax { get; set; }
/// <summary>
/// Перепад давления, атм. Уставка
/// </summary>
[Range(0, 60.0, ErrorMessage = "Перепад давления, атм. уставка, должно быть в пределах от 0 до 60.0")]
public double DifferentialPressure { get; set; }
/// <summary>
/// Перепад давления, атм. Ограничение
/// </summary>
[Range(0, 60.0, ErrorMessage = "Перепад давления, атм., ограничение, должно быть в пределах от 0 до 60.0")]
public double DifferentialPressureLimitMax { get; set; }
/// <summary>
/// Нагрузка, т. Уставка
/// </summary>
[Range(0, 50.0, ErrorMessage = " Нагрузка, т., уставка, должно быть в пределах от 0 до 50.0")]
public double WeightOnBit { get; set; }
/// <summary>
/// Нагрузка, т. Ограничение
/// </summary>
[Range(0, 50.0, ErrorMessage = "Нагрузка, т., ограничение, должно быть в пределах от 0 до 50.0")]
public double WeightOnBitLimitMax { get; set; }
/// <summary>
/// Расход л/с. Уставка
/// </summary>
[Range(0, 100.0, ErrorMessage = "Расход, л/с., уставка, должно быть в пределах от 0 до 50.0")]
public double FlowRate { get; set; }
/// <summary>
/// Расход л/с. Ограничение
/// </summary>
[Range(0, 100.0, ErrorMessage = "Расход, л/с., ограничение, должно быть в пределах от 0 до 100.0")]
public double FlowRateLimitMax { get; set; }
/// <summary>
/// Расчётная пружина, градус
/// </summary>
[Range(0, 9999.9, ErrorMessage = "Расчётная пружина, градус, должно быть в пределах от 0 до 9999.9")]
public double Spring { get; set; }
/// <summary>
/// Складывание инструмента, м
/// </summary>
[Range(0, 9999.9, ErrorMessage = "Складывание инструмента, м, должно быть в пределах от 0 до 9999.9")]
public double ToolBuckling { get; set; }
/// <summary>
/// Примечание
/// </summary>
[StringLength(1024, ErrorMessage = "Примечание, не должно превышать 1024 символов")]
public string Note { get; set; } = string.Empty;
}

View File

@ -34,6 +34,6 @@ namespace AsbCloudApp.Repositories
/// <param name="idWell"></param> /// <param name="idWell"></param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
Task<IEnumerable<ProcessMapPlanDrillingDto>> GetCompositeProcessMap(int idWell, CancellationToken token); Task<IEnumerable<ProcessMapPlanBaseDto>> GetCompositeProcessMap(int idWell, CancellationToken token);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,324 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace AsbCloudDb.Migrations
{
/// <inheritdoc />
public partial class Add_ProcessMapPlanRotor_And_Slide : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_process_map_plan_rotor",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
rop_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимально допустимая скорость, м/ч"),
pressure_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимально допустимое давление, атм"),
differential_pressure = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, атм. Уставка"),
differential_pressure_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, атм. Ограничение"),
weight_on_bit = table.Column<double>(type: "double precision", nullable: false, comment: "Нагрузка, т. Уставка"),
weight_on_bit_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Нагрузка, т. Ограничение"),
top_drive_torque = table.Column<double>(type: "double precision", nullable: false, comment: "Момент на ВСП, кН*м. Уставка"),
top_drive_torque_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Момент на ВСП, кН*м. Ограничение"),
revolution_per_minute = table.Column<double>(type: "double precision", nullable: false, comment: "Обороты на ВСП, об/мин. Уставка"),
revolutions_per_minute_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Обороты на ВСП, об/мин. Ограничение"),
flow_rate = table.Column<double>(type: "double precision", nullable: false, comment: "Расход л/с. Уставка"),
flow_rate_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Расход л/с. Ограничение"),
note = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false, comment: "Примечание"),
id_author = table.Column<int>(type: "integer", nullable: false, comment: "Автор"),
id_editor = table.Column<int>(type: "integer", nullable: true, comment: "Редактор"),
creation = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "дата создания"),
obsolete = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true, comment: "дата устаревания"),
id_state = table.Column<int>(type: "integer", nullable: false, comment: "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная"),
id_previous = table.Column<int>(type: "integer", nullable: true, comment: "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная"),
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
id_wellsection_type = table.Column<int>(type: "integer", 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: "Глубина по стволу до, м")
},
constraints: table =>
{
table.PrimaryKey("PK_t_process_map_plan_rotor", x => x.id);
table.ForeignKey(
name: "FK_t_process_map_plan_rotor_t_process_map_plan_rotor_id_previo~",
column: x => x.id_previous,
principalTable: "t_process_map_plan_rotor",
principalColumn: "id");
table.ForeignKey(
name: "FK_t_process_map_plan_rotor_t_user_id_author",
column: x => x.id_author,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_t_process_map_plan_rotor_t_user_id_editor",
column: x => x.id_editor,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_t_process_map_plan_rotor_t_well_id_well",
column: x => x.id_well,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_process_map_plan_rotor_t_well_section_type_id_wellsection~",
column: x => x.id_wellsection_type,
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "РТК план бурение ротор");
migrationBuilder.CreateTable(
name: "t_process_map_plan_slide",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
rop_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимально допустимая скорость, м/ч"),
pressure_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимально допустимое давление, атм"),
differential_pressure = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, атм. Уставка"),
differential_pressure_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, атм. Ограничение"),
weight_on_bit = table.Column<double>(type: "double precision", nullable: false, comment: "Нагрузка, т. Уставка"),
weight_on_bit_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Нагрузка, т. Ограничение"),
flow_rate = table.Column<double>(type: "double precision", nullable: false, comment: "Расход л/с. Уставка"),
flow_rate_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Расход л/с. Ограничение"),
spring = table.Column<double>(type: "double precision", nullable: false, comment: "Расчётная пружина, градус"),
tool_buckling = table.Column<double>(type: "double precision", nullable: false, comment: "Складывание инструмента, м"),
note = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false, comment: "Примечание"),
id_author = table.Column<int>(type: "integer", nullable: false, comment: "Автор"),
id_editor = table.Column<int>(type: "integer", nullable: true, comment: "Редактор"),
creation = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "дата создания"),
obsolete = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true, comment: "дата устаревания"),
id_state = table.Column<int>(type: "integer", nullable: false, comment: "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная"),
id_previous = table.Column<int>(type: "integer", nullable: true, comment: "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная"),
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
id_wellsection_type = table.Column<int>(type: "integer", 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: "Глубина по стволу до, м")
},
constraints: table =>
{
table.PrimaryKey("PK_t_process_map_plan_slide", x => x.id);
table.ForeignKey(
name: "FK_t_process_map_plan_slide_t_process_map_plan_slide_id_previo~",
column: x => x.id_previous,
principalTable: "t_process_map_plan_slide",
principalColumn: "id");
table.ForeignKey(
name: "FK_t_process_map_plan_slide_t_user_id_author",
column: x => x.id_author,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_t_process_map_plan_slide_t_user_id_editor",
column: x => x.id_editor,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_t_process_map_plan_slide_t_well_id_well",
column: x => x.id_well,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_process_map_plan_slide_t_well_section_type_id_wellsection~",
column: x => x.id_wellsection_type,
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "РТК план бурение слайд");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_rotor_id_author",
table: "t_process_map_plan_rotor",
column: "id_author");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_rotor_id_editor",
table: "t_process_map_plan_rotor",
column: "id_editor");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_rotor_id_previous",
table: "t_process_map_plan_rotor",
column: "id_previous");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_rotor_id_well",
table: "t_process_map_plan_rotor",
column: "id_well");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_rotor_id_wellsection_type",
table: "t_process_map_plan_rotor",
column: "id_wellsection_type");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_slide_id_author",
table: "t_process_map_plan_slide",
column: "id_author");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_slide_id_editor",
table: "t_process_map_plan_slide",
column: "id_editor");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_slide_id_previous",
table: "t_process_map_plan_slide",
column: "id_previous");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_slide_id_well",
table: "t_process_map_plan_slide",
column: "id_well");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_slide_id_wellsection_type",
table: "t_process_map_plan_slide",
column: "id_wellsection_type");
migrationBuilder.Sql(@"INSERT INTO public.t_process_map_plan_rotor
(id, id_wellsection_type, rop_limit_max, depth_start, depth_end, differential_pressure,
differential_pressure_limit_max, weight_on_bit, weight_on_bit_limit_max,
top_drive_torque, top_drive_torque_limit_max, revolution_per_minute,
revolutions_per_minute_limit_max, flow_rate, flow_rate_limit_max, note,
pressure_limit_max, id_author, creation, id_state, id_well, id_editor)
SELECT id, id_wellsection_type, rop_plan, depth_start, depth_end, delta_pressure_plan,
delta_pressure_limit_max, axial_load_plan, axial_load_limit_max,
top_drive_torque_plan, top_drive_torque_limit_max, top_drive_speed_plan,
top_drive_speed_limit_max, flow_plan, flow_limit_max, comment, 0, id_author, creation, id_state, id_well,
id_editor
FROM public.t_process_map_plan_drilling WHERE id_mode = 1 AND obsolete is null");
migrationBuilder.Sql(@"INSERT INTO public.t_process_map_plan_slide
(id, id_wellsection_type, rop_limit_max, depth_start, depth_end, differential_pressure,
differential_pressure_limit_max, weight_on_bit, weight_on_bit_limit_max,
flow_rate, flow_rate_limit_max, note, pressure_limit_max, id_author, creation,
id_state, id_well, spring, tool_buckling, id_editor)
SELECT id, id_wellsection_type, rop_plan, depth_start, depth_end, delta_pressure_plan,
delta_pressure_limit_max, axial_load_plan, axial_load_limit_max,
flow_plan, flow_limit_max, comment, 0, id_author, creation, id_state, id_well, 0, 0, id_editor
FROM public.t_process_map_plan_drilling
WHERE id_mode = 2 AND obsolete is null");
migrationBuilder.DropTable(name: "t_process_map_plan_drilling");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_process_map_plan_rotor");
migrationBuilder.DropTable(
name: "t_process_map_plan_slide");
migrationBuilder.CreateTable(
name: "t_process_map_plan_drilling",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
id_author = table.Column<int>(type: "integer", nullable: false, comment: "Автор"),
id_editor = table.Column<int>(type: "integer", nullable: true, comment: "Редактор"),
id_previous = table.Column<int>(type: "integer", nullable: true, comment: "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная"),
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
id_wellsection_type = table.Column<int>(type: "integer", nullable: false, comment: "Тип секции"),
axial_load_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Осевая нагрузка, т, допустимый максимум"),
axial_load_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Осевая нагрузка, т, план"),
comment = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false, comment: "Комментарий"),
creation = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "дата создания"),
delta_pressure_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, атм, допустимый максимум"),
delta_pressure_plan = 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_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Расход, л/с, допустимый максимум"),
flow_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Расход, л/с, план"),
id_mode = table.Column<int>(type: "integer", nullable: false, comment: "Id режима (1- ротор, 2 слайд)"),
id_state = table.Column<int>(type: "integer", nullable: false, comment: "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная"),
obsolete = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true, comment: "дата устаревания"),
rop_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Плановая механическая скорость, м/ч"),
top_drive_speed_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Обороты на ВСП, допустимый максимум"),
top_drive_speed_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Обороты на ВСП, план"),
top_drive_torque_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Момент на ВСП, допустимый максимум"),
top_drive_torque_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Момент на ВСП, план"),
usage_saub = table.Column<double>(type: "double precision", nullable: false, comment: "Плановый процент использования АКБ"),
usage_spin = table.Column<double>(type: "double precision", nullable: false, comment: "Плановый процент использования spin master")
},
constraints: table =>
{
table.PrimaryKey("PK_t_process_map_plan_drilling", x => x.id);
table.ForeignKey(
name: "FK_t_process_map_plan_drilling_t_process_map_plan_drilling_id_~",
column: x => x.id_previous,
principalTable: "t_process_map_plan_drilling",
principalColumn: "id");
table.ForeignKey(
name: "FK_t_process_map_plan_drilling_t_user_id_author",
column: x => x.id_author,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_t_process_map_plan_drilling_t_user_id_editor",
column: x => x.id_editor,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_t_process_map_plan_drilling_t_well_id_well",
column: x => x.id_well,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_process_map_plan_drilling_t_well_section_type_id_wellsect~",
column: x => x.id_wellsection_type,
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "РТК план бурение");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_drilling_id_author",
table: "t_process_map_plan_drilling",
column: "id_author");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_drilling_id_editor",
table: "t_process_map_plan_drilling",
column: "id_editor");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_drilling_id_previous",
table: "t_process_map_plan_drilling",
column: "id_previous");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_drilling_id_well",
table: "t_process_map_plan_drilling",
column: "id_well");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_drilling_id_wellsection_type",
table: "t_process_map_plan_drilling",
column: "id_wellsection_type");
}
}
}

View File

@ -2629,161 +2629,6 @@ namespace AsbCloudDb.Migrations
}); });
}); });
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanDrilling", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasComment("Идентификатор");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("AxialLoadLimitMax")
.HasColumnType("double precision")
.HasColumnName("axial_load_limit_max")
.HasComment("Осевая нагрузка, т, допустимый максимум");
b.Property<double>("AxialLoadPlan")
.HasColumnType("double precision")
.HasColumnName("axial_load_plan")
.HasComment("Осевая нагрузка, т, план");
b.Property<string>("Comment")
.IsRequired()
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasColumnName("comment")
.HasComment("Комментарий");
b.Property<DateTimeOffset>("Creation")
.HasColumnType("timestamp with time zone")
.HasColumnName("creation")
.HasComment("дата создания");
b.Property<double>("DeltaPressureLimitMax")
.HasColumnType("double precision")
.HasColumnName("delta_pressure_limit_max")
.HasComment("Перепад давления, атм, допустимый максимум");
b.Property<double>("DeltaPressurePlan")
.HasColumnType("double precision")
.HasColumnName("delta_pressure_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>("FlowLimitMax")
.HasColumnType("double precision")
.HasColumnName("flow_limit_max")
.HasComment("Расход, л/с, допустимый максимум");
b.Property<double>("FlowPlan")
.HasColumnType("double precision")
.HasColumnName("flow_plan")
.HasComment("Расход, л/с, план");
b.Property<int>("IdAuthor")
.HasColumnType("integer")
.HasColumnName("id_author")
.HasComment("Автор");
b.Property<int?>("IdEditor")
.HasColumnType("integer")
.HasColumnName("id_editor")
.HasComment("Редактор");
b.Property<int>("IdMode")
.HasColumnType("integer")
.HasColumnName("id_mode")
.HasComment("Id режима (1- ротор, 2 слайд)");
b.Property<int?>("IdPrevious")
.HasColumnType("integer")
.HasColumnName("id_previous")
.HasComment("ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная");
b.Property<int>("IdState")
.HasColumnType("integer")
.HasColumnName("id_state")
.HasComment("ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная");
b.Property<int>("IdWell")
.HasColumnType("integer")
.HasColumnName("id_well")
.HasComment("Id скважины");
b.Property<int>("IdWellSectionType")
.HasColumnType("integer")
.HasColumnName("id_wellsection_type")
.HasComment("Тип секции");
b.Property<DateTimeOffset?>("Obsolete")
.HasColumnType("timestamp with time zone")
.HasColumnName("obsolete")
.HasComment("дата устаревания");
b.Property<double>("RopPlan")
.HasColumnType("double precision")
.HasColumnName("rop_plan")
.HasComment("Плановая механическая скорость, м/ч");
b.Property<double>("TopDriveSpeedLimitMax")
.HasColumnType("double precision")
.HasColumnName("top_drive_speed_limit_max")
.HasComment("Обороты на ВСП, допустимый максимум");
b.Property<double>("TopDriveSpeedPlan")
.HasColumnType("double precision")
.HasColumnName("top_drive_speed_plan")
.HasComment("Обороты на ВСП, план");
b.Property<double>("TopDriveTorqueLimitMax")
.HasColumnType("double precision")
.HasColumnName("top_drive_torque_limit_max")
.HasComment("Момент на ВСП, допустимый максимум");
b.Property<double>("TopDriveTorquePlan")
.HasColumnType("double precision")
.HasColumnName("top_drive_torque_plan")
.HasComment("Момент на ВСП, план");
b.Property<double>("UsageSaub")
.HasColumnType("double precision")
.HasColumnName("usage_saub")
.HasComment("Плановый процент использования АКБ");
b.Property<double>("UsageSpin")
.HasColumnType("double precision")
.HasColumnName("usage_spin")
.HasComment("Плановый процент использования spin master");
b.HasKey("Id");
b.HasIndex("IdAuthor");
b.HasIndex("IdEditor");
b.HasIndex("IdPrevious");
b.HasIndex("IdWell");
b.HasIndex("IdWellSectionType");
b.ToTable("t_process_map_plan_drilling", t =>
{
t.HasComment("РТК план бурение");
});
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanReam", b => modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanReam", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -2905,6 +2750,286 @@ namespace AsbCloudDb.Migrations
}); });
}); });
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanRotor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasComment("Идентификатор");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTimeOffset>("Creation")
.HasColumnType("timestamp with time zone")
.HasColumnName("creation")
.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>("DifferentialPressure")
.HasColumnType("double precision")
.HasColumnName("differential_pressure")
.HasComment("Перепад давления, атм. Уставка");
b.Property<double>("DifferentialPressureLimitMax")
.HasColumnType("double precision")
.HasColumnName("differential_pressure_limit_max")
.HasComment("Перепад давления, атм. Ограничение");
b.Property<double>("FlowRate")
.HasColumnType("double precision")
.HasColumnName("flow_rate")
.HasComment("Расход л/с. Уставка");
b.Property<double>("FlowRateLimitMax")
.HasColumnType("double precision")
.HasColumnName("flow_rate_limit_max")
.HasComment("Расход л/с. Ограничение");
b.Property<int>("IdAuthor")
.HasColumnType("integer")
.HasColumnName("id_author")
.HasComment("Автор");
b.Property<int?>("IdEditor")
.HasColumnType("integer")
.HasColumnName("id_editor")
.HasComment("Редактор");
b.Property<int?>("IdPrevious")
.HasColumnType("integer")
.HasColumnName("id_previous")
.HasComment("ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная");
b.Property<int>("IdState")
.HasColumnType("integer")
.HasColumnName("id_state")
.HasComment("ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная");
b.Property<int>("IdWell")
.HasColumnType("integer")
.HasColumnName("id_well")
.HasComment("Id скважины");
b.Property<int>("IdWellSectionType")
.HasColumnType("integer")
.HasColumnName("id_wellsection_type")
.HasComment("Тип секции");
b.Property<string>("Note")
.IsRequired()
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasColumnName("note")
.HasComment("Примечание");
b.Property<DateTimeOffset?>("Obsolete")
.HasColumnType("timestamp with time zone")
.HasColumnName("obsolete")
.HasComment("дата устаревания");
b.Property<double>("PressureLimitMax")
.HasColumnType("double precision")
.HasColumnName("pressure_limit_max")
.HasComment("Максимально допустимое давление, атм");
b.Property<double>("RevolutionsPerMinute")
.HasColumnType("double precision")
.HasColumnName("revolution_per_minute")
.HasComment("Обороты на ВСП, об/мин. Уставка");
b.Property<double>("RevolutionsPerMinuteLimitMax")
.HasColumnType("double precision")
.HasColumnName("revolutions_per_minute_limit_max")
.HasComment("Обороты на ВСП, об/мин. Ограничение");
b.Property<double>("RopLimitMax")
.HasColumnType("double precision")
.HasColumnName("rop_limit_max")
.HasComment("Максимально допустимая скорость, м/ч");
b.Property<double>("TopDriveTorque")
.HasColumnType("double precision")
.HasColumnName("top_drive_torque")
.HasComment("Момент на ВСП, кН*м. Уставка");
b.Property<double>("TopDriveTorqueLimit")
.HasColumnType("double precision")
.HasColumnName("top_drive_torque_limit_max")
.HasComment("Момент на ВСП, кН*м. Ограничение");
b.Property<double>("WeightOnBit")
.HasColumnType("double precision")
.HasColumnName("weight_on_bit")
.HasComment("Нагрузка, т. Уставка");
b.Property<double>("WeightOnBitLimitMax")
.HasColumnType("double precision")
.HasColumnName("weight_on_bit_limit_max")
.HasComment("Нагрузка, т. Ограничение");
b.HasKey("Id");
b.HasIndex("IdAuthor");
b.HasIndex("IdEditor");
b.HasIndex("IdPrevious");
b.HasIndex("IdWell");
b.HasIndex("IdWellSectionType");
b.ToTable("t_process_map_plan_rotor", t =>
{
t.HasComment("РТК план бурение ротор");
});
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanSlide", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasComment("Идентификатор");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTimeOffset>("Creation")
.HasColumnType("timestamp with time zone")
.HasColumnName("creation")
.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>("DifferentialPressure")
.HasColumnType("double precision")
.HasColumnName("differential_pressure")
.HasComment("Перепад давления, атм. Уставка");
b.Property<double>("DifferentialPressureLimitMax")
.HasColumnType("double precision")
.HasColumnName("differential_pressure_limit_max")
.HasComment("Перепад давления, атм. Ограничение");
b.Property<double>("FlowRate")
.HasColumnType("double precision")
.HasColumnName("flow_rate")
.HasComment("Расход л/с. Уставка");
b.Property<double>("FlowRateLimitMax")
.HasColumnType("double precision")
.HasColumnName("flow_rate_limit_max")
.HasComment("Расход л/с. Ограничение");
b.Property<int>("IdAuthor")
.HasColumnType("integer")
.HasColumnName("id_author")
.HasComment("Автор");
b.Property<int?>("IdEditor")
.HasColumnType("integer")
.HasColumnName("id_editor")
.HasComment("Редактор");
b.Property<int?>("IdPrevious")
.HasColumnType("integer")
.HasColumnName("id_previous")
.HasComment("ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная");
b.Property<int>("IdState")
.HasColumnType("integer")
.HasColumnName("id_state")
.HasComment("ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная");
b.Property<int>("IdWell")
.HasColumnType("integer")
.HasColumnName("id_well")
.HasComment("Id скважины");
b.Property<int>("IdWellSectionType")
.HasColumnType("integer")
.HasColumnName("id_wellsection_type")
.HasComment("Тип секции");
b.Property<string>("Note")
.IsRequired()
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasColumnName("note")
.HasComment("Примечание");
b.Property<DateTimeOffset?>("Obsolete")
.HasColumnType("timestamp with time zone")
.HasColumnName("obsolete")
.HasComment("дата устаревания");
b.Property<double>("PressureLimitMax")
.HasColumnType("double precision")
.HasColumnName("pressure_limit_max")
.HasComment("Максимально допустимое давление, атм");
b.Property<double>("RopLimitMax")
.HasColumnType("double precision")
.HasColumnName("rop_limit_max")
.HasComment("Максимально допустимая скорость, м/ч");
b.Property<double>("Spring")
.HasColumnType("double precision")
.HasColumnName("spring")
.HasComment("Расчётная пружина, градус");
b.Property<double>("ToolBuckling")
.HasColumnType("double precision")
.HasColumnName("tool_buckling")
.HasComment("Складывание инструмента, м");
b.Property<double>("WeightOnBit")
.HasColumnType("double precision")
.HasColumnName("weight_on_bit")
.HasComment("Нагрузка, т. Уставка");
b.Property<double>("WeightOnBitLimitMax")
.HasColumnType("double precision")
.HasColumnName("weight_on_bit_limit_max")
.HasComment("Нагрузка, т. Ограничение");
b.HasKey("Id");
b.HasIndex("IdAuthor");
b.HasIndex("IdEditor");
b.HasIndex("IdPrevious");
b.HasIndex("IdWell");
b.HasIndex("IdWellSectionType");
b.ToTable("t_process_map_plan_slide", t =>
{
t.HasComment("РТК план бурение слайд");
});
});
modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b => modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b =>
{ {
b.Property<int>("IdCompany") b.Property<int>("IdCompany")
@ -8864,46 +8989,6 @@ namespace AsbCloudDb.Migrations
b.Navigation("Well"); b.Navigation("Well");
}); });
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanDrilling", b =>
{
b.HasOne("AsbCloudDb.Model.User", "Author")
.WithMany()
.HasForeignKey("IdAuthor")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("AsbCloudDb.Model.User", "Editor")
.WithMany()
.HasForeignKey("IdEditor")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanDrilling", "Previous")
.WithMany()
.HasForeignKey("IdPrevious");
b.HasOne("AsbCloudDb.Model.Well", "Well")
.WithMany()
.HasForeignKey("IdWell")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
.WithMany()
.HasForeignKey("IdWellSectionType")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Author");
b.Navigation("Editor");
b.Navigation("Previous");
b.Navigation("Well");
b.Navigation("WellSectionType");
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanReam", b => modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanReam", b =>
{ {
b.HasOne("AsbCloudDb.Model.User", "Author") b.HasOne("AsbCloudDb.Model.User", "Author")
@ -8937,6 +9022,86 @@ namespace AsbCloudDb.Migrations
b.Navigation("WellSectionType"); b.Navigation("WellSectionType");
}); });
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanRotor", b =>
{
b.HasOne("AsbCloudDb.Model.User", "Author")
.WithMany()
.HasForeignKey("IdAuthor")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("AsbCloudDb.Model.User", "Editor")
.WithMany()
.HasForeignKey("IdEditor")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanRotor", "Previous")
.WithMany()
.HasForeignKey("IdPrevious");
b.HasOne("AsbCloudDb.Model.Well", "Well")
.WithMany()
.HasForeignKey("IdWell")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
.WithMany()
.HasForeignKey("IdWellSectionType")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Author");
b.Navigation("Editor");
b.Navigation("Previous");
b.Navigation("Well");
b.Navigation("WellSectionType");
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanSlide", b =>
{
b.HasOne("AsbCloudDb.Model.User", "Author")
.WithMany()
.HasForeignKey("IdAuthor")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("AsbCloudDb.Model.User", "Editor")
.WithMany()
.HasForeignKey("IdEditor")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanSlide", "Previous")
.WithMany()
.HasForeignKey("IdPrevious");
b.HasOne("AsbCloudDb.Model.Well", "Well")
.WithMany()
.HasForeignKey("IdWell")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
.WithMany()
.HasForeignKey("IdWellSectionType")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Author");
b.Navigation("Editor");
b.Navigation("Previous");
b.Navigation("Well");
b.Navigation("WellSectionType");
});
modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b => modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b =>
{ {
b.HasOne("AsbCloudDb.Model.Company", "Company") b.HasOne("AsbCloudDb.Model.Company", "Company")

View File

@ -19,7 +19,8 @@ namespace AsbCloudDb.Model
public virtual DbSet<Deposit> Deposits => Set<Deposit>(); public virtual DbSet<Deposit> Deposits => Set<Deposit>();
public virtual DbSet<DetectedOperation> DetectedOperations => Set<DetectedOperation>(); public virtual DbSet<DetectedOperation> DetectedOperations => Set<DetectedOperation>();
public virtual DbSet<TrajectoryPlan> TrajectoriesPlan => Set<TrajectoryPlan>(); public virtual DbSet<TrajectoryPlan> TrajectoriesPlan => Set<TrajectoryPlan>();
public virtual DbSet<ProcessMapPlanDrilling> ProcessMapPlanDrilling => Set<ProcessMapPlanDrilling>(); public virtual DbSet<ProcessMapPlanRotor> ProcessMapPlanRotor => Set<ProcessMapPlanRotor>();
public virtual DbSet<ProcessMapPlanSlide> ProcessMapPlanSlide => Set<ProcessMapPlanSlide>();
public virtual DbSet<ProcessMapPlanReam> ProcessMapPlanReams => Set<ProcessMapPlanReam>(); public virtual DbSet<ProcessMapPlanReam> ProcessMapPlanReams => Set<ProcessMapPlanReam>();
public virtual DbSet<DrillingProgramPart> DrillingProgramParts => Set<DrillingProgramPart>(); public virtual DbSet<DrillingProgramPart> DrillingProgramParts => Set<DrillingProgramPart>();
public virtual DbSet<FileCategory> FileCategories => Set<FileCategory>(); public virtual DbSet<FileCategory> FileCategories => Set<FileCategory>();
@ -442,12 +443,22 @@ namespace AsbCloudDb.Model
.HasIndex(w => new { w.IdWell, w.IdSectionType }) .HasIndex(w => new { w.IdWell, w.IdSectionType })
.IsUnique(); .IsUnique();
modelBuilder.Entity<ProcessMapPlanDrilling>() modelBuilder.Entity<ProcessMapPlanRotor>()
.HasOne(p => p.Author) .HasOne(p => p.Author)
.WithMany() .WithMany()
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanDrilling>() modelBuilder.Entity<ProcessMapPlanSlide>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanRotor>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanSlide>()
.HasOne(p => p.Editor) .HasOne(p => p.Editor)
.WithMany() .WithMany()
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);

View File

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model.ProcessMapPlan; namespace AsbCloudDb.Model.ProcessMapPlan;
@ -12,9 +13,11 @@ public abstract class ProcessMapPlanBase : ChangeLogAbstract, IId, IWellRelated
public int IdWellSectionType { get; set; } public int IdWellSectionType { get; set; }
[Column("depth_start"), Comment("Глубина по стволу от, м")] [Column("depth_start"), Comment("Глубина по стволу от, м")]
[Range(0.0, 9999.9)]
public double DepthStart { get; set; } public double DepthStart { get; set; }
[Column("depth_end"), Comment("Глубина по стволу до, м")] [Column("depth_end"), Comment("Глубина по стволу до, м")]
[Range(0.0, 9999.9)]
public double DepthEnd { get; set; } public double DepthEnd { get; set; }
[ForeignKey(nameof(IdWell))] [ForeignKey(nameof(IdWell))]

View File

@ -1,58 +0,0 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using AsbCloudDb.Model.ProcessMapPlan;
using Microsoft.EntityFrameworkCore;
namespace AsbCloudDb.Model.ProcessMaps;
[Table("t_process_map_plan_drilling"), Comment("РТК план бурение")]
public class ProcessMapPlanDrilling : ProcessMapPlanBase
{
[Column("id_mode"), Comment("Id режима (1- ротор, 2 слайд)")]
public int IdMode { get; set; }
[Column("axial_load_plan"), Comment("Осевая нагрузка, т, план")]
public double AxialLoadPlan { get; set; }
[Column("axial_load_limit_max"), Comment("Осевая нагрузка, т, допустимый максимум")]
public double AxialLoadLimitMax { get; set; }
[Column("delta_pressure_plan"), Comment("Перепад давления, атм, план")]
public double DeltaPressurePlan { get; set; }
[Column("delta_pressure_limit_max"), Comment("Перепад давления, атм, допустимый максимум")]
public double DeltaPressureLimitMax { get; set; }
[Column("top_drive_torque_plan"), Comment("Момент на ВСП, план")]
public double TopDriveTorquePlan { get; set; }
[Column("top_drive_torque_limit_max"), Comment("Момент на ВСП, допустимый максимум")]
public double TopDriveTorqueLimitMax { get; set; }
[Column("top_drive_speed_plan"), Comment("Обороты на ВСП, план")]
public double TopDriveSpeedPlan { get; set; }
[Column("top_drive_speed_limit_max"), Comment("Обороты на ВСП, допустимый максимум")]
public double TopDriveSpeedLimitMax { get; set; }
[Column("flow_plan"), Comment("Расход, л/с, план")]
public double FlowPlan { get; set; }
[Column("flow_limit_max"), Comment("Расход, л/с, допустимый максимум")]
public double FlowLimitMax { get; set; }
[Column("rop_plan"), Comment("Плановая механическая скорость, м/ч")]
public double RopPlan { get; set; }
[Column("usage_saub"), Comment("Плановый процент использования АКБ")]
public double UsageSaub { get; set; }
[Column("usage_spin"), Comment("Плановый процент использования spin master")]
public double UsageSpin { get; set; }
[Column("comment"), Comment("Комментарий"), StringLength(1024)]
public string Comment { get; set; } = string.Empty;
[ForeignKey(nameof(IdPrevious))]
public virtual ProcessMapPlanDrilling? Previous { get; set; }
}

View File

@ -0,0 +1,76 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using AsbCloudDb.Model.ProcessMapPlan;
using Microsoft.EntityFrameworkCore;
namespace AsbCloudDb.Model.ProcessMaps;
[Table("t_process_map_plan_rotor"), Comment("РТК план бурение ротор")]
public class ProcessMapPlanRotor : ProcessMapPlanBase
{
[Column("rop_limit_max"), Comment("Максимально допустимая скорость, м/ч")]
[Range(0, 800.0)]
[Required]
public double RopLimitMax { get; set; }
[Column("pressure_limit_max"), Comment("Максимально допустимое давление, атм")]
[Range(0.0, 400.0)]
[Required]
public double PressureLimitMax { get; set; }
[Column("differential_pressure"), Comment("Перепад давления, атм. Уставка")]
[Range(0.0, 60.0)]
[Required]
public double DifferentialPressure { get; set; }
[Column("differential_pressure_limit_max"), Comment("Перепад давления, атм. Ограничение")]
[Range(0.0, 60.0)]
[Required]
public double DifferentialPressureLimitMax { get; set; }
[Column("weight_on_bit"), Comment("Нагрузка, т. Уставка")]
[Range(0.0, 99.0)]
[Required]
public double WeightOnBit { get; set; }
[Column("weight_on_bit_limit_max"), Comment("Нагрузка, т. Ограничение")]
[Range(0.0, 99.0)]
[Required]
public double WeightOnBitLimitMax { get; set; }
[Column("top_drive_torque"), Comment("Момент на ВСП, кН*м. Уставка")]
[Range(0.0, 35.0)]
[Required]
public double TopDriveTorque { get; set; }
[Column("top_drive_torque_limit_max"), Comment("Момент на ВСП, кН*м. Ограничение")]
[Range(0.0, 35.0)]
[Required]
public double TopDriveTorqueLimit { get; set; }
[Column("revolution_per_minute"), Comment("Обороты на ВСП, об/мин. Уставка")]
[Range(0.0, 270.0)]
[Required]
public double RevolutionsPerMinute { get; set; }
[Column("revolutions_per_minute_limit_max"), Comment("Обороты на ВСП, об/мин. Ограничение")]
[Range(0.0, 270.0)]
[Required]
public double RevolutionsPerMinuteLimitMax { get; set; }
[Column("flow_rate"), Comment("Расход л/с. Уставка")]
[Range(0.0, 100.0)]
[Required]
public double FlowRate { get; set; }
[Column("flow_rate_limit_max"), Comment("Расход л/с. Ограничение")]
[Range(0.0, 100.0)]
[Required]
public double FlowRateLimitMax { get; set; }
[Column("note"), Comment("Примечание"), StringLength(1024)]
public string Note { get; set; } = string.Empty;
[ForeignKey(nameof(IdPrevious))]
public virtual ProcessMapPlanRotor? Previous { get; set; }
}

View File

@ -0,0 +1,66 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using AsbCloudDb.Model.ProcessMapPlan;
using Microsoft.EntityFrameworkCore;
namespace AsbCloudDb.Model.ProcessMaps;
[Table("t_process_map_plan_slide"), Comment("РТК план бурение слайд")]
public class ProcessMapPlanSlide : ProcessMapPlanBase
{
[Column("rop_limit_max"), Comment("Максимально допустимая скорость, м/ч")]
[Range(0, 800.0)]
[Required]
public double RopLimitMax { get; set; }
[Column("pressure_limit_max"), Comment("Максимально допустимое давление, атм")]
[Range(0, 400.0)]
[Required]
public double PressureLimitMax { get; set; }
[Column("differential_pressure"), Comment("Перепад давления, атм. Уставка")]
[Range(0, 60.0)]
[Required]
public double DifferentialPressure { get; set; }
[Column("differential_pressure_limit_max"), Comment("Перепад давления, атм. Ограничение")]
[Range(0, 60.0)]
[Required]
public double DifferentialPressureLimitMax { get; set; }
[Column("weight_on_bit"), Comment("Нагрузка, т. Уставка")]
[Range(0, 50.0)]
[Required]
public double WeightOnBit { get; set; }
[Column("weight_on_bit_limit_max"), Comment("Нагрузка, т. Ограничение")]
[Range(0, 50.0)]
[Required]
public double WeightOnBitLimitMax { get; set; }
[Column("flow_rate"), Comment("Расход л/с. Уставка")]
[Range(0, 100.0)]
[Required]
public double FlowRate { get; set; }
[Column("flow_rate_limit_max"), Comment("Расход л/с. Ограничение")]
[Range(0, 100.0)]
[Required]
public double FlowRateLimitMax { get; set; }
[Column("spring"), Comment("Расчётная пружина, градус")]
[Range(0, 9999.9)]
[Required]
public double Spring { get; set; }
[Column("tool_buckling"), Comment("Складывание инструмента, м")]
[Range(0, 9999.9)]
[Required]
public double ToolBuckling { get; set; }
[Column("note"), Comment("Примечание"), StringLength(1024)]
public string Note { get; set; } = string.Empty;
[ForeignKey(nameof(IdPrevious))]
public virtual ProcessMapPlanSlide? Previous { get; set; }
}

View File

@ -15,6 +15,8 @@
<None Remove="Services\DailyReport\DailyReportTemplate.xlsx" /> <None Remove="Services\DailyReport\DailyReportTemplate.xlsx" />
<None Remove="Services\DrillTestReport\DrillTestReportTemplate.xlsx" /> <None Remove="Services\DrillTestReport\DrillTestReportTemplate.xlsx" />
<None Remove="Services\ProcessMapPlan\Templates\ProcessMapPlanReamTemplate.xlsx" /> <None Remove="Services\ProcessMapPlan\Templates\ProcessMapPlanReamTemplate.xlsx" />
<None Remove="Services\ProcessMapPlan\Templates\ProcessMapPlanRotorTemplate.xlsx" />
<None Remove="Services\ProcessMapPlan\Templates\ProcessMapPlanSlideTemplate.xlsx" />
<None Remove="Services\ProcessMaps\Report\ProcessMapReportDataSaubStatTemplate.xlsx" /> <None Remove="Services\ProcessMaps\Report\ProcessMapReportDataSaubStatTemplate.xlsx" />
<None Remove="Services\Trajectory\FactTrajectoryTemplate.xlsx" /> <None Remove="Services\Trajectory\FactTrajectoryTemplate.xlsx" />
<None Remove="Services\Trajectory\NnbTrajectoryTemplate.xlsx" /> <None Remove="Services\Trajectory\NnbTrajectoryTemplate.xlsx" />
@ -39,7 +41,8 @@
<EmbeddedResource Include="Services\DailyReport\DailyReportTemplate.xlsx" /> <EmbeddedResource Include="Services\DailyReport\DailyReportTemplate.xlsx" />
<EmbeddedResource Include="Services\DrillTestReport\DrillTestReportTemplate.xlsx" /> <EmbeddedResource Include="Services\DrillTestReport\DrillTestReportTemplate.xlsx" />
<EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanReamTemplate.xlsx" /> <EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanReamTemplate.xlsx" />
<EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanDrillingTemplate.xlsx" /> <EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanRotorTemplate.xlsx" />
<EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanSlideTemplate.xlsx" />
<EmbeddedResource Include="Services\ProcessMaps\Report\ProcessMapReportDataSaubStatTemplate.xlsx" /> <EmbeddedResource Include="Services\ProcessMaps\Report\ProcessMapReportDataSaubStatTemplate.xlsx" />
<EmbeddedResource Include="Services\Trajectory\Templates\TrajectoryFactNnbTemplate.xlsx" /> <EmbeddedResource Include="Services\Trajectory\Templates\TrajectoryFactNnbTemplate.xlsx" />
<EmbeddedResource Include="Services\Trajectory\Templates\TrajectoryFactManualTemplate.xlsx" /> <EmbeddedResource Include="Services\Trajectory\Templates\TrajectoryFactManualTemplate.xlsx" />

View File

@ -132,11 +132,18 @@ namespace AsbCloudInfrastructure
Plan = src.WellDepthPlan Plan = src.WellDepthPlan
}); });
TypeAdapterConfig<ChangeLogAbstract, ChangeLogDto<ProcessMapPlanDrillingDto>>.NewConfig() TypeAdapterConfig<ChangeLogAbstract, ChangeLogDto<ProcessMapPlanRotorDto>>.NewConfig()
.Include<ProcessMapPlanDrilling, ChangeLogDto<ProcessMapPlanDrillingDto>>() .Include<ProcessMapPlanRotor, ChangeLogDto<ProcessMapPlanRotorDto>>()
.Map(dest => dest, src => new ChangeLogDto<ProcessMapPlanDrillingDto>() .Map(dest => dest, src => new ChangeLogDto<ProcessMapPlanRotorDto>()
{ {
Item = src.Adapt<ProcessMapPlanDrillingDto>() Item = src.Adapt<ProcessMapPlanRotorDto>()
});
TypeAdapterConfig<ChangeLogAbstract, ChangeLogDto<ProcessMapPlanSlideDto>>.NewConfig()
.Include<ProcessMapPlanSlide, ChangeLogDto<ProcessMapPlanSlideDto>>()
.Map(dest => dest, src => new ChangeLogDto<ProcessMapPlanSlideDto>()
{
Item = src.Adapt<ProcessMapPlanSlideDto>()
}); });
} }
@ -196,8 +203,12 @@ namespace AsbCloudInfrastructure
services.AddTransient<IDataSaubStatRepository, DataSaubStatRepository>(); services.AddTransient<IDataSaubStatRepository, DataSaubStatRepository>();
services.AddTransient< services.AddTransient<
IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell>, IChangeLogRepository<ProcessMapPlanRotorDto, ProcessMapPlanBaseRequestWithWell>,
ProcessMapPlanBaseRepository<ProcessMapPlanDrilling, ProcessMapPlanDrillingDto>>(); ProcessMapPlanBaseRepository<ProcessMapPlanRotor, ProcessMapPlanRotorDto>>();
services.AddTransient<
IChangeLogRepository<ProcessMapPlanSlideDto, ProcessMapPlanBaseRequestWithWell>,
ProcessMapPlanBaseRepository<ProcessMapPlanSlide, ProcessMapPlanSlideDto>>();
services.AddTransient< services.AddTransient<
IChangeLogRepository<ProcessMapPlanReamDto, ProcessMapPlanBaseRequestWithWell>, IChangeLogRepository<ProcessMapPlanReamDto, ProcessMapPlanBaseRequestWithWell>,
@ -248,7 +259,8 @@ namespace AsbCloudInfrastructure
services.AddTransient<IHelpPageRepository, HelpPageRepository>(); services.AddTransient<IHelpPageRepository, HelpPageRepository>();
services.AddTransient<IFileRepository, FileRepository>(); services.AddTransient<IFileRepository, FileRepository>();
services.AddTransient<IFileStorageRepository, FileStorageRepository>(); services.AddTransient<IFileStorageRepository, FileStorageRepository>();
services.AddTransient<IWellCompositeRepository, WellCompositeRepository>(); services.AddTransient<IWellCompositeRepository, WellCompositeRepository<ProcessMapPlanRotorDto>>();
services.AddTransient<IWellCompositeRepository, WellCompositeRepository<ProcessMapPlanSlideDto>>();
services.AddTransient<IUserRoleRepository, UserRoleRepository>(); services.AddTransient<IUserRoleRepository, UserRoleRepository>();
services.AddTransient<IUserRepository, UserRepository>(); services.AddTransient<IUserRepository, UserRepository>();
services.AddTransient<ILimitingParameterRepository, LimitingParameterRepository>(); services.AddTransient<ILimitingParameterRepository, LimitingParameterRepository>();
@ -302,14 +314,16 @@ namespace AsbCloudInfrastructure
services.AddTransient<TrajectoryPlanParser>(); services.AddTransient<TrajectoryPlanParser>();
services.AddTransient<TrajectoryFactManualParser>(); services.AddTransient<TrajectoryFactManualParser>();
services.AddTransient<ProcessMapPlanDrillingParser>(); services.AddTransient<ProcessMapPlanRotorParser>();
services.AddTransient<ProcessMapPlanSlideParser>();
services.AddTransient<ProcessMapPlanReamParser>(); services.AddTransient<ProcessMapPlanReamParser>();
services.AddTransient<TrajectoryPlanExportService>(); services.AddTransient<TrajectoryPlanExportService>();
services.AddTransient<TrajectoryFactManualExportService>(); services.AddTransient<TrajectoryFactManualExportService>();
services.AddTransient<TrajectoryFactNnbExportService>(); services.AddTransient<TrajectoryFactNnbExportService>();
services.AddTransient<ProcessMapPlanDrillingExportService>(); services.AddTransient<ProcessMapPlanRotorExportService>();
services.AddTransient<ProcessMapPlanSlideExportService>();
services.AddTransient<ProcessMapPlanReamExportService>(); services.AddTransient<ProcessMapPlanReamExportService>();
services.AddTransient<WellOperationParserFactory>(); services.AddTransient<WellOperationParserFactory>();

View File

@ -13,14 +13,15 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Repository; namespace AsbCloudInfrastructure.Repository;
public class WellCompositeRepository : IWellCompositeRepository public class WellCompositeRepository<TDto> : IWellCompositeRepository
where TDto : ProcessMapPlanBaseDto
{ {
private readonly IAsbCloudDbContext db; private readonly IAsbCloudDbContext db;
private readonly IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanDrillingRepository; private readonly IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> processMapPlanDrillingRepository;
public WellCompositeRepository( public WellCompositeRepository(
IAsbCloudDbContext db, IAsbCloudDbContext db,
IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanDrillingRepository) IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> processMapPlanDrillingRepository)
{ {
this.db = db; this.db = db;
this.processMapPlanDrillingRepository = processMapPlanDrillingRepository; this.processMapPlanDrillingRepository = processMapPlanDrillingRepository;
@ -51,7 +52,7 @@ public class WellCompositeRepository : IWellCompositeRepository
} }
/// <inheritdoc/> /// <inheritdoc/>
public Task<IEnumerable<ProcessMapPlanDrillingDto>> GetCompositeProcessMap(int idWell, CancellationToken token) public Task<IEnumerable<ProcessMapPlanBaseDto>> GetCompositeProcessMap(int idWell, CancellationToken token)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -1,35 +0,0 @@
using System.Collections.Generic;
using AsbCloudApp.Data.ProcessMaps;
namespace AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
public class ProcessMapPlanDrillingTemplate : ITemplateParameters
{
public string SheetName => "План";
public int HeaderRowsCount => 2;
public string FileName => "ProcessMapPlanDrillingTemplate.xlsx";
public IDictionary<string, Cell> Cells => new Dictionary<string, Cell>
{
{ nameof(ProcessMapPlanDrillingDto.Section), new Cell(1, typeof(string)) },
{ nameof(ProcessMapPlanDrillingDto.Mode), new Cell(2, typeof(string)) },
{ nameof(ProcessMapPlanDrillingDto.DepthStart), new Cell(3, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.DepthEnd), new Cell(4, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.DeltaPressurePlan), new Cell(5, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.DeltaPressureLimitMax), new Cell(6, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.AxialLoadPlan), new Cell(7, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.AxialLoadLimitMax), new Cell(8, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.TopDriveTorquePlan), new Cell(9, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.TopDriveTorqueLimitMax), new Cell(10, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.TopDriveSpeedPlan), new Cell(11, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.TopDriveSpeedLimitMax), new Cell(12, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.FlowPlan), new Cell(13, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.FlowLimitMax), new Cell(14, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.RopPlan), new Cell(15, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.UsageSaub), new Cell(16, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.UsageSpin), new Cell(17, typeof(double)) },
{ nameof(ProcessMapPlanDrillingDto.Comment), new Cell(18, typeof(string)) }
};
}

View File

@ -0,0 +1,33 @@
using System.Collections.Generic;
using AsbCloudApp.Data.ProcessMaps;
namespace AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
public class ProcessMapPlanRotorTemplate : ITemplateParameters
{
public string SheetName => "Бурение ротор";
public int HeaderRowsCount => 2;
public string FileName => "ProcessMapPlanRotorTemplate.xlsx";
public IDictionary<string, Cell> Cells => new Dictionary<string, Cell>
{
{ nameof(ProcessMapPlanRotorDto.Section), new Cell(1, typeof(string)) },
{ nameof(ProcessMapPlanRotorDto.DepthStart), new Cell(2, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.DepthEnd), new Cell(3, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.RopLimitMax), new Cell(4, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.PressureLimitMax), new Cell(5, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.DifferentialPressure), new Cell(6, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.DifferentialPressureLimitMax), new Cell(7, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.WeightOnBit), new Cell(8, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.WeightOnBitLimitMax), new Cell(9, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.TopDriveTorque), new Cell(10, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.TopDriveTorqueLimit), new Cell(11, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.RevolutionsPerMinute), new Cell(12, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.RevolutionsPerMinuteLimitMax), new Cell(13, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.FlowRate), new Cell(14, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.FlowRateLimitMax), new Cell(15, typeof(double)) },
{ nameof(ProcessMapPlanRotorDto.Note), new Cell(16, typeof(double)) },
};
}

View File

@ -0,0 +1,31 @@
using System.Collections.Generic;
using AsbCloudApp.Data.ProcessMaps;
namespace AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
public class ProcessMapPlanSlideTemplate : ITemplateParameters
{
public string SheetName => "Бурение слайд";
public int HeaderRowsCount => 2;
public string FileName => "ProcessMapPlanSlideTemplate.xlsx";
public IDictionary<string, Cell> Cells => new Dictionary<string, Cell>
{
{ nameof(ProcessMapPlanSlideDto.Section), new Cell(1, typeof(string)) },
{ nameof(ProcessMapPlanSlideDto.DepthStart), new Cell(2, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.DepthEnd), new Cell(3, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.RopLimitMax), new Cell(4, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.PressureLimitMax), new Cell(5, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.DifferentialPressure), new Cell(6, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.DifferentialPressureLimitMax), new Cell(7, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.WeightOnBit), new Cell(8, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.WeightOnBitLimitMax), new Cell(9, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.FlowRate), new Cell(10, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.FlowRateLimitMax), new Cell(11, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.Spring), new Cell(12, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.ToolBuckling), new Cell(13, typeof(double)) },
{ nameof(ProcessMapPlanSlideDto.Note), new Cell(14, typeof(double)) }
};
}

View File

@ -1,52 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Requests.ExportOptions;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
public class ProcessMapPlanDrillingExportService : ProcessMapPlanExportService<ProcessMapPlanDrillingDto>
{
public ProcessMapPlanDrillingExportService(
IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRepository,
IWellService wellService)
: base(processMapPlanRepository, wellService)
{
}
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanDrillingTemplate();
protected override async Task<string> BuildFileNameAsync(WellRelatedExportRequest options, CancellationToken token)
{
var caption = await wellService.GetWellCaptionByIdAsync(options.IdWell, token);
return $"{caption}_РТК_План_бурение.xlsx";
}
protected override async Task<IEnumerable<ProcessMapPlanDrillingDto>> GetDtosAsync(WellRelatedExportRequest options,
CancellationToken token)
{
var dtos = await base.GetDtosAsync(options, token);
var dtosWithMode = dtos.Select(dto =>
{
dto.Mode = dto.IdMode switch
{
1 => "Ротор",
2 => "Слайд",
_ => throw new ArgumentOutOfRangeException()
};
return dto;
});
return dtosWithMode;
}
}

View File

@ -0,0 +1,30 @@
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Requests.ExportOptions;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
public class ProcessMapPlanRotorExportService : ProcessMapPlanExportService<ProcessMapPlanRotorDto>
{
public ProcessMapPlanRotorExportService(
IChangeLogRepository<ProcessMapPlanRotorDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRepository,
IWellService wellService)
: base(processMapPlanRepository, wellService)
{
}
protected override ITemplateParameters TemplateParameters { get; } = new ProcessMapPlanRotorTemplate();
protected override async Task<string> BuildFileNameAsync(WellRelatedExportRequest options, CancellationToken token)
{
var caption = await wellService.GetWellCaptionByIdAsync(options.IdWell, token);
return $"{caption}_РТК_План_бурение_ротор.xlsx";
}
}

View File

@ -0,0 +1,30 @@
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Requests.ExportOptions;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
public class ProcessMapPlanSlideExportService : ProcessMapPlanExportService<ProcessMapPlanSlideDto>
{
public ProcessMapPlanSlideExportService(
IChangeLogRepository<ProcessMapPlanSlideDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRepository,
IWellService wellService)
: base(processMapPlanRepository, wellService)
{
}
protected override ITemplateParameters TemplateParameters { get; } = new ProcessMapPlanSlideTemplate();
protected override async Task<string> BuildFileNameAsync(WellRelatedExportRequest options, CancellationToken token)
{
var caption = await wellService.GetWellCaptionByIdAsync(options.IdWell, token);
return $"{caption}_РТК_План_бурение_слайд.xlsx";
}
}

View File

@ -27,12 +27,4 @@ public abstract class ProcessMapPlanParser<TDto> : ParserExcelService<TDto, Well
return result; return result;
} }
protected static int? GetIdMode(string? modeName) =>
modeName?.Trim().ToLower() switch
{
"ротор" => 1,
"слайд" => 2,
_ => null
};
} }

View File

@ -9,16 +9,16 @@ using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemp
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser; namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
public class ProcessMapPlanDrillingParser : ProcessMapPlanParser<ProcessMapPlanDrillingDto> public class ProcessMapPlanRotorParser : ProcessMapPlanParser<ProcessMapPlanRotorDto>
{ {
public ProcessMapPlanDrillingParser(IWellOperationRepository wellOperationRepository) public ProcessMapPlanRotorParser(IWellOperationRepository wellOperationRepository)
: base(wellOperationRepository) : base(wellOperationRepository)
{ {
} }
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanDrillingTemplate(); protected override ITemplateParameters TemplateParameters => new ProcessMapPlanRotorTemplate();
protected override ProcessMapPlanDrillingDto BuildDto(IDictionary<string, object?> row, int rowNumber) protected override ProcessMapPlanRotorDto BuildDto(IDictionary<string, object?> row, int rowNumber)
{ {
var dto = base.BuildDto(row, rowNumber); var dto = base.BuildDto(row, rowNumber);
@ -30,25 +30,12 @@ public class ProcessMapPlanDrillingParser : ProcessMapPlanParser<ProcessMapPlanD
var message = string.Format(XLExtentions.ProblemDetailsTemplate, var message = string.Format(XLExtentions.ProblemDetailsTemplate,
TemplateParameters.SheetName, TemplateParameters.SheetName,
rowNumber, rowNumber,
TemplateParameters.Cells[nameof(ProcessMapPlanDrillingDto.Section)], TemplateParameters.Cells[nameof(ProcessMapPlanBaseDto.Section)],
"Указана некорректная секция"); "Указана некорректная секция");
throw new FileFormatException(message); throw new FileFormatException(message);
} }
var idMode = GetIdMode(dto.Mode);
if (idMode is null)
{
var message = string.Format(XLExtentions.ProblemDetailsTemplate,
TemplateParameters.SheetName,
rowNumber,
TemplateParameters.Cells[nameof(ProcessMapPlanDrillingDto.Mode)],
"Указан некорректный режим бурения");
throw new FileFormatException(message);
}
dto.IdWellSectionType = section.Id; dto.IdWellSectionType = section.Id;
dto.IdMode = idMode.Value;
return dto; return dto;
} }

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
public class ProcessMapPlanSlideParser : ProcessMapPlanParser<ProcessMapPlanSlideDto>
{
public ProcessMapPlanSlideParser(IWellOperationRepository wellOperationRepository)
: base(wellOperationRepository)
{
}
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanSlideTemplate();
protected override ProcessMapPlanSlideDto BuildDto(IDictionary<string, object?> row, int rowNumber)
{
var dto = base.BuildDto(row, rowNumber);
var section = sections.FirstOrDefault(s =>
string.Equals(s.Caption.Trim(), dto.Section?.Trim(), StringComparison.CurrentCultureIgnoreCase));
if (section is null)
{
var message = string.Format(XLExtentions.ProblemDetailsTemplate,
TemplateParameters.SheetName,
rowNumber,
TemplateParameters.Cells[nameof(ProcessMapPlanBaseDto.Section)],
"Указана некорректная секция");
throw new FileFormatException(message);
}
dto.IdWellSectionType = section.Id;
return dto;
}
}

View File

@ -20,20 +20,23 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report;
public class ProcessMapReportDrillingService : IProcessMapReportDrillingService public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
{ {
private readonly IWellService wellService; private readonly IWellService wellService;
private readonly IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository; private readonly IChangeLogRepository<ProcessMapPlanRotorDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRotorRepository;
private readonly IChangeLogRepository<ProcessMapPlanSlideDto, ProcessMapPlanBaseRequestWithWell> processMapPlanSlideRepository;
private readonly IDataSaubStatRepository dataSaubStatRepository; private readonly IDataSaubStatRepository dataSaubStatRepository;
private readonly IWellOperationRepository wellOperationRepository; private readonly IWellOperationRepository wellOperationRepository;
private readonly IWellOperationCategoryRepository wellOperationCategoryRepository; private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
public ProcessMapReportDrillingService(IWellService wellService, public ProcessMapReportDrillingService(IWellService wellService,
IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository, IChangeLogRepository<ProcessMapPlanRotorDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRotorRepository,
IChangeLogRepository<ProcessMapPlanSlideDto, ProcessMapPlanBaseRequestWithWell> processMapPlanSlideRepository,
IDataSaubStatRepository dataSaubStatRepository, IDataSaubStatRepository dataSaubStatRepository,
IWellOperationRepository wellOperationRepository, IWellOperationRepository wellOperationRepository,
IWellOperationCategoryRepository wellOperationCategoryRepository IWellOperationCategoryRepository wellOperationCategoryRepository
) )
{ {
this.wellService = wellService; this.wellService = wellService;
this.processMapPlanBaseRepository = processMapPlanBaseRepository; this.processMapPlanRotorRepository = processMapPlanRotorRepository;
this.processMapPlanSlideRepository = processMapPlanSlideRepository;
this.dataSaubStatRepository = dataSaubStatRepository; this.dataSaubStatRepository = dataSaubStatRepository;
this.wellOperationRepository = wellOperationRepository; this.wellOperationRepository = wellOperationRepository;
this.wellOperationCategoryRepository = wellOperationCategoryRepository; this.wellOperationCategoryRepository = wellOperationCategoryRepository;
@ -48,7 +51,15 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>(); return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
var requestProcessMapPlan = new ProcessMapPlanBaseRequestWithWell(idWell); var requestProcessMapPlan = new ProcessMapPlanBaseRequestWithWell(idWell);
var changeLogProcessMaps = await processMapPlanBaseRepository.GetChangeLogForDate(requestProcessMapPlan, null, token);
var changeLogProcessMapsRotor = await processMapPlanRotorRepository.GetChangeLogForDate(requestProcessMapPlan, null, token);
var changeLogProcessMapsSlide = await processMapPlanSlideRepository.GetChangeLogForDate(requestProcessMapPlan, null, token);
var changeLogProcessMaps = changeLogProcessMapsRotor
.Select(p => ConvertToChangeLogDtoWithProcessMapPlanBase(p))
.Union(changeLogProcessMapsSlide.Select(p => ConvertToChangeLogDtoWithProcessMapPlanBase(p)));
if (!changeLogProcessMaps.Any()) if (!changeLogProcessMaps.Any())
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>(); return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
@ -95,9 +106,24 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
return result; return result;
} }
private ChangeLogDto<ProcessMapPlanBaseDto> ConvertToChangeLogDtoWithProcessMapPlanBase<T>(ChangeLogDto<T> p)
where T: ProcessMapPlanBaseDto
{
return new ChangeLogDto<ProcessMapPlanBaseDto>()
{
Item = p.Item,
Author = p.Author,
Creation = p.Creation,
Editor = p.Editor,
IdPrevious = p.IdPrevious,
IdState = p.IdState,
Obsolete = p.Obsolete,
};
}
private static IEnumerable<ProcessMapReportDataSaubStatDto> CalcByIntervals( private static IEnumerable<ProcessMapReportDataSaubStatDto> CalcByIntervals(
DataSaubStatRequest request, DataSaubStatRequest request,
IEnumerable<ChangeLogDto<ProcessMapPlanDrillingDto>> changeLogProcessMaps, IEnumerable<ChangeLogDto<ProcessMapPlanBaseDto>> changeLogProcessMaps,
Span<DataSaubStatDto> dataSaubStats, Span<DataSaubStatDto> dataSaubStats,
IEnumerable<WellOperationDto> wellOperations, IEnumerable<WellOperationDto> wellOperations,
IEnumerable<WellOperationCategoryDto> wellOperationCategories, IEnumerable<WellOperationCategoryDto> wellOperationCategories,
@ -125,15 +151,15 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
return operation.IdWellSectionType; return operation.IdWellSectionType;
} }
ProcessMapPlanDrillingDto? GetProcessMapPlan(int idWellSectionType, DataSaubStatDto data) ProcessMapPlanBaseDto? GetProcessMapPlan(int idWellSectionType, DataSaubStatDto data)
=> changeLogProcessMaps => changeLogProcessMaps
.Where(p => p.Item.IdWellSectionType == idWellSectionType) .Where(p => p.Item.IdWellSectionType == idWellSectionType)
.Where(p => p.Item.DepthStart <= data.DepthStart) .Where(p => p.Item.DepthStart <= data.DepthStart)
.Where(p => p.Item.DepthEnd >= data.DepthStart) .Where(p => p.Item.DepthEnd >= data.DepthStart)
.Where(p => IsModeMatchOperationCategory(p.Item.IdMode, data.IdCategory)) .Where(p => IsModeMatchOperationCategory(p.Item, data.IdCategory))
.WhereActualAtMoment(data.DateStart) .WhereActualAtMoment(data.DateStart)
.Select(p => p.Item) .Select(p => p.Item)
.FirstOrDefault(); .FirstOrDefault();
var idWellSectionType = GetSection(firstElemInInterval); var idWellSectionType = GetSection(firstElemInInterval);
var prevProcessMapPlan = GetProcessMapPlan(idWellSectionType, firstElemInInterval); var prevProcessMapPlan = GetProcessMapPlan(idWellSectionType, firstElemInInterval);
@ -175,13 +201,13 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
return list; return list;
} }
private static bool IsModeMatchOperationCategory(int idMode, int idCategory) private static bool IsModeMatchOperationCategory(ProcessMapPlanBaseDto dto, int idCategory)
{ {
return (idMode == 1 && idCategory == 5003) || (idMode == 2 && idCategory == 5002); return (dto is ProcessMapPlanRotorDto && idCategory == 5003) || (dto is ProcessMapPlanSlideDto && idCategory == 5002);
} }
private static ProcessMapReportDataSaubStatDto? CalcStat( private static ProcessMapReportDataSaubStatDto? CalcStat(
ProcessMapPlanDrillingDto? processMapPlanFilteredByDepth, ProcessMapPlanBaseDto? processMapPlanFilteredByDepth,
Span<DataSaubStatDto> span, Span<DataSaubStatDto> span,
string wellOperationCategoryName, string wellOperationCategoryName,
WellSectionTypeDto wellSectionType WellSectionTypeDto wellSectionType
@ -206,54 +232,70 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
DrillingMode = wellOperationCategoryName, DrillingMode = wellOperationCategoryName,
PressureDiff = new ProcessMapReportDataSaubStatParamsDto() PressureDiff = new ProcessMapReportDataSaubStatParamsDto()
{ {
SetpointPlan = processMapPlanFilteredByDepth?.DeltaPressurePlan,
SetpointFact = firstElemInInterval.PressureSp - firstElemInInterval.PressureIdle, SetpointFact = firstElemInInterval.PressureSp - firstElemInInterval.PressureIdle,
FactWavg = aggregatedValues.Pressure, FactWavg = aggregatedValues.Pressure,
Limit = processMapPlanFilteredByDepth?.DeltaPressureLimitMax,
SetpointUsage = aggregatedValues.SetpointUsagePressure SetpointUsage = aggregatedValues.SetpointUsagePressure
}, },
AxialLoad = new ProcessMapReportDataSaubStatParamsDto() AxialLoad = new ProcessMapReportDataSaubStatParamsDto()
{ {
SetpointPlan = processMapPlanFilteredByDepth?.AxialLoadPlan,
SetpointFact = aggregatedValues.AxialLoadSp, SetpointFact = aggregatedValues.AxialLoadSp,
FactWavg = aggregatedValues.AxialLoad, FactWavg = aggregatedValues.AxialLoad,
Limit = processMapPlanFilteredByDepth?.AxialLoadLimitMax,
SetpointUsage = aggregatedValues.SetpointUsageAxialLoad SetpointUsage = aggregatedValues.SetpointUsageAxialLoad
}, },
TopDriveTorque = new ProcessMapReportDataSaubStatParamsDto() TopDriveTorque = new ProcessMapReportDataSaubStatParamsDto()
{ {
SetpointPlan = processMapPlanFilteredByDepth?.TopDriveTorquePlan,
SetpointFact = aggregatedValues.RotorTorqueSp, SetpointFact = aggregatedValues.RotorTorqueSp,
FactWavg = aggregatedValues.RotorTorque, FactWavg = aggregatedValues.RotorTorque,
FactMax = aggregatedValues.RotorTorqueMax, FactMax = aggregatedValues.RotorTorqueMax,
Limit = processMapPlanFilteredByDepth?.TopDriveTorqueLimitMax,
SetpointUsage = aggregatedValues.SetpointUsageRotorTorque SetpointUsage = aggregatedValues.SetpointUsageRotorTorque
}, },
SpeedLimit = new ProcessMapReportDataSaubStatParamsDto SpeedLimit = new ProcessMapReportDataSaubStatParamsDto
{ {
SetpointPlan = processMapPlanFilteredByDepth?.RopPlan,
SetpointFact = aggregatedValues.BlockSpeedSp, SetpointFact = aggregatedValues.BlockSpeedSp,
FactWavg = deltaDepth / aggregatedValues.DrilledTime, FactWavg = deltaDepth / aggregatedValues.DrilledTime,
SetpointUsage = aggregatedValues.SetpointUsageRopPlan SetpointUsage = aggregatedValues.SetpointUsageRopPlan
}, },
TopDriveSpeed = new ProcessMapReportDataSaubStatParamsDto TopDriveSpeed = new ProcessMapReportDataSaubStatParamsDto
{ {
SetpointPlan = processMapPlanFilteredByDepth?.TopDriveSpeedPlan,
FactWavg = aggregatedValues.RotorSpeed, FactWavg = aggregatedValues.RotorSpeed,
FactMax = aggregatedValues.RotorSpeedMax FactMax = aggregatedValues.RotorSpeedMax
}, },
Flow = new ProcessMapReportDataSaubStatParamsDto Flow = new ProcessMapReportDataSaubStatParamsDto
{ {
SetpointPlan = processMapPlanFilteredByDepth?.FlowPlan,
FactWavg = aggregatedValues.MaxFlow, FactWavg = aggregatedValues.MaxFlow,
Limit = processMapPlanFilteredByDepth?.FlowLimitMax,
}, },
Rop = new PlanFactDto<double?> Rop = new PlanFactDto<double?>
{ {
Plan = processMapPlanFilteredByDepth?.RopPlan,
Fact = deltaDepth / aggregatedValues.DrilledTime Fact = deltaDepth / aggregatedValues.DrilledTime
}, },
}; };
if(processMapPlanFilteredByDepth is ProcessMapPlanRotorDto processMapPlanRotorFilteredByDepth)
{
result.PressureDiff.SetpointPlan = processMapPlanRotorFilteredByDepth.DifferentialPressure;
result.PressureDiff.Limit = processMapPlanRotorFilteredByDepth.DifferentialPressureLimitMax;
result.AxialLoad.SetpointPlan = processMapPlanRotorFilteredByDepth.WeightOnBit;
result.AxialLoad.Limit = processMapPlanRotorFilteredByDepth.WeightOnBitLimitMax;
result.TopDriveTorque.SetpointPlan = processMapPlanRotorFilteredByDepth.TopDriveTorque;
result.TopDriveTorque.Limit = processMapPlanRotorFilteredByDepth.TopDriveTorqueLimit;
result.SpeedLimit.SetpointPlan = processMapPlanRotorFilteredByDepth.RopLimitMax;
result.TopDriveSpeed.SetpointPlan = processMapPlanRotorFilteredByDepth.RevolutionsPerMinute;
result.Flow.SetpointPlan = processMapPlanRotorFilteredByDepth.FlowRate;
result.Flow.Limit = processMapPlanRotorFilteredByDepth.FlowRateLimitMax;
result.Rop.Plan = processMapPlanRotorFilteredByDepth.RopLimitMax;
}
if (processMapPlanFilteredByDepth is ProcessMapPlanSlideDto processMapPlanSlideFilteredByDepth)
{
result.PressureDiff.SetpointPlan = processMapPlanSlideFilteredByDepth.DifferentialPressure;
result.PressureDiff.Limit = processMapPlanSlideFilteredByDepth.DifferentialPressureLimitMax;
result.AxialLoad.SetpointPlan = processMapPlanSlideFilteredByDepth.WeightOnBit;
result.AxialLoad.Limit = processMapPlanSlideFilteredByDepth.WeightOnBitLimitMax;
result.SpeedLimit.SetpointPlan = processMapPlanSlideFilteredByDepth.RopLimitMax;
result.Flow.SetpointPlan = processMapPlanSlideFilteredByDepth.FlowRate;
result.Flow.Limit = processMapPlanSlideFilteredByDepth.FlowRateLimitMax;
result.Rop.Plan = processMapPlanSlideFilteredByDepth.RopLimitMax;
}
return result; return result;
} }

View File

@ -32,7 +32,8 @@ public class WellInfoService
{ {
var wellService = services.GetRequiredService<IWellService>(); var wellService = services.GetRequiredService<IWellService>();
var operationsStatService = services.GetRequiredService<IOperationsStatService>(); var operationsStatService = services.GetRequiredService<IOperationsStatService>();
var processMapPlanWellDrillingRepository = services.GetRequiredService<IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell>>(); var processMapPlanRotorRepository = services.GetRequiredService<IChangeLogRepository<ProcessMapPlanRotorDto, ProcessMapPlanBaseRequestWithWell>>();
var processMapPlanSlideRepository = services.GetRequiredService<IChangeLogRepository<ProcessMapPlanSlideDto, ProcessMapPlanBaseRequestWithWell>>();
var subsystemService = services.GetRequiredService<ISubsystemService>(); var subsystemService = services.GetRequiredService<ISubsystemService>();
var telemetryDataSaubCache = services.GetRequiredService<ITelemetryDataCache<TelemetryDataSaubDto>>(); var telemetryDataSaubCache = services.GetRequiredService<ITelemetryDataCache<TelemetryDataSaubDto>>();
var messageHub = services.GetRequiredService<IIntegrationEventHandler<UpdateWellInfoEvent>>(); var messageHub = services.GetRequiredService<IIntegrationEventHandler<UpdateWellInfoEvent>>();
@ -44,11 +45,14 @@ public class WellInfoService
var wellsIds = activeWells.Select(w => w.Id); var wellsIds = activeWells.Select(w => w.Id);
var processMapPlanWellDrillingRequests = wellsIds.Select(id => new ProcessMapPlanBaseRequestWithWell(id)); var processMapPlanWellDrillingRequests = wellsIds.Select(id => new ProcessMapPlanBaseRequestWithWell(id));
var processMapPlanWellDrillings = new List<ProcessMapPlanDrillingDto>(); var processMapPlanWellDrillings = new List<ProcessMapPlanBaseDto>();
foreach (var processMapPlanWellDrillingRequest in processMapPlanWellDrillingRequests) foreach (var processMapPlanWellDrillingRequest in processMapPlanWellDrillingRequests)
{ {
var processMaps = await processMapPlanWellDrillingRepository.GetCurrent(processMapPlanWellDrillingRequest, token); var processMapsRotor = await processMapPlanRotorRepository.GetCurrent(processMapPlanWellDrillingRequest, token);
processMapPlanWellDrillings.AddRange(processMaps); var processMapsSlide = await processMapPlanSlideRepository.GetCurrent(processMapPlanWellDrillingRequest, token);
processMapPlanWellDrillings.AddRange(processMapsRotor);
processMapPlanWellDrillings.AddRange(processMapsSlide);
} }
var wellDepthByProcessMap = processMapPlanWellDrillings var wellDepthByProcessMap = processMapPlanWellDrillings
@ -95,7 +99,7 @@ public class WellInfoService
.OrderBy(p => p.DepthEnd); .OrderBy(p => p.DepthEnd);
int? idSection = wellLastFactSection?.Id; int? idSection = wellLastFactSection?.Id;
ProcessMapPlanDrillingDto? processMapPlanWellDrilling = null; ProcessMapPlanBaseDto? processMapPlanWellDrilling = null;
if (idSection.HasValue && currentDepth.HasValue) if (idSection.HasValue && currentDepth.HasValue)
{ {
@ -126,25 +130,21 @@ public class WellInfoService
wellMapInfo.AxialLoad = new() wellMapInfo.AxialLoad = new()
{ {
Plan = processMapPlanWellDrilling?.AxialLoadPlan,
Fact = lastSaubTelemetry?.AxialLoad Fact = lastSaubTelemetry?.AxialLoad
}; };
wellMapInfo.TopDriveSpeed = new() wellMapInfo.TopDriveSpeed = new()
{ {
Plan = processMapPlanWellDrilling?.TopDriveSpeedPlan,
Fact = lastSaubTelemetry?.RotorSpeed Fact = lastSaubTelemetry?.RotorSpeed
}; };
wellMapInfo.TopDriveTorque = new() wellMapInfo.TopDriveTorque = new()
{ {
Plan = processMapPlanWellDrilling?.TopDriveTorquePlan,
Fact = lastSaubTelemetry?.RotorTorque Fact = lastSaubTelemetry?.RotorTorque
}; };
wellMapInfo.Pressure = new() wellMapInfo.Pressure = new()
{ {
Plan = processMapPlanWellDrilling?.DeltaPressurePlan,
Fact = lastSaubTelemetry?.Pressure Fact = lastSaubTelemetry?.Pressure
}; };
@ -158,7 +158,6 @@ public class WellInfoService
wellMapInfo.ROP = new() wellMapInfo.ROP = new()
{ {
Plan = processMapPlanWellDrilling?.RopPlan,
Fact = wellOperationsStat?.Total.Fact?.Rop, Fact = wellOperationsStat?.Total.Fact?.Rop,
}; };
@ -168,6 +167,28 @@ public class WellInfoService
Fact = wellOperationsStat?.Total.Fact?.RouteSpeed, Fact = wellOperationsStat?.Total.Fact?.RouteSpeed,
}; };
if(processMapPlanWellDrilling is ProcessMapPlanRotorDto processMapPlanRotor)
{
wellMapInfo.AxialLoad.Plan = processMapPlanRotor?.WeightOnBit;
wellMapInfo.TopDriveSpeed.Plan = processMapPlanRotor?.RevolutionsPerMinute;
wellMapInfo.TopDriveTorque.Plan = processMapPlanRotor?.TopDriveTorque;
wellMapInfo.Pressure.Plan = processMapPlanRotor?.DifferentialPressure;
wellMapInfo.ROP.Plan = processMapPlanRotor?.RopLimitMax;
}
if (processMapPlanWellDrilling is ProcessMapPlanSlideDto processMapPlanSlide)
{
wellMapInfo.AxialLoad.Plan = processMapPlanSlide?.WeightOnBit;
wellMapInfo.Pressure.Plan = processMapPlanSlide?.DifferentialPressure;
wellMapInfo.ROP.Plan = processMapPlanSlide?.RopLimitMax;
}
var wellSubsystemStat = subsystemStat.FirstOrDefault(s => s.Well.Id == well.Id); var wellSubsystemStat = subsystemStat.FirstOrDefault(s => s.Well.Id == well.Id);
wellMapInfo.SaubUsage = wellSubsystemStat?.SubsystemAPD?.KUsage ?? 0d; wellMapInfo.SaubUsage = wellSubsystemStat?.SubsystemAPD?.KUsage ?? 0d;
wellMapInfo.SpinUsage = wellSubsystemStat?.SubsystemOscillation?.KUsage ?? 0d; wellMapInfo.SpinUsage = wellSubsystemStat?.SubsystemOscillation?.KUsage ?? 0d;

View File

@ -19,10 +19,18 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Controllers\ProcessMapPlan\Files\ProcessMapPlanRotorInvalid.xlsx" />
<None Remove="Controllers\ProcessMapPlan\Files\ProcessMapPlanRotorValid.xlsx" />
<None Remove="Controllers\ProcessMapPlan\Files\ProcessMapPlanSlideInvalid.xlsx" />
<None Remove="Controllers\ProcessMapPlan\Files\ProcessMapPlanSlideValid.xlsx" />
<None Remove="WellOperationsPlan.xlsx" /> <None Remove="WellOperationsPlan.xlsx" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Controllers\ProcessMapPlan\Files\ProcessMapPlanRotorInvalid.xlsx" />
<EmbeddedResource Include="Controllers\ProcessMapPlan\Files\ProcessMapPlanRotorValid.xlsx" />
<EmbeddedResource Include="Controllers\ProcessMapPlan\Files\ProcessMapPlanSlideInvalid.xlsx" />
<EmbeddedResource Include="Controllers\ProcessMapPlan\Files\ProcessMapPlanSlideValid.xlsx" />
<EmbeddedResource Include="Controllers\WellOperations\Files\PlanWellOperations.xlsx" /> <EmbeddedResource Include="Controllers\WellOperations\Files\PlanWellOperations.xlsx" />
<EmbeddedResource Include="Controllers\WellOperations\Files\FactWellOperations.xlsx" /> <EmbeddedResource Include="Controllers\WellOperations\Files\FactWellOperations.xlsx" />
<EmbeddedResource Include="WellOperationsPlan.xlsx" /> <EmbeddedResource Include="WellOperationsPlan.xlsx" />
@ -32,9 +40,4 @@
<ProjectReference Include="..\AsbCloudWebApi\AsbCloudWebApi.csproj" /> <ProjectReference Include="..\AsbCloudWebApi\AsbCloudWebApi.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Controllers\ProcessMapPlan\Files\ProcessMapPlanDrillingInvalid.xlsx" />
<EmbeddedResource Include="Controllers\ProcessMapPlan\Files\ProcessMapPlanDrillingValid.xlsx" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,41 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMaps;
using Refit;
namespace AsbCloudWebApi.IntegrationTests.Clients;
public interface IProcessMapPlanClient<TDto> where TDto : ProcessMapPlanBaseDto
{
public const string BaseRoute = "/api/well/{idWell}/{controller}";
[Post(BaseRoute)]
Task<IApiResponse<int>> InsertRange(int idWell, string controller, [Body] IEnumerable<TDto> dtos);
[Post($"{BaseRoute}/replace")]
Task<IApiResponse<int>> ClearAndInsertRange(int idWell, string controller, [Body] IEnumerable<TDto> dtos);
[Delete(BaseRoute)]
Task<IApiResponse<int>> DeleteRange(int idWell, string controller, [Body] IEnumerable<int> ids);
[Delete($"{BaseRoute}/clear")]
Task<IApiResponse<int>> Clear(int idWell, string controller);
[Get(BaseRoute)]
Task<IApiResponse<IEnumerable<TDto>>> Get(int idWell, string controller);
[Get($"{BaseRoute}/changelogByMoment")]
Task<IApiResponse<IEnumerable<ChangeLogDto<TDto>>>> Get(int idWell, string controller, DateTimeOffset? moment);
[Get("/api/telemetry/{uid}/{controller}")]
Task<IApiResponse<IEnumerable<ChangeLogDto<TDto>>>> Get(string uid, string controller, DateTimeOffset? updateFrom);
[Get($"{BaseRoute}/dates")]
Task<IApiResponse<IEnumerable<DateOnly>>> GetDatesChange(int idWell, string controller);
[Put(BaseRoute)]
Task<IApiResponse<int>> UpdateOrInsertRange(int idWell, string controller, IEnumerable<TDto> dtos);
[Multipart]
[Post(BaseRoute + "/parse")]
Task<IApiResponse<ParserResultDto<TDto>>> Parse(int idWell, string controller, [AliasAs("file")] StreamPart stream);
}

View File

@ -1,156 +1,75 @@
using AsbCloudApp.Requests; using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Data.User;
using AsbCloudApp.Requests;
using AsbCloudDb.Model;
using AsbCloudDb.Model.ProcessMapPlan; using AsbCloudDb.Model.ProcessMapPlan;
using AsbCloudWebApi.IntegrationTests.Clients; using AsbCloudWebApi.IntegrationTests.Clients;
using AsbCloudWebApi.IntegrationTests.Data;
using Mapster; using Mapster;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Refit;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using AsbCloudDb.Model.ProcessMaps;
using AsbCloudWebApi.IntegrationTests.Data;
using Refit;
using Xunit; using Xunit;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudDb.Model;
using AsbCloudApp.Data.User;
using AsbCloudApp.Data;
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan; namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
public abstract class ProcessMapPlanBaseControllerTest<TEntity, TDto> : BaseIntegrationTest
public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest where TEntity : ProcessMapPlanBase
where TDto : ProcessMapPlanBaseDto
{ {
private const int IdWell = 1; private IProcessMapPlanClient<TDto> client;
private string controllerName;
private readonly ProcessMapPlanDrillingDto dto = new() protected abstract TEntity? GetByWellId();
protected abstract TEntity GetByNote(DbSet<TEntity> dbSet, TDto dto);
protected abstract TDto GetByNote(IEnumerable<TDto> dtos, TDto dto);
public ProcessMapPlanBaseControllerTest(WebAppFactoryFixture factory, string controllerName) : base(factory)
{ {
Id = 0, dbContext.CleanupDbSet<TEntity>();
client = factory.GetAuthorizedHttpClient<IProcessMapPlanClient<TDto>>(string.Empty);
IdWell = IdWell, this.controllerName = controllerName;
Section = "Кондуктор",
IdWellSectionType = 3,
DepthStart = 0.5,
DepthEnd = 1.5,
IdMode = 1,
AxialLoadPlan = 2.718281,
AxialLoadLimitMax = 3.1415926,
DeltaPressurePlan = 4,
DeltaPressureLimitMax = 5,
TopDriveTorquePlan = 6,
TopDriveTorqueLimitMax = 7,
TopDriveSpeedPlan = 8,
TopDriveSpeedLimitMax = 9,
FlowPlan = 10,
FlowLimitMax = 11,
RopPlan = 12,
UsageSaub = 13,
UsageSpin = 14,
Comment = "это тестовая запись",
};
private readonly ProcessMapPlanDrilling entity = new()
{
Id = 0,
IdAuthor = 1,
IdEditor = null,
Creation = DateTimeOffset.UtcNow,
Obsolete = null,
IdState = AsbCloudDb.Model.ChangeLogAbstract.IdStateActual,
IdPrevious = null,
IdWell = IdWell,
IdWellSectionType = 1,
DepthStart = 0.5,
DepthEnd = 1.5,
IdMode = 1,
AxialLoadPlan = 2.718281,
AxialLoadLimitMax = 3.1415926,
DeltaPressurePlan = 4,
DeltaPressureLimitMax = 5,
TopDriveTorquePlan = 6,
TopDriveTorqueLimitMax = 7,
TopDriveSpeedPlan = 8,
TopDriveSpeedLimitMax = 9,
FlowPlan = 10,
FlowLimitMax = 11,
RopPlan = 12,
UsageSaub = 13,
UsageSpin = 14,
Comment = "это тестовая запись",
};
private IProcessMapPlanDrillingClient<ProcessMapPlanDrillingDto> client;
public ProcessMapPlanDrillingControllerTest(WebAppFactoryFixture factory) : base(factory)
{
dbContext.CleanupDbSet<ProcessMapPlanDrilling>();
client = factory.GetAuthorizedHttpClient<IProcessMapPlanDrillingClient<ProcessMapPlanDrillingDto>>(string.Empty);
} }
public async Task InsertRangeSuccess(TDto dto)
[Fact]
public async Task InsertRange_returns_success()
{ {
//arrange //arrange
var expected = dto.Adapt<ProcessMapPlanDrillingDto>(); var expected = dto.Adapt<TDto>();
//act //act
var response = await client.InsertRange(dto.IdWell, new[] { expected }); var response = await client.InsertRange(dto.IdWell, controllerName, new TDto[] { expected });
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal(1, response.Content); Assert.Equal(1, response.Content);
var entity = dbContext var entity = GetByWellId();
.Set<ProcessMapPlanDrilling>()
.Where(p => p.AxialLoadPlan == dto.AxialLoadPlan)
.Where(p => p.AxialLoadLimitMax == dto.AxialLoadLimitMax)
.Where(p => p.Comment == dto.Comment)
.FirstOrDefault(p => p.IdWell == dto.IdWell);
Assert.NotNull(entity); Assert.NotNull(entity);
var actual = entity.Adapt<ChangeLogDto<ProcessMapPlanDrillingDto>>(); var actual = entity.Adapt<ChangeLogDto<TDto>>();
Assert.Equal(ProcessMapPlanBase.IdStateActual, actual.IdState); Assert.Equal(ProcessMapPlanBase.IdStateActual, actual.IdState);
var excludeProps = new[] { var excludeProps = new[] {
nameof(ProcessMapPlanDrillingDto.Id), nameof(ProcessMapPlanBaseDto.Id),
nameof(ProcessMapPlanDrillingDto.Section) nameof(ProcessMapPlanBaseDto.Section)
}; };
MatchHelper.Match(expected, actual.Item, excludeProps); MatchHelper.Match(expected, actual.Item, excludeProps);
} }
[Fact] public async Task InsertRangeFailed(TDto dto)
public async Task InsertRange_returns_BadRequest_for_IdWellSectionType()
{ {
//arrange
var badDto = dto.Adapt<ProcessMapPlanDrillingDto>();
badDto.IdWellSectionType = int.MaxValue;
//act //act
var response = await client.InsertRange(dto.IdWell, new[] { badDto }); var response = await client.InsertRange(dto.IdWell, controllerName, new[] { dto });
//assert //assert
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
} }
[Fact] public async Task ClearAndInsertRange(TEntity entity, TDto dto)
public async Task InsertRange_returns_BadRequest_for_IdMode()
{
//arrange
var badDto = dto.Adapt<ProcessMapPlanDrillingDto>();
badDto.IdMode = int.MaxValue;
//act
var response = await client.InsertRange(dto.IdWell, new[] { badDto });
//assert
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
}
[Fact]
public async Task ClearAndInsertRange_returns_success()
{ {
// arrange // arrange
var dbset = dbContext.Set<ProcessMapPlanDrilling>(); var dbset = dbContext.Set<TEntity>();
var entry = dbset.Add(entity); var entry = dbset.Add(entity);
dbContext.SaveChanges(); dbContext.SaveChanges();
@ -159,7 +78,7 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
var startTime = DateTimeOffset.UtcNow; var startTime = DateTimeOffset.UtcNow;
// act // act
var result = await client.ClearAndInsertRange(entity.IdWell, new ProcessMapPlanDrillingDto[] { dto }); var result = await client.ClearAndInsertRange(entity.IdWell, controllerName, new TDto[] { dto });
// assert // assert
var doneTime = DateTimeOffset.UtcNow; var doneTime = DateTimeOffset.UtcNow;
@ -184,13 +103,12 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.InRange(newEntity.Creation, startTime, doneTime); Assert.InRange(newEntity.Creation, startTime, doneTime);
} }
[Fact] public async Task UpdateOrInsertRange(TEntity entity, TDto dtoUpdate, TDto dtoInsert)
public async Task UpdateOrInsertRange_returns_success()
{ {
// arrange // arrange
var startTime = DateTimeOffset.UtcNow; var startTime = DateTimeOffset.UtcNow;
var dbset = dbContext.Set<ProcessMapPlanDrilling>(); var dbset = dbContext.Set<TEntity>();
var user = dbContext.Set<User>().First().Adapt<UserDto>(); var user = dbContext.Set<User>().First().Adapt<UserDto>();
user.Surname = "userSurname"; user.Surname = "userSurname";
user.Email = "user@mail.domain"; user.Email = "user@mail.domain";
@ -199,43 +117,10 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
dbContext.SaveChanges(); dbContext.SaveChanges();
entry.State = EntityState.Detached; entry.State = EntityState.Detached;
var dtoUpdate = dto.Adapt<ProcessMapPlanDrillingDto>();
dtoUpdate.IdWell = 0;
dtoUpdate.Id = entry.Entity.Id; dtoUpdate.Id = entry.Entity.Id;
dtoUpdate.Comment = "nebuchadnezzar";
dtoUpdate.DeltaPressureLimitMax++;
dtoUpdate.DeltaPressurePlan++;
dtoUpdate.FlowPlan++;
dtoUpdate.FlowLimitMax++;
dtoUpdate.RopPlan++;
dtoUpdate.AxialLoadPlan++;
dtoUpdate.AxialLoadLimitMax++;
dtoUpdate.DepthStart++;
dtoUpdate.DepthEnd++;
dtoUpdate.TopDriveSpeedPlan++;
dtoUpdate.TopDriveSpeedLimitMax++;
dtoUpdate.TopDriveTorquePlan++;
dtoUpdate.TopDriveTorqueLimitMax++;
var dtoInsert = dtoUpdate.Adapt<ProcessMapPlanDrillingDto>();
dtoInsert.Id = 0;
dtoInsert.Comment = "nebuchad";
dtoInsert.DeltaPressureLimitMax++;
dtoInsert.DeltaPressurePlan++;
dtoInsert.FlowPlan++;
dtoInsert.FlowLimitMax++;
dtoInsert.RopPlan++;
dtoInsert.AxialLoadPlan++;
dtoInsert.AxialLoadLimitMax++;
dtoInsert.DepthStart++;
dtoInsert.DepthEnd++;
dtoInsert.TopDriveSpeedPlan++;
dtoInsert.TopDriveSpeedLimitMax++;
dtoInsert.TopDriveTorquePlan++;
dtoInsert.TopDriveTorqueLimitMax++;
// act // act
var result = await client.UpdateOrInsertRange(entity.IdWell, new ProcessMapPlanDrillingDto[] { dtoUpdate, dtoInsert }); var result = await client.UpdateOrInsertRange(entity.IdWell, controllerName, new TDto[] { dtoUpdate, dtoInsert });
// assert // assert
var doneTime = DateTimeOffset.UtcNow; var doneTime = DateTimeOffset.UtcNow;
@ -251,7 +136,7 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.NotNull(oldEntity.Obsolete); Assert.NotNull(oldEntity.Obsolete);
Assert.InRange(oldEntity.Obsolete.Value, startTime, doneTime); Assert.InRange(oldEntity.Obsolete.Value, startTime, doneTime);
var newEntity = dbset.First(p => p.Comment == dtoUpdate.Comment); var newEntity = GetByNote(dbset, dtoUpdate);
Assert.Equal(ProcessMapPlanBase.IdStateActual, newEntity.IdState); Assert.Equal(ProcessMapPlanBase.IdStateActual, newEntity.IdState);
Assert.Equal(1, newEntity.IdAuthor); Assert.Equal(1, newEntity.IdAuthor);
Assert.Null(newEntity.IdEditor); Assert.Null(newEntity.IdEditor);
@ -259,23 +144,22 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.Equal(oldEntity.Id, newEntity.IdPrevious); Assert.Equal(oldEntity.Id, newEntity.IdPrevious);
Assert.InRange(newEntity.Creation, startTime, doneTime); Assert.InRange(newEntity.Creation, startTime, doneTime);
var expected = dtoUpdate.Adapt<ProcessMapPlanDrilling>(); var expected = dtoUpdate.Adapt<TEntity>();
var excludeProps = new[] { var excludeProps = new[] {
nameof(ProcessMapPlanDrilling.Id), nameof(ProcessMapPlanBase.Id),
nameof(ProcessMapPlanDrilling.IdWell), nameof(ProcessMapPlanBase.IdWell),
nameof(ProcessMapPlanDrilling.Author), nameof(ProcessMapPlanBase.Author),
nameof(ProcessMapPlanDrilling.IdAuthor), nameof(ProcessMapPlanBase.IdAuthor),
nameof(ProcessMapPlanDrilling.Editor), nameof(ProcessMapPlanBase.Editor),
nameof(ProcessMapPlanDrilling.Creation), nameof(ProcessMapPlanBase.Creation),
}; };
MatchHelper.Match(expected, newEntity!, excludeProps); MatchHelper.Match(expected, newEntity!, excludeProps);
} }
[Fact] public async Task DeleteRange(TEntity entity, TDto dto)
public async Task DeleteRange_returns_success()
{ {
//arrange //arrange
var dbset = dbContext.Set<ProcessMapPlanDrilling>(); var dbset = dbContext.Set<TEntity>();
var entry = dbset.Add(entity); var entry = dbset.Add(entity);
dbContext.SaveChanges(); dbContext.SaveChanges();
@ -284,7 +168,7 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
var startTime = DateTimeOffset.UtcNow; var startTime = DateTimeOffset.UtcNow;
//act //act
var response = await client.DeleteRange(dto.IdWell, new[] { entry.Entity.Id }); var response = await client.DeleteRange(dto.IdWell, controllerName, new[] { entry.Entity.Id });
//assert //assert
var doneTime = DateTimeOffset.UtcNow; var doneTime = DateTimeOffset.UtcNow;
@ -292,7 +176,7 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.Equal(1, response.Content); Assert.Equal(1, response.Content);
var actual = dbContext var actual = dbContext
.Set<ProcessMapPlanDrilling>() .Set<TEntity>()
.FirstOrDefault(p => p.Id == entry.Entity.Id); .FirstOrDefault(p => p.Id == entry.Entity.Id);
Assert.NotNull(actual); Assert.NotNull(actual);
@ -302,12 +186,10 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.InRange(actual.Obsolete.Value, startTime, doneTime); Assert.InRange(actual.Obsolete.Value, startTime, doneTime);
} }
public async Task Clear(TEntity entity, TDto dto)
[Fact]
public async Task Clear_returns_success()
{ {
//arrange //arrange
var dbset = dbContext.Set<ProcessMapPlanDrilling>(); var dbset = dbContext.Set<TEntity>();
var entry = dbset.Add(entity); var entry = dbset.Add(entity);
dbContext.SaveChanges(); dbContext.SaveChanges();
@ -316,7 +198,7 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
var startTime = DateTimeOffset.UtcNow; var startTime = DateTimeOffset.UtcNow;
//act //act
var response = await client.Clear(dto.IdWell); var response = await client.Clear(dto.IdWell, controllerName);
//assert //assert
var doneTime = DateTimeOffset.UtcNow; var doneTime = DateTimeOffset.UtcNow;
@ -324,7 +206,7 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.Equal(1, response.Content); Assert.Equal(1, response.Content);
var actual = dbContext var actual = dbContext
.Set<ProcessMapPlanDrilling>() .Set<TEntity>()
.FirstOrDefault(p => p.Id == entry.Entity.Id); .FirstOrDefault(p => p.Id == entry.Entity.Id);
Assert.NotNull(actual); Assert.NotNull(actual);
@ -334,13 +216,12 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.InRange(actual.Obsolete.Value, startTime, doneTime); Assert.InRange(actual.Obsolete.Value, startTime, doneTime);
} }
[Fact] public async Task GetDatesChange(TEntity entity, TDto dto)
public async Task GetDatesChange_returns_success()
{ {
//arrange //arrange
var dbset = dbContext.Set<ProcessMapPlanDrilling>(); var dbset = dbContext.Set<TEntity>();
var entity2 = entity.Adapt<ProcessMapPlanDrilling>(); var entity2 = entity.Adapt<TEntity>();
entity2.Creation = entity.Creation.AddDays(1); entity2.Creation = entity.Creation.AddDays(1);
dbset.Add(entity); dbset.Add(entity);
dbset.Add(entity2); dbset.Add(entity2);
@ -352,7 +233,7 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
.Select(d => new DateOnly(d.Year, d.Month, d.Day)); .Select(d => new DateOnly(d.Year, d.Month, d.Day));
//act //act
var response = await client.GetDatesChange(dto.IdWell); var response = await client.GetDatesChange(dto.IdWell, controllerName);
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
@ -361,25 +242,23 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.All(response.Content, d => dates.Contains(d)); Assert.All(response.Content, d => dates.Contains(d));
} }
[Fact] public async Task Get(TEntity entity, TDto dto)
public async Task Get_actual_returns_success()
{ {
//arrange //arrange
var dbset = dbContext.Set<ProcessMapPlanDrilling>(); var dbset = dbContext.Set<TEntity>();
dbset.Add(entity); dbset.Add(entity);
var entityDeleted = entity.Adapt<ProcessMapPlanDrilling>(); var entityDeleted = entity.Adapt<TEntity>();
entityDeleted.Creation = entity.Creation.AddDays(-1); entityDeleted.Creation = entity.Creation.AddDays(-1);
entityDeleted.Obsolete = entity.Creation; entityDeleted.Obsolete = entity.Creation;
entityDeleted.IdState = ProcessMapPlanBase.IdStateDeleted; entityDeleted.IdState = ProcessMapPlanBase.IdStateDeleted;
entityDeleted.IdEditor = 1; entityDeleted.IdEditor = 1;
entityDeleted.Comment = "nothing";
dbset.Add(entityDeleted); dbset.Add(entityDeleted);
dbContext.SaveChanges(); dbContext.SaveChanges();
var response = await client.Get(dto.IdWell); var response = await client.Get(dto.IdWell, controllerName);
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
@ -389,41 +268,38 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
var actual = response.Content.First()!; var actual = response.Content.First()!;
Assert.NotNull(actual.Section); Assert.NotNull(actual.Section);
Assert.NotEmpty(actual.Section); Assert.NotEmpty(actual.Section);
var expected = entity.Adapt<ProcessMapPlanDrillingDto>()!; var expected = entity.Adapt<TDto>()!;
var excludeProps = new[] { var excludeProps = new[] {
nameof(ProcessMapPlanDrillingDto.Id), nameof(ProcessMapPlanBaseDto.Id),
}; };
MatchHelper.Match(expected, actual, excludeProps); MatchHelper.Match(expected, actual, excludeProps);
} }
[Fact] public async Task GetAtMoment(TEntity entity, TDto dto)
public async Task Get_at_moment_returns_success()
{ {
//arrange //arrange
var dbset = dbContext.Set<ProcessMapPlanDrilling>(); var dbset = dbContext.Set<TEntity>();
var now = DateTimeOffset.UtcNow; var now = DateTimeOffset.UtcNow;
var entityDeleted = entity.Adapt<ProcessMapPlanDrilling>(); var entityDeleted = entity.Adapt<TEntity>();
entityDeleted.Creation = now; entityDeleted.Creation = now;
entityDeleted.Obsolete = now.AddMinutes(1); entityDeleted.Obsolete = now.AddMinutes(1);
entityDeleted.IdState = ProcessMapPlanBase.IdStateDeleted; entityDeleted.IdState = ProcessMapPlanBase.IdStateDeleted;
entityDeleted.IdEditor = 1; entityDeleted.IdEditor = 1;
entityDeleted.Comment = "nothing";
dbset.Add(entityDeleted); dbset.Add(entityDeleted);
var entityDeleted2 = entity.Adapt<ProcessMapPlanDrilling>(); var entityDeleted2 = entity.Adapt<TEntity>();
entityDeleted2.Creation = now.AddMinutes(1); entityDeleted2.Creation = now.AddMinutes(1);
entityDeleted2.Obsolete = now.AddMinutes(2); entityDeleted2.Obsolete = now.AddMinutes(2);
entityDeleted2.IdState = ProcessMapPlanBase.IdStateDeleted; entityDeleted2.IdState = ProcessMapPlanBase.IdStateDeleted;
entityDeleted2.IdEditor = 1; entityDeleted2.IdEditor = 1;
entityDeleted2.Comment = "nothing";
dbset.Add(entityDeleted2); dbset.Add(entityDeleted2);
dbContext.SaveChanges(); dbContext.SaveChanges();
//act //act
var response = await client.Get(dto.IdWell, now.AddMinutes(0.5)); var response = await client.Get(dto.IdWell, controllerName, now.AddMinutes(0.5));
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
@ -431,44 +307,40 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.Single(response.Content); Assert.Single(response.Content);
} }
[Fact] public async Task GetByUpdated(TEntity entity, TDto dto)
public async Task Get_by_updated_from_returns_success()
{ {
//arrange //arrange
var dbset = dbContext.Set<ProcessMapPlanDrilling>(); var dbset = dbContext.Set<TEntity>();
dbset.Add(entity); dbset.Add(entity);
var entity2 = entity.Adapt<ProcessMapPlanDrilling>(); var entity2 = entity.Adapt<TEntity>();
entity2.Obsolete = DateTimeOffset.UtcNow; entity2.Obsolete = DateTimeOffset.UtcNow;
dbset.Add(entity2); dbset.Add(entity2);
dbContext.SaveChanges(); dbContext.SaveChanges();
//act //act
var response = await client.Get(Defaults.RemoteUid, DateTimeOffset.UtcNow.AddHours(-1)); var response = await client.Get(Defaults.RemoteUid, controllerName, DateTimeOffset.UtcNow.AddHours(-1));
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content); Assert.NotNull(response.Content);
Assert.Equal(2, response.Content.Count()); Assert.Equal(2, response.Content.Count());
} }
[Fact] public async Task GetUpdated(TEntity entity, TDto dto)
public async Task Get_updated_returns_success()
{ {
//arrange //arrange
var dbset = dbContext.Set<ProcessMapPlanDrilling>(); var dbset = dbContext.Set<TEntity>();
dbset.Add(entity); dbset.Add(entity);
var entity2 = entity.Adapt<ProcessMapPlanDrilling>(); var entity2 = entity.Adapt<TEntity>();
entity2.Creation = entity.Creation.AddHours(1); entity2.Creation = entity.Creation.AddHours(1);
entity2.Comment = "IdWellSectionType = 2";
dbset.Add(entity2); dbset.Add(entity2);
var entity3 = entity.Adapt<ProcessMapPlanDrilling>(); var entity3 = entity.Adapt<TEntity>();
entity3.Obsolete = entity.Creation.AddHours(1); entity3.Obsolete = entity.Creation.AddHours(1);
entity3.Comment = "IdWellSectionType = 3";
dbset.Add(entity3); dbset.Add(entity3);
dbContext.SaveChanges(); dbContext.SaveChanges();
@ -482,34 +354,32 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
{ {
UpdateFrom = updateFrom, UpdateFrom = updateFrom,
}; };
var response = await client.Get(dto.IdWell); var response = await client.Get(dto.IdWell, controllerName);
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content); Assert.NotNull(response.Content);
Assert.Equal(2, response.Content.Count()); Assert.Equal(2, response.Content.Count());
var actual = response.Content var entity2Dto = entity2.Adapt<TDto>();
.First(p => p.Comment == entity2.Comment); var actual = GetByNote(response.Content, entity2Dto);
var expected = entity2.Adapt<ProcessMapPlanDrillingDto>(); var expected = entity2.Adapt<TDto>();
var excludeProps = new[] { var excludeProps = new[] {
nameof(ProcessMapPlanDrillingDto.Id), nameof(ProcessMapPlanBaseDto.Id),
}; };
MatchHelper.Match(expected, actual, excludeProps); MatchHelper.Match(expected, actual, excludeProps);
} }
[Fact] public async Task Parse(int IdWell, string fileName, TDto dto)
public async Task Parse_returns_success()
{ {
//arrange //arrange
const string fileName = "ProcessMapPlanDrillingValid.xlsx";
var stream = Assembly.GetExecutingAssembly().GetFileCopyStream(fileName); var stream = Assembly.GetExecutingAssembly().GetFileCopyStream(fileName);
var streamPart = new StreamPart(stream, fileName, "application/octet-stream"); var streamPart = new StreamPart(stream, fileName, "application/octet-stream");
//act //act
var response = await client.Parse(IdWell, streamPart); var response = await client.Parse(IdWell, controllerName, streamPart);
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
@ -525,21 +395,19 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.True(row.IsValid); Assert.True(row.IsValid);
var excludeProps = new[] { nameof(ProcessMapPlanDrillingDto.IdWell) }; var excludeProps = new[] { nameof(ProcessMapPlanBaseDto.IdWell) };
MatchHelper.Match(dto, dtoActual, excludeProps); MatchHelper.Match(dto, dtoActual, excludeProps);
} }
[Fact] public async Task ParseWithWarnings(int IdWell, string fileName)
public async Task Parse_returns_success_for_result_with_warnings()
{ {
//arrange //arrange
const string fileName = "ProcessMapPlanDrillingInvalid.xlsx";
var stream = Assembly.GetExecutingAssembly().GetFileCopyStream(fileName); var stream = Assembly.GetExecutingAssembly().GetFileCopyStream(fileName);
var streamPart = new StreamPart(stream, fileName, "application/octet-stream"); var streamPart = new StreamPart(stream, fileName, "application/octet-stream");
//act //act
var response = await client.Parse(IdWell, streamPart); var response = await client.Parse(IdWell, controllerName, streamPart);
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
@ -555,4 +423,4 @@ public class ProcessMapPlanDrillingControllerTest : BaseIntegrationTest
Assert.False(row.IsValid); Assert.False(row.IsValid);
Assert.Equal(2, row.Warnings.Count()); Assert.Equal(2, row.Warnings.Count());
} }
} }

View File

@ -0,0 +1,210 @@
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudDb.Model.ProcessMaps;
using DocumentFormat.OpenXml.Drawing.Charts;
using Mapster;
using Microsoft.EntityFrameworkCore;
using Xunit;
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
public class ProcessMapPlanRotorControllerTest : ProcessMapPlanBaseControllerTest<AsbCloudDb.Model.ProcessMaps.ProcessMapPlanRotor, ProcessMapPlanRotorDto>
{
private readonly ProcessMapPlanRotorDto dto = new ProcessMapPlanRotorDto()
{
IdWell = 1,
DepthStart = 1,
DepthEnd = 2,
RopLimitMax = 3,
PressureLimitMax = 4,
DifferentialPressure = 5,
DifferentialPressureLimitMax = 6,
WeightOnBit = 7,
WeightOnBitLimitMax = 8,
TopDriveTorque = 9,
TopDriveTorqueLimit = 10,
RevolutionsPerMinute = 11,
RevolutionsPerMinuteLimitMax = 12,
FlowRate = 13,
FlowRateLimitMax = 14,
Note = "15",
Id = 0,
IdWellSectionType = 1,
};
private readonly ProcessMapPlanRotor entity = new ProcessMapPlanRotor()
{
IdWell = 1,
DepthEnd = 10,
DepthStart = 2,
DifferentialPressure = 3,
DifferentialPressureLimitMax = 4,
FlowRate = 5,
FlowRateLimitMax = 6,
Id = 0,
IdWellSectionType = 1,
Note = "1",
PressureLimitMax = 2,
RevolutionsPerMinute = 3,
RevolutionsPerMinuteLimitMax = 4,
RopLimitMax = 5,
TopDriveTorque = 6,
TopDriveTorqueLimit = 7,
WeightOnBit = 8,
WeightOnBitLimitMax = 9,
IdAuthor = 1,
IdEditor = 1,
Creation = DateTimeOffset.UtcNow
};
public ProcessMapPlanRotorControllerTest(WebAppFactoryFixture factory) : base(factory, "ProcessMapPlanRotor")
{
}
protected override ProcessMapPlanRotor? GetByWellId()
{
var entity = dbContext
.Set<ProcessMapPlanRotor>()
.Where(p => p.WeightOnBit == dto.WeightOnBit)
.Where(p => p.WeightOnBitLimitMax == dto.WeightOnBitLimitMax)
.Where(p => p.Note == dto.Note)
.FirstOrDefault(p => p.IdWell == dto.IdWell);
return entity;
}
protected override ProcessMapPlanRotor GetByNote(
DbSet<ProcessMapPlanRotor> dbSet,
ProcessMapPlanRotorDto dto)
{
var entity = dbSet.First(p => p.Note == dto.Note);
return entity;
}
protected override ProcessMapPlanRotorDto GetByNote(
IEnumerable<ProcessMapPlanRotorDto> dtos,
ProcessMapPlanRotorDto dto)
{
var entity = dtos.First(p => p.Note == dto.Note);
return entity;
}
[Fact]
public async Task InsertRange_returns_success()
{
await InsertRangeSuccess(dto);
}
[Fact]
public async Task InsertRange_returns_BadRequest_for_IdWellSectionType()
{
//arrange
var badDto = dto.Adapt<ProcessMapPlanRotorDto>();
badDto.IdWellSectionType = int.MaxValue;
await InsertRangeFailed(badDto);
}
[Fact]
public async Task ClearAndInsertRange_returns_success()
{
await ClearAndInsertRange(entity, dto);
}
[Fact]
public async Task UpdateOrInsertRange_returns_success()
{
var dtoUpdate = dto.Adapt<ProcessMapPlanRotorDto>();
dtoUpdate.IdWell = 0;
dtoUpdate.Note = "nebuchadnezzar";
dtoUpdate.DifferentialPressureLimitMax++;
dtoUpdate.DifferentialPressure++;
dtoUpdate.FlowRate++;
dtoUpdate.FlowRateLimitMax++;
dtoUpdate.RopLimitMax++;
dtoUpdate.WeightOnBit++;
dtoUpdate.WeightOnBitLimitMax++;
dtoUpdate.DepthStart++;
dtoUpdate.DepthEnd++;
dtoUpdate.RevolutionsPerMinute++;
dtoUpdate.RevolutionsPerMinuteLimitMax++;
dtoUpdate.TopDriveTorque++;
dtoUpdate.TopDriveTorqueLimit++;
var dtoInsert = dtoUpdate.Adapt<ProcessMapPlanRotorDto>();
dtoInsert.Id = 0;
dtoInsert.Note = "nebuchad";
dtoInsert.DifferentialPressureLimitMax++;
dtoInsert.DifferentialPressure++;
dtoInsert.FlowRate++;
dtoInsert.FlowRateLimitMax++;
dtoInsert.RopLimitMax++;
dtoInsert.WeightOnBit++;
dtoInsert.WeightOnBitLimitMax++;
dtoInsert.DepthStart++;
dtoInsert.DepthEnd++;
dtoInsert.RevolutionsPerMinute++;
dtoInsert.RevolutionsPerMinuteLimitMax++;
dtoInsert.TopDriveTorque++;
dtoInsert.TopDriveTorqueLimit++;
await UpdateOrInsertRange(entity, dtoUpdate, dtoInsert);
}
[Fact]
public async Task DeleteRange_returns_success()
{
await DeleteRange(entity, dto);
}
[Fact]
public async Task Clear_returns_success()
{
await Clear(entity, dto);
}
[Fact]
public async Task GetDatesChange_returns_success()
{
await GetDatesChange(entity, dto);
}
[Fact]
public async Task Get_actual_returns_success()
{
await Get(entity, dto);
}
[Fact]
public async Task Get_at_moment_returns_success()
{
await GetAtMoment(entity, dto);
}
[Fact]
public async Task Get_by_updated_from_returns_success()
{
await GetByUpdated(entity, dto);
}
[Fact]
public async Task Get_updated_returns_success()
{
await GetUpdated(entity, dto);
}
[Fact]
public async Task Parse_returns_success()
{
await Parse(dto.IdWell, "ProcessMapPlanRotorValid.xlsx", dto);
}
[Fact]
public async Task Parse_returns_success_for_result_with_warnings()
{
await ParseWithWarnings(dto.IdWell, "ProcessMapPlanRotorInvalid.xlsx");
}
}

View File

@ -0,0 +1,201 @@
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudDb.Model.ProcessMaps;
using Mapster;
using Microsoft.EntityFrameworkCore;
using Xunit;
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
public class ProcessMapPlanSlideControllerTest : ProcessMapPlanBaseControllerTest<ProcessMapPlanSlide, ProcessMapPlanSlideDto>
{
private readonly ProcessMapPlanSlideDto dto = new ProcessMapPlanSlideDto()
{
IdWell = 1,
DepthStart = 1,
DepthEnd = 2,
RopLimitMax = 3,
PressureLimitMax = 4,
DifferentialPressure = 5,
DifferentialPressureLimitMax = 6,
WeightOnBit = 7,
WeightOnBitLimitMax = 8,
FlowRate = 9,
FlowRateLimitMax = 10,
Spring = 11,
ToolBuckling = 12,
Id = 0,
IdWellSectionType = 1,
Note = "13"
};
private readonly ProcessMapPlanSlide entity = new ProcessMapPlanSlide()
{
IdWell = 1,
DepthEnd = 10,
DepthStart = 2,
DifferentialPressure = 3,
DifferentialPressureLimitMax = 4,
FlowRate = 5,
FlowRateLimitMax = 6,
Id = 0,
IdWellSectionType = 1,
Note = "1",
PressureLimitMax = 2,
RopLimitMax = 5,
WeightOnBit = 8,
WeightOnBitLimitMax = 9,
IdAuthor = 1,
IdEditor = 1,
Creation = DateTimeOffset.UtcNow,
Spring = 10,
ToolBuckling = 11,
};
public ProcessMapPlanSlideControllerTest(WebAppFactoryFixture factory) : base(factory, "ProcessMapPlanSlide")
{
}
protected override ProcessMapPlanSlide? GetByWellId()
{
var entity = dbContext
.Set<ProcessMapPlanSlide>()
.Where(p => p.WeightOnBit == dto.WeightOnBit)
.Where(p => p.WeightOnBitLimitMax == dto.WeightOnBitLimitMax)
.Where(p => p.Note == dto.Note)
.FirstOrDefault(p => p.IdWell == dto.IdWell);
return entity;
}
protected override ProcessMapPlanSlide GetByNote(
DbSet<ProcessMapPlanSlide> dbSet,
ProcessMapPlanSlideDto dto)
{
var entity = dbSet.First(p => p.Note == dto.Note);
return entity;
}
protected override ProcessMapPlanSlideDto GetByNote(
IEnumerable<ProcessMapPlanSlideDto> dtos,
ProcessMapPlanSlideDto dto)
{
var entity = dtos.First(p => p.Note == dto.Note);
return entity;
}
[Fact]
public async Task InsertRange_returns_success()
{
await InsertRangeSuccess(dto);
}
[Fact]
public async Task InsertRange_returns_BadRequest_for_IdWellSectionType()
{
//arrange
var badDto = dto.Adapt<ProcessMapPlanSlideDto>();
badDto.IdWellSectionType = int.MaxValue;
await InsertRangeFailed(badDto);
}
[Fact]
public async Task ClearAndInsertRange_returns_success()
{
await ClearAndInsertRange(entity, dto);
}
[Fact]
public async Task UpdateOrInsertRange_returns_success()
{
var dtoUpdate = dto.Adapt<ProcessMapPlanSlideDto>();
dtoUpdate.IdWell = 0;
dtoUpdate.Note = "nebuchadnezzar";
dtoUpdate.DifferentialPressureLimitMax++;
dtoUpdate.DifferentialPressure++;
dtoUpdate.FlowRate++;
dtoUpdate.FlowRateLimitMax++;
dtoUpdate.RopLimitMax++;
dtoUpdate.WeightOnBit++;
dtoUpdate.WeightOnBitLimitMax++;
dtoUpdate.DepthStart++;
dtoUpdate.DepthEnd++;
dtoUpdate.Spring++;
dtoUpdate.ToolBuckling++;
var dtoInsert = dtoUpdate.Adapt<ProcessMapPlanSlideDto>();
dtoInsert.Id = 0;
dtoInsert.Note = "nebuchad";
dtoInsert.DifferentialPressureLimitMax++;
dtoInsert.DifferentialPressure++;
dtoInsert.FlowRate++;
dtoInsert.FlowRateLimitMax++;
dtoInsert.RopLimitMax++;
dtoInsert.WeightOnBit++;
dtoInsert.WeightOnBitLimitMax++;
dtoInsert.DepthStart++;
dtoInsert.DepthEnd++;
dtoUpdate.Spring++;
dtoUpdate.ToolBuckling++;
await UpdateOrInsertRange(entity, dtoUpdate, dtoInsert);
}
[Fact]
public async Task DeleteRange_returns_success()
{
await DeleteRange(entity, dto);
}
[Fact]
public async Task Clear_returns_success()
{
await Clear(entity, dto);
}
[Fact]
public async Task GetDatesChange_returns_success()
{
await GetDatesChange(entity, dto);
}
[Fact]
public async Task Get_actual_returns_success()
{
await Get(entity, dto);
}
[Fact]
public async Task Get_at_moment_returns_success()
{
await GetAtMoment(entity, dto);
}
[Fact]
public async Task Get_by_updated_from_returns_success()
{
await GetByUpdated(entity, dto);
}
[Fact]
public async Task Get_updated_returns_success()
{
await GetUpdated(entity, dto);
}
[Fact]
public async Task Parse_returns_success()
{
await Parse(dto.IdWell, "ProcessMapPlanSlideValid.xlsx", dto);
}
[Fact]
public async Task Parse_returns_success_for_result_with_warnings()
{
await ParseWithWarnings(dto.IdWell, "ProcessMapPlanSlideInvalid.xlsx");
}
}

View File

@ -1,256 +1,256 @@
using AsbCloudApp.Requests; //using AsbCloudApp.Requests;
using AsbCloudDb.Model; //using AsbCloudDb.Model;
using AsbCloudDb.Model.ProcessMaps; //using AsbCloudDb.Model.ProcessMaps;
using AsbCloudWebApi.IntegrationTests.Clients; //using AsbCloudWebApi.IntegrationTests.Clients;
using System.Net; //using System.Net;
using AsbCloudWebApi.IntegrationTests.Data; //using AsbCloudWebApi.IntegrationTests.Data;
using Xunit; //using Xunit;
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan; //namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
public class ProcessMapReportDrillingControllerTest : BaseIntegrationTest //public class ProcessMapReportDrillingControllerTest : BaseIntegrationTest
{ //{
private IProcessMapReportDrilling client; // private IProcessMapReportDrilling client;
public ProcessMapReportDrillingControllerTest(WebAppFactoryFixture factory) // public ProcessMapReportDrillingControllerTest(WebAppFactoryFixture factory)
: base(factory) // : base(factory)
{ // {
dbContext.CleanupDbSet<DataSaubStat>(); // dbContext.CleanupDbSet<DataSaubStat>();
dbContext.CleanupDbSet<ProcessMapPlanDrilling>(); // dbContext.CleanupDbSet<ProcessMapPlanDrilling>();
client = factory.GetAuthorizedHttpClient<IProcessMapReportDrilling>(string.Empty); // client = factory.GetAuthorizedHttpClient<IProcessMapReportDrilling>(string.Empty);
} // }
[Fact] // [Fact]
public async Task Get_rtk_report_by_default_request_returns_success() // public async Task Get_rtk_report_by_default_request_returns_success()
{ // {
//arrange // //arrange
var well = dbContext.Wells.First(); // var well = dbContext.Wells.First();
var processMapPlanDrilling = CreateProcessMapPlanDrilling(well.Id); // var processMapPlanDrilling = CreateProcessMapPlanDrilling(well.Id);
dbContext.ProcessMapPlanDrilling.Add(processMapPlanDrilling); // dbContext.ProcessMapPlanDrilling.Add(processMapPlanDrilling);
var wellOperation = CreateWellOperation(well.Id); // var wellOperation = CreateWellOperation(well.Id);
dbContext.WellOperations.Add(wellOperation); // dbContext.WellOperations.Add(wellOperation);
var dataSaubStats = CreateDataSaubStats(well.IdTelemetry!.Value, wellOperation.IdCategory); // var dataSaubStats = CreateDataSaubStats(well.IdTelemetry!.Value, wellOperation.IdCategory);
dbContext.DataSaubStat.AddRange(dataSaubStats); // dbContext.DataSaubStat.AddRange(dataSaubStats);
await dbContext.SaveChangesAsync(); // await dbContext.SaveChangesAsync();
//act // //act
var request = new DataSaubStatRequest(); // var request = new DataSaubStatRequest();
var response = await client.GetReportAsync(well.Id, request, CancellationToken.None); // var response = await client.GetReportAsync(well.Id, request, CancellationToken.None);
//assert // //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); // Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content); // Assert.NotNull(response.Content);
Assert.Equal(dataSaubStats.Count() - 1, response.Content.Count()); // Assert.Equal(dataSaubStats.Count() - 1, response.Content.Count());
} // }
[Fact] // [Fact]
public async Task Get_rtk_report_by_parametrize_request_returns_success() // public async Task Get_rtk_report_by_parametrize_request_returns_success()
{ // {
//arrange // //arrange
var well = dbContext.Wells.First(); // var well = dbContext.Wells.First();
var processMapPlanDrilling = CreateProcessMapPlanDrilling(well.Id); // var processMapPlanDrilling = CreateProcessMapPlanDrilling(well.Id);
dbContext.ProcessMapPlanDrilling.Add(processMapPlanDrilling); // dbContext.ProcessMapPlanDrilling.Add(processMapPlanDrilling);
var wellOperation = CreateWellOperation(well.Id); // var wellOperation = CreateWellOperation(well.Id);
dbContext.WellOperations.Add(wellOperation); // dbContext.WellOperations.Add(wellOperation);
var dataSaubStats = CreateDataSaubStats(well.IdTelemetry!.Value, wellOperation.IdCategory); // var dataSaubStats = CreateDataSaubStats(well.IdTelemetry!.Value, wellOperation.IdCategory);
dbContext.DataSaubStat.AddRange(dataSaubStats); // dbContext.DataSaubStat.AddRange(dataSaubStats);
await dbContext.SaveChangesAsync(); // await dbContext.SaveChangesAsync();
var request = new DataSaubStatRequest // var request = new DataSaubStatRequest
{ // {
DeltaAxialLoad = 5, // DeltaAxialLoad = 5,
DeltaPressure = 15, // DeltaPressure = 15,
DeltaRotorTorque = 10 // DeltaRotorTorque = 10
}; // };
//act // //act
var response = await client.GetReportAsync(well.Id, request, CancellationToken.None); // var response = await client.GetReportAsync(well.Id, request, CancellationToken.None);
//assert // //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); // Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content); // Assert.NotNull(response.Content);
Assert.Single(response.Content); // Assert.Single(response.Content);
} // }
[Fact] // [Fact]
public async Task Get_rtk_report_returns_BadRequest() // public async Task Get_rtk_report_returns_BadRequest()
{ // {
//act // //act
var request = new DataSaubStatRequest() // var request = new DataSaubStatRequest()
{ // {
DeltaAxialLoad = 15, // DeltaAxialLoad = 15,
DeltaPressure = 25, // DeltaPressure = 25,
DeltaRotorTorque = 20 // DeltaRotorTorque = 20
}; // };
var response = await client.GetReportAsync(0, request, CancellationToken.None); // var response = await client.GetReportAsync(0, request, CancellationToken.None);
//assert // //assert
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); // Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
} // }
[Fact] // [Fact]
public async Task Export_rtk_report_returns_success() // public async Task Export_rtk_report_returns_success()
{ // {
//arrange // //arrange
var well = dbContext.Wells.First(); // var well = dbContext.Wells.First();
var processMapPlanDrilling = CreateProcessMapPlanDrilling(well.Id); // var processMapPlanDrilling = CreateProcessMapPlanDrilling(well.Id);
dbContext.ProcessMapPlanDrilling.Add(processMapPlanDrilling); // dbContext.ProcessMapPlanDrilling.Add(processMapPlanDrilling);
var wellOperation = CreateWellOperation(well.Id); // var wellOperation = CreateWellOperation(well.Id);
dbContext.WellOperations.Add(wellOperation); // dbContext.WellOperations.Add(wellOperation);
var dataSaubStats = CreateDataSaubStats(well.IdTelemetry!.Value, wellOperation.IdCategory); // var dataSaubStats = CreateDataSaubStats(well.IdTelemetry!.Value, wellOperation.IdCategory);
dbContext.DataSaubStat.AddRange(dataSaubStats); // dbContext.DataSaubStat.AddRange(dataSaubStats);
await dbContext.SaveChangesAsync(); // await dbContext.SaveChangesAsync();
//act // //act
var request = new DataSaubStatRequest(); // var request = new DataSaubStatRequest();
var response = await client.ExportReportAsync(1, request, CancellationToken.None); // var response = await client.ExportReportAsync(1, request, CancellationToken.None);
//assert // //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); // Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal("application/octet-stream", response.ContentHeaders?.ContentType?.MediaType); // Assert.Equal("application/octet-stream", response.ContentHeaders?.ContentType?.MediaType);
Assert.True(response.ContentHeaders?.ContentLength > 0); // Assert.True(response.ContentHeaders?.ContentLength > 0);
} // }
private static WellOperation CreateWellOperation(int idWell) => // private static WellOperation CreateWellOperation(int idWell) =>
new() // new()
{ // {
CategoryInfo = "CategoryInfo", // CategoryInfo = "CategoryInfo",
Comment = "Comment", // Comment = "Comment",
DateStart = DateTimeOffset.UtcNow, // DateStart = DateTimeOffset.UtcNow,
DepthEnd = 1, // DepthEnd = 1,
DepthStart = 0.6, // DepthStart = 0.6,
DurationHours = 10, // DurationHours = 10,
IdCategory = WellOperationCategory.IdSlide, // IdCategory = WellOperationCategory.IdSlide,
IdPlan = null, // IdPlan = null,
IdType = WellOperation.IdOperationTypeFact, // IdType = WellOperation.IdOperationTypeFact,
IdUser = 1, // IdUser = 1,
IdWell = idWell, // IdWell = idWell,
IdWellSectionType = 1, // IdWellSectionType = 1,
LastUpdateDate = DateTimeOffset.UtcNow // LastUpdateDate = DateTimeOffset.UtcNow
}; // };
private static ProcessMapPlanDrilling CreateProcessMapPlanDrilling(int idWell) => // private static ProcessMapPlanDrilling CreateProcessMapPlanDrilling(int idWell) =>
new() // new()
{ // {
IdAuthor = 1, // IdAuthor = 1,
IdEditor = null, // IdEditor = null,
Creation = DateTimeOffset.UtcNow, // Creation = DateTimeOffset.UtcNow,
Obsolete = null, // Obsolete = null,
IdState = ChangeLogAbstract.IdStateActual, // IdState = ChangeLogAbstract.IdStateActual,
IdPrevious = null, // IdPrevious = null,
IdWell = idWell, // IdWell = idWell,
IdWellSectionType = 1, // IdWellSectionType = 1,
DepthStart = 0.5, // DepthStart = 0.5,
DepthEnd = 1.5, // DepthEnd = 1.5,
IdMode = 1, // IdMode = 1,
AxialLoadPlan = 2.718281, // AxialLoadPlan = 2.718281,
AxialLoadLimitMax = 3.1415926, // AxialLoadLimitMax = 3.1415926,
DeltaPressurePlan = 4, // DeltaPressurePlan = 4,
DeltaPressureLimitMax = 5, // DeltaPressureLimitMax = 5,
TopDriveTorquePlan = 6, // TopDriveTorquePlan = 6,
TopDriveTorqueLimitMax = 7, // TopDriveTorqueLimitMax = 7,
TopDriveSpeedPlan = 8, // TopDriveSpeedPlan = 8,
TopDriveSpeedLimitMax = 9, // TopDriveSpeedLimitMax = 9,
FlowPlan = 10, // FlowPlan = 10,
FlowLimitMax = 11, // FlowLimitMax = 11,
RopPlan = 12, // RopPlan = 12,
UsageSaub = 13, // UsageSaub = 13,
UsageSpin = 14, // UsageSpin = 14,
Comment = "это тестовая запись", // Comment = "это тестовая запись",
}; // };
private static IEnumerable<DataSaubStat> CreateDataSaubStats(int idTelemetry, // private static IEnumerable<DataSaubStat> CreateDataSaubStats(int idTelemetry,
int idCategory) => // int idCategory) =>
new[] // new[]
{ // {
new DataSaubStat // new DataSaubStat
{ // {
AxialLoad = 0, // AxialLoad = 0,
AxialLoadLimitMax = 10, // AxialLoadLimitMax = 10,
AxialLoadSp = 8, // AxialLoadSp = 8,
BlockSpeedSp = 50.0, // BlockSpeedSp = 50.0,
DateEnd = DateTimeOffset.UtcNow.AddMinutes(40), // DateEnd = DateTimeOffset.UtcNow.AddMinutes(40),
DateStart = DateTimeOffset.UtcNow.AddMinutes(30), // DateStart = DateTimeOffset.UtcNow.AddMinutes(30),
DepthEnd = 85.99299621582031, // DepthEnd = 85.99299621582031,
DepthStart = 85.9260025024414, // DepthStart = 85.9260025024414,
EnabledSubsystems = 0, // EnabledSubsystems = 0,
Flow = 10, // Flow = 10,
IdCategory = idCategory, // IdCategory = idCategory,
HasOscillation = true, // HasOscillation = true,
IdFeedRegulator = 0, // IdFeedRegulator = 0,
IdTelemetry = idTelemetry, // IdTelemetry = idTelemetry,
Pressure = 24, // Pressure = 24,
PressureIdle = 0, // PressureIdle = 0,
PressureSp = 40, // PressureSp = 40,
RotorSpeed = 11.3, // RotorSpeed = 11.3,
RotorTorque = 1, // RotorTorque = 1,
RotorTorqueLimitMax = 26.5, // RotorTorqueLimitMax = 26.5,
RotorTorqueSp = 5, // RotorTorqueSp = 5,
Speed = 80.3924560546875 // Speed = 80.3924560546875
}, // },
new DataSaubStat // new DataSaubStat
{ // {
AxialLoad = 2, // AxialLoad = 2,
AxialLoadLimitMax = 10.0, // AxialLoadLimitMax = 10.0,
AxialLoadSp = 8, // AxialLoadSp = 8,
BlockSpeedSp = 20, // BlockSpeedSp = 20,
DateEnd = DateTimeOffset.UtcNow.AddMinutes(30), // DateEnd = DateTimeOffset.UtcNow.AddMinutes(30),
DateStart = DateTimeOffset.UtcNow.AddMinutes(20), // DateStart = DateTimeOffset.UtcNow.AddMinutes(20),
DepthEnd = 86.28099822998047, // DepthEnd = 86.28099822998047,
DepthStart = 86.21900177001953, // DepthStart = 86.21900177001953,
EnabledSubsystems = 1, // EnabledSubsystems = 1,
Flow = 20, // Flow = 20,
HasOscillation = true, // HasOscillation = true,
IdCategory = idCategory, // IdCategory = idCategory,
IdFeedRegulator = 1, // IdFeedRegulator = 1,
IdTelemetry = idTelemetry, // IdTelemetry = idTelemetry,
Pressure = 30, // Pressure = 30,
PressureIdle = 20, // PressureIdle = 20,
PressureSp = 40, // PressureSp = 40,
RotorSpeed = 11.251153300212916, // RotorSpeed = 11.251153300212916,
RotorTorque = 7, // RotorTorque = 7,
RotorTorqueLimitMax = 26.5, // RotorTorqueLimitMax = 26.5,
RotorTorqueSp = 9, // RotorTorqueSp = 9,
Speed = 74.395751953125 // Speed = 74.395751953125
}, // },
new DataSaubStat // new DataSaubStat
{ // {
AxialLoad = 4, // AxialLoad = 4,
AxialLoadLimitMax = 15.0, // AxialLoadLimitMax = 15.0,
AxialLoadSp = 8, // AxialLoadSp = 8,
BlockSpeedSp = 110.0, // BlockSpeedSp = 110.0,
DateEnd = DateTimeOffset.UtcNow.AddMinutes(20), // DateEnd = DateTimeOffset.UtcNow.AddMinutes(20),
DateStart = DateTimeOffset.UtcNow.AddMinutes(10), // DateStart = DateTimeOffset.UtcNow.AddMinutes(10),
DepthEnd = 106.7490005493164, // DepthEnd = 106.7490005493164,
DepthStart = 106.47899627685547, // DepthStart = 106.47899627685547,
EnabledSubsystems = 1, // EnabledSubsystems = 1,
Flow = 30, // Flow = 30,
HasOscillation = true, // HasOscillation = true,
IdFeedRegulator = 1, // IdFeedRegulator = 1,
IdTelemetry = idTelemetry, // IdTelemetry = idTelemetry,
IdCategory = idCategory, // IdCategory = idCategory,
Pressure = 36, // Pressure = 36,
PressureIdle = 23.0, // PressureIdle = 23.0,
PressureSp = 63.0, // PressureSp = 63.0,
RotorSpeed = 11.334207942999628, // RotorSpeed = 11.334207942999628,
RotorTorque = 14, // RotorTorque = 14,
RotorTorqueLimitMax = 15.0, // RotorTorqueLimitMax = 15.0,
RotorTorqueSp = 13, // RotorTorqueSp = 13,
Speed = 108.001708984375 // Speed = 108.001708984375
} // }
}; // };
} //}

View File

@ -1,297 +1,297 @@
using AsbCloudApp.Data; //using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMaps; //using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Data.WellOperation; //using AsbCloudApp.Data.WellOperation;
using AsbCloudApp.Repositories; //using AsbCloudApp.Repositories;
using AsbCloudApp.Requests; //using AsbCloudApp.Requests;
using AsbCloudApp.Services; //using AsbCloudApp.Services;
using AsbCloudDb.Model; //using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.ProcessMaps.Report; //using AsbCloudInfrastructure.Services.ProcessMaps.Report;
using NSubstitute; //using NSubstitute;
using System; //using System;
using System.Collections.Generic; //using System.Collections.Generic;
using System.Linq; //using System.Linq;
using System.Threading; //using System.Threading;
using System.Threading.Tasks; //using System.Threading.Tasks;
using Xunit; //using Xunit;
namespace AsbCloudWebApi.Tests.Services.ProcessMaps; //namespace AsbCloudWebApi.Tests.Services.ProcessMaps;
public class ProcessMapReportDataSaubStatServiceTest //public class ProcessMapReportDataSaubStatServiceTest
{ //{
private IWellService wellService // private IWellService wellService
= Substitute.For<IWellService>(); // = Substitute.For<IWellService>();
private IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository // private IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository
= Substitute.For<IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell>>(); // = Substitute.For<IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell>>();
private IWellOperationRepository wellOperationRepository // private IWellOperationRepository wellOperationRepository
= Substitute.For<IWellOperationRepository>(); // = Substitute.For<IWellOperationRepository>();
private IWellOperationCategoryRepository wellOperationCategoryRepository // private IWellOperationCategoryRepository wellOperationCategoryRepository
= Substitute.For<IWellOperationCategoryRepository>(); // = Substitute.For<IWellOperationCategoryRepository>();
private IDataSaubStatRepository dataSaubStatRepository // private IDataSaubStatRepository dataSaubStatRepository
= Substitute.For<IDataSaubStatRepository>(); // = Substitute.For<IDataSaubStatRepository>();
private ProcessMapReportDrillingService service; // private ProcessMapReportDrillingService service;
private readonly static SimpleTimezoneDto timezone = new() { Hours = 2 }; // private readonly static SimpleTimezoneDto timezone = new() { Hours = 2 };
private static readonly DateTimeOffset dateStart = new(2024, 01, 01, 00, 11, 11, timezone.Offset); // private static readonly DateTimeOffset dateStart = new(2024, 01, 01, 00, 11, 11, timezone.Offset);
private readonly static WellDto well = new() // private readonly static WellDto well = new()
{ // {
Id = 1, // Id = 1,
IdTelemetry = 1, // IdTelemetry = 1,
Timezone = timezone // Timezone = timezone
}; // };
private readonly static IEnumerable<ProcessMapPlanDrillingDto> processMapPlan = new List<ProcessMapPlanDrillingDto>() // private readonly static IEnumerable<ProcessMapPlanBaseDto> processMapPlan = new List<ProcessMapPlanBaseDto>()
{ // {
new() { // new() {
DepthStart = 0, // DepthStart = 0,
DepthEnd = 100, // DepthEnd = 100,
IdMode = 1, // IdMode = 1,
IdWell = well.Id, // IdWell = well.Id,
IdWellSectionType = 1, // IdWellSectionType = 1,
AxialLoadPlan = 0.2, // AxialLoadPlan = 0.2,
AxialLoadLimitMax = 0.3, // AxialLoadLimitMax = 0.3,
DeltaPressurePlan = 0.4, // DeltaPressurePlan = 0.4,
DeltaPressureLimitMax = 0.5, // DeltaPressureLimitMax = 0.5,
TopDriveTorquePlan = 0.6, // TopDriveTorquePlan = 0.6,
TopDriveTorqueLimitMax = 0.7, // TopDriveTorqueLimitMax = 0.7,
TopDriveSpeedPlan = 0.8, // TopDriveSpeedPlan = 0.8,
TopDriveSpeedLimitMax = 0.9, // TopDriveSpeedLimitMax = 0.9,
FlowPlan = 0.10, // FlowPlan = 0.10,
FlowLimitMax = 0.11, // FlowLimitMax = 0.11,
RopPlan = 0.12, // RopPlan = 0.12,
UsageSaub = 0.12, // UsageSaub = 0.12,
UsageSpin = 0.14, // UsageSpin = 0.14,
Comment = "r", // Comment = "r",
}, // },
new() { // new() {
DepthStart = 0, // DepthStart = 0,
DepthEnd = 100, // DepthEnd = 100,
IdMode = 2, // IdMode = 2,
IdWell = well.Id, // IdWell = well.Id,
IdWellSectionType = 1, // IdWellSectionType = 1,
AxialLoadPlan = 0.12, // AxialLoadPlan = 0.12,
AxialLoadLimitMax = 0.13, // AxialLoadLimitMax = 0.13,
DeltaPressurePlan = 0.14, // DeltaPressurePlan = 0.14,
DeltaPressureLimitMax = 0.15, // DeltaPressureLimitMax = 0.15,
TopDriveTorquePlan = 0.16, // TopDriveTorquePlan = 0.16,
TopDriveTorqueLimitMax = 0.17, // TopDriveTorqueLimitMax = 0.17,
TopDriveSpeedPlan = 0.18, // TopDriveSpeedPlan = 0.18,
TopDriveSpeedLimitMax = 0.19, // TopDriveSpeedLimitMax = 0.19,
FlowPlan = 0.110, // FlowPlan = 0.110,
FlowLimitMax = 0.111, // FlowLimitMax = 0.111,
RopPlan = 0.112, // RopPlan = 0.112,
UsageSaub = 0.112, // UsageSaub = 0.112,
UsageSpin = 0.114, // UsageSpin = 0.114,
Comment = "s", // Comment = "s",
}, // },
new() { // new() {
DepthStart = 100, // DepthStart = 100,
DepthEnd = 200, // DepthEnd = 200,
IdMode = 1, // IdMode = 1,
IdWell = well.Id, // IdWell = well.Id,
IdWellSectionType = 1, // IdWellSectionType = 1,
AxialLoadPlan = 0.22, // AxialLoadPlan = 0.22,
AxialLoadLimitMax = 0.23, // AxialLoadLimitMax = 0.23,
DeltaPressurePlan = 0.24, // DeltaPressurePlan = 0.24,
DeltaPressureLimitMax = 0.25, // DeltaPressureLimitMax = 0.25,
TopDriveTorquePlan = 0.26, // TopDriveTorquePlan = 0.26,
TopDriveTorqueLimitMax = 0.27, // TopDriveTorqueLimitMax = 0.27,
TopDriveSpeedPlan = 0.28, // TopDriveSpeedPlan = 0.28,
TopDriveSpeedLimitMax = 0.29, // TopDriveSpeedLimitMax = 0.29,
FlowPlan = 0.210, // FlowPlan = 0.210,
FlowLimitMax = 0.211, // FlowLimitMax = 0.211,
RopPlan = 0.212, // RopPlan = 0.212,
UsageSaub = 0.212, // UsageSaub = 0.212,
UsageSpin = 0.214, // UsageSpin = 0.214,
Comment = "r", // Comment = "r",
}, // },
new() { // new() {
DepthStart = 100, // DepthStart = 100,
DepthEnd = 200, // DepthEnd = 200,
IdMode = 2, // IdMode = 2,
IdWell = well.Id, // IdWell = well.Id,
IdWellSectionType = 1, // IdWellSectionType = 1,
AxialLoadPlan = 0.32, // AxialLoadPlan = 0.32,
AxialLoadLimitMax = 0.33, // AxialLoadLimitMax = 0.33,
DeltaPressurePlan = 0.34, // DeltaPressurePlan = 0.34,
DeltaPressureLimitMax = 0.35, // DeltaPressureLimitMax = 0.35,
TopDriveTorquePlan = 0.36, // TopDriveTorquePlan = 0.36,
TopDriveTorqueLimitMax = 0.37, // TopDriveTorqueLimitMax = 0.37,
TopDriveSpeedPlan = 0.38, // TopDriveSpeedPlan = 0.38,
TopDriveSpeedLimitMax = 0.39, // TopDriveSpeedLimitMax = 0.39,
FlowPlan = 0.310, // FlowPlan = 0.310,
FlowLimitMax = 0.311, // FlowLimitMax = 0.311,
RopPlan = 0.312, // RopPlan = 0.312,
UsageSaub = 0.312, // UsageSaub = 0.312,
UsageSpin = 0.314, // UsageSpin = 0.314,
Comment = "s", // Comment = "s",
}, // },
}; // };
private readonly static IEnumerable<ChangeLogDto<ProcessMapPlanDrillingDto>> processMapPlanChangeLog = processMapPlan.Select(p => new ChangeLogDto<ProcessMapPlanDrillingDto>() // private readonly static IEnumerable<ChangeLogDto<ProcessMapPlanDrillingDto>> processMapPlanChangeLog = processMapPlan.Select(p => new ChangeLogDto<ProcessMapPlanDrillingDto>()
{ // {
Item = p, // Item = p,
}); // });
private readonly static IEnumerable<WellOperationDto> operations = new List<WellOperationDto>() // private readonly static IEnumerable<WellOperationDto> operations = new List<WellOperationDto>()
{ // {
new() // new()
{ // {
Id = 1, // Id = 1,
IdWell = well.Id, // IdWell = well.Id,
IdWellSectionType = 1, // IdWellSectionType = 1,
IdCategory = WellOperationCategory.IdRotor, // IdCategory = WellOperationCategory.IdRotor,
IdParentCategory = WellOperationCategory.IdMechanicalDrilling, // IdParentCategory = WellOperationCategory.IdMechanicalDrilling,
IdType = WellOperation.IdOperationTypeFact, // IdType = WellOperation.IdOperationTypeFact,
DepthStart = 0, // DepthStart = 0,
DepthEnd = 10, // DepthEnd = 10,
DateStart = dateStart, // DateStart = dateStart,
DurationHours = 1, // DurationHours = 1,
}, // },
new() // new()
{ // {
Id = 1, // Id = 1,
IdWell = well.Id, // IdWell = well.Id,
IdWellSectionType = 2, // IdWellSectionType = 2,
IdCategory = WellOperationCategory.IdRotor, // IdCategory = WellOperationCategory.IdRotor,
IdParentCategory = WellOperationCategory.IdMechanicalDrilling, // IdParentCategory = WellOperationCategory.IdMechanicalDrilling,
IdType = WellOperation.IdOperationTypeFact, // IdType = WellOperation.IdOperationTypeFact,
DepthStart = 50, // DepthStart = 50,
DepthEnd = 100, // DepthEnd = 100,
DateStart = dateStart, // DateStart = dateStart,
DurationHours = 1, // DurationHours = 1,
} // }
}; // };
private readonly static IEnumerable<WellOperationCategoryDto> operationCategories = new List<WellOperationCategoryDto>() // private readonly static IEnumerable<WellOperationCategoryDto> operationCategories = new List<WellOperationCategoryDto>()
{ // {
new(){Id = WellOperationCategory.IdRotor, IdParent = WellOperationCategory.IdMechanicalDrilling, Name = "РОТОР"}, // new(){Id = WellOperationCategory.IdRotor, IdParent = WellOperationCategory.IdMechanicalDrilling, Name = "РОТОР"},
new(){Id = WellOperationCategory.IdSlide, IdParent = WellOperationCategory.IdMechanicalDrilling, Name = "СЛАЙД"}, // new(){Id = WellOperationCategory.IdSlide, IdParent = WellOperationCategory.IdMechanicalDrilling, Name = "СЛАЙД"},
}; // };
private readonly static IEnumerable<WellSectionTypeDto> sectionTypes = new List<WellSectionTypeDto>() { // private readonly static IEnumerable<WellSectionTypeDto> sectionTypes = new List<WellSectionTypeDto>() {
new(){ Id = 1, Caption = "Секция 1"}, // new(){ Id = 1, Caption = "Секция 1"},
new(){ Id = 2, Caption = "Секция 2"}, // new(){ Id = 2, Caption = "Секция 2"},
new(){ Id = 3, Caption = "Секция 3"}, // new(){ Id = 3, Caption = "Секция 3"},
new(){ Id = 4, Caption = "Секция 4"}, // new(){ Id = 4, Caption = "Секция 4"},
}; // };
private readonly static IEnumerable<DataSaubStatDto> dataSaubStat = new List<DataSaubStatDto>() { // private readonly static IEnumerable<DataSaubStatDto> dataSaubStat = new List<DataSaubStatDto>() {
new(){ // new(){
Id = 1, // Id = 1,
IdTelemetry = 1, // IdTelemetry = 1,
IdCategory = WellOperationCategory.IdRotor, // IdCategory = WellOperationCategory.IdRotor,
DateStart = dateStart, // DateStart = dateStart,
DateEnd = dateStart.AddHours(3.25), // DateEnd = dateStart.AddHours(3.25),
DepthStart = 0, // DepthStart = 0,
DepthEnd = 20, // DepthEnd = 20,
Speed = 0.1, // Speed = 0.1,
BlockSpeedSp = 0.2, // BlockSpeedSp = 0.2,
Pressure = 0.3, // Pressure = 0.3,
PressureIdle = 0.4, // PressureIdle = 0.4,
PressureSp = 0.5, // PressureSp = 0.5,
AxialLoad = 0.6, // AxialLoad = 0.6,
AxialLoadSp = 0.7, // AxialLoadSp = 0.7,
AxialLoadLimitMax = 0.8, // AxialLoadLimitMax = 0.8,
RotorTorque = 0.9, // RotorTorque = 0.9,
RotorTorqueSp = 0.11, // RotorTorqueSp = 0.11,
RotorTorqueLimitMax = 0.12, // RotorTorqueLimitMax = 0.12,
RotorSpeed = 0.14, // RotorSpeed = 0.14,
Flow = 0.17, // Flow = 0.17,
IdFeedRegulator = LimitingParameterDto.AxialLoad, // IdFeedRegulator = LimitingParameterDto.AxialLoad,
EnabledSubsystems = 15, // EnabledSubsystems = 15,
HasOscillation = false, // HasOscillation = false,
}, // },
new(){ // new(){
Id = 1, // Id = 1,
IdTelemetry = 1, // IdTelemetry = 1,
IdCategory = WellOperationCategory.IdRotor, // IdCategory = WellOperationCategory.IdRotor,
DateStart = dateStart.AddHours(3.25), // DateStart = dateStart.AddHours(3.25),
DateEnd = dateStart.AddHours(4.25), // DateEnd = dateStart.AddHours(4.25),
DepthStart = 20, // DepthStart = 20,
DepthEnd = 190, // DepthEnd = 190,
Speed = 0.21, // Speed = 0.21,
BlockSpeedSp = 0.22, // BlockSpeedSp = 0.22,
Pressure = 0.23, // Pressure = 0.23,
PressureIdle = 0.24, // PressureIdle = 0.24,
PressureSp = 0.25, // PressureSp = 0.25,
AxialLoad = 0.26, // AxialLoad = 0.26,
AxialLoadSp = 0.27, // AxialLoadSp = 0.27,
AxialLoadLimitMax = 0.28, // AxialLoadLimitMax = 0.28,
RotorTorque = 0.29, // RotorTorque = 0.29,
RotorTorqueSp = 0.211, // RotorTorqueSp = 0.211,
RotorTorqueLimitMax = 0.212, // RotorTorqueLimitMax = 0.212,
RotorSpeed = 0.214, // RotorSpeed = 0.214,
Flow = 0.217, // Flow = 0.217,
IdFeedRegulator = LimitingParameterDto.AxialLoad, // IdFeedRegulator = LimitingParameterDto.AxialLoad,
EnabledSubsystems = 15, // EnabledSubsystems = 15,
HasOscillation = false, // HasOscillation = false,
}, // },
new(){ // new(){
Id = 1, // Id = 1,
IdTelemetry = 1, // IdTelemetry = 1,
IdCategory = WellOperationCategory.IdRotor, // IdCategory = WellOperationCategory.IdRotor,
DateStart = dateStart.AddHours(4.25), // DateStart = dateStart.AddHours(4.25),
DateEnd = dateStart.AddHours(16), // DateEnd = dateStart.AddHours(16),
DepthStart = 190, // DepthStart = 190,
DepthEnd = 290, // DepthEnd = 290,
Speed = 0.31, // Speed = 0.31,
BlockSpeedSp = 0.32, // BlockSpeedSp = 0.32,
Pressure = 0.33, // Pressure = 0.33,
PressureIdle = 0.34, // PressureIdle = 0.34,
PressureSp = 0.35, // PressureSp = 0.35,
AxialLoad = 0.36, // AxialLoad = 0.36,
AxialLoadSp = 0.37, // AxialLoadSp = 0.37,
AxialLoadLimitMax = 0.38, // AxialLoadLimitMax = 0.38,
RotorTorque = 0.39, // RotorTorque = 0.39,
RotorTorqueSp = 0.231, // RotorTorqueSp = 0.231,
RotorTorqueLimitMax = 0.232, // RotorTorqueLimitMax = 0.232,
RotorSpeed = 0.234, // RotorSpeed = 0.234,
Flow = 0.237, // Flow = 0.237,
IdFeedRegulator = LimitingParameterDto.AxialLoad, // IdFeedRegulator = LimitingParameterDto.AxialLoad,
EnabledSubsystems = 15, // EnabledSubsystems = 15,
HasOscillation = false, // HasOscillation = false,
} // }
}; // };
public ProcessMapReportDataSaubStatServiceTest() // public ProcessMapReportDataSaubStatServiceTest()
{ // {
wellService.GetOrDefaultAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()) // wellService.GetOrDefaultAsync(Arg.Any<int>(), Arg.Any<CancellationToken>())
.Returns(well); // .Returns(well);
processMapPlanBaseRepository.GetCurrent(Arg.Any<ProcessMapPlanBaseRequestWithWell>(), Arg.Any<CancellationToken>()) // processMapPlanBaseRepository.GetCurrent(Arg.Any<ProcessMapPlanBaseRequestWithWell>(), Arg.Any<CancellationToken>())
.Returns(processMapPlan); // .Returns(processMapPlan);
processMapPlanBaseRepository.GetChangeLogForDate(Arg.Any<ProcessMapPlanBaseRequestWithWell>(), null, Arg.Any<CancellationToken>()) // processMapPlanBaseRepository.GetChangeLogForDate(Arg.Any<ProcessMapPlanBaseRequestWithWell>(), null, Arg.Any<CancellationToken>())
.Returns(processMapPlanChangeLog); // .Returns(processMapPlanChangeLog);
wellOperationRepository.GetAsync(Arg.Any<WellOperationRequest>(), Arg.Any<CancellationToken>()) // wellOperationRepository.GetAsync(Arg.Any<WellOperationRequest>(), Arg.Any<CancellationToken>())
.Returns(operations); // .Returns(operations);
wellOperationRepository.GetSectionTypes() // wellOperationRepository.GetSectionTypes()
.Returns(sectionTypes); // .Returns(sectionTypes);
wellOperationCategoryRepository.Get(Arg.Any<bool>()) // wellOperationCategoryRepository.Get(Arg.Any<bool>())
.Returns(operationCategories); // .Returns(operationCategories);
dataSaubStatRepository.GetAsync(Arg.Any<int>(), Arg.Any<DateTimeOffset>(), Arg.Any<DateTimeOffset>(), Arg.Any<CancellationToken>()) // dataSaubStatRepository.GetAsync(Arg.Any<int>(), Arg.Any<DateTimeOffset>(), Arg.Any<DateTimeOffset>(), Arg.Any<CancellationToken>())
.Returns(dataSaubStat); // .Returns(dataSaubStat);
service = new ProcessMapReportDrillingService(wellService, processMapPlanBaseRepository, dataSaubStatRepository, wellOperationRepository, wellOperationCategoryRepository); // service = new ProcessMapReportDrillingService(wellService, processMapPlanBaseRepository, dataSaubStatRepository, wellOperationRepository, wellOperationCategoryRepository);
} // }
[Fact] // [Fact]
public async Task GetAsync_return_data() // public async Task GetAsync_return_data()
{ // {
// arrange // // arrange
DataSaubStatRequest request = new() { }; // DataSaubStatRequest request = new() { };
// act // // act
var result = await service.GetAsync(well.Id, request, CancellationToken.None); // var result = await service.GetAsync(well.Id, request, CancellationToken.None);
// assert // // assert
Assert.NotEmpty(result); // Assert.NotEmpty(result);
} // }
} //}

View File

@ -9,18 +9,18 @@ using AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
namespace AsbCloudWebApi.Controllers.ProcessMaps; namespace AsbCloudWebApi.Controllers.ProcessMaps;
/// <summary> /// <summary>
/// РТК план бурения /// РТК план бурения (ротор)
/// </summary> /// </summary>
public class ProcessMapPlanDrillingController : ProcessMapPlanBaseController<ProcessMapPlanDrilling, ProcessMapPlanDrillingDto> public class ProcessMapPlanRotorController : ProcessMapPlanBaseController<ProcessMapPlanRotor, ProcessMapPlanRotorDto>
{ {
public ProcessMapPlanDrillingController(IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> repository, public ProcessMapPlanRotorController(IChangeLogRepository<ProcessMapPlanRotorDto, ProcessMapPlanBaseRequestWithWell> repository,
IWellService wellService, IWellService wellService,
ProcessMapPlanDrillingParser parserService, ProcessMapPlanRotorParser parserService,
ITelemetryService telemetryService, ITelemetryService telemetryService,
ProcessMapPlanDrillingExportService processMapPlanExportService) ProcessMapPlanRotorExportService processMapPlanExportService)
: base(repository, wellService, parserService, processMapPlanExportService, telemetryService) : base(repository, wellService, parserService, processMapPlanExportService, telemetryService)
{ {
} }
protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_бурение.xlsx"; protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_бурение_ротор.xlsx";
} }

View File

@ -0,0 +1,26 @@
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudDb.Model.ProcessMaps;
using AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
using AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
namespace AsbCloudWebApi.Controllers.ProcessMaps;
/// <summary>
/// РТК план бурения (ротор)
/// </summary>
public class ProcessMapPlanSlideController : ProcessMapPlanBaseController<ProcessMapPlanSlide, ProcessMapPlanSlideDto>
{
public ProcessMapPlanSlideController(IChangeLogRepository<ProcessMapPlanSlideDto, ProcessMapPlanBaseRequestWithWell> repository,
IWellService wellService,
ProcessMapPlanSlideParser parserService,
ITelemetryService telemetryService,
ProcessMapPlanSlideExportService processMapPlanExportService)
: base(repository, wellService, parserService, processMapPlanExportService, telemetryService)
{
}
protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_бурение_слайд.xlsx";
}

View File

@ -182,7 +182,7 @@ public class WellSectionPlanController : ControllerBase
private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken) private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken)
{ {
_ = await wellSectionRepository.GetOrDefaultAsync(idWellSectionType, cancellationToken) _ = await wellSectionRepository.GetOrDefaultAsync(idWellSectionType, cancellationToken)
?? throw new ArgumentInvalidException(nameof(ProcessMapPlanDrillingDto.IdWellSectionType), ?? throw new ArgumentInvalidException(nameof(ProcessMapPlanBaseDto.IdWellSectionType),
$"Тип секции с Id: {idWellSectionType} не найден"); $"Тип секции с Id: {idWellSectionType} не найден");
} }
} }

View File

@ -73,7 +73,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns> /// <returns></returns>
[HttpGet("compositeProcessMap")] [HttpGet("compositeProcessMap")]
[Permission] [Permission]
[ProducesResponseType(typeof(IEnumerable<ProcessMapPlanDrillingDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<ProcessMapPlanBaseDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetCompositeProcessMap(int idWell, CancellationToken token) public async Task<IActionResult> GetCompositeProcessMap(int idWell, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))