forked from ddrilling/AsbCloudServer
CS2-97: Added DrillFlowChartParams infrastructure
This commit is contained in:
parent
70ee22bccf
commit
911deb5b8b
37
AsbCloudApp/Data/DrillFlowChartParamsDto.cs
Normal file
37
AsbCloudApp/Data/DrillFlowChartParamsDto.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
public class DrillFlowChartParamsDto : IId
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
|
public DateTime LastUpdate { get; set; }
|
||||||
|
|
||||||
|
public double DepthStart { get; set; }
|
||||||
|
|
||||||
|
public double DepthEnd { get; set; }
|
||||||
|
|
||||||
|
public double AxialLoadMin { get; set; }
|
||||||
|
|
||||||
|
public double AxialLoadMax { get; set; }
|
||||||
|
|
||||||
|
public double PressureMin { get; set; }
|
||||||
|
|
||||||
|
public double PressureMax { get; set; }
|
||||||
|
|
||||||
|
public double RotorTorqueMin { get; set; }
|
||||||
|
|
||||||
|
public double RotorTorqueMax { get; set; }
|
||||||
|
|
||||||
|
public double RotorSpeedMin { get; set; }
|
||||||
|
|
||||||
|
public double RotorSpeedMax { get; set; }
|
||||||
|
|
||||||
|
public double FlowMin { get; set; }
|
||||||
|
|
||||||
|
public double FlowMax { get; set; }
|
||||||
|
}
|
||||||
|
}
|
22
AsbCloudApp/Services/IDrillFlowChartService.cs
Normal file
22
AsbCloudApp/Services/IDrillFlowChartService.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudApp.Data;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Services
|
||||||
|
{
|
||||||
|
public interface IDrillFlowChartService : ICrudService<DrillFlowChartParamsDto>
|
||||||
|
{
|
||||||
|
Task<IEnumerable<DrillFlowChartParamsDto>> GetAllAsync(int idWell,
|
||||||
|
CancellationToken token = default);
|
||||||
|
|
||||||
|
Task<int> InsertAsync(int idWell, DrillFlowChartParamsDto dto,
|
||||||
|
CancellationToken token = default);
|
||||||
|
|
||||||
|
Task<int> InsertRangeAsync(int idWell, IEnumerable<DrillFlowChartParamsDto> dtos,
|
||||||
|
CancellationToken token = default);
|
||||||
|
|
||||||
|
Task<int> UpdateAsync(int idWell, int idDto, DrillFlowChartParamsDto dto,
|
||||||
|
CancellationToken token = default);
|
||||||
|
}
|
||||||
|
}
|
2681
AsbCloudDb/Migrations/20211013123137_Add_Drill_Flow_Chart.Designer.cs
generated
Normal file
2681
AsbCloudDb/Migrations/20211013123137_Add_Drill_Flow_Chart.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
56
AsbCloudDb/Migrations/20211013123137_Add_Drill_Flow_Chart.cs
Normal file
56
AsbCloudDb/Migrations/20211013123137_Add_Drill_Flow_Chart.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class Add_Drill_Flow_Chart : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "t_drill_flow_chart_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 скважины"),
|
||||||
|
last_update = table.Column<DateTime>(type: "timestamp without 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_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальная нагрузка"),
|
||||||
|
axial_load_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальная нагрузка"),
|
||||||
|
pressure_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальное давление"),
|
||||||
|
pressure_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальное давление"),
|
||||||
|
rotor_torque_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный момент на ВСП"),
|
||||||
|
rotor_torque_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный момент на ВСП"),
|
||||||
|
rotor_speed_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальные обороты на ВСП"),
|
||||||
|
rotor_speed_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальные обороты на ВСП"),
|
||||||
|
flow_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный расход"),
|
||||||
|
flow_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный расход")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_t_drill_flow_chart_params", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_t_drill_flow_chart_params_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_params_well_id",
|
||||||
|
table: "t_drill_flow_chart_params",
|
||||||
|
column: "well_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "t_drill_flow_chart_params");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -156,6 +156,94 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasComment("Месторождение");
|
.HasComment("Месторождение");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChartParams", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
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<DateTime>("LastUpdate")
|
||||||
|
.HasColumnType("timestamp without 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.ToTable("t_drill_flow_chart_params");
|
||||||
|
|
||||||
|
b
|
||||||
|
.HasComment("Параметры корридоров бурения (диапазоны параметров бурения)");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.DrillParams", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.DrillParams", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -2208,6 +2296,17 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.Navigation("CompanyType");
|
b.Navigation("CompanyType");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChartParams", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("IdWell")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Well");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.DrillParams", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.DrillParams", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||||
|
@ -36,6 +36,7 @@ namespace AsbCloudDb.Model
|
|||||||
public virtual DbSet<WellSectionType> WellSectionTypes { get; set; }
|
public virtual DbSet<WellSectionType> WellSectionTypes { get; set; }
|
||||||
public virtual DbSet<WellType> WellTypes { get; set; }
|
public virtual DbSet<WellType> WellTypes { get; set; }
|
||||||
public virtual DbSet<DrillParams> DrillParams { get; set; }
|
public virtual DbSet<DrillParams> DrillParams { get; set; }
|
||||||
|
public virtual DbSet<DrillFlowChartParams> DrillFlowChartParams { get; set; }
|
||||||
|
|
||||||
//var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
//var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
||||||
// .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
// .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
||||||
|
62
AsbCloudDb/Model/DrillFlowChartParams.cs
Normal file
62
AsbCloudDb/Model/DrillFlowChartParams.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Model
|
||||||
|
{
|
||||||
|
[Table("t_drill_flow_chart_params"), Comment("Параметры корридоров бурения (диапазоны параметров бурения)")]
|
||||||
|
public class DrillFlowChartParams : IId
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[Column("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Column("well_id"), Comment("Id скважины")]
|
||||||
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
|
[Column("last_update"), Comment("Дата последнего изменения")]
|
||||||
|
public DateTime 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; }
|
||||||
|
}
|
||||||
|
}
|
@ -34,6 +34,7 @@ namespace AsbCloudDb.Model
|
|||||||
DbSet<MeasureCategory> MeasureCategories { get; set; }
|
DbSet<MeasureCategory> MeasureCategories { get; set; }
|
||||||
DbSet<TelemetryDataSpin> TelemetryDataSpin { get; set; }
|
DbSet<TelemetryDataSpin> TelemetryDataSpin { get; set; }
|
||||||
DbSet<DrillParams> DrillParams { get; set; }
|
DbSet<DrillParams> DrillParams { get; set; }
|
||||||
|
DbSet<DrillFlowChartParams> DrillFlowChartParams { get; set; }
|
||||||
|
|
||||||
DatabaseFacade Database { get; }
|
DatabaseFacade Database { get; }
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<IDrillingProgramService, DrillingProgramService>();
|
services.AddTransient<IDrillingProgramService, DrillingProgramService>();
|
||||||
services.AddTransient<IDrillingProgramApacheService, DrillingProgramApacheService>();
|
services.AddTransient<IDrillingProgramApacheService, DrillingProgramApacheService>();
|
||||||
services.AddTransient<IDrillParamsService, DrillParamsService>();
|
services.AddTransient<IDrillParamsService, DrillParamsService>();
|
||||||
|
services.AddTransient<IDrillFlowChartService, DrillFlowChartService>();
|
||||||
|
|
||||||
// admin crud services:
|
// admin crud services:
|
||||||
services.AddTransient<ICrudService<DepositDto>, CrudServiceBase<DepositDto, Deposit>>();
|
services.AddTransient<ICrudService<DepositDto>, CrudServiceBase<DepositDto, Deposit>>();
|
||||||
|
76
AsbCloudInfrastructure/Services/DrillFlowChartService.cs
Normal file
76
AsbCloudInfrastructure/Services/DrillFlowChartService.cs
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using AsbCloudDb.Model;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Mapster;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure.Services
|
||||||
|
{
|
||||||
|
public class DrillFlowChartService : CrudServiceBase<DrillFlowChartParamsDto, DrillFlowChartParams>,
|
||||||
|
IDrillFlowChartService
|
||||||
|
{
|
||||||
|
private readonly IAsbCloudDbContext db;
|
||||||
|
private readonly ITelemetryService telemetryService;
|
||||||
|
|
||||||
|
public DrillFlowChartService(IAsbCloudDbContext context, ITelemetryService telemetryService)
|
||||||
|
: base(context)
|
||||||
|
{
|
||||||
|
this.db = context;
|
||||||
|
this.telemetryService = telemetryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<DrillFlowChartParamsDto>> GetAllAsync(int idWell,
|
||||||
|
CancellationToken token = default)
|
||||||
|
{
|
||||||
|
var entities = await (from p in db.DrillFlowChartParams
|
||||||
|
where p.IdWell == idWell
|
||||||
|
orderby p.Id
|
||||||
|
select p)
|
||||||
|
.ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
var dto = entities.Adapt<DrillFlowChartParamsDto>();
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> InsertAsync(int idWell, DrillFlowChartParamsDto dto,
|
||||||
|
CancellationToken token = default)
|
||||||
|
{
|
||||||
|
dto.IdWell = idWell;
|
||||||
|
dto.LastUpdate = DateTime.Now;
|
||||||
|
|
||||||
|
var result = await base.InsertAsync(dto, token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> InsertRangeAsync(int idWell, IEnumerable<DrillFlowChartParamsDto> dtos,
|
||||||
|
CancellationToken token = default)
|
||||||
|
{
|
||||||
|
foreach (var dto in dtos)
|
||||||
|
{
|
||||||
|
dto.IdWell = idWell;
|
||||||
|
dto.LastUpdate = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await base.InsertRangeAsync(dtos, token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> UpdateAsync(int idWell, int idDto, DrillFlowChartParamsDto dto,
|
||||||
|
CancellationToken token = default)
|
||||||
|
{
|
||||||
|
dto.IdWell = idWell;
|
||||||
|
dto.LastUpdate = DateTime.Now;
|
||||||
|
|
||||||
|
var result = await base.UpdateAsync(idDto, dto, token).ConfigureAwait(false);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
168
AsbCloudWebApi/Controllers/DrillFlowChartController.cs
Normal file
168
AsbCloudWebApi/Controllers/DrillFlowChartController.cs
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
|
||||||
|
namespace AsbCloudWebApi.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Контроллер для корридоров бурения на панели
|
||||||
|
/// </summary>
|
||||||
|
[Route("api/drillFlowChartParams/{idWell}")]
|
||||||
|
[ApiController]
|
||||||
|
public class DrillFlowChartController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IDrillFlowChartService drillFlowChartService;
|
||||||
|
private readonly ITelemetryService telemetryService;
|
||||||
|
private readonly IWellService wellService;
|
||||||
|
|
||||||
|
public DrillFlowChartController(IDrillFlowChartService drillFlowChartService,
|
||||||
|
ITelemetryService telemetryService, IWellService wellService)
|
||||||
|
{
|
||||||
|
this.drillFlowChartService = drillFlowChartService;
|
||||||
|
this.telemetryService = telemetryService;
|
||||||
|
this.wellService = wellService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращает все значения для корридоров бурения по id скважины
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"> id скважины </param>
|
||||||
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
|
/// <returns> Список параметров для корридоров бурения </returns>
|
||||||
|
[HttpGet("paramsByIdWell")]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<DrillFlowChartParamsDto>), (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 drillFlowChartService.GetAllAsync(idWell, token);
|
||||||
|
|
||||||
|
return Ok(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращает все значения для корридоров бурения по uid панели
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uid"> uid панели </param>
|
||||||
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
|
/// <returns> Список параметров для корридоров бурения </returns>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<DrillFlowChartParamsDto>), (int) System.Net.HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> GetAllAsync(string uid, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
var idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
|
var idWell = telemetryService.GetidWellByTelemetryUid(uid);
|
||||||
|
|
||||||
|
if (idCompany is null || idWell is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
|
(int)idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
var dto = await drillFlowChartService.GetAllAsync((int)idWell, token);
|
||||||
|
|
||||||
|
return Ok(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохраняет значения для корридоров бурения
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"> id скважины </param>
|
||||||
|
/// <param name="drillFlowChartParamsDto"> Параметры корридоров бурения</param>
|
||||||
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> InsertAsync(int idWell,
|
||||||
|
DrillFlowChartParamsDto drillFlowChartParamsDto, 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 drillFlowChartService.InsertAsync(idWell, drillFlowChartParamsDto, token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавляет массив объектов корридоров бурения
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"> id скважины </param>
|
||||||
|
/// <param name="drillFlowChartParams"> Массив объектов параметров корридоров бурения</param>
|
||||||
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("range")]
|
||||||
|
[ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> InsertRangeAsync(int idWell,
|
||||||
|
IEnumerable<DrillFlowChartParamsDto> drillFlowChartParams, 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 drillFlowChartService.InsertRangeAsync(idWell, drillFlowChartParams,
|
||||||
|
token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Изменяет значения выбранного корридора бурения
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"> id скважины </param>
|
||||||
|
/// <param name="drillFlowChartParams"> Параметры корридоров бурения</param>
|
||||||
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut]
|
||||||
|
[ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> EditAsync(int idWell,
|
||||||
|
DrillFlowChartParamsDto drillFlowChartParams, 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 drillFlowChartService.UpdateAsync(idWell,
|
||||||
|
drillFlowChartParams, token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удаляет значения выбранного корридора бурения
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"> id скважины </param>
|
||||||
|
/// <param name="drillFlowChartParamsId"> Id объекта корридоров бурения</param>
|
||||||
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete]
|
||||||
|
[ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> DeleteAsync(int idWell,
|
||||||
|
int drillFlowChartParamsId, 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 drillFlowChartService.DeleteAsync(drillFlowChartParamsId,
|
||||||
|
token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user