forked from ddrilling/AsbCloudServer
Merge branch 'dev' into feature/7796681
This commit is contained in:
commit
d2c638f667
@ -1,86 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Ïàðàìåòðû êîðèäîðîâ áóðåíèÿ (äèàïàçîíû ïàðàìåòðîâ áóðåíèÿ)
|
||||
/// </summary>
|
||||
public class DrillFlowChartDto : IId, IWellRelated
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id òèïà îïåðàöèè
|
||||
/// </summary>
|
||||
public int IdWellOperationCategory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Äàòà ïîñëåäíåãî èçìåíåíèÿ
|
||||
/// </summary>
|
||||
public DateTime LastUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ñòàðòîâàÿ ãëóáèíà
|
||||
/// </summary>
|
||||
public double DepthStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ãëóáèíà îêîí÷àíèÿ èíòåðâàëà
|
||||
/// </summary>
|
||||
public double DepthEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ìèíèìàëüíàÿ íàãðóçêà
|
||||
/// </summary>
|
||||
public double AxialLoadMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ìàêñèìàëüíàÿ íàãðóçêà
|
||||
/// </summary>
|
||||
public double AxialLoadMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ìèíèìàëüíîå äàâëåíèå
|
||||
/// </summary>
|
||||
public double PressureMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ìàêñèìàëüíîå äàâëåíèå
|
||||
/// </summary>
|
||||
public double PressureMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ìèíèìàëüíûé ìîìåíò íà ÂÑÏ
|
||||
/// </summary>
|
||||
public double RotorTorqueMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ìàêñèìàëüíûé ìîìåíò íà ÂÑÏ
|
||||
/// </summary>
|
||||
public double RotorTorqueMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ìèíèìàëüíûå îáîðîòû íà ÂÑÏ
|
||||
/// </summary>
|
||||
public double RotorSpeedMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ìàêñèìàëüíûå îáîðîòû íà ÂÑÏ
|
||||
/// </summary>
|
||||
public double RotorSpeedMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ìèíèìàëüíûé ðàñõîä
|
||||
/// </summary>
|
||||
public double FlowMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ìàêñèìàëüíûé ðàñõîä
|
||||
/// </summary>
|
||||
public double FlowMax { get; set; }
|
||||
}
|
||||
}
|
24
AsbCloudApp/Data/PlanFactDto.cs
Normal file
24
AsbCloudApp/Data/PlanFactDto.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Плановое и фактическое значения
|
||||
/// </summary>
|
||||
public class PlanFactDto
|
||||
{
|
||||
/// <summary>
|
||||
/// План
|
||||
/// </summary>
|
||||
public double Plan { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Факт
|
||||
/// </summary>
|
||||
public double? Fact { get; set; }
|
||||
}
|
||||
}
|
73
AsbCloudApp/Data/ProcessMapDto.cs
Normal file
73
AsbCloudApp/Data/ProcessMapDto.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// РТК
|
||||
/// </summary>
|
||||
public class ProcessMapDto : IId, IWellRelated
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id пользователя, поле заполнять не нужно, подставляется автоматически
|
||||
/// </summary>
|
||||
public int? IdUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Тип секции
|
||||
/// </summary>
|
||||
public int IdWellSectionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата последнего изменения
|
||||
/// </summary>
|
||||
public DateTimeOffset LastUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Стартовая глубина
|
||||
/// </summary>
|
||||
public double DepthStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Глубина окончания интервала
|
||||
/// </summary>
|
||||
public double DepthEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Нагрузка
|
||||
/// </summary>
|
||||
public PlanFactDto AxialLoad { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Перепад давления
|
||||
/// </summary>
|
||||
public PlanFactDto Pressure { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Момент на ВСП
|
||||
/// </summary>
|
||||
public PlanFactDto TopDriveTorque { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Обороты на ВСП
|
||||
/// </summary>
|
||||
public PlanFactDto TopDriveSpeed { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Расход
|
||||
/// </summary>
|
||||
public PlanFactDto Flow { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Плановая механическая скорость, м/ч
|
||||
/// </summary>
|
||||
public double RopPlan { get; set; }
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -9,7 +9,7 @@ namespace AsbCloudApp.Services
|
||||
/// <summary>
|
||||
/// ÐÒÊ
|
||||
/// </summary>
|
||||
public interface IDrillFlowChartRepository : IRepositoryWellRelated<DrillFlowChartDto>
|
||||
public interface IProcessMapRepository : IRepositoryWellRelated<ProcessMapDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// Ïîëó÷èòü ïàðàìåòðû áóðåíèÿ íà÷èíàÿ ñ äàòû.
|
||||
@ -18,7 +18,7 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="updateFrom"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<DrillFlowChartDto>> GetAllAsync(int idWell,
|
||||
DateTime updateFrom, CancellationToken token = default);
|
||||
Task<IEnumerable<ProcessMapDto>> GetAllAsync(int idWell,
|
||||
DateTime? updateFrom, CancellationToken token = default);
|
||||
}
|
||||
}
|
6459
AsbCloudDb/Migrations/20221202040010_RemoveTable_t_drill_params.Designer.cs
generated
Normal file
6459
AsbCloudDb/Migrations/20221202040010_RemoveTable_t_drill_params.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,73 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class RemoveTable_t_drill_params : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "t_drill_params");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "t_drill_params",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
well_id = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
|
||||
id_wellsection_type = table.Column<int>(type: "integer", nullable: false, comment: "Id с типом секции скважины"),
|
||||
axial_load_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Средняя нагрузка"),
|
||||
axial_load_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальная нагрузка"),
|
||||
axial_load_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальная нагрузка"),
|
||||
depth_end = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина окончания интервала"),
|
||||
depth_start = table.Column<double>(type: "double precision", nullable: false, comment: "Стартовая глубина"),
|
||||
flow_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Средний расход"),
|
||||
flow_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный расход"),
|
||||
flow_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный расход"),
|
||||
pressure_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Среднее давление"),
|
||||
pressure_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальное давление"),
|
||||
pressure_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальное давление"),
|
||||
rotor_speed_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Средние обороты на ВСП"),
|
||||
rotor_speed_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальные обороты на ВСП"),
|
||||
rotor_speed_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальные обороты на ВСП"),
|
||||
rotor_torque_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Средний момент на ВСП"),
|
||||
rotor_torque_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный момент на ВСП"),
|
||||
rotor_torque_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный момент на ВСП")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_t_drill_params", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "FK_t_drill_params_t_well_well_id",
|
||||
column: x => x.well_id,
|
||||
principalTable: "t_well",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "t_drill_params_t_well_section_type_id_fk",
|
||||
column: x => x.id_wellsection_type,
|
||||
principalTable: "t_well_section_type",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
},
|
||||
comment: "Режим бурения в секции (диапазоны параметров бурения)");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_drill_params_id_wellsection_type",
|
||||
table: "t_drill_params",
|
||||
column: "id_wellsection_type");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_drill_params_well_id",
|
||||
table: "t_drill_params",
|
||||
column: "well_id");
|
||||
}
|
||||
}
|
||||
}
|
6353
AsbCloudDb/Migrations/20221205063810_DeleteTable_t_drill_flow_chart.Designer.cs
generated
Normal file
6353
AsbCloudDb/Migrations/20221205063810_DeleteTable_t_drill_flow_chart.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class DeleteTable_t_drill_flow_chart : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "t_drill_flow_chart");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "t_drill_flow_chart",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
well_id = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
|
||||
axial_load_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальная нагрузка"),
|
||||
axial_load_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальная нагрузка"),
|
||||
depth_end = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина окончания интервала"),
|
||||
depth_start = table.Column<double>(type: "double precision", nullable: false, comment: "Стартовая глубина"),
|
||||
flow_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный расход"),
|
||||
flow_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный расход"),
|
||||
id_operation_category = table.Column<int>(type: "integer", nullable: false, comment: "Id типа операции"),
|
||||
last_update = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата последнего изменения"),
|
||||
pressure_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальное давление"),
|
||||
pressure_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальное давление"),
|
||||
rotor_speed_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальные обороты на ВСП"),
|
||||
rotor_speed_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальные обороты на ВСП"),
|
||||
rotor_torque_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный момент на ВСП"),
|
||||
rotor_torque_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный момент на ВСП")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_t_drill_flow_chart", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "FK_t_drill_flow_chart_t_well_well_id",
|
||||
column: x => x.well_id,
|
||||
principalTable: "t_well",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
},
|
||||
comment: "Параметры коридоров бурения (диапазоны параметров бурения)");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_drill_flow_chart_id_operation_category",
|
||||
table: "t_drill_flow_chart",
|
||||
column: "id_operation_category");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_drill_flow_chart_well_id",
|
||||
table: "t_drill_flow_chart",
|
||||
column: "well_id");
|
||||
}
|
||||
}
|
||||
}
|
6449
AsbCloudDb/Migrations/20221205064341_AddTable_t_process_map.Designer.cs
generated
Normal file
6449
AsbCloudDb/Migrations/20221205064341_AddTable_t_process_map.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class AddTable_t_process_map : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "t_process_map",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
well_id = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
|
||||
section = table.Column<int>(type: "integer", nullable: false, comment: "Секция"),
|
||||
last_update = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата последнего изменения"),
|
||||
depth_start = table.Column<double>(type: "double precision", nullable: false, comment: "Стартовая глубина"),
|
||||
depth_end = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина окончания интервала"),
|
||||
axial_load_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Нагрузка, план"),
|
||||
axial_load_fact = table.Column<double>(type: "double precision", nullable: true, comment: "Нагрузка, факт"),
|
||||
pressure_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, план"),
|
||||
pressure_fact = table.Column<double>(type: "double precision", nullable: true, comment: "Перепад давления, факт"),
|
||||
rotor_torque_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Момент на ВСП, план"),
|
||||
rotor_torque_fact = table.Column<double>(type: "double precision", nullable: true, comment: "Момент на ВСП, факт"),
|
||||
rotor_speed_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Обороты на ВСП, план"),
|
||||
rotor_speed_fact = table.Column<double>(type: "double precision", nullable: true, comment: "Обороты на ВСП, факт"),
|
||||
flow_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Расход, план"),
|
||||
flow_fact = table.Column<double>(type: "double precision", nullable: true, comment: "Расход, факт"),
|
||||
mechanical_speed_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Плановая механическая скорость, м/ч")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_t_process_map", x => x.id);
|
||||
},
|
||||
comment: "Операции по скважине – РТК");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "t_process_map");
|
||||
}
|
||||
}
|
||||
}
|
6472
AsbCloudDb/Migrations/20221206053310_UpdateTable_t_process_map.Designer.cs
generated
Normal file
6472
AsbCloudDb/Migrations/20221206053310_UpdateTable_t_process_map.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,131 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class UpdateTable_t_process_map : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "section",
|
||||
table: "t_process_map");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "rotor_torque_plan",
|
||||
table: "t_process_map",
|
||||
newName: "top_drive_torque_plan");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "rotor_torque_fact",
|
||||
table: "t_process_map",
|
||||
newName: "top_drive_torque_fact");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "rotor_speed_plan",
|
||||
table: "t_process_map",
|
||||
newName: "top_drive_speed_plan");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "rotor_speed_fact",
|
||||
table: "t_process_map",
|
||||
newName: "top_drive_speed_fact");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "mechanical_speed_plan",
|
||||
table: "t_process_map",
|
||||
newName: "rop_plan");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "id_wellsection_type",
|
||||
table: "t_process_map",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
comment: "Тип секции");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_process_map_id_wellsection_type",
|
||||
table: "t_process_map",
|
||||
column: "id_wellsection_type");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_process_map_well_id",
|
||||
table: "t_process_map",
|
||||
column: "well_id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_t_process_map_t_well_section_type_id_wellsection_type",
|
||||
table: "t_process_map",
|
||||
column: "id_wellsection_type",
|
||||
principalTable: "t_well_section_type",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_t_process_map_t_well_well_id",
|
||||
table: "t_process_map",
|
||||
column: "well_id",
|
||||
principalTable: "t_well",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_t_process_map_t_well_section_type_id_wellsection_type",
|
||||
table: "t_process_map");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_t_process_map_t_well_well_id",
|
||||
table: "t_process_map");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_t_process_map_id_wellsection_type",
|
||||
table: "t_process_map");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_t_process_map_well_id",
|
||||
table: "t_process_map");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "id_wellsection_type",
|
||||
table: "t_process_map");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "top_drive_torque_plan",
|
||||
table: "t_process_map",
|
||||
newName: "rotor_torque_plan");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "top_drive_torque_fact",
|
||||
table: "t_process_map",
|
||||
newName: "rotor_torque_fact");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "top_drive_speed_plan",
|
||||
table: "t_process_map",
|
||||
newName: "rotor_speed_plan");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "top_drive_speed_fact",
|
||||
table: "t_process_map",
|
||||
newName: "rotor_speed_fact");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "rop_plan",
|
||||
table: "t_process_map",
|
||||
newName: "mechanical_speed_plan");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "section",
|
||||
table: "t_process_map",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
comment: "Секция");
|
||||
}
|
||||
}
|
||||
}
|
6487
AsbCloudDb/Migrations/20221206091023_UpdateTable_t_process_map_add_user_id.Designer.cs
generated
Normal file
6487
AsbCloudDb/Migrations/20221206091023_UpdateTable_t_process_map_add_user_id.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,48 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class UpdateTable_t_process_map_add_user_id : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "id_user",
|
||||
table: "t_process_map",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
comment: "Id пользователя");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_process_map_id_user",
|
||||
table: "t_process_map",
|
||||
column: "id_user");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_t_process_map_t_user_id_user",
|
||||
table: "t_process_map",
|
||||
column: "id_user",
|
||||
principalTable: "t_user",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_t_process_map_t_user_id_user",
|
||||
table: "t_process_map");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_t_process_map_id_user",
|
||||
table: "t_process_map");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "id_user",
|
||||
table: "t_process_map");
|
||||
}
|
||||
}
|
||||
}
|
6477
AsbCloudDb/Migrations/20221207034419_UpdateTable_t_process_map_delete_fk.Designer.cs
generated
Normal file
6477
AsbCloudDb/Migrations/20221207034419_UpdateTable_t_process_map_delete_fk.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class UpdateTable_t_process_map_delete_fk : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_t_process_map_t_user_id_user",
|
||||
table: "t_process_map");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_t_process_map_id_user",
|
||||
table: "t_process_map");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_process_map_id_user",
|
||||
table: "t_process_map",
|
||||
column: "id_user");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_t_process_map_t_user_id_user",
|
||||
table: "t_process_map",
|
||||
column: "id_user",
|
||||
principalTable: "t_user",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
@ -297,101 +297,6 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasComment("Бурильщик");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChart", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("AxialLoadMax")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("axial_load_max")
|
||||
.HasComment("Максимальная нагрузка");
|
||||
|
||||
b.Property<double>("AxialLoadMin")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("axial_load_min")
|
||||
.HasComment("Минимальная нагрузка");
|
||||
|
||||
b.Property<double>("DepthEnd")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("depth_end")
|
||||
.HasComment("Глубина окончания интервала");
|
||||
|
||||
b.Property<double>("DepthStart")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("depth_start")
|
||||
.HasComment("Стартовая глубина");
|
||||
|
||||
b.Property<double>("FlowMax")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("flow_max")
|
||||
.HasComment("Максимальный расход");
|
||||
|
||||
b.Property<double>("FlowMin")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("flow_min")
|
||||
.HasComment("Минимальный расход");
|
||||
|
||||
b.Property<int>("IdWell")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("well_id")
|
||||
.HasComment("Id скважины");
|
||||
|
||||
b.Property<int>("IdWellOperationCategory")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_operation_category")
|
||||
.HasComment("Id типа операции");
|
||||
|
||||
b.Property<DateTimeOffset>("LastUpdate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("last_update")
|
||||
.HasComment("Дата последнего изменения");
|
||||
|
||||
b.Property<double>("PressureMax")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("pressure_max")
|
||||
.HasComment("Максимальное давление");
|
||||
|
||||
b.Property<double>("PressureMin")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("pressure_min")
|
||||
.HasComment("Минимальное давление");
|
||||
|
||||
b.Property<double>("RotorSpeedMax")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rotor_speed_max")
|
||||
.HasComment("Максимальные обороты на ВСП");
|
||||
|
||||
b.Property<double>("RotorSpeedMin")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rotor_speed_min")
|
||||
.HasComment("Минимальные обороты на ВСП");
|
||||
|
||||
b.Property<double>("RotorTorqueMax")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rotor_torque_max")
|
||||
.HasComment("Максимальный момент на ВСП");
|
||||
|
||||
b.Property<double>("RotorTorqueMin")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rotor_torque_min")
|
||||
.HasComment("Минимальный момент на ВСП");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdWell");
|
||||
|
||||
b.HasIndex("IdWellOperationCategory");
|
||||
|
||||
b.ToTable("t_drill_flow_chart");
|
||||
|
||||
b.HasComment("Параметры коридоров бурения (диапазоны параметров бурения)");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -421,121 +326,6 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasComment("части программ бурения");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillParams", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("AxialLoadAvg")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("axial_load_avg")
|
||||
.HasComment("Средняя нагрузка");
|
||||
|
||||
b.Property<double>("AxialLoadMax")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("axial_load_max")
|
||||
.HasComment("Максимальная нагрузка");
|
||||
|
||||
b.Property<double>("AxialLoadMin")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("axial_load_min")
|
||||
.HasComment("Минимальная нагрузка");
|
||||
|
||||
b.Property<double>("DepthEnd")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("depth_end")
|
||||
.HasComment("Глубина окончания интервала");
|
||||
|
||||
b.Property<double>("DepthStart")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("depth_start")
|
||||
.HasComment("Стартовая глубина");
|
||||
|
||||
b.Property<double>("FlowAvg")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("flow_avg")
|
||||
.HasComment("Средний расход");
|
||||
|
||||
b.Property<double>("FlowMax")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("flow_max")
|
||||
.HasComment("Максимальный расход");
|
||||
|
||||
b.Property<double>("FlowMin")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("flow_min")
|
||||
.HasComment("Минимальный расход");
|
||||
|
||||
b.Property<int>("IdWell")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("well_id")
|
||||
.HasComment("Id скважины");
|
||||
|
||||
b.Property<int>("IdWellSectionType")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_wellsection_type")
|
||||
.HasComment("Id с типом секции скважины");
|
||||
|
||||
b.Property<double>("PressureAvg")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("pressure_avg")
|
||||
.HasComment("Среднее давление");
|
||||
|
||||
b.Property<double>("PressureMax")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("pressure_max")
|
||||
.HasComment("Максимальное давление");
|
||||
|
||||
b.Property<double>("PressureMin")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("pressure_min")
|
||||
.HasComment("Минимальное давление");
|
||||
|
||||
b.Property<double>("RotorSpeedAvg")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rotor_speed_avg")
|
||||
.HasComment("Средние обороты на ВСП");
|
||||
|
||||
b.Property<double>("RotorSpeedMax")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rotor_speed_max")
|
||||
.HasComment("Максимальные обороты на ВСП");
|
||||
|
||||
b.Property<double>("RotorSpeedMin")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rotor_speed_min")
|
||||
.HasComment("Минимальные обороты на ВСП");
|
||||
|
||||
b.Property<double>("RotorTorqueAvg")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rotor_torque_avg")
|
||||
.HasComment("Средний момент на ВСП");
|
||||
|
||||
b.Property<double>("RotorTorqueMax")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rotor_torque_max")
|
||||
.HasComment("Максимальный момент на ВСП");
|
||||
|
||||
b.Property<double>("RotorTorqueMin")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rotor_torque_min")
|
||||
.HasComment("Минимальный момент на ВСП");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdWell");
|
||||
|
||||
b.HasIndex("IdWellSectionType");
|
||||
|
||||
b.ToTable("t_drill_params");
|
||||
|
||||
b.HasComment("Режим бурения в секции (диапазоны параметров бурения)");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.FileCategory", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -1972,6 +1762,111 @@ namespace AsbCloudDb.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.ProcessMap", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double?>("AxialLoadFact")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("axial_load_fact")
|
||||
.HasComment("Нагрузка, факт");
|
||||
|
||||
b.Property<double>("AxialLoadPlan")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("axial_load_plan")
|
||||
.HasComment("Нагрузка, план");
|
||||
|
||||
b.Property<double>("DepthEnd")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("depth_end")
|
||||
.HasComment("Глубина окончания интервала");
|
||||
|
||||
b.Property<double>("DepthStart")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("depth_start")
|
||||
.HasComment("Стартовая глубина");
|
||||
|
||||
b.Property<double?>("FlowFact")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("flow_fact")
|
||||
.HasComment("Расход, факт");
|
||||
|
||||
b.Property<double>("FlowPlan")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("flow_plan")
|
||||
.HasComment("Расход, план");
|
||||
|
||||
b.Property<int>("IdUser")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_user")
|
||||
.HasComment("Id пользователя");
|
||||
|
||||
b.Property<int>("IdWell")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("well_id")
|
||||
.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("Дата последнего изменения");
|
||||
|
||||
b.Property<double?>("PressureFact")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("pressure_fact")
|
||||
.HasComment("Перепад давления, факт");
|
||||
|
||||
b.Property<double>("PressurePlan")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("pressure_plan")
|
||||
.HasComment("Перепад давления, план");
|
||||
|
||||
b.Property<double>("RopPlan")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("rop_plan")
|
||||
.HasComment("Плановая механическая скорость, м/ч");
|
||||
|
||||
b.Property<double?>("TopDriveSpeedFact")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("top_drive_speed_fact")
|
||||
.HasComment("Обороты на ВСП, факт");
|
||||
|
||||
b.Property<double>("TopDriveSpeedPlan")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("top_drive_speed_plan")
|
||||
.HasComment("Обороты на ВСП, план");
|
||||
|
||||
b.Property<double?>("TopDriveTorqueFact")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("top_drive_torque_fact")
|
||||
.HasComment("Момент на ВСП, факт");
|
||||
|
||||
b.Property<double>("TopDriveTorquePlan")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("top_drive_torque_plan")
|
||||
.HasComment("Момент на ВСП, план");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdWell");
|
||||
|
||||
b.HasIndex("IdWellSectionType");
|
||||
|
||||
b.ToTable("t_process_map");
|
||||
|
||||
b.HasComment("Операции по скважине – РТК");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b =>
|
||||
{
|
||||
b.Property<int>("IdCompany")
|
||||
@ -6135,17 +6030,6 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChart", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdWell")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Well");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.FileCategory", "FileCategory")
|
||||
@ -6165,26 +6049,6 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("Well");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillParams", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdWell")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
|
||||
.WithMany("DrillParamsCollection")
|
||||
.HasForeignKey("IdWellSectionType")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_drill_params_t_well_section_type_id_fk");
|
||||
|
||||
b.Navigation("Well");
|
||||
|
||||
b.Navigation("WellSectionType");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.FileInfo", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.User", "Author")
|
||||
@ -6280,6 +6144,25 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("Well");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.ProcessMap", b =>
|
||||
{
|
||||
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("Well");
|
||||
|
||||
b.Navigation("WellSectionType");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Company", "Company")
|
||||
@ -6838,8 +6721,6 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.WellSectionType", b =>
|
||||
{
|
||||
b.Navigation("DrillParamsCollection");
|
||||
|
||||
b.Navigation("WellComposites");
|
||||
|
||||
b.Navigation("WellOperations");
|
||||
|
@ -13,9 +13,8 @@ namespace AsbCloudDb.Model
|
||||
public virtual DbSet<DailyReport.DailyReport> DailyReports => Set <DailyReport.DailyReport >();
|
||||
public virtual DbSet<Deposit> Deposits => Set<Deposit>();
|
||||
public virtual DbSet<DetectedOperation> DetectedOperations => Set<DetectedOperation>();
|
||||
public virtual DbSet<DrillFlowChart> DrillFlowChart => Set<DrillFlowChart>();
|
||||
public virtual DbSet<ProcessMap> ProcessMap => Set<ProcessMap>();
|
||||
public virtual DbSet<DrillingProgramPart> DrillingProgramParts => Set<DrillingProgramPart>();
|
||||
public virtual DbSet<DrillParams> DrillParams => Set<DrillParams>();
|
||||
public virtual DbSet<FileCategory> FileCategories => Set<FileCategory>();
|
||||
public virtual DbSet<FileInfo> Files => Set<FileInfo>();
|
||||
public virtual DbSet<FileMark> FileMarks => Set<FileMark>();
|
||||
@ -260,19 +259,6 @@ namespace AsbCloudDb.Model
|
||||
entity.HasIndex(d => d.DateStart);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<DrillParams>(entity =>
|
||||
{
|
||||
entity.HasOne(r => r.WellSectionType)
|
||||
.WithMany(w => w.DrillParamsCollection)
|
||||
.HasForeignKey(r => r.IdWellSectionType)
|
||||
.HasConstraintName("t_drill_params_t_well_section_type_id_fk");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<DrillFlowChart>(entity =>
|
||||
{
|
||||
entity.HasIndex(d => d.IdWellOperationCategory);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<DrillingProgramPart>(entity =>
|
||||
{
|
||||
entity.HasIndex(x => new { x.IdWell, x.IdFileCategory })
|
||||
|
@ -1,66 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
#nullable disable
|
||||
[Table("t_drill_flow_chart"), Comment("Параметры коридоров бурения (диапазоны параметров бурения)")]
|
||||
public class DrillFlowChart : IId, IWellRelated
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("well_id"), Comment("Id скважины")]
|
||||
public int IdWell { get; set; }
|
||||
|
||||
[Column("id_operation_category"), Comment("Id типа операции")]
|
||||
public int IdWellOperationCategory { get; set; }
|
||||
|
||||
[Column("last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего изменения")]
|
||||
public DateTimeOffset LastUpdate { get; set; }
|
||||
|
||||
[Column("depth_start"), Comment("Стартовая глубина")]
|
||||
public double DepthStart { get; set; }
|
||||
|
||||
[Column("depth_end"), Comment("Глубина окончания интервала")]
|
||||
public double DepthEnd { get; set; }
|
||||
|
||||
[Column("axial_load_min"), Comment("Минимальная нагрузка")]
|
||||
public double AxialLoadMin { get; set; }
|
||||
|
||||
[Column("axial_load_max"), Comment("Максимальная нагрузка")]
|
||||
public double AxialLoadMax { get; set; }
|
||||
|
||||
[Column("pressure_min"), Comment("Минимальное давление")]
|
||||
public double PressureMin { get; set; }
|
||||
|
||||
[Column("pressure_max"), Comment("Максимальное давление")]
|
||||
public double PressureMax { get; set; }
|
||||
|
||||
[Column("rotor_torque_min"), Comment("Минимальный момент на ВСП")]
|
||||
public double RotorTorqueMin { get; set; }
|
||||
|
||||
[Column("rotor_torque_max"), Comment("Максимальный момент на ВСП")]
|
||||
public double RotorTorqueMax { get; set; }
|
||||
|
||||
[Column("rotor_speed_min"), Comment("Минимальные обороты на ВСП")]
|
||||
public double RotorSpeedMin { get; set; }
|
||||
|
||||
[Column("rotor_speed_max"), Comment("Максимальные обороты на ВСП")]
|
||||
public double RotorSpeedMax { get; set; }
|
||||
|
||||
[Column("flow_min"), Comment("Минимальный расход")]
|
||||
public double FlowMin { get; set; }
|
||||
|
||||
[Column("flow_max"), Comment("Максимальный расход")]
|
||||
public double FlowMax { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey(nameof(IdWell))]
|
||||
public virtual Well Well { get; set; }
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
#nullable disable
|
||||
[Table("t_drill_params"), Comment("Режим бурения в секции (диапазоны параметров бурения)")]
|
||||
public class DrillParams : IId
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("well_id"), Comment("Id скважины")]
|
||||
public int IdWell { get; set; }
|
||||
|
||||
[Column("depth_start"), Comment("Стартовая глубина")]
|
||||
public double DepthStart { get; set; }
|
||||
|
||||
[Column("depth_end"), Comment("Глубина окончания интервала")]
|
||||
public double DepthEnd { get; set; }
|
||||
|
||||
[Column("id_wellsection_type"), Comment("Id с типом секции скважины")]
|
||||
public int IdWellSectionType { get; set; }
|
||||
|
||||
[Column("axial_load_min"), Comment("Минимальная нагрузка")]
|
||||
public double AxialLoadMin { get; set; }
|
||||
|
||||
[Column("axial_load_avg"), Comment("Средняя нагрузка")]
|
||||
public double AxialLoadAvg { get; set; }
|
||||
|
||||
[Column("axial_load_max"), Comment("Максимальная нагрузка")]
|
||||
public double AxialLoadMax { get; set; }
|
||||
|
||||
[Column("pressure_min"), Comment("Минимальное давление")]
|
||||
public double PressureMin { get; set; }
|
||||
|
||||
[Column("pressure_avg"), Comment("Среднее давление")]
|
||||
public double PressureAvg { get; set; }
|
||||
|
||||
[Column("pressure_max"), Comment("Максимальное давление")]
|
||||
public double PressureMax { get; set; }
|
||||
|
||||
[Column("rotor_torque_min"), Comment("Минимальный момент на ВСП")]
|
||||
public double RotorTorqueMin { get; set; }
|
||||
|
||||
[Column("rotor_torque_avg"), Comment("Средний момент на ВСП")]
|
||||
public double RotorTorqueAvg { get; set; }
|
||||
|
||||
[Column("rotor_torque_max"), Comment("Максимальный момент на ВСП")]
|
||||
public double RotorTorqueMax { get; set; }
|
||||
|
||||
[Column("rotor_speed_min"), Comment("Минимальные обороты на ВСП")]
|
||||
public double RotorSpeedMin { get; set; }
|
||||
|
||||
[Column("rotor_speed_avg"), Comment("Средние обороты на ВСП")]
|
||||
public double RotorSpeedAvg { get; set; }
|
||||
|
||||
[Column("rotor_speed_max"), Comment("Максимальные обороты на ВСП")]
|
||||
public double RotorSpeedMax { get; set; }
|
||||
|
||||
[Column("flow_min"), Comment("Минимальный расход")]
|
||||
public double FlowMin { get; set; }
|
||||
|
||||
[Column("flow_avg"), Comment("Средний расход")]
|
||||
public double FlowAvg { get; set; }
|
||||
|
||||
[Column("flow_max"), Comment("Максимальный расход")]
|
||||
public double FlowMax { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey(nameof(IdWell))]
|
||||
public virtual Well Well { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey(nameof(IdWellSectionType))]
|
||||
public virtual WellSectionType WellSectionType { get; set; }
|
||||
}
|
||||
}
|
@ -15,9 +15,8 @@ namespace AsbCloudDb.Model
|
||||
DbSet<DailyReport.DailyReport> DailyReports { get; }
|
||||
DbSet<Deposit> Deposits { get; }
|
||||
DbSet<DetectedOperation> DetectedOperations { get; }
|
||||
DbSet<DrillFlowChart> DrillFlowChart { get; }
|
||||
DbSet<ProcessMap> ProcessMap { get; }
|
||||
DbSet<DrillingProgramPart> DrillingProgramParts { get; }
|
||||
DbSet<DrillParams> DrillParams { get; }
|
||||
DbSet<FileCategory> FileCategories { get; }
|
||||
DbSet<FileInfo> Files { get; }
|
||||
DbSet<FileMark> FileMarks { get; }
|
||||
|
77
AsbCloudDb/Model/ProcessMap.cs
Normal file
77
AsbCloudDb/Model/ProcessMap.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
#nullable enable
|
||||
[Table("t_process_map"), Comment("Операции по скважине – РТК")]
|
||||
public class ProcessMap : IId, IWellRelated
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("well_id"), Comment("Id скважины")]
|
||||
public int IdWell { get; set; }
|
||||
|
||||
[Column("id_user"), Comment("Id пользователя")]
|
||||
public int IdUser { get; set; }
|
||||
|
||||
[Column("id_wellsection_type"), Comment("Тип секции")]
|
||||
public int IdWellSectionType { get; set; }
|
||||
|
||||
[Column("last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего изменения")]
|
||||
public DateTimeOffset LastUpdate { get; set; }
|
||||
|
||||
[Column("depth_start"), Comment("Стартовая глубина")]
|
||||
public double DepthStart { get; set; }
|
||||
|
||||
[Column("depth_end"), Comment("Глубина окончания интервала")]
|
||||
public double DepthEnd { get; set; }
|
||||
|
||||
[Column("axial_load_plan"), Comment("Нагрузка, план")]
|
||||
public double AxialLoadPlan { get; set; }
|
||||
|
||||
[Column("axial_load_fact"), Comment("Нагрузка, факт")]
|
||||
public double? AxialLoadFact { get; set; }
|
||||
|
||||
[Column("pressure_plan"), Comment("Перепад давления, план")]
|
||||
public double PressurePlan { get; set; }
|
||||
|
||||
[Column("pressure_fact"), Comment("Перепад давления, факт")]
|
||||
public double? PressureFact { get; set; }
|
||||
|
||||
[Column("top_drive_torque_plan"), Comment("Момент на ВСП, план")]
|
||||
public double TopDriveTorquePlan { get; set; }
|
||||
|
||||
[Column("top_drive_torque_fact"), Comment("Момент на ВСП, факт")]
|
||||
public double? TopDriveTorqueFact { get; set; }
|
||||
|
||||
[Column("top_drive_speed_plan"), Comment("Обороты на ВСП, план")]
|
||||
public double TopDriveSpeedPlan { get; set; }
|
||||
|
||||
[Column("top_drive_speed_fact"), Comment("Обороты на ВСП, факт")]
|
||||
public double? TopDriveSpeedFact { get; set; }
|
||||
|
||||
[Column("flow_plan"), Comment("Расход, план")]
|
||||
public double FlowPlan { get; set; }
|
||||
|
||||
[Column("flow_fact"), Comment("Расход, факт")]
|
||||
public double? FlowFact { get; set; }
|
||||
|
||||
[Column("rop_plan"), Comment("Плановая механическая скорость, м/ч")]
|
||||
public double RopPlan { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey(nameof(IdWell))]
|
||||
public virtual Well Well { get; set; } = null!;
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey(nameof(IdWellSectionType))]
|
||||
public virtual WellSectionType WellSectionType { get; set; } = null!;
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -21,10 +21,6 @@ namespace AsbCloudDb.Model
|
||||
[InverseProperty(nameof(WellOperation.WellSectionType))]
|
||||
public virtual ICollection<WellOperation> WellOperations { get; set; } = null!;
|
||||
|
||||
[JsonIgnore]
|
||||
[InverseProperty(nameof(DrillParams.WellSectionType))]
|
||||
public virtual ICollection<DrillParams> DrillParamsCollection { get; set; } = null!;
|
||||
|
||||
[JsonIgnore]
|
||||
[InverseProperty(nameof(WellComposite.WellSectionType))]
|
||||
public virtual ICollection<WellComposite> WellComposites { get; set; } = null!;
|
||||
|
@ -109,9 +109,8 @@ namespace AsbCloudInfrastructure
|
||||
|
||||
services.AddTransient<IAuthService, AuthService>();
|
||||
services.AddTransient<IClusterService, ClusterService>();
|
||||
services.AddTransient<IDrillFlowChartRepository, DrillFlowChartRepository>();
|
||||
services.AddTransient<IProcessMapRepository, ProcessMapRepository>();
|
||||
services.AddTransient<IDrillingProgramService, DrillingProgramService>();
|
||||
services.AddTransient<IDrillParamsService, DrillParamsService>();
|
||||
services.AddTransient<IEventService, EventService>();
|
||||
services.AddTransient<FileService>();
|
||||
services.AddTransient<IMeasureService, MeasureService>();
|
||||
@ -130,7 +129,7 @@ namespace AsbCloudInfrastructure
|
||||
services.AddTransient<IDetectedOperationService, DetectedOperationService>();
|
||||
services.AddTransient<ISubsystemOperationTimeService, SubsystemOperationTimeService>();
|
||||
services.AddTransient<IScheduleRepository, ScheduleRepository>();
|
||||
services.AddTransient<IRepositoryWellRelated<OperationValueDto>, CrudWellRelatedServiceBase<OperationValueDto, OperationValue>>();
|
||||
services.AddTransient<IRepositoryWellRelated<OperationValueDto>, CrudWellRelatedRepositoryBase<OperationValueDto, OperationValue>>();
|
||||
services.AddTransient<IUserSettingsRepository, UserSettingsRepository>();
|
||||
services.AddTransient<IWellFinalDocumentsService, WellFinalDocumentsService>();
|
||||
services.AddTransient<IFileCategoryService, FileCategoryService>();
|
||||
@ -142,7 +141,6 @@ namespace AsbCloudInfrastructure
|
||||
s.GetService<IAsbCloudDbContext>(),
|
||||
s.GetService<IMemoryCache>(),
|
||||
dbSet => dbSet.Include(t => t.Well))); // может быть включен в сервис TelemetryService
|
||||
services.AddTransient<ICrudRepository<DrillParamsDto>, DrillParamsService>();
|
||||
services.AddTransient<ICrudRepository<DepositDto>, CrudCacheRepositoryBase<DepositDto, Deposit>>(s =>
|
||||
new CrudCacheRepositoryBase<DepositDto, Deposit>(
|
||||
s.GetService<IAsbCloudDbContext>(),
|
||||
|
@ -29,7 +29,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
{ }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual async Task<IEnumerable<TDto>> GetAllAsync(CancellationToken token = default)
|
||||
public virtual async Task<IEnumerable<TDto>> GetAllAsync(CancellationToken token)
|
||||
{
|
||||
var entities = await GetQuery()
|
||||
.AsNoTracking()
|
||||
@ -40,7 +40,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual async Task<TDto?> GetOrDefaultAsync(int id, CancellationToken token = default)
|
||||
public virtual async Task<TDto?> GetOrDefaultAsync(int id, CancellationToken token)
|
||||
{
|
||||
var entity = await GetQuery()
|
||||
.AsNoTracking()
|
||||
@ -65,7 +65,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual async Task<int> InsertAsync(TDto item, CancellationToken token = default)
|
||||
public virtual async Task<int> InsertAsync(TDto item, CancellationToken token)
|
||||
{
|
||||
var entity = Convert(item);
|
||||
entity.Id = 0;
|
||||
@ -76,7 +76,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual async Task<int> InsertRangeAsync(IEnumerable<TDto> items, CancellationToken token = default)
|
||||
public virtual async Task<int> InsertRangeAsync(IEnumerable<TDto> items, CancellationToken token)
|
||||
{
|
||||
if (!items.Any())
|
||||
return 0;
|
||||
@ -98,7 +98,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual async Task<int> UpdateAsync(TDto item, CancellationToken token = default)
|
||||
public virtual async Task<int> UpdateAsync(TDto item, CancellationToken token)
|
||||
{
|
||||
var existingEntity = await dbSet
|
||||
.AsNoTracking()
|
||||
@ -116,7 +116,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual Task<int> DeleteAsync(int id, CancellationToken token = default)
|
||||
public virtual Task<int> DeleteAsync(int id, CancellationToken token)
|
||||
{
|
||||
var entity = dbSet
|
||||
.AsNoTracking()
|
||||
|
@ -11,14 +11,14 @@ using System.Threading.Tasks;
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
#nullable enable
|
||||
public class CrudWellRelatedCacheServiceBase<TDto, TEntity> : CrudCacheRepositoryBase<TDto, TEntity>, IRepositoryWellRelated<TDto>
|
||||
public class CrudWellRelatedCacheRepositoryBase<TDto, TEntity> : CrudCacheRepositoryBase<TDto, TEntity>, IRepositoryWellRelated<TDto>
|
||||
where TDto : AsbCloudApp.Data.IId, AsbCloudApp.Data.IWellRelated
|
||||
where TEntity : class, IId, IWellRelated
|
||||
{
|
||||
public CrudWellRelatedCacheServiceBase(IAsbCloudDbContext context, IMemoryCache memoryCache)
|
||||
public CrudWellRelatedCacheRepositoryBase(IAsbCloudDbContext context, IMemoryCache memoryCache)
|
||||
: base(context, memoryCache) { }
|
||||
|
||||
public CrudWellRelatedCacheServiceBase(IAsbCloudDbContext context, IMemoryCache memoryCache, Func<DbSet<TEntity>, IQueryable<TEntity>> makeQuery)
|
||||
public CrudWellRelatedCacheRepositoryBase(IAsbCloudDbContext context, IMemoryCache memoryCache, Func<DbSet<TEntity>, IQueryable<TEntity>> makeQuery)
|
||||
: base(context, memoryCache, makeQuery) { }
|
||||
|
||||
public async Task<IEnumerable<TDto>?> GetByIdWellAsync(int idWell, CancellationToken token)
|
@ -10,14 +10,14 @@ using System.Threading.Tasks;
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
#nullable enable
|
||||
public class CrudWellRelatedServiceBase<TDto, TEntity> : CrudRepositoryBase<TDto, TEntity>, IRepositoryWellRelated<TDto>
|
||||
public class CrudWellRelatedRepositoryBase<TDto, TEntity> : CrudRepositoryBase<TDto, TEntity>, IRepositoryWellRelated<TDto>
|
||||
where TDto : AsbCloudApp.Data.IId, AsbCloudApp.Data.IWellRelated
|
||||
where TEntity : class, IId, IWellRelated
|
||||
{
|
||||
public CrudWellRelatedServiceBase(IAsbCloudDbContext context)
|
||||
public CrudWellRelatedRepositoryBase(IAsbCloudDbContext context)
|
||||
: base(context) { }
|
||||
|
||||
public CrudWellRelatedServiceBase(IAsbCloudDbContext context, Func<DbSet<TEntity>, IQueryable<TEntity>> makeQuery)
|
||||
public CrudWellRelatedRepositoryBase(IAsbCloudDbContext context, Func<DbSet<TEntity>, IQueryable<TEntity>> makeQuery)
|
||||
: base(context, makeQuery) { }
|
||||
|
||||
public async Task<IEnumerable<TDto>?> GetByIdWellAsync(int idWell, CancellationToken token)
|
@ -1,63 +0,0 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
public class DrillFlowChartRepository : CrudWellRelatedServiceBase<DrillFlowChartDto, DrillFlowChart>,
|
||||
IDrillFlowChartRepository
|
||||
{
|
||||
private readonly IWellService wellService;
|
||||
|
||||
public DrillFlowChartRepository(IAsbCloudDbContext context, IWellService wellService)
|
||||
: base(context)
|
||||
{
|
||||
this.wellService = wellService;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<DrillFlowChartDto>> GetAllAsync(int idWell,
|
||||
DateTime updateFrom, CancellationToken token = default)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var updateFromUtc = updateFrom.ToUtcDateTimeOffset(timezone.Hours);
|
||||
var entities = await GetQuery()
|
||||
.Where(e => e.IdWell == idWell)
|
||||
.Where(e => e.LastUpdate == updateFromUtc)
|
||||
.OrderBy(e => e.DepthStart)
|
||||
.ThenBy(e => e.Id)
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entities.Select(entity =>
|
||||
{
|
||||
var dto = entity.Adapt<DrillFlowChartDto>();
|
||||
dto.LastUpdate = entity.LastUpdate.ToRemoteDateTime(timezone.Hours);
|
||||
return dto;
|
||||
});
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public override async Task<int> InsertAsync(DrillFlowChartDto dto,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
dto.LastUpdate = DateTime.UtcNow;
|
||||
var result = await base.InsertAsync(dto, token);
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task<int> UpdateAsync(DrillFlowChartDto dto,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
dto.LastUpdate = DateTime.UtcNow;
|
||||
var result = await base.UpdateAsync(dto, token);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
105
AsbCloudInfrastructure/Repository/ProcessMapRepository.cs
Normal file
105
AsbCloudInfrastructure/Repository/ProcessMapRepository.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
#nullable enable
|
||||
public class ProcessMapRepository : CrudWellRelatedRepositoryBase<ProcessMapDto, ProcessMap>,
|
||||
IProcessMapRepository
|
||||
{
|
||||
private readonly IWellService wellService;
|
||||
|
||||
public ProcessMapRepository(IAsbCloudDbContext context, IWellService wellService)
|
||||
: base(context, dbSet =>
|
||||
dbSet.Include(x => x.Well)
|
||||
.Include(x => x.WellSectionType)
|
||||
)
|
||||
{
|
||||
this.wellService = wellService;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ProcessMapDto>> GetAllAsync(int idWell,
|
||||
DateTime? updateFrom, CancellationToken token)
|
||||
{
|
||||
var entities = await BuildQuery(idWell, updateFrom)
|
||||
.OrderBy(e => e.DepthStart)
|
||||
.ThenBy(e => e.Id)
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entities.Select(Convert);
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public override async Task<int> InsertAsync(ProcessMapDto dto,
|
||||
CancellationToken token)
|
||||
{
|
||||
dto.LastUpdate = DateTime.UtcNow;
|
||||
var result = await base.InsertAsync(dto, token);
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task<int> UpdateAsync(ProcessMapDto dto,
|
||||
CancellationToken token)
|
||||
{
|
||||
dto.LastUpdate = DateTime.UtcNow;
|
||||
var result = await base.UpdateAsync(dto, token);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private IQueryable<ProcessMap> BuildQuery(int idWell, DateTime? updateFrom)
|
||||
{
|
||||
var query = GetQuery().Where(e => e.IdWell == idWell);
|
||||
|
||||
if (updateFrom is not null)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var updateFromUtc = updateFrom?.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query.Where(e => e.LastUpdate >= updateFromUtc);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
protected override ProcessMapDto Convert(ProcessMap entity)
|
||||
{
|
||||
var dto = entity.Adapt<ProcessMapDto>();
|
||||
dto.LastUpdate = entity.LastUpdate.ToRemoteDateTime(entity.Well.Timezone.Hours);
|
||||
dto.AxialLoad = new PlanFactDto
|
||||
{
|
||||
Fact = entity.AxialLoadFact,
|
||||
Plan = entity.AxialLoadPlan
|
||||
};
|
||||
dto.Flow = new PlanFactDto
|
||||
{
|
||||
Fact = entity.FlowFact,
|
||||
Plan = entity.FlowPlan
|
||||
};
|
||||
dto.Pressure = new PlanFactDto
|
||||
{
|
||||
Fact = entity.FlowFact,
|
||||
Plan = entity.FlowPlan
|
||||
};
|
||||
dto.TopDriveSpeed = new PlanFactDto
|
||||
{
|
||||
Fact = entity.TopDriveSpeedFact,
|
||||
Plan = entity.TopDriveSpeedPlan
|
||||
};
|
||||
dto.TopDriveTorque = new PlanFactDto
|
||||
{
|
||||
Fact = entity.TopDriveTorqueFact,
|
||||
Plan = entity.TopDriveTorquePlan
|
||||
};
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -11,7 +11,7 @@ using System.Threading.Tasks;
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
#nullable enable
|
||||
public class ScheduleRepository : CrudWellRelatedServiceBase<ScheduleDto, Schedule>, IScheduleRepository
|
||||
public class ScheduleRepository : CrudWellRelatedRepositoryBase<ScheduleDto, Schedule>, IScheduleRepository
|
||||
{
|
||||
private readonly IWellService wellService;
|
||||
|
||||
|
@ -11,7 +11,7 @@ using System.Linq;
|
||||
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
public class SetpointsRequestRepository : CrudWellRelatedCacheServiceBase<SetpointsRequestDto, SetpointsRequest>
|
||||
public class SetpointsRequestRepository : CrudWellRelatedCacheRepositoryBase<SetpointsRequestDto, SetpointsRequest>
|
||||
{
|
||||
private readonly IWellService wellService;
|
||||
|
||||
|
@ -48,9 +48,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
.Include(w => w.WellType)
|
||||
.Include(w => w.Cluster)
|
||||
.ThenInclude(c => c.Deposit)
|
||||
from p in db.DrillParams
|
||||
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany) &&
|
||||
well.Id == p.IdWell
|
||||
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany)
|
||||
select well).ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
|
@ -1,222 +0,0 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure.Repository;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
#nullable enable
|
||||
public class DrillParamsService : CrudRepositoryBase<DrillParamsDto, DrillParams>, IDrillParamsService
|
||||
{
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly ITelemetryService telemetryService;
|
||||
|
||||
public DrillParamsService(IAsbCloudDbContext context, ITelemetryService telemetryService)
|
||||
: base(context)
|
||||
{
|
||||
this.db = context;
|
||||
this.telemetryService = telemetryService;
|
||||
}
|
||||
|
||||
public async Task<DrillParamsDto?> GetDefaultDrillParamsAsync(int idWell,
|
||||
double startDepth, double endDepth, CancellationToken token = default)
|
||||
{
|
||||
var idTelemetry = telemetryService.GetOrDefaultIdTelemetryByIdWell(idWell);
|
||||
|
||||
if (idTelemetry is null)
|
||||
return null;
|
||||
|
||||
var drillParamsDto = await (from telemetry in db.TelemetryDataSaub
|
||||
where telemetry.IdTelemetry == idTelemetry &&
|
||||
telemetry.WellDepth >= startDepth &&
|
||||
telemetry.WellDepth <= endDepth
|
||||
group telemetry by telemetry.IdTelemetry into g
|
||||
select new DrillParamsDto()
|
||||
{
|
||||
IdWell = idWell,
|
||||
Depth = new MinMaxDto<double>
|
||||
{
|
||||
Min = endDepth,
|
||||
Max = startDepth
|
||||
},
|
||||
IdWellSectionType = 0,
|
||||
AxialLoad = new MinMaxExtendedViewDto
|
||||
{
|
||||
Min = g.Min(t => t.AxialLoad) ?? double.NaN,
|
||||
Avg = g.Average(t => t.AxialLoad) ?? double.NaN,
|
||||
Max = g.Max(t => t.AxialLoad) ?? double.NaN
|
||||
},
|
||||
Pressure = new MinMaxExtendedViewDto
|
||||
{
|
||||
Min = g.Min(t => t.Pressure) ?? double.NaN,
|
||||
Avg = g.Average(t => t.Pressure) ?? double.NaN,
|
||||
Max = g.Max(t => t.Pressure) ?? double.NaN
|
||||
},
|
||||
RotorTorque = new MinMaxExtendedViewDto
|
||||
{
|
||||
Min = g.Min(t => t.RotorTorque) ?? double.NaN,
|
||||
Avg = g.Average(t => t.RotorTorque) ?? double.NaN,
|
||||
Max = g.Max(t => t.RotorTorque) ?? double.NaN
|
||||
},
|
||||
RotorSpeed = new MinMaxExtendedViewDto
|
||||
{
|
||||
Min = g.Min(t => t.RotorSpeed) ?? double.NaN,
|
||||
Avg = g.Average(t => t.RotorSpeed) ?? double.NaN,
|
||||
Max = g.Max(t => t.RotorSpeed) ?? double.NaN
|
||||
},
|
||||
Flow = new MinMaxExtendedViewDto
|
||||
{
|
||||
Min = g.Min(t => t.Flow) ?? double.NaN,
|
||||
Avg = g.Min(t => t.Flow) ?? double.NaN,
|
||||
Max = g.Min(t => t.Flow) ?? double.NaN
|
||||
}
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.AxialLoad.Min)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return drillParamsDto;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<DrillParamsDto>> GetAllAsync(int idWell,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var entities = await db.DrillParams
|
||||
.Where(p => p.IdWell == idWell)
|
||||
.OrderBy(p=> p.Id)
|
||||
.AsNoTracking()
|
||||
.ToArrayAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entities.Select(p =>
|
||||
{
|
||||
var dto = new DrillParamsDto
|
||||
{
|
||||
IdWell = p.IdWell,
|
||||
Id = p.Id,
|
||||
IdWellSectionType = p.IdWellSectionType,
|
||||
Depth = new MinMaxDto<double> { Max = p.PressureMax, Min = p.PressureMin },
|
||||
Pressure = MakeMinMaxExtended(p.PressureAvg, p.PressureMax, p.PressureMin),
|
||||
AxialLoad = MakeMinMaxExtended(p.AxialLoadAvg, p.AxialLoadMax, p.AxialLoadMin),
|
||||
Flow = MakeMinMaxExtended(p.FlowAvg, p.FlowMax, p.FlowMin),
|
||||
RotorSpeed = MakeMinMaxExtended(p.RotorSpeedAvg, p.RotorSpeedMax, p.RotorSpeedMin),
|
||||
RotorTorque = MakeMinMaxExtended(p.RotorTorqueAvg, p.RotorTorqueMax, p.RotorTorqueMin)
|
||||
};
|
||||
return dto;
|
||||
});
|
||||
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<DrillParamsDto>> GetCompositeAllAsync(int idWell,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var allDrillParamsQuery = db.WellComposites
|
||||
.Where(c => c.IdWell == idWell)
|
||||
.Join(db.DrillParams,
|
||||
c => c.IdWellSrc,
|
||||
p => p.IdWell,
|
||||
(c, p) => p);
|
||||
|
||||
var allDrillParams = await allDrillParamsQuery
|
||||
.AsNoTracking()
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var compositeWellDrillParamsQuery = db.WellComposites
|
||||
.Where(c => c.IdWell == idWell)
|
||||
.Join(db.DrillParams,
|
||||
c => new { IdWell = c.IdWellSrc, IdSection = c.IdWellSectionType },
|
||||
p => new { IdWell = p.IdWell, IdSection = p.IdWellSectionType },
|
||||
(c, p) => p);
|
||||
|
||||
var compositeWellDrillParams = await compositeWellDrillParamsQuery
|
||||
.AsNoTracking()
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var result = compositeWellDrillParams.Select(x => Convert(x, allDrillParams));
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<int> InsertAsync(int idWell, DrillParamsDto dto,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
dto.IdWell = idWell;
|
||||
|
||||
var result = await base.InsertAsync(dto, token).ConfigureAwait(false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<int> InsertRangeAsync(int idWell, IEnumerable<DrillParamsDto> dtos,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
foreach (var dto in dtos)
|
||||
dto.IdWell = idWell;
|
||||
|
||||
var result = await base.InsertRangeAsync(dtos, token).ConfigureAwait(false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<int> SaveAsync(int idWell, IEnumerable<DrillParamsDto> dtos,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
db.DrillParams.RemoveRange(db.DrillParams.Where(d => d.IdWell == idWell));
|
||||
|
||||
foreach (var dto in dtos)
|
||||
dto.IdWell = idWell;
|
||||
|
||||
var result = await base.InsertRangeAsync(dtos, token).ConfigureAwait(false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<int> UpdateAsync(int idWell, int dtoId, DrillParamsDto dto,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
dto.IdWell = idWell;
|
||||
|
||||
var result = await base.UpdateAsync(dto, token).ConfigureAwait(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static DrillParamsDto Convert(DrillParams entity, IEnumerable<DrillParams> drillParams)
|
||||
{
|
||||
return new DrillParamsDto
|
||||
{
|
||||
Id = entity.Id,
|
||||
IdWellSectionType = entity.IdWellSectionType,
|
||||
AxialLoad = MakeMinMaxExtended(entity.AxialLoadAvg, entity.AxialLoadMax, entity.AxialLoadMin, drillParams.Select(x => (x.AxialLoadMin, x.AxialLoadMax))),
|
||||
Depth = new MinMaxDto<double> {
|
||||
Min = entity.DepthEnd,
|
||||
Max = entity.DepthStart
|
||||
},
|
||||
Flow = MakeMinMaxExtended(entity.FlowAvg, entity.FlowMax, entity.FlowMin, drillParams.Select(x => (x.FlowMin, x.FlowMax))),
|
||||
IdWell = entity.IdWell,
|
||||
Pressure = MakeMinMaxExtended(entity.PressureAvg, entity.PressureMax, entity.PressureMin, drillParams.Select(x => (x.PressureMin, x.PressureMax))),
|
||||
RotorSpeed = MakeMinMaxExtended(entity.RotorSpeedAvg, entity.RotorSpeedMax, entity.RotorSpeedMin, drillParams.Select(x => (x.RotorSpeedMin, x.RotorSpeedMax))),
|
||||
RotorTorque = MakeMinMaxExtended(entity.RotorTorqueAvg, entity.RotorTorqueMax, entity.RotorTorqueMin, drillParams.Select(x => (x.RotorTorqueMin, x.RotorTorqueMax)))
|
||||
};
|
||||
}
|
||||
|
||||
private static MinMaxExtendedViewDto MakeMinMaxExtended(double avg, double max, double min, IEnumerable<(double min, double max)>? allDrillParams = null)
|
||||
=> new MinMaxExtendedViewDto {
|
||||
Avg = avg,
|
||||
Max = max,
|
||||
Min = min,
|
||||
IsMax = (! allDrillParams?.Any (mx => mx.max > max)) ?? false,
|
||||
IsMin = (! allDrillParams?.Any (mn => mn.min < min)) ?? false
|
||||
};
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -10,7 +10,7 @@ namespace AsbCloudInfrastructure.Validators
|
||||
// services.AddTransient<IValidator<ClusterDto>, ClusterDtoValidator>();
|
||||
// services.AddTransient<IValidator<CompanyDto>, CompanyDtoValidator>();
|
||||
// services.AddTransient<IValidator<DepositDto>, DepositDtoValidator>();
|
||||
// services.AddTransient<IValidator<DrillFlowChartDto>, DrillFlowChartDtoValidator>();
|
||||
// services.AddTransient<IValidator<DrillFlowChartDto>, ProcessMapValidator>();
|
||||
// services.AddTransient<IValidator<EventDto>, EventDtoValidator>();
|
||||
// services.AddTransient<IValidator<FileInfoDto>, FileInfoDtoValidator>();
|
||||
// services.AddTransient<IValidator<FileMarkDto>, FileMarkDtoValidator>();
|
||||
|
@ -3,14 +3,12 @@ using FluentValidation;
|
||||
|
||||
namespace AsbCloudInfrastructure.Validators
|
||||
{
|
||||
public class DrillFlowChartDtoValidator : AbstractValidator<DrillFlowChartDto>
|
||||
public class ProcessMapValidator : AbstractValidator<ProcessMapDto>
|
||||
{
|
||||
public DrillFlowChartDtoValidator()
|
||||
public ProcessMapValidator()
|
||||
{
|
||||
RuleFor(x => x.IdWell).GreaterThan(0)
|
||||
.WithMessage("Id скважины не может быть меньше 1");
|
||||
RuleFor(x => x.IdWellOperationCategory).GreaterThan(0)
|
||||
.WithMessage("Id категории операции не может быть меньше 1");
|
||||
RuleFor(x => x.DepthStart).GreaterThan(-1)
|
||||
.WithMessage("Глубина не может быть отрицательной");
|
||||
RuleFor(x => x.DepthEnd).GreaterThan(-1)
|
@ -61,12 +61,6 @@ public class ClusterServiceTest
|
||||
new WellSectionType { Id = 1, Caption = "Test well section type 1" }
|
||||
};
|
||||
|
||||
private readonly List<DrillParams> drillParams = new()
|
||||
{
|
||||
new DrillParams {Id = 1, IdWell = 1, IdWellSectionType = 1},
|
||||
new DrillParams {Id = 2, IdWell = 2, IdWellSectionType = 1}
|
||||
};
|
||||
|
||||
public ClusterServiceTest()
|
||||
{
|
||||
context = TestHelpter.MakeRealTestContext();
|
||||
@ -78,7 +72,6 @@ public class ClusterServiceTest
|
||||
context.Companies.RemoveRange(context.Companies);
|
||||
context.RelationCompaniesWells.RemoveRange(context.RelationCompaniesWells);
|
||||
context.WellSectionTypes.RemoveRange(context.WellSectionTypes);
|
||||
context.DrillParams.RemoveRange(context.DrillParams);
|
||||
if (context.ChangeTracker.HasChanges())
|
||||
context.SaveChanges();
|
||||
context.Deposits.AddRange(deposits);
|
||||
@ -88,7 +81,6 @@ public class ClusterServiceTest
|
||||
context.Companies.AddRange(companies);
|
||||
context.RelationCompaniesWells.AddRange(relations);
|
||||
context.WellSectionTypes.AddRange(wellSectionTypes);
|
||||
context.DrillParams.AddRange(drillParams);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ using System.Threading.Tasks;
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// CRUD контроллер для админки.
|
||||
/// </summary>
|
||||
@ -25,9 +26,9 @@ namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
protected readonly TService service;
|
||||
|
||||
public Func<T, CancellationToken, Task<bool>> InsertForbidAsync { get; protected set; } = null;
|
||||
public Func<T, CancellationToken, Task<bool>> UpdateForbidAsync { get; protected set; } = null;
|
||||
public Func<int, CancellationToken, Task<bool>> DeleteForbidAsync { get; protected set; } = null;
|
||||
public Func<T, CancellationToken, Task<bool>> InsertForbidAsync { get; protected set; } = null!;
|
||||
public Func<T, CancellationToken, Task<bool>> UpdateForbidAsync { get; protected set; } = null!;
|
||||
public Func<int, CancellationToken, Task<bool>> DeleteForbidAsync { get; protected set; } = null!;
|
||||
|
||||
public CrudController(TService service)
|
||||
{
|
||||
@ -55,7 +56,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <returns>запись</returns>
|
||||
[HttpGet("{id}")]
|
||||
[Permission]
|
||||
public virtual async Task<ActionResult<T>> GetAsync(int id, CancellationToken token)
|
||||
public virtual async Task<ActionResult<T?>> GetOrDefaultAsync(int id, CancellationToken token)
|
||||
{
|
||||
var result = await service.GetOrDefaultAsync(id, token).ConfigureAwait(false);
|
||||
return Ok(result);
|
||||
@ -139,4 +140,5 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// CRUD контроллер dto связных со скважиной для админки.
|
||||
/// </summary>
|
||||
@ -75,14 +76,17 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <param name="token"></param>
|
||||
/// <returns>запись</returns>
|
||||
[HttpGet("{id}")]
|
||||
public override async Task<ActionResult<T>> GetAsync(int id, CancellationToken token)
|
||||
public override async Task<ActionResult<T?>> GetOrDefaultAsync(int id, CancellationToken token)
|
||||
{
|
||||
var actionResult = await base.GetAsync(id, token);
|
||||
// TODO: this can be nullref
|
||||
var result = actionResult.Value;
|
||||
if (!await UserHasAccesToWellAsync(result.IdWell, token))
|
||||
return Forbid();
|
||||
return Ok(result);
|
||||
var actionResult = await base.GetOrDefaultAsync(id, token);
|
||||
if(actionResult.Result is OkObjectResult okResult)
|
||||
{
|
||||
if (okResult.Value is IWellRelated wellRelated)
|
||||
if (!await UserHasAccesToWellAsync(wellRelated.IdWell, token))
|
||||
return Forbid();
|
||||
}
|
||||
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -157,4 +161,5 @@ namespace AsbCloudWebApi.Controllers
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Коридоры бурения для панели бурильщика
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
public class DrillFlowChartController : CrudWellRelatedController<DrillFlowChartDto, IDrillFlowChartRepository>
|
||||
{
|
||||
private readonly ITelemetryService telemetryService;
|
||||
|
||||
public DrillFlowChartController(IWellService wellService, IDrillFlowChartRepository service,
|
||||
ITelemetryService telemetryService)
|
||||
: base(wellService, service)
|
||||
{
|
||||
this.telemetryService = telemetryService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает все значения для коридоров бурения по uid панели
|
||||
/// </summary>
|
||||
/// <param name="uid"> uid панели </param>
|
||||
/// <param name="updateFrom"> Дата, с которой следует искать новые параметры </param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns> Список параметров для коридоров бурения </returns>
|
||||
[HttpGet]
|
||||
[Route("/api/telemetry/{uid}/drillFlowChart")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<DrillFlowChartDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetByTelemetryAsync(string uid, DateTime updateFrom = default, CancellationToken token = default)
|
||||
{
|
||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
||||
if (idWell is null)
|
||||
return BadRequest($"Wrong uid {uid}");
|
||||
|
||||
var dto = await service.GetAllAsync((int)idWell,
|
||||
updateFrom, token);
|
||||
|
||||
return Ok(dto);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,222 +0,0 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Режимы бурения
|
||||
/// </summary>
|
||||
[Route("api/well/{idWell}/drillParams/")]
|
||||
[ApiController]
|
||||
public class DrillParamsController : ControllerBase
|
||||
{
|
||||
private readonly IDrillParamsService drillParamsService;
|
||||
private readonly IWellService wellService;
|
||||
|
||||
public DrillParamsController(IDrillParamsService drillParamsService,
|
||||
IWellService wellService)
|
||||
{
|
||||
this.drillParamsService = drillParamsService;
|
||||
this.wellService = wellService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает автоматически рассчитанные значения для режимов бурения
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="startDepth"> Стартовая глубина </param>
|
||||
/// <param name="endDepth"> Конечная глубина </param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns> Значения по умолчанию для режимов бурения </returns>
|
||||
[HttpGet("autoParams")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(DrillParamsDto), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetDefaultAsync(int idWell,
|
||||
double startDepth, double endDepth, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var drillParamsDo = await drillParamsService.GetDefaultDrillParamsAsync(idWell,
|
||||
startDepth, endDepth, token);
|
||||
|
||||
return Ok(drillParamsDo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает все значения для режимов бурения на скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns> Список параметров для режимов бурения на скважине </returns>
|
||||
[HttpGet]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(IEnumerable<DrillParamsDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetAllAsync(int idWell,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var dto = await drillParamsService.GetAllAsync(idWell, token);
|
||||
|
||||
return Ok(dto);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сохраняет значения для режимов бурения по секции на скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="drillParamsDto"> Параметры режимов бурений для секции</param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> InsertAsync(int idWell,
|
||||
DrillParamsDto drillParamsDto, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await drillParamsService.InsertAsync(idWell, drillParamsDto, token);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавляет массив объектов режимов бурений
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="drillParams"> Массив объектов параметров режима бурений для секции</param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("range")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> InsertRangeAsync(int idWell,
|
||||
IEnumerable<DrillParamsDto> drillParams, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await drillParamsService.InsertRangeAsync(idWell, drillParams,
|
||||
token);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаляет старые режимы бурения по скважине и добавляет новые
|
||||
/// </summary>
|
||||
/// <param name="idWell">Id скважины для добавления</param>
|
||||
/// <param name="drillParams">Новые режимы бурения </param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns>кол-во затронутых изменениями записей</returns>
|
||||
[HttpPost("save")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> SaveAsync(int idWell, IEnumerable<DrillParamsDto> drillParams, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await drillParamsService.SaveAsync(idWell, drillParams,
|
||||
token);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Изменяет значения выбранного режима бурения
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="dtoId"> id dto для изменения </param>
|
||||
/// <param name="drillParamsDto"> Параметры режимов бурений для секции</param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> UpdateAsync(int idWell, int dtoId,
|
||||
DrillParamsDto drillParamsDto, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await drillParamsService.UpdateAsync(idWell, dtoId,
|
||||
drillParamsDto, token);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаляет объект значений выбранного режима бурения
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="drillParamsId"> Id объекта параметров режима бурений для секции</param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> DeleteAsync(int idWell,
|
||||
int drillParamsId, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await drillParamsService.DeleteAsync(drillParamsId,
|
||||
token);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает значения для режимов бурения на композитной скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns> Список параметров для режимов бурения на композитной скважине </returns>
|
||||
[HttpGet("composite")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(IEnumerable<DrillParamsDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetCompositeAllAsync(int idWell, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var dto = await drillParamsService.GetCompositeAllAsync(idWell, token);
|
||||
|
||||
return Ok(dto);
|
||||
}
|
||||
}
|
||||
}
|
117
AsbCloudWebApi/Controllers/ProcessMapController.cs
Normal file
117
AsbCloudWebApi/Controllers/ProcessMapController.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// РТК
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
public class ProcessMapController : CrudWellRelatedController<ProcessMapDto, IProcessMapRepository>
|
||||
{
|
||||
private readonly ITelemetryService telemetryService;
|
||||
|
||||
public ProcessMapController(IWellService wellService, IProcessMapRepository service,
|
||||
ITelemetryService telemetryService)
|
||||
: base(wellService, service)
|
||||
{
|
||||
this.telemetryService = telemetryService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает все значения для коридоров бурения по uid панели
|
||||
/// </summary>
|
||||
/// <param name="uid"> uid панели </param>
|
||||
/// <param name="updateFrom"> Дата, с которой следует искать новые параметры </param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns> Список параметров для коридоров бурения </returns>
|
||||
[HttpGet]
|
||||
[Obsolete("use GetByUidAsync(..) instead")]
|
||||
[Route("/api/telemetry/{uid}/drillFlowChart")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<ProcessMapDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public IActionResult GetByTelemetry(string uid, DateTime updateFrom, CancellationToken token)
|
||||
{
|
||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
||||
if (idWell is null)
|
||||
return BadRequest($"Wrong uid {uid}");
|
||||
|
||||
var dto = Enumerable.Empty<ProcessMapDto>();
|
||||
return Ok(dto);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает РТК по uid телеметрии
|
||||
/// </summary>
|
||||
/// <param name="uid"> uid телеметрии </param>
|
||||
/// <param name="updateFrom"> Дата, с которой следует искать новые параметры </param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns> Список параметров для коридоров бурения </returns>
|
||||
[HttpGet]
|
||||
[Route("/api/telemetry/{uid}/processMap")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<ProcessMapDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetByUidAsync(string uid, DateTime updateFrom, CancellationToken token)
|
||||
{
|
||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
||||
if (idWell is null)
|
||||
return BadRequest($"Wrong uid {uid}");
|
||||
|
||||
var dto = await service.GetAllAsync((int)idWell,
|
||||
updateFrom, token);
|
||||
|
||||
return Ok(dto);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Выгрузка расширенной РТК
|
||||
/// </summary>
|
||||
/// <param name="wellId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
[HttpGet]
|
||||
[Route("getReportFile/{wellId}")]
|
||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
||||
public Task<IActionResult> GetReportFileAsync(int wellId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавить запись
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public override async Task<ActionResult<int>> InsertAsync([FromBody] ProcessMapDto value, CancellationToken token)
|
||||
{
|
||||
value.IdUser = User.GetUserId() ?? -1;
|
||||
return await base.InsertAsync(value, token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Редактировать запись по id
|
||||
/// </summary>
|
||||
/// <param name="value">запись</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns>1 - успешно отредактировано, 0 - нет</returns>
|
||||
[HttpPut]
|
||||
public override async Task<ActionResult<int>> UpdateAsync([FromBody] ProcessMapDto value, CancellationToken token)
|
||||
{
|
||||
value.IdUser = User.GetUserId() ?? -1;
|
||||
return await base.InsertAsync(value, token);
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
Loading…
Reference in New Issue
Block a user