Merge branch 'dev' into fix/#13108961-typing-signalr-clients-methods

This commit is contained in:
on.nemtina 2023-10-30 14:30:16 +05:00
commit 89ede5b71e
6 changed files with 67 additions and 7 deletions

View File

@ -21,7 +21,7 @@ namespace AsbCloudApp.Data.SAUB
/// <summary> /// <summary>
/// id категории события /// id категории события
/// </summary> /// </summary>
[Range(1, int.MaxValue, ErrorMessage = "Id категории события не может быть отрицательным")] [Range(0, int.MaxValue, ErrorMessage = "Id категории события не может быть отрицательным")]
public int IdCategory { get; set; } public int IdCategory { get; set; }
/// <summary> /// <summary>
@ -32,7 +32,7 @@ namespace AsbCloudApp.Data.SAUB
/// <summary> /// <summary>
/// тип определения наступления события /// тип определения наступления события
/// </summary> /// </summary>
[Range(1, int.MaxValue, ErrorMessage = "Id типа события не может быть отрицательным")] [Range(0, int.MaxValue, ErrorMessage = "Id типа события не может быть отрицательным")]
public int EventType { get; set; } public int EventType { get; set; }
/// <summary> /// <summary>

View File

@ -44,4 +44,5 @@ public class SectionByOperationsDto
/// Дата после завершения последней операции операции в секции /// Дата после завершения последней операции операции в секции
/// </summary> /// </summary>
public DateTimeOffset DateEnd { get; set; } public DateTimeOffset DateEnd { get; set; }
public string Caption { get; set; }
} }

View File

@ -104,7 +104,7 @@ namespace AsbCloudDb.Model
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
if (!optionsBuilder.IsConfigured) 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)) //, builder=>builder.EnableRetryOnFailure(2, System.TimeSpan.FromMinutes(1))
); );
} }

View File

@ -128,12 +128,14 @@ public class WellOperationRepository : IWellOperationRepository
operation.IdWell, operation.IdWell,
operation.IdType, operation.IdType,
operation.IdWellSectionType, operation.IdWellSectionType,
operation.WellSectionType.Caption,
}) })
.Select(group => new .Select(group => new
{ {
group.Key.IdWell, group.Key.IdWell,
group.Key.IdType, group.Key.IdType,
group.Key.IdWellSectionType, group.Key.IdWellSectionType,
group.Key.Caption,
First = group First = group
.OrderBy(operation => operation.DateStart) .OrderBy(operation => operation.DateStart)
@ -162,6 +164,8 @@ public class WellOperationRepository : IWellOperationRepository
IdType = item.IdType, IdType = item.IdType,
IdWellSectionType = item.IdWellSectionType, IdWellSectionType = item.IdWellSectionType,
Caption = item.Caption,
DateStart = item.First.DateStart, DateStart = item.First.DateStart,
DepthStart = item.First.DepthStart, DepthStart = item.First.DepthStart,

View File

@ -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;
/// <summary>
/// Секции скважины
/// </summary>
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class WellSectionsController : ControllerBase
{
private readonly IWellOperationRepository wellOperationRepository;
public WellSectionsController(IWellOperationRepository wellOperationRepository)
{
this.wellOperationRepository = wellOperationRepository;
}
/// <summary>
/// Получение списка плановых секций скважин
/// </summary>
/// <param name="idsWells">Идентификаторы скважин</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("plan")]
[ProducesResponseType(typeof(IEnumerable<SectionByOperationsDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetPlanAsync([FromQuery] IEnumerable<int> idsWells,
CancellationToken cancellationToken)
{
var sections = await wellOperationRepository.GetSectionsAsync(idsWells, cancellationToken);
sections = sections.Where(section => section.IdType == 0);
return Ok(sections);
}
/// <summary>
/// Получение списка фактических секций скважин
/// </summary>
/// <param name="idsWells">Идентификаторы скважин</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("fact")]
[ProducesResponseType(typeof(IEnumerable<SectionByOperationsDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetFactAsync([FromQuery] IEnumerable<int> idsWells,
CancellationToken cancellationToken)
{
var sections = await wellOperationRepository.GetSectionsAsync(idsWells, cancellationToken);
sections = sections.Where(section => section.IdType == 1);
return Ok(sections);
}
}

View File

@ -1,15 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsbCloudApp.Data; using AsbCloudApp.Data;
using AsbCloudApp.Exceptions;
using AsbCloudApp.Requests;
using AsbCloudApp.Services; using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Asn1.Ocsp;
namespace AsbCloudWebApi.Controllers; namespace AsbCloudWebApi.Controllers;