From d79c7c9c970fc2c5da9bbe31a9b91007a7f0b64b Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Fri, 27 Oct 2023 09:49:32 +0500 Subject: [PATCH 1/4] Dix EventDto validation --- AsbCloudApp/Data/SAUB/EventDto.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AsbCloudApp/Data/SAUB/EventDto.cs b/AsbCloudApp/Data/SAUB/EventDto.cs index d8103d17..f426c4eb 100644 --- a/AsbCloudApp/Data/SAUB/EventDto.cs +++ b/AsbCloudApp/Data/SAUB/EventDto.cs @@ -21,7 +21,7 @@ namespace AsbCloudApp.Data.SAUB /// /// id категории события /// - [Range(1, int.MaxValue, ErrorMessage = "Id категории события не может быть отрицательным")] + [Range(0, int.MaxValue, ErrorMessage = "Id категории события не может быть отрицательным")] public int IdCategory { get; set; } /// @@ -32,7 +32,7 @@ namespace AsbCloudApp.Data.SAUB /// /// тип определения наступления события /// - [Range(1, int.MaxValue, ErrorMessage = "Id типа события не может быть отрицательным")] + [Range(0, int.MaxValue, ErrorMessage = "Id типа события не может быть отрицательным")] public int EventType { get; set; } /// From 77a3652b10956a176543eac927802ca3cea88414 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Fri, 27 Oct 2023 10:58:28 +0500 Subject: [PATCH 2/4] =?UTF-8?q?=D0=92=20DbContext=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=20"Include=20Error=20Detail"=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudDb/Model/AsbCloudDbContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index 8b5a359f..d5b179e8 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -104,7 +104,7 @@ namespace AsbCloudDb.Model protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) - optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True" + optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail" //, builder=>builder.EnableRetryOnFailure(2, System.TimeSpan.FromMinutes(1)) ); } From 2afab2077fae595f0d0660ed1fc52c0c0171886b Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Fri, 27 Oct 2023 10:58:28 +0500 Subject: [PATCH 3/4] =?UTF-8?q?=D0=92=20DbContext=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=20"Include=20Error=20Detail"=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudDb/Model/AsbCloudDbContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index 8b5a359f..b26c7a25 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -104,7 +104,7 @@ namespace AsbCloudDb.Model protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) - optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True" + optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True;" //, builder=>builder.EnableRetryOnFailure(2, System.TimeSpan.FromMinutes(1)) ); } From bc986e789a2cdbb34de3e3bb10c9c9a5005e526f Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Fri, 27 Oct 2023 12:02:19 +0500 Subject: [PATCH 4/4] WellSectionsController --- AsbCloudApp/Data/SectionByOperationsDto.cs | 1 + .../Repository/WellOperationRepository.cs | 4 ++ .../Controllers/WellSectionsController.cs | 59 +++++++++++++++++++ .../Controllers/WellboreController.cs | 4 -- 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 AsbCloudWebApi/Controllers/WellSectionsController.cs diff --git a/AsbCloudApp/Data/SectionByOperationsDto.cs b/AsbCloudApp/Data/SectionByOperationsDto.cs index 80d2a3b4..8123ad11 100644 --- a/AsbCloudApp/Data/SectionByOperationsDto.cs +++ b/AsbCloudApp/Data/SectionByOperationsDto.cs @@ -44,4 +44,5 @@ public class SectionByOperationsDto /// Дата после завершения последней операции операции в секции /// public DateTimeOffset DateEnd { get; set; } + public string Caption { get; set; } } diff --git a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs index cd913980..8c72be8e 100644 --- a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs +++ b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs @@ -128,12 +128,14 @@ public class WellOperationRepository : IWellOperationRepository operation.IdWell, operation.IdType, operation.IdWellSectionType, + operation.WellSectionType.Caption, }) .Select(group => new { group.Key.IdWell, group.Key.IdType, group.Key.IdWellSectionType, + group.Key.Caption, First = group .OrderBy(operation => operation.DateStart) @@ -162,6 +164,8 @@ public class WellOperationRepository : IWellOperationRepository IdType = item.IdType, IdWellSectionType = item.IdWellSectionType, + Caption = item.Caption, + DateStart = item.First.DateStart, DepthStart = item.First.DepthStart, diff --git a/AsbCloudWebApi/Controllers/WellSectionsController.cs b/AsbCloudWebApi/Controllers/WellSectionsController.cs new file mode 100644 index 00000000..aa364439 --- /dev/null +++ b/AsbCloudWebApi/Controllers/WellSectionsController.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using AsbCloudApp.Data; +using AsbCloudApp.Repositories; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace AsbCloudWebApi.Controllers; + +/// +/// Секции скважины +/// +[Authorize] +[ApiController] +[Route("api/[controller]")] +public class WellSectionsController : ControllerBase +{ + private readonly IWellOperationRepository wellOperationRepository; + + public WellSectionsController(IWellOperationRepository wellOperationRepository) + { + this.wellOperationRepository = wellOperationRepository; + } + + /// + /// Получение списка плановых секций скважин + /// + /// Идентификаторы скважин + /// + /// + [HttpGet("plan")] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + public async Task GetPlanAsync([FromQuery] IEnumerable idsWells, + CancellationToken cancellationToken) + { + var sections = await wellOperationRepository.GetSectionsAsync(idsWells, cancellationToken); + sections = sections.Where(section => section.IdType == 0); + return Ok(sections); + } + + /// + /// Получение списка фактических секций скважин + /// + /// Идентификаторы скважин + /// + /// + [HttpGet("fact")] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + public async Task GetFactAsync([FromQuery] IEnumerable idsWells, + CancellationToken cancellationToken) + { + var sections = await wellOperationRepository.GetSectionsAsync(idsWells, cancellationToken); + sections = sections.Where(section => section.IdType == 1); + return Ok(sections); + } +} diff --git a/AsbCloudWebApi/Controllers/WellboreController.cs b/AsbCloudWebApi/Controllers/WellboreController.cs index 8b0a94bf..b3f77810 100644 --- a/AsbCloudWebApi/Controllers/WellboreController.cs +++ b/AsbCloudWebApi/Controllers/WellboreController.cs @@ -1,15 +1,11 @@ using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; using AsbCloudApp.Data; -using AsbCloudApp.Exceptions; -using AsbCloudApp.Requests; using AsbCloudApp.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Org.BouncyCastle.Asn1.Ocsp; namespace AsbCloudWebApi.Controllers;