remove all old processMaps

This commit is contained in:
Frolov-Nikita 2024-02-21 15:08:51 +05:00
parent 809e113ea5
commit 02d6b299b3
No known key found for this signature in database
GPG Key ID: 719E3386D12B0760
50 changed files with 19583 additions and 1274 deletions

View File

@ -1,51 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data.ProcessMapPlan;
/// <inheritdoc/>
public abstract class ProcessMapPlanBaseDto : ChangeLogAbstract, IId, IWellRelated, IValidatableObject
{
/// <summary>
/// Id скважины
/// </summary>
[Range(1, int.MaxValue, ErrorMessage = "Id скважины не может быть меньше 1")]
public int IdWell { get; set; }
/// <summary>
/// Тип секции
/// </summary>
[Range(1, int.MaxValue, ErrorMessage = "Id секции скважины не может быть меньше 1")]
public int IdWellSectionType { get; set; }
/// <summary>
/// Название секции
/// </summary>
public string? Section { get; set; }
/// <summary>
/// Глубина по стволу от, м
/// <para>
/// на начало интервала
/// </para>
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Глубина не может быть отрицательной")]
public double DepthStart { get; set; }
/// <summary>
/// Глубина по стволу до, м
/// <para>
/// на конец интервала
/// </para>
/// </summary>
[Range(0, 99999.9, ErrorMessage = "Глубина не может быть отрицательной")]
public double DepthEnd { get; set; }
/// <inheritdoc/>
public virtual IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(DepthEnd <= DepthStart)
yield return new ("Глубина окончания должна быть больше глубины начала", new string[] {nameof(DepthEnd), nameof(DepthStart) });
}
}

View File

@ -1,103 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data.ProcessMapPlan;
/// <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

@ -1,83 +0,0 @@
using AsbCloudApp.Data.ProcessMapPlan;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data.ProcessMaps;
/// <summary>
/// РТК план проработка скважины
/// </summary>
public class ProcessMapPlanWellReamDto : ProcessMapPlanBaseDto, IValidatableObject
{
/// <summary>
/// Количество повторений
/// </summary>
[Required]
[Range(0, 100, ErrorMessage = "Количество повторений должно быть в пределах от 0 до 100")]
public double Repeats { get; set; }
/// <summary>
/// Вращение при движении вверх, об/мин
/// </summary>
[Required]
[Range(0, 99999.9, ErrorMessage = "Количество вращений вверх должно быть в пределах от 0 до 99999.9")]
public double SpinUpward { get; set; }
/// <summary>
/// Вращение при движении вниз, об/мин
/// </summary>
[Required]
[Range(0, 99999.9, ErrorMessage = "Количество вращений вниз должно быть в пределах от 0 до 99999.9")]
public double SpinDownward { get; set; }
/// <summary>
/// Скорость подъёма, м/ч
/// </summary>
[Required]
[Range(0, 99999.9, ErrorMessage = "Скорость подъёма должна быть в пределах от 0 до 99999.9")]
public double SpeedUpward { get; set; }
/// <summary>
/// Скорость спуска, м/ч
/// </summary>
[Required]
[Range(0, 99999.9, ErrorMessage = "Скорость спуска должна быть в пределах от 0 до 99999.9")]
public double SpeedDownward { get; set; }
/// <summary>
/// Уставка зятяжки, т
/// </summary>
[Required]
[Range(0, 99999.9, ErrorMessage = "Значение затяжек уставки должно быть в пределах от 0 до 99999.9")]
public double SetpointDrag { get; set; }
/// <summary>
/// Уставка посадки, т
/// </summary>
[Required]
[Range(0, 99999.9, ErrorMessage = "Значение посадки уставки должно быть в пределах от 0 до 99999.9")]
public double SetpointTight { get; set; }
/// <summary>
/// Давление, атм
/// </summary>
[Required]
[Range(0, 99999.9, ErrorMessage = "Давление должно быть в пределах от 0 до 99999.9")]
public double Pressure { get; set; }
/// <summary>
/// Момент, кН*м
/// </summary>
[Required]
[Range(0, 99999.9, ErrorMessage = "Крутящий момент должен быть в пределах от 0 до 99999.9")]
public double Torque { get; set; }
/// <inheritdoc/>
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (DepthEnd < DepthStart)
yield return new ValidationResult(
$"{nameof(DepthEnd)}:{DepthEnd:#0.0} меньше {nameof(DepthStart)}:{DepthStart:#0.0}",
new[] { nameof(DepthEnd), nameof(DepthStart) });
}
}

View File

@ -93,6 +93,4 @@ public interface IChangeLogRepository<TDto, TRequest>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<TDto>> Get(TRequest request, CancellationToken token);
}

View File

@ -1,5 +1,5 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

View File

@ -8,7 +8,7 @@ namespace AsbCloudApp.Requests;
public class ChangeLogBaseRequest
{
/// <summary>
/// Дата/время на которую записи были актуальны. Если не задано, то не фильтруется
/// Дата/время на которую записи были актуальны. Если не задано, то возвращаются все данные без учета их актуальности
/// </summary>
public DateTimeOffset? Moment { get; set; }
}

View File

@ -1,39 +0,0 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Threading;
namespace AsbCloudApp.Services.ProcessMaps;
/// <summary>
/// Сервис импорта РТК
/// </summary>
[Obsolete]
public interface IProcessMapPlanImportService
{
/// <summary>
/// Загрузить данные из файла
/// </summary>
/// <param name="idWell"></param>
/// <param name="idUser"></param>
/// <param name="deleteBeforeImport"></param>
/// <param name="stream"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task ImportAsync(int idWell, int idUser, bool deleteBeforeImport, Stream stream,
CancellationToken cancellationToken);
/// <summary>
/// Сформировать файл с данными
/// </summary>
/// <param name="idWell"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<(string Name, Stream File)> ExportAsync(int idWell, CancellationToken cancellationToken);
/// <summary>
/// Получение шаблона для заполнения
/// </summary>
/// <returns></returns>
Task<(string Name, Stream File)> GetExcelTemplateStreamAsync(CancellationToken cancellationToken);
}

View File

@ -1,22 +0,0 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
namespace AsbCloudApp.Services.ProcessMaps;
/// <summary>
/// РТК
/// </summary>
public interface IProcessMapPlanService<T>
where T : ProcessMapPlanBaseDto
{
/// <summary>
/// Получение РТК план по скважине
/// </summary>
/// <param name="idWell"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<IEnumerable<ValidationResultDto<T>>> GetAsync(int idWell, CancellationToken cancellationToken);
}

View File

@ -1,26 +0,0 @@
using AsbCloudApp.Data.ProcessMaps.Report;
using AsbCloudApp.Requests;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudApp.Services.ProcessMaps.WellDrilling
{
/// <summary>
/// Получить РТК-отчет по бурению
/// </summary>
public interface IProcessMapReportDataSaubStatService
{
/// <summary>
/// Получения строк РТК-отчёта
/// </summary>
/// <param name="idWell">ключ скважины</param>
/// <param name="request">параметры запроса</param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<ProcessMapReportDataSaubStatDto>> GetAsync(int idWell, DataSaubStatRequest request, CancellationToken token);
}
}

