From 8dbc380f179e9822ff1a0e39083768200e5cd459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A1=D1=82?= =?UTF-8?q?=D0=B5=D0=BF=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Fri, 30 Jun 2023 14:55:44 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B0=D0=BA=D1=82=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D1=81=D0=BA=D0=B8=D0=B5=20=D1=82=D1=80=D0=B0=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Контроллер для фактических категорий 2. Дополнил TrajectoryGeoDto, некоторые параметры траекторий могу совпадать. Принял решение вынести это в базовый класс 3. Рефакторинг репозитория --- AsbCloudApp/Data/TrajectoryGeoFactDto.cs | 27 +++++++++++- AsbCloudApp/Data/TrajectoryGeoPlanDto.cs | 25 ----------- .../Repository/TrajectoryFactRepository.cs | 17 +++++--- .../Controllers/FactTrajectoryController.cs | 43 +++++++++++++++++++ 4 files changed, 80 insertions(+), 32 deletions(-) create mode 100644 AsbCloudWebApi/Controllers/FactTrajectoryController.cs diff --git a/AsbCloudApp/Data/TrajectoryGeoFactDto.cs b/AsbCloudApp/Data/TrajectoryGeoFactDto.cs index 0cd896cc..0880e507 100644 --- a/AsbCloudApp/Data/TrajectoryGeoFactDto.cs +++ b/AsbCloudApp/Data/TrajectoryGeoFactDto.cs @@ -5,6 +5,11 @@ /// public abstract class TrajectoryGeoDto { + /// + /// Id скважины + /// + public int IdWell { get; set; } + /// /// Глубина по стволу /// @@ -18,13 +23,33 @@ public abstract class TrajectoryGeoDto /// Азимут Географ. /// public double AzimuthGeo { get; set; } + + /// + /// Азимут Магнитный + /// + public double? AzimuthMagnetic { get; set; } + + /// + /// Глубина вертикальная + /// + public double? VerticalDepth { get; set; } + + /// + /// Север отн- но устья + /// + public double? NorthOrifice { get; set; } + + /// + /// Восток отн- но устья + /// + public double? EastOrifice { get; set; } } /// /// Формирование данных по фактической географической траектории /// public class TrajectoryGeoFactDto : TrajectoryGeoDto -{} +{ } diff --git a/AsbCloudApp/Data/TrajectoryGeoPlanDto.cs b/AsbCloudApp/Data/TrajectoryGeoPlanDto.cs index 9f2b3d33..ca538979 100644 --- a/AsbCloudApp/Data/TrajectoryGeoPlanDto.cs +++ b/AsbCloudApp/Data/TrajectoryGeoPlanDto.cs @@ -11,11 +11,6 @@ namespace AsbCloudApp.Data /// public int Id { get; set; } - /// - /// ИД скважины - /// - public int IdWell { get; set; } - /// /// Дата загрузки /// @@ -26,31 +21,11 @@ namespace AsbCloudApp.Data /// public int IdUser { get; set; } - /// - /// Азимут Магнитный - /// - public double AzimuthMagnetic { get; set; } - - /// - /// Глубина вертикальная - /// - public double VerticalDepth { get; set; } - /// /// Абсолютная отметка /// public double AbsoluteMark { get; set; } - /// - /// Север отн- но устья - /// - public double NorthOrifice { get; set; } - - /// - /// Восток отн- но устья - /// - public double EastOrifice { get; set; } - /// /// Восток картографический /// diff --git a/AsbCloudInfrastructure/Repository/TrajectoryFactRepository.cs b/AsbCloudInfrastructure/Repository/TrajectoryFactRepository.cs index 21a1ffff..23cf92a6 100644 --- a/AsbCloudInfrastructure/Repository/TrajectoryFactRepository.cs +++ b/AsbCloudInfrastructure/Repository/TrajectoryFactRepository.cs @@ -1,5 +1,4 @@ using AsbCloudApp.Data; -using AsbCloudApp.Exceptions; using AsbCloudApp.Repositories; using AsbCloudApp.Services; using AsbCloudDb.Model; @@ -20,24 +19,30 @@ namespace AsbCloudInfrastructure.Repository this.db = db; this.wellService = wellService; } - + public async Task> GetAsync(int idWell, CancellationToken token) { - var well = wellService.GetOrDefault(idWell); - if (well is null || well.Timezone is null) - throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell)); + var well = await wellService.GetOrDefaultAsync(idWell, + token); + + if (well is null) + return Enumerable.Empty(); var entities = await db.Record7 .AsNoTracking() .Where(x => x.IdTelemetry == well.IdTelemetry) .Where(coord => coord.Deptsvym != null && coord.Svyinc != null && coord.Svyazc != null) .OrderBy(e => e.Deptsvym) - .Select(x => new { x.Deptsvym, x.Svyinc, x.Svyazc }) .ToArrayAsync(token); var result = entities .Select(coord => new TrajectoryGeoFactDto { + IdWell = idWell, + AzimuthMagnetic = coord.Svymtf, + VerticalDepth = coord.Deptsvyv, + NorthOrifice = coord.Svyns, + EastOrifice = coord.Svyew, WellboreDepth = coord.Deptsvym!.Value, ZenithAngle = coord.Svyinc!.Value, AzimuthGeo = coord.Svyazc!.Value diff --git a/AsbCloudWebApi/Controllers/FactTrajectoryController.cs b/AsbCloudWebApi/Controllers/FactTrajectoryController.cs new file mode 100644 index 00000000..c17ce3fd --- /dev/null +++ b/AsbCloudWebApi/Controllers/FactTrajectoryController.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using AsbCloudApp.Data; +using AsbCloudApp.Repositories; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace AsbCloudWebApi.Controllers; + +/// +/// Фактическая траектория +/// +[Authorize] +[ApiController] +[Route("api/well/{idWell}/[controller]")] +public class FactTrajectoryController : ControllerBase +{ + private readonly ITrajectoryFactRepository trajectoryFactRepository; + + public FactTrajectoryController(ITrajectoryFactRepository trajectoryFactRepository) + { + this.trajectoryFactRepository = trajectoryFactRepository; + } + + /// + /// Метод получения всех строк траекторий по id скважины + /// + /// Id скважины + /// Токен отмены операции + /// + [HttpGet] + [Route("getRows")] + [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] + public async Task GetRowsAsync([FromRoute] int idWell, + CancellationToken cancellationToken) + { + var factTrajectories = await trajectoryFactRepository.GetAsync(idWell, + cancellationToken); + + return Ok(factTrajectories); + } +} \ No newline at end of file