View File

@ -12,7 +12,7 @@ namespace AsbCloudApp.Services.ProcessMaps.WellDrilling
/// <summary>
/// Сервис экспорт РТК
/// </summary>
public interface IProcessMapReportDataSaubStatExportService
public interface IProcessMapReportDrillingExportService
{
/// <summary>
/// Сформировать файл с данными

View File

@ -0,0 +1,22 @@
using AsbCloudApp.Data.ProcessMaps.Report;
using AsbCloudApp.Requests;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudApp.Services.ProcessMaps.WellDrilling;
/// <summary>
/// РТК-отчет по бурению
/// </summary>
public interface IProcessMapReportDrillingService
{
/// <summary>
/// Получения строк РТК-отчёта
/// </summary>
/// <param name="idWell">ключ скважины</param>
/// <param name="request">параметры запроса</param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<ProcessMapReportDataSaubStatDto>> GetAsync(int idWell, DataSaubStatRequest request, CancellationToken token);
}

View File

@ -65,8 +65,7 @@ namespace AsbCloudDb.Migrations
@"tpmwd.id_wellsection_type, " +
@"tpmwd.depth_start, " +
@"tpmwd.depth_end " +
@"from t_process_map_well_drilling tpmwd " +
@"where id_well = 522;");
@"from t_process_map_well_drilling tpmwd;");
}
protected override void Down(MigrationBuilder migrationBuilder)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,95 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Add_ProcessMapPlanReams : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_process_map_plan_ream",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
repeats = table.Column<double>(type: "double precision", nullable: false, comment: "Количество повторений"),
spin_upward = table.Column<double>(type: "double precision", nullable: false, comment: "Вращение при движении вверх, об/мин"),
spin_downward = table.Column<double>(type: "double precision", nullable: false, comment: "Вращение при движении вниз, об/мин"),
speed_upward = table.Column<double>(type: "double precision", nullable: false, comment: "Скорость подъёма, м/ч"),
speed_downward = table.Column<double>(type: "double precision", nullable: false, comment: "Скорость спуска, м/ч"),
setpoint_drag = table.Column<double>(type: "double precision", nullable: false, comment: "Уставка зятяжки, т"),
setpoint_tight = table.Column<double>(type: "double precision", nullable: false, comment: "Уставка посадки, т"),
pressure = table.Column<double>(type: "double precision", nullable: false, comment: "Давление, атм"),
torque = table.Column<double>(type: "double precision", 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_ream", x => x.id);
table.ForeignKey(
name: "FK_t_process_map_plan_ream_t_user_id_author",
column: x => x.id_author,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_process_map_plan_ream_t_user_id_editor",
column: x => x.id_editor,
principalTable: "t_user",
principalColumn: "id");
table.ForeignKey(
name: "FK_t_process_map_plan_ream_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_ream_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_ream_id_author",
table: "t_process_map_plan_ream",
column: "id_author");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_ream_id_editor",
table: "t_process_map_plan_ream",
column: "id_editor");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_ream_id_well",
table: "t_process_map_plan_ream",
column: "id_well");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_ream_id_wellsection_type",
table: "t_process_map_plan_ream",
column: "id_wellsection_type");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_process_map_plan_ream");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,152 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Remove_old_ProcessMapPlans : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_process_map_well_drilling");
migrationBuilder.DropTable(
name: "t_process_map_well_ream");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_process_map_well_drilling",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
id_user = table.Column<int>(type: "integer", nullable: false, comment: "Id пользователя"),
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: "text", nullable: true, 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 слайд)"),
last_update = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата последнего изменения"),
pressure_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, допустимый максимум"),
pressure_plan = table.Column<double>(type: "double precision", nullable: false, 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_well_drilling", x => x.id);
table.ForeignKey(
name: "FK_t_process_map_well_drilling_t_user_id_user",
column: x => x.id_user,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_process_map_well_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_well_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.CreateTable(
name: "t_process_map_well_ream",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
id_user = table.Column<int>(type: "integer", nullable: false, comment: "Id пользователя"),
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
id_wellsection_type = table.Column<int>(type: "integer", nullable: false, comment: "Тип секции"),
comment = table.Column<string>(type: "text", nullable: true, comment: "Комментарий"),
depth_end = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина по стволу до, м"),
depth_start = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина по стволу от, м"),
last_update = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата последнего изменения"),
pressure = table.Column<double>(type: "double precision", nullable: false, comment: "Давление, атм"),
repeats = table.Column<double>(type: "double precision", nullable: false, comment: "Количество повторений"),
setpoint_drag = table.Column<double>(type: "double precision", nullable: false, comment: "Уставка зятяжки, т"),
setpoint_tight = table.Column<double>(type: "double precision", nullable: false, comment: "Уставка посадки, т"),
speed_downward = table.Column<double>(type: "double precision", nullable: false, comment: "Скорость спуска, м/ч"),
speed_upward = table.Column<double>(type: "double precision", nullable: false, comment: "Скорость подъёма, м/ч"),
spin_downward = table.Column<double>(type: "double precision", nullable: false, comment: "Вращение при движении вниз, об/мин"),
spin_upward = table.Column<double>(type: "double precision", nullable: false, comment: "Вращение при движении вверх, об/мин"),
torque = table.Column<double>(type: "double precision", nullable: false, comment: "Момент, кН*м")
},
constraints: table =>
{
table.PrimaryKey("PK_t_process_map_well_ream", x => x.id);
table.ForeignKey(
name: "FK_t_process_map_well_ream_t_user_id_user",
column: x => x.id_user,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_process_map_well_ream_t_well_id_well",
column: x => x.id_well,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_process_map_well_ream_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_well_drilling_id_user",
table: "t_process_map_well_drilling",
column: "id_user");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_well_drilling_id_well",
table: "t_process_map_well_drilling",
column: "id_well");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_well_drilling_id_wellsection_type",
table: "t_process_map_well_drilling",
column: "id_wellsection_type");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_well_ream_id_user",
table: "t_process_map_well_ream",
column: "id_user");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_well_ream_id_well",
table: "t_process_map_well_ream",
column: "id_well");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_well_ream_id_wellsection_type",
table: "t_process_map_well_ream",
column: "id_wellsection_type");
}
}
}

View File

@ -2747,29 +2747,20 @@ namespace AsbCloudDb.Migrations
b.HasComment("РТК план бурение");
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapWellDrilling", b =>
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanReam", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
.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")
.HasColumnType("text")
.HasColumnName("comment")
.HasComment("Комментарий");
b.Property<DateTimeOffset>("Creation")
.HasColumnType("timestamp with time zone")
.HasColumnName("creation")
.HasComment("дата создания");
b.Property<double>("DepthEnd")
.HasColumnType("double precision")
@ -2781,25 +2772,25 @@ namespace AsbCloudDb.Migrations
.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>("IdMode")
b.Property<int>("IdAuthor")
.HasColumnType("integer")
.HasColumnName("id_mode")
.HasComment("Id режима (1- ротор, 2 слайд)");
.HasColumnName("id_author")
.HasComment("Автор");
b.Property<int>("IdUser")
b.Property<int?>("IdEditor")
.HasColumnType("integer")
.HasColumnName("id_user")
.HasComment("Id пользователя");
.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")
@ -2811,112 +2802,10 @@ namespace AsbCloudDb.Migrations
.HasColumnName("id_wellsection_type")
.HasComment("Тип секции");
b.Property<DateTimeOffset>("LastUpdate")
b.Property<DateTimeOffset?>("Obsolete")
.HasColumnType("timestamp with time zone")
.HasColumnName("last_update")
.HasComment("Дата последнего изменения");
b.Property<double>("PressureLimitMax")
.HasColumnType("double precision")
.HasColumnName("pressure_limit_max")
.HasComment("Перепад давления, допустимый максимум");
b.Property<double>("PressurePlan")
.HasColumnType("double precision")
.HasColumnName("pressure_plan")
.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("IdUser");
b.HasIndex("IdWell");
b.HasIndex("IdWellSectionType");
b.ToTable("t_process_map_well_drilling");
b.HasComment("РТК бурение скважины");
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapWellReam", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("text")
.HasColumnName("comment")
.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<int>("IdUser")
.HasColumnType("integer")
.HasColumnName("id_user")
.HasComment("Id пользователя");
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>("LastUpdate")
.HasColumnType("timestamp with time zone")
.HasColumnName("last_update")
.HasComment("Дата последнего изменения");
.HasColumnName("obsolete")
.HasComment("дата устаревания");
b.Property<double>("Pressure")
.HasColumnType("double precision")
@ -2965,13 +2854,15 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.HasIndex("IdUser");
b.HasIndex("IdAuthor");
b.HasIndex("IdEditor");
b.HasIndex("IdWell");
b.HasIndex("IdWellSectionType");
b.ToTable("t_process_map_well_ream");
b.ToTable("t_process_map_plan_ream");
b.HasComment("РТК проработка скважины");
});
@ -8742,14 +8633,18 @@ namespace AsbCloudDb.Migrations
b.Navigation("WellSectionType");
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapWellDrilling", b =>
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanReam", b =>
{
b.HasOne("AsbCloudDb.Model.User", "User")
b.HasOne("AsbCloudDb.Model.User", "Author")
.WithMany()
.HasForeignKey("IdUser")
.HasForeignKey("IdAuthor")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AsbCloudDb.Model.User", "Editor")
.WithMany()
.HasForeignKey("IdEditor");
b.HasOne("AsbCloudDb.Model.Well", "Well")
.WithMany()
.HasForeignKey("IdWell")
@ -8762,34 +8657,9 @@ namespace AsbCloudDb.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
b.Navigation("Author");
b.Navigation("Well");
b.Navigation("WellSectionType");
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapWellReam", b =>
{
b.HasOne("AsbCloudDb.Model.User", "User")
.WithMany()
.HasForeignKey("IdUser")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
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("User");
b.Navigation("Editor");
b.Navigation("Well");

View File

@ -19,9 +19,8 @@ namespace AsbCloudDb.Model
public virtual DbSet<Deposit> Deposits => Set<Deposit>();
public virtual DbSet<DetectedOperation> DetectedOperations => Set<DetectedOperation>();
public virtual DbSet<TrajectoryPlan> TrajectoriesPlan => Set<TrajectoryPlan>();
public virtual DbSet<ProcessMapWellDrilling> ProcessMapWellDrillings => Set<ProcessMapWellDrilling>();
public virtual DbSet<ProcessMapWellReam> ProcessMapWellReams => Set<ProcessMapWellReam>();
public virtual DbSet<ProcessMapPlanDrilling> ProcessMapPlanDrilling => Set<ProcessMapPlanDrilling>();
public virtual DbSet<ProcessMapPlanReam> ProcessMapPlanReams => Set<ProcessMapPlanReam>();
public virtual DbSet<DrillingProgramPart> DrillingProgramParts => Set<DrillingProgramPart>();
public virtual DbSet<FileCategory> FileCategories => Set<FileCategory>();
public virtual DbSet<FileInfo> Files => Set<FileInfo>();

View File

@ -23,8 +23,6 @@ namespace AsbCloudDb.Model
DbSet<Deposit> Deposits { get; }
DbSet<DetectedOperation> DetectedOperations { get; }
DbSet<TrajectoryPlan> TrajectoriesPlan { get; }
DbSet<ProcessMapWellDrilling> ProcessMapWellDrillings { get; }
DbSet<ProcessMapWellReam> ProcessMapWellReams { get; }
DbSet<DrillingProgramPart> DrillingProgramParts { get; }
DbSet<FileCategory> FileCategories { get; }
DbSet<FileInfo> Files { get; }
@ -82,6 +80,7 @@ namespace AsbCloudDb.Model
DbSet<WellSectionPlan> WellSectionsPlan { get; }
DbSet<DataSaubStat> DataSaubStat { get; }
DatabaseFacade Database { get; }
DbSet<ProcessMapPlanReam> ProcessMapPlanReams { get; }
Task<int> RefreshMaterializedViewAsync(string mwName, CancellationToken token);
Task<int> RefreshMaterializedViewAsync<TEntity>(CancellationToken token) where TEntity : class;

View File

@ -1,10 +1,11 @@
using System.ComponentModel.DataAnnotations.Schema;
using AsbCloudDb.Model.ProcessMapPlan;
using Microsoft.EntityFrameworkCore;
namespace AsbCloudDb.Model.ProcessMaps;
[Table("t_process_map_well_ream"), Comment("РТК проработка скважины")]
public class ProcessMapWellReam : ProcessMapBase
[Table("t_process_map_plan_ream"), Comment("РТК проработка скважины")]
public class ProcessMapPlanReam : ProcessMapPlanBase
{
[Column("repeats"), Comment("Количество повторений")]
public double Repeats { get; set; }

View File

@ -1,43 +0,0 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model.ProcessMaps;
public abstract class ProcessMapBase : IId, IWellRelated
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("id_well"), Comment("Id скважины")]
public int IdWell { get; set; }
[Column("id_wellsection_type"), Comment("Тип секции")]
public int IdWellSectionType { get; set; }
[Column("id_user"), Comment("Id пользователя")]
public int IdUser { get; set; }
[Column("last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего изменения")]
public DateTimeOffset LastUpdate { get; set; }
[Column("depth_start"), Comment("Глубина по стволу от, м")]
public double DepthStart { get; set; }
[Column("depth_end"), Comment("Глубина по стволу до, м")]
public double DepthEnd { get; set; }
[Column("comment"), Comment("Комментарий")]
public string? Comment { get; set; }
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; } = null!;
[ForeignKey(nameof(IdUser))]
public virtual User User { get; set; } = null!;
[ForeignKey(nameof(IdWellSectionType))]
public virtual WellSectionType WellSectionType { get; set; } = null!;
}

View File

@ -1,50 +0,0 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model.ProcessMaps;
[Table("t_process_map_well_drilling"), Comment("РТК бурение скважины")]
public class ProcessMapWellDrilling : ProcessMapBase
{
[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("pressure_plan"), Comment("Перепад давления, план")]
public double PressurePlan { get; set; }
[Column("pressure_limit_max"), Comment("Перепад давления, допустимый максимум")]
public double PressureLimitMax { 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; }
}

View File

@ -14,6 +14,7 @@
<None Remove="CommonLibs\Readme.md" />
<None Remove="Services\DailyReport\DailyReportTemplate.xlsx" />
<None Remove="Services\DrillTestReport\DrillTestReportTemplate.xlsx" />
<None Remove="Services\ProcessMapPlan\Templates\ProcessMapPlanReamTemplate.xlsx" />
<None Remove="Services\ProcessMaps\Report\ProcessMapReportDataSaubStatTemplate.xlsx" />
<None Remove="Services\Trajectory\FactTrajectoryTemplate.xlsx" />
<None Remove="Services\Trajectory\NnbTrajectoryTemplate.xlsx" />
@ -37,6 +38,7 @@
<EmbeddedResource Include="Services\DetectOperations\DetectOperations.xlsx" />
<EmbeddedResource Include="Services\DailyReport\DailyReportTemplate.xlsx" />
<EmbeddedResource Include="Services\DrillTestReport\DrillTestReportTemplate.xlsx" />
<EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanReamTemplate.xlsx" />
<EmbeddedResource Include="Services\ProcessMapPlan\Templates\ProcessMapPlanDrillingTemplate.xlsx" />
<EmbeddedResource Include="Services\ProcessMaps\Report\ProcessMapReportDataSaubStatTemplate.xlsx" />
<EmbeddedResource Include="Services\Trajectory\Templates\TrajectoryFactNnbTemplate.xlsx" />

View File

@ -2,7 +2,6 @@
using AsbCloudApp.Data.DailyReport.Blocks.TimeBalance;
using AsbCloudApp.Data.DrillTestReport;
using AsbCloudApp.Data.Manuals;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Data.Subsystems;
@ -157,7 +156,7 @@ namespace AsbCloudInfrastructure
services.AddTransient<ITimezoneService, TimezoneService>();
services.AddScoped<IWellService, WellService>();
services.AddTransient<IWellOperationImportService, WellOperationImportService>();
services.AddTransient<IProcessMapReportDataSaubStatExportService, ProcessMapReportDataSaubStatExportService>();
services.AddTransient<IProcessMapReportDrillingExportService, ProcessMapReportDataSaubStatExportService>();
services.AddTransient<TrajectoryPlanExportService>();
services.AddTransient<TrajectoryFactManualExportService>();
services.AddTransient<TrajectoryFactNnbExportService>();
@ -181,10 +180,10 @@ namespace AsbCloudInfrastructure
ProcessMapPlanBaseRepository<ProcessMapPlanDrillingDto, ProcessMapPlanDrilling>>();
services.AddTransient<
IChangeLogRepository<ProcessMapPlanWellReamDto, ProcessMapPlanBaseRequestWithWell>,
ProcessMapPlanBaseRepository<ProcessMapPlanWellReamDto, ProcessMapPlanDrilling>>();
IChangeLogRepository<ProcessMapPlanReamDto, ProcessMapPlanBaseRequestWithWell>,
ProcessMapPlanBaseRepository<ProcessMapPlanReamDto, ProcessMapPlanDrilling>>();
services.AddTransient<IProcessMapReportDataSaubStatService, ProcessMapReportDataSaubStatService>();
services.AddTransient<IProcessMapReportDrillingService, ProcessMapReportDrillingService>();
services.AddTransient<TrajectoryService>();
@ -283,9 +282,6 @@ namespace AsbCloudInfrastructure
services.AddTransient<IRepositoryWellRelated<WellSectionPlanDto>, CrudWellRelatedRepositoryBase<WellSectionPlanDto, WellSectionPlan>>();
services.AddTransient<IProcessMapPlanService<ProcessMapPlanDrillingDto>, ProcessMapPlanService<ProcessMapPlanDrillingDto>>();
services.AddTransient<IProcessMapPlanService<ProcessMapPlanWellReamDto>, ProcessMapPlanService<ProcessMapPlanWellReamDto>>();
services.AddTransient<IWellSectionPlanRepository, WellSectionPlanRepository>();
services.AddTransient<IWellOperationCategoryRepository, WellOperationCategoryRepository>();
services.AddTransient<IDetectedOperationRepository, DetectedOperationRepository>();
@ -293,6 +289,7 @@ namespace AsbCloudInfrastructure
services.AddTransient<TrajectoryPlanParser>();
services.AddTransient<TrajectoryFactManualParser>();
services.AddTransient<ProcessMapPlanDrillingParser>();
services.AddTransient<ProcessMapPlanReamParser>();
return services;
}

View File

@ -1,4 +1,4 @@
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudDb.Model;

View File

@ -1,5 +1,4 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
@ -12,11 +11,10 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Repository
{
namespace AsbCloudInfrastructure.Repository;
public class WellCompositeRepository : IWellCompositeRepository
{
public class WellCompositeRepository : IWellCompositeRepository
{
private readonly IAsbCloudDbContext db;
private readonly IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanDrillingRepository;
@ -77,6 +75,5 @@ namespace AsbCloudInfrastructure.Repository
var dto = entity.Adapt<WellCompositeDto>();
return dto;
}
}
}

View File

@ -29,7 +29,7 @@ public class DailyReportService : IDailyReportService
private readonly IScheduleRepository scheduleRepository;
private readonly IWellOperationRepository wellOperationRepository;
private readonly ISubsystemService subsystemService;
private readonly IProcessMapReportDataSaubStatService processMapReportDataSaubStatService;
private readonly IProcessMapReportDrillingService processMapReportDrillingService;
private readonly IDetectedOperationService detectedOperationService;
public DailyReportService(IWellService wellService,
@ -38,7 +38,7 @@ public class DailyReportService : IDailyReportService
IScheduleRepository scheduleRepository,
IWellOperationRepository wellOperationRepository,
ISubsystemService subsystemService,
IProcessMapReportDataSaubStatService processMapReportDataSaubStatService,
IProcessMapReportDrillingService processMapReportDrillingService,
IDetectedOperationService detectedOperationService)
{
this.wellService = wellService;
@ -47,7 +47,7 @@ public class DailyReportService : IDailyReportService
this.scheduleRepository = scheduleRepository;
this.wellOperationRepository = wellOperationRepository;
this.subsystemService = subsystemService;
this.processMapReportDataSaubStatService = processMapReportDataSaubStatService;
this.processMapReportDrillingService = processMapReportDrillingService;
this.detectedOperationService = detectedOperationService;
}
@ -376,7 +376,7 @@ public class DailyReportService : IDailyReportService
var leDate = dailyReport.Date.AddDays(1).ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
var request = new DataSaubStatRequest();
dailyReport.ProcessMapWellDrillingBlock = (await processMapReportDataSaubStatService.GetAsync(dailyReport.IdWell, request,
dailyReport.ProcessMapWellDrillingBlock = (await processMapReportDrillingService.GetAsync(dailyReport.IdWell, request,
cancellationToken)).Where(p => p.DateStart >= geDate && p.DateStart <= leDate)
.GroupBy(p => p.DrillingMode)
.Select(g => new ProcessMapWellDrillingRecordDto

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudInfrastructure.Services.Parser;
using Microsoft.Extensions.DependencyInjection;

View File

@ -1,5 +1,5 @@
using System;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudInfrastructure.Services.Parser;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;

View File

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudInfrastructure.Services.Parser;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
public class ProcessMapPlanReamParser : ProcessMapPlanParser<ProcessMapPlanReamDto>
{
private readonly IEnumerable<WellSectionTypeDto> sections;
public ProcessMapPlanReamParser(IWellOperationRepository wellOperationRepository)
{
sections = wellOperationRepository.GetSectionTypes();
}
protected override string SheetName => "План";
protected override string TemplateFileName => "ProcessMapPlanReamTemplate.xlsx";
private const int ColumnSection = 1;
private const int ColumnMode = 2;
protected override IDictionary<string, Cell> Cells => new Dictionary<string, Cell>
{
{ nameof(ProcessMapPlanReamDto.Section), new Cell(ColumnSection, typeof(string)) },
{ nameof(ProcessMapPlanReamDto.DepthStart), new Cell(2, typeof(double)) },
{ nameof(ProcessMapPlanReamDto.DepthEnd), new Cell(3, typeof(double)) },
{ nameof(ProcessMapPlanReamDto.Repeats), new Cell(4, typeof(double)) },
{ nameof(ProcessMapPlanReamDto.SpinUpward), new Cell(5, typeof(double)) },
{ nameof(ProcessMapPlanReamDto.SpinUpward), new Cell(6, typeof(double)) },
{ nameof(ProcessMapPlanReamDto.SpeedDownward), new Cell(7, typeof(double)) },
{ nameof(ProcessMapPlanReamDto.SpeedUpward), new Cell(8, typeof(double)) },
{ nameof(ProcessMapPlanReamDto.SetpointDrag), new Cell(9, typeof(double)) },
{ nameof(ProcessMapPlanReamDto.SetpointTight), new Cell(10, typeof(double)) },
{ nameof(ProcessMapPlanReamDto.Pressure), new Cell(11, typeof(double)) },
{ nameof(ProcessMapPlanReamDto.Torque), new Cell(12, typeof(double)) },
};
protected override ProcessMapPlanReamDto 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, SheetName, rowNumber, ColumnSection,
"Указана некорректная секция");
throw new FileFormatException(message);
}
dto.IdWellSectionType = section.Id;
return dto;
}
}

View File

@ -1,69 +0,0 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.ProcessMaps;
public class ProcessMapPlanService<T> : AsbCloudApp.Services.ProcessMaps.IProcessMapPlanService<T>
where T : ProcessMapPlanBaseDto
{
private readonly ICrudRepository<WellSectionTypeDto> wellSectionTypeRepository;
private readonly IChangeLogRepository<T, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository;
private readonly IRepositoryWellRelated<WellSectionPlanDto> wellSectionPlanRepository;
public ProcessMapPlanService(
ICrudRepository<WellSectionTypeDto> wellSectionTypeRepository,
IChangeLogRepository<T, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository,
IRepositoryWellRelated<WellSectionPlanDto> wellSectionPlanRepository)
{
this.wellSectionTypeRepository = wellSectionTypeRepository;
this.processMapPlanBaseRepository = processMapPlanBaseRepository;
this.wellSectionPlanRepository = wellSectionPlanRepository;
}
public async Task<IEnumerable<ValidationResultDto<T>>> GetAsync(int idWell, CancellationToken cancellationToken)
{
var wellSectionTypes = await wellSectionTypeRepository.GetAllAsync(cancellationToken);
var request = new ProcessMapPlanBaseRequestWithWell(idWell);
var processMapsPlan = await processMapPlanBaseRepository.Get(request, cancellationToken);
var wellSectionsPlan = await wellSectionPlanRepository.GetByIdWellAsync(idWell, cancellationToken);
return processMapsPlan.Select(processMapPlan =>
{
var wellSectionPlan = wellSectionsPlan.FirstOrDefault(s => s.IdSectionType == processMapPlan.IdWellSectionType);
var isValid = wellSectionPlan is not null && wellSectionPlan.DepthStart <= processMapPlan.DepthStart &&
wellSectionPlan.DepthEnd >= processMapPlan.DepthEnd;
var validationResult = new ValidationResultDto<T>
{
Item = processMapPlan
};
if (isValid)
return validationResult;
var wellSectionType = wellSectionTypes.FirstOrDefault(s => s.Id == processMapPlan.IdWellSectionType);
validationResult.Warnings = new ValidationResult[]
{
new($"Конструкция секции: {wellSectionType?.Caption}; " +
$"Интервал бурения от {processMapPlan.DepthStart} до {processMapPlan.DepthEnd} не совпадает с данными указанными на странице " +
$"Конструкция скважины / План", new[] { nameof(processMapPlan.DepthStart), nameof(processMapPlan.DepthEnd) })
};
return validationResult;
});
}
}

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.ProcessMaps.Report;
public class ProcessMapReportDataSaubStatExportService : IProcessMapReportDataSaubStatExportService
public class ProcessMapReportDataSaubStatExportService : IProcessMapReportDrillingExportService
{
private const int firstColumn = 2;
private const int lastColumn = 35;
@ -21,13 +21,13 @@ public class ProcessMapReportDataSaubStatExportService : IProcessMapReportDataSa
private const string sheetName = "Отчёт";
private readonly IWellService wellService;
private readonly IProcessMapReportDataSaubStatService processMapReportDataSaubStatService;
private readonly IProcessMapReportDrillingService processMapReportDrillingService;
public ProcessMapReportDataSaubStatExportService(IWellService wellService,
IProcessMapReportDataSaubStatService processMapReportDataSaubStatService)
IProcessMapReportDrillingService processMapReportDrillingService)
{
this.wellService = wellService;
this.processMapReportDataSaubStatService = processMapReportDataSaubStatService;
this.processMapReportDrillingService = processMapReportDrillingService;
}
public async Task<(string Name, Stream File)?> ExportAsync(int idWell, DataSaubStatRequest request, CancellationToken cancellationToken)
@ -40,7 +40,7 @@ public class ProcessMapReportDataSaubStatExportService : IProcessMapReportDataSa
var stream = Assembly.GetExecutingAssembly().GetTemplateCopyStream(TemplateName);
using var workbook = new XLWorkbook(stream);
var data = await processMapReportDataSaubStatService.GetAsync(idWell, request, cancellationToken);
var data = await processMapReportDrillingService.GetAsync(idWell, request, cancellationToken);
FillProcessMapToWorkbook(workbook, data);

View File

@ -1,5 +1,5 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Data.ProcessMaps.Report;
using AsbCloudApp.Exceptions;
using AsbCloudApp.Extensions;
@ -16,7 +16,7 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.ProcessMaps.Report;
public class ProcessMapReportDataSaubStatService : IProcessMapReportDataSaubStatService
public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
{
private readonly IWellService wellService;
private readonly IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository;
@ -24,7 +24,7 @@ public class ProcessMapReportDataSaubStatService : IProcessMapReportDataSaubStat
private readonly IWellOperationRepository wellOperationRepository;
private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
public ProcessMapReportDataSaubStatService(IWellService wellService,
public ProcessMapReportDrillingService(IWellService wellService,
IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanBaseRepository,
IDataSaubStatRepository dataSaubStatRepository,
IWellOperationRepository wellOperationRepository,

View File

@ -1,5 +1,5 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Data.WITS;
using AsbCloudApp.IntegrationEvents;

View File

@ -1,5 +1,5 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Requests;
using Refit;

View File

@ -1,5 +1,4 @@
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Requests;
using AsbCloudApp.Requests;
using AsbCloudDb.Model.ProcessMapPlan;
using AsbCloudWebApi.IntegrationTests.Clients;
using Mapster;
@ -10,6 +9,7 @@ using AsbCloudDb.Model.ProcessMaps;
using AsbCloudWebApi.IntegrationTests.Data;
using Refit;
using Xunit;
using AsbCloudApp.Data.ProcessMaps;
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;

View File

@ -207,7 +207,7 @@ public class DailyReportServiceTest
private readonly IScheduleRepository scheduleRepositoryMock = Substitute.For<IScheduleRepository>();
private readonly IWellOperationRepository wellOperationRepositoryMock = Substitute.For<IWellOperationRepository>();
private readonly ISubsystemService subsystemServiceMock = Substitute.For<ISubsystemService>();
private readonly IProcessMapReportDataSaubStatService processMapReportWellDrillingServiceMock = Substitute.For<IProcessMapReportDataSaubStatService>();
private readonly IProcessMapReportDrillingService processMapReportWellDrillingServiceMock = Substitute.For<IProcessMapReportDrillingService>();
private readonly IDetectedOperationService detectedOperationServiceMock = Substitute.For<IDetectedOperationService>();
private readonly DailyReportService dailyReportService;

View File

@ -1,96 +0,0 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ProcessMaps;
using NSubstitute;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace AsbCloudWebApi.Tests.Services.ProcessMaps;
public class ProcessMapPlanServiceTests
{
private const int idWellSectionPlan = 1;
private const int idWell = 3;
private const int idWellSectionType = 54;
private readonly IEnumerable<WellSectionPlanDto> fakeCollectionWellSectionPlan = new WellSectionPlanDto[]
{
new()
{
Id = idWellSectionPlan,
IdWell = idWell,
IdSectionType = idWellSectionType,
DepthStart = 80,
DepthEnd = 150
}
};
private readonly IEnumerable<WellSectionTypeDto> fakeCollectionWellSectionTypes = new WellSectionTypeDto[]
{
new()
{
Id = idWellSectionType,
Caption = "Направление 1",
Order = 1
}
};
private readonly ICrudRepository<WellSectionTypeDto> wellSectionTypeRepositoryMock =
Substitute.For<ICrudRepository<WellSectionTypeDto>>();
private readonly IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRepositoryMock =
Substitute.For<IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell>>();
private readonly IRepositoryWellRelated<WellSectionPlanDto> wellSectionPlanRepositoryMock =
Substitute.For<IRepositoryWellRelated<WellSectionPlanDto>>();
private readonly ProcessMapPlanService<ProcessMapPlanDrillingDto> processMapPlanService;
public ProcessMapPlanServiceTests()
{
processMapPlanService = new ProcessMapPlanService<ProcessMapPlanDrillingDto>(wellSectionTypeRepositoryMock,
processMapPlanRepositoryMock, wellSectionPlanRepositoryMock);
wellSectionPlanRepositoryMock.GetByIdWellAsync(Arg.Any<int>(), Arg.Any<CancellationToken>())
.ReturnsForAnyArgs(fakeCollectionWellSectionPlan);
wellSectionTypeRepositoryMock.GetAllAsync(Arg.Any<CancellationToken>())
.ReturnsForAnyArgs(fakeCollectionWellSectionTypes);
}
[Theory]
[InlineData(80, 150, true)]
[InlineData(90, 140, true)]
[InlineData(0, 110, false)]
[InlineData(110, 200, false)]
public async Task GetAsync_ReturnsValidatedCollectionProcessMapPlanWellDrilling(int depthStart, int depthEnd, bool isValidCollection)
{
//arrange
var fakeCollectionProcessMapPlanWellDrilling = new ProcessMapPlanDrillingDto[]
{
new()
{
IdWellSectionType = idWellSectionType,
DepthStart = depthStart,
DepthEnd = depthEnd
}
};
processMapPlanRepositoryMock.Get(Arg.Any<ProcessMapPlanBaseRequestWithWell>(), Arg.Any<CancellationToken>())
.ReturnsForAnyArgs(fakeCollectionProcessMapPlanWellDrilling);
//act
var result = (await processMapPlanService.GetAsync(idWell, CancellationToken.None)).ToArray();
//assert
Assert.Equal(isValidCollection, result.All(r => r.IsValid));
Assert.Single(result);
}
}

View File

@ -4,7 +4,6 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
@ -39,7 +38,7 @@ public class ProcessMapReportDataSaubStatServiceTest
private IDataSaubStatRepository dataSaubStatRepository
= Substitute.For<IDataSaubStatRepository>();
private ProcessMapReportDataSaubStatService service;
private ProcessMapReportDrillingService service;
private readonly static SimpleTimezoneDto timezone = new() { Hours = 2 };
private static readonly DateTimeOffset dateStart = new (2024, 01, 01, 00, 11, 11, timezone.Offset);
@ -274,7 +273,7 @@ public class ProcessMapReportDataSaubStatServiceTest
dataSaubStatRepository.GetAsync(Arg.Any<int>(), Arg.Any<DateTimeOffset>(), Arg.Any<DateTimeOffset>(), Arg.Any<CancellationToken>())
.Returns(dataSaubStat);
service = new ProcessMapReportDataSaubStatService(wellService, processMapPlanBaseRepository, dataSaubStatRepository, wellOperationRepository, wellOperationCategoryRepository);
service = new ProcessMapReportDrillingService(wellService, processMapPlanBaseRepository, dataSaubStatRepository, wellOperationRepository, wellOperationCategoryRepository);
}
[Fact]

View File

@ -1,19 +0,0 @@
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
namespace AsbCloudWebApi.Controllers.ProcessMapPlan;
public class ProcessMapPlanDrillingController : ProcessMapPlanBaseController<ProcessMapPlanDrillingDto>
{
public ProcessMapPlanDrillingController(IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> repository,
IWellService wellService,
ProcessMapPlanDrillingParser parserService)
: base(repository, wellService, parserService)
{
}
protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_бурение.xlsx";
}

View File

@ -1,221 +0,0 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Exceptions;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudApp.Services.ProcessMaps;
using AsbCloudWebApi.SignalR;
using AsbCloudWebApi.SignalR.Clients;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers.ProcessMaps;
/// <summary>
/// РТК
/// </summary>
[ApiController]
[Route("api/well/{idWell}/[controller]")]
[Authorize]
public abstract class ProcessMapBaseController<T> : ControllerBase
where T : ProcessMapPlanBaseDto
{
private readonly IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext;
private readonly ITelemetryService telemetryService;
private readonly IWellService wellService;
private readonly IUserRepository userRepository;
private readonly ICrudRepository<WellSectionTypeDto> wellSectionRepository;
private readonly IChangeLogRepository<T, ProcessMapPlanBaseRequestWithWell> repository;
private readonly IProcessMapPlanService<T> service;
protected ProcessMapBaseController(IWellService wellService,
IChangeLogRepository<T, ProcessMapPlanBaseRequestWithWell> repository,
IUserRepository userRepository,
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
ITelemetryService telemetryService,
IProcessMapPlanService<T> service)
{
this.wellService = wellService;
this.repository = repository;
this.userRepository = userRepository;
this.wellSectionRepository = wellSectionRepository;
this.telemetryHubContext = telemetryHubContext;
this.telemetryService = telemetryService;
this.service = service;
}
protected abstract string SignalRGroup { get; }
protected int IdUser
{
get
{
var idUser = User.GetUserId();
if (!idUser.HasValue)
throw new ForbidException("Неизвестный пользователь");
return idUser.Value;
}
}
/// <summary>
/// Создание плановой РТК
/// </summary>
/// <param name="processMap">Тело запроса</param>
/// <param name="idWell">Id скважины</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpPost]
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public virtual async Task<IActionResult> InsertAsync(T processMap, int idWell, CancellationToken cancellationToken)
{
processMap.IdWell = idWell;
await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken);
await AssertUserHasAccessToEditProcessMapAsync(processMap.IdWell, cancellationToken);
var result = await repository.InsertRange(IdUser, new T[1] { processMap }, cancellationToken);
await NotifyUsersBySignalR(idWell, cancellationToken);
return Ok(result);
}
/// <summary>
/// Обновление плановой РТК
/// </summary>
/// <param name="processMap">Тело запроса</param>
/// <param name="idWell">Id скважины</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpPut]
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public virtual async Task<IActionResult> UpdateAsync(T processMap, int idWell, CancellationToken cancellationToken)
{
processMap.IdWell = idWell;
await CheckIsExistsWellSectionTypeAsync(processMap.IdWellSectionType, cancellationToken);
await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken);
var result = await repository.UpdateRange(IdUser, new T[1] { processMap }, cancellationToken);
if (result == ICrudRepository<T>.ErrorIdNotFound)
return this.ValidationBadRequest(nameof(processMap.Id), $"РТК с Id: {processMap.Id} не существует");
await NotifyUsersBySignalR(idWell, cancellationToken);
return Ok(result);
}
/// <summary>
/// Удаление плановой РТК
/// </summary>
/// <param name="id">Id удаляемой РТК</param>
/// <param name="idWell">Id скважины</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpDelete]
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
public virtual async Task<IActionResult> DeleteAsync(int id, int idWell, CancellationToken cancellationToken)
{
await AssertUserHasAccessToEditProcessMapAsync(idWell, cancellationToken);
var result = await repository.DeleteRange(IdUser, new int[] { id }, cancellationToken);
await NotifyUsersBySignalR(idWell, cancellationToken);
return Ok(result);
}
/// <summary>
/// Получение РТК по Id скважины
/// </summary>
/// <param name="idWell">Id скважины</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
public async Task<ActionResult<IEnumerable<ValidationResultDto<T>>>> GetAsync(int idWell, CancellationToken cancellationToken)
{
var processMaps = await service.GetAsync(idWell, cancellationToken);
if (!processMaps.Any())
return NoContent();
return Ok(processMaps);
}
/// <summary>
/// Получение РТК по телеметрии
/// </summary>
/// <param name="uid">Уникальный ключ телеметрии</param>
/// <param name="updateFrom">Дата с которой требуется получить РТК</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("/api/telemetry/{uid}/[controller]")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<ActionResult<IEnumerable<T>>> GetProcessMapPlanByTelemetry(string uid, DateTime updateFrom, CancellationToken cancellationToken)
{
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
if (!idWell.HasValue)
return this.ValidationBadRequest(nameof(uid), $"Wrong uid {uid}");
var request = new ProcessMapPlanBaseRequestWithWell(idWell.Value) {
UpdateFrom = updateFrom,
};
var processMaps = await repository.Get(request, cancellationToken);
return Ok(processMaps);
}
protected async Task AssertUserHasAccessToEditProcessMapAsync(int idWell, CancellationToken cancellationToken)
{
var well = await wellService.GetOrDefaultAsync(idWell, cancellationToken)
?? throw new ArgumentInvalidException(nameof(idWell), $"Скважины с {idWell} не существует");
var idCompany = User.GetCompanyId();
if (!idCompany.HasValue ||
!await wellService.IsCompanyInvolvedInWellAsync(idCompany.Value, idWell, cancellationToken))
throw new ForbidException("Нет доступа к скважине");
if (well.IdState == 2 && !userRepository.HasPermission(IdUser, "ProcessMap.editCompletedWell"))
throw new ForbidException("Недостаточно прав для редактирования РТК завершенной скважины");
}
protected async Task NotifyUsersBySignalR(int idWell, CancellationToken cancellationToken)
{
var request = new ProcessMapPlanBaseRequestWithWell(idWell);
var dtos = await repository.Get(request, cancellationToken);
await telemetryHubContext.Clients
.Group($"{SignalRGroup}_{idWell}")
.UpdateProcessMap(dtos, cancellationToken);
}
private async Task CheckIsExistsWellSectionTypeAsync(int idWellSectionType, CancellationToken cancellationToken)
{
_ = await wellSectionRepository.GetOrDefaultAsync(idWellSectionType, cancellationToken)
?? throw new ArgumentInvalidException(nameof(ProcessMapPlanDrillingDto.IdWellSectionType), $"Тип секции с Id: {idWellSectionType} не найден");
}
}

View File

@ -1,5 +1,4 @@
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Repositories;
using AsbCloudApp.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
@ -15,11 +14,12 @@ using System.Linq;
using AsbCloudApp.Data;
using AsbCloudApp.Requests.ParserOptions;
using AsbCloudInfrastructure.Services.Parser;
using AsbCloudApp.Data.ProcessMaps;
namespace AsbCloudWebApi.Controllers.ProcessMapPlan;
namespace AsbCloudWebApi.Controllers.ProcessMaps;
/// <summary>
/// РТК план
/// РТК план базовый
/// </summary>
[ApiController]
[Route("api/well/{idWell}/[controller]")]
@ -94,7 +94,7 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
[HttpDelete]
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<IActionResult> DeleteRange([FromRoute]int idWell, IEnumerable<int> ids, CancellationToken token)
public async Task<IActionResult> DeleteRange([FromRoute] int idWell, IEnumerable<int> ids, CancellationToken token)
{
var idUser = await AssertUserHasAccessToWell(idWell, token);
@ -130,7 +130,7 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<ActionResult<IEnumerable<TDto>>> Get([FromRoute] int idWell, [FromQuery]ProcessMapPlanBaseRequest request, CancellationToken token)
public async Task<ActionResult<IEnumerable<TDto>>> Get([FromRoute] int idWell, [FromQuery] ProcessMapPlanBaseRequest request, CancellationToken token)
{
await AssertUserHasAccessToWell(idWell, token);

View File

@ -0,0 +1,22 @@
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
namespace AsbCloudWebApi.Controllers.ProcessMaps;
/// <summary>
/// РТК план бурения
/// </summary>
public class ProcessMapPlanDrillingController : ProcessMapPlanBaseController<ProcessMapPlanDrillingDto>
{
public ProcessMapPlanDrillingController(IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> repository,
IWellService wellService,
ProcessMapPlanDrillingParser parserService)
: base(repository, wellService, parserService)
{
}
protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_бурение.xlsx";
}

View File

@ -0,0 +1,22 @@
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
namespace AsbCloudWebApi.Controllers.ProcessMaps;
/// <summary>
/// РТК план проработка
/// </summary>
public class ProcessMapPlanReamController : ProcessMapPlanBaseController<ProcessMapPlanReamDto>
{
public ProcessMapPlanReamController(IChangeLogRepository<ProcessMapPlanReamDto, ProcessMapPlanBaseRequestWithWell> repository,
IWellService wellService,
ProcessMapPlanReamParser parserService)
: base(repository, wellService, parserService)
{
}
protected override string TemplateFileName => "ЕЦП_шаблон_файла_РТК_план_проработка.xlsx";
}

View File

@ -0,0 +1,67 @@
using AsbCloudApp.Data.ProcessMaps.Report;
using AsbCloudApp.Requests;
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers.ProcessMaps;
/// <summary>
/// РТК отчет по бурению
/// </summary>
[ApiController]
[Route("api/well/{idWell:int}/[controller]")]
[Authorize]
public class ProcessMapReportDrillingController: ControllerBase
{
private readonly IProcessMapReportDrillingService processMapReportDrillingService;
private readonly IProcessMapReportDrillingExportService processMapReportDrillingExportService;
public ProcessMapReportDrillingController(
IProcessMapReportDrillingExportService processMapReportDrillingExportService,
IProcessMapReportDrillingService processMapReportDrillingService)
{
this.processMapReportDrillingExportService = processMapReportDrillingExportService;
this.processMapReportDrillingService = processMapReportDrillingService;
}
/// <summary>
/// Получение данных для отчета РТК бурение
/// </summary>
/// <param name="idWell">Id</param>
/// <param name="request">параметры запроса</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpPost("report")]
[ProducesResponseType(typeof(IEnumerable<ProcessMapReportDataSaubStatDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetReportAsync(int idWell, DataSaubStatRequest request, CancellationToken cancellationToken)
{
var report = await processMapReportDrillingService.GetAsync(idWell, request, cancellationToken);
return Ok(report);
}
/// <summary>
/// Экспорт отчета РТК бурение
/// </summary>
/// <param name="idWell">Id скважины</param>
/// <param name="request">Параметры запроса</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("report/export")]
[ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK, "application/octet-stream")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> ExportReportAsync(int idWell, [FromQuery] DataSaubStatRequest request, CancellationToken cancellationToken)
{
var report = await processMapReportDrillingExportService.ExportAsync(idWell, request, cancellationToken);
if (report is null)
return NoContent();
return File(report.Value.File, "application/octet-stream", report.Value.Name);
}
}

View File

@ -1,80 +0,0 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps.Report;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudApp.Services.ProcessMaps;
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
using AsbCloudWebApi.SignalR;
using AsbCloudWebApi.SignalR.Clients;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers.ProcessMaps;
/// <summary>
/// РТК бурение
/// </summary>
public class ProcessMapWellDrillingController : ProcessMapBaseController<ProcessMapPlanDrillingDto>
{
private readonly IProcessMapReportDataSaubStatService processMapReportDataSaubStatService;
private readonly IProcessMapReportDataSaubStatExportService processMapReportDataSaubStatExportService;
protected override string SignalRGroup => "ProcessMapWellDrilling";
public ProcessMapWellDrillingController(IWellService wellService,
IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> repository,
IUserRepository userRepository,
IProcessMapReportDataSaubStatExportService processMapReportDataSaubStatExportService,
IProcessMapReportDataSaubStatService processMapReportDataSaubStatService,
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
ITelemetryService telemetryService,
IProcessMapPlanService<ProcessMapPlanDrillingDto> service)
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service)
{
this.processMapReportDataSaubStatExportService = processMapReportDataSaubStatExportService;
this.processMapReportDataSaubStatService = processMapReportDataSaubStatService;
}
/// <summary>
/// Получение данных для отчета РТК бурение
/// </summary>
/// <param name="idWell">Id</param>
/// <param name="request">параметры запроса</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpPost("report")]
[ProducesResponseType(typeof(IEnumerable<ProcessMapReportDataSaubStatDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetReportAsync(int idWell, DataSaubStatRequest request, CancellationToken cancellationToken)
{
var report = await processMapReportDataSaubStatService.GetAsync(idWell, request, cancellationToken);
return Ok(report);
}
/// <summary>
/// Экспорт отчета РТК бурение
/// </summary>
/// <param name="idWell">Id скважины</param>
/// <param name="request">Параметры запроса</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("report/export")]
[ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK, "application/octet-stream")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> ExportReportAsync(int idWell, [FromQuery] DataSaubStatRequest request, CancellationToken cancellationToken)
{
var report = await processMapReportDataSaubStatExportService.ExportAsync(idWell, request, cancellationToken);
if (report is null)
return NoContent();
return File(report.Value.File, "application/octet-stream", report.Value.Name);
}
}

View File

@ -1,30 +0,0 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudApp.Services.ProcessMaps;
using AsbCloudWebApi.SignalR;
using AsbCloudWebApi.SignalR.Clients;
using Microsoft.AspNetCore.SignalR;
namespace AsbCloudWebApi.Controllers.ProcessMaps;
/// <summary>
/// РТК проработки скважины
/// </summary>
public class ProcessMapWellReamController : ProcessMapBaseController<ProcessMapPlanWellReamDto>
{
public ProcessMapWellReamController(IWellService wellService,
IChangeLogRepository<ProcessMapPlanWellReamDto, ProcessMapPlanBaseRequestWithWell> repository,
IUserRepository userRepository,
ICrudRepository<WellSectionTypeDto> wellSectionRepository,
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext,
ITelemetryService telemetryService,
IProcessMapPlanService<ProcessMapPlanWellReamDto> service)
: base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service)
{
}
protected override string SignalRGroup => "ProcessMapWellReam";
}

View File

@ -1,5 +1,4 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Exceptions;
using AsbCloudApp.Repositories;

View File

@ -1,5 +1,5 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMapPlan;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;