forked from ddrilling/AsbCloudServer
#7887519 Замечания
This commit is contained in:
parent
17cf2c6573
commit
046a6a765d
@ -13,13 +13,13 @@ namespace AsbCloudApp.Repositories
|
|||||||
public interface ILimitingParameterRepository
|
public interface ILimitingParameterRepository
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение информации идентификатору скважины
|
/// Получение списка ограничивающих параметров по идентификатору скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="wellDto"></param>
|
/// <param name="wellDto"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<LimitingParameterDataDto>> GetStatOrDefaultAsync(LimitingParameterRequest request, WellDto wellDto, CancellationToken token);
|
Task<IEnumerable<LimitingParameterDataDto>> GetLimitingParametersAsync(LimitingParameterRequest request, WellDto wellDto, CancellationToken token);
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,12 @@ namespace AsbCloudApp.Services
|
|||||||
public interface ILimitingParameterService
|
public interface ILimitingParameterService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение информации идентификатору скважины
|
/// Получение статистики по ограничивающим параметрам
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<LimitingParameterDto>?> GetStatOrDefaultAsync(LimitingParameterRequest request, CancellationToken token);
|
Task<IEnumerable<LimitingParameterDto>> GetStatAsync(LimitingParameterRequest request, CancellationToken token);
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,10 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
public async Task<IEnumerable<LimitingParameterDataDto>> GetStatOrDefaultAsync(LimitingParameterRequest request, WellDto wellDto, CancellationToken token)
|
public async Task<IEnumerable<LimitingParameterDataDto>> GetLimitingParametersAsync(LimitingParameterRequest request, WellDto wellDto, CancellationToken token)
|
||||||
{
|
{
|
||||||
var query = BuildQuery(request, wellDto);
|
var query = BuildQuery(request, wellDto);
|
||||||
|
|
||||||
if (query is null)
|
|
||||||
return Enumerable.Empty<LimitingParameterDataDto>();
|
|
||||||
|
|
||||||
var data = (await query.ToListAsync(token))
|
var data = (await query.ToListAsync(token))
|
||||||
.Select(x => new LimitingParameterDataDto
|
.Select(x => new LimitingParameterDataDto
|
||||||
{
|
{
|
||||||
|
@ -150,52 +150,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await result.DisposeAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//var rows = new List<(short IdLimiting, DateTimeOffset Date, float WellDepth)>(32);
|
|
||||||
//{
|
|
||||||
// using var result = await ExecuteReaderAsync(db, query, token);
|
|
||||||
// int? idLimitingLast = null;
|
|
||||||
// while (result.Read())
|
|
||||||
// {
|
|
||||||
// var idLimiting = result.GetFieldValue<short>(1);
|
|
||||||
// var wellDepth = result.GetFieldValue<float>(2);
|
|
||||||
// if (idLimitingLast != idLimiting)
|
|
||||||
// {
|
|
||||||
// idLimitingLast = idLimiting;
|
|
||||||
// var date = result.GetFieldValue<DateTimeOffset>(0);
|
|
||||||
// rows.Add((idLimiting, date, wellDepth));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// await result.DisposeAsync();
|
|
||||||
//}
|
|
||||||
|
|
||||||
//if (rows.Count < 2)
|
|
||||||
// return Enumerable.Empty<LimitingParameter>();
|
|
||||||
|
|
||||||
//var limitingParameters = new List<LimitingParameter>(32);
|
|
||||||
|
|
||||||
//for (int i = 1; i < rows.Count; i++)
|
|
||||||
//{
|
|
||||||
// var r0 = rows[i - 1];
|
|
||||||
// var r1 = rows[i];
|
|
||||||
// if (r0.IdLimiting != r1.IdLimiting)
|
|
||||||
// {
|
|
||||||
// var limitingParameter = new LimitingParameter()
|
|
||||||
// {
|
|
||||||
// IdTelemetry = idTelemetry,
|
|
||||||
// DateStart = r0.Date,
|
|
||||||
// DateEnd = r1.Date,
|
|
||||||
// DepthStart = r0.WellDepth,
|
|
||||||
// DepthEnd = r1.WellDepth,
|
|
||||||
// IdFeedRegulator = (short)r0.IdLimiting
|
|
||||||
// };
|
|
||||||
|
|
||||||
// limitingParameters.Add(limitingParameter);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
return limitingParameters;
|
return limitingParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,17 +23,17 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<LimitingParameterDto>?> GetStatOrDefaultAsync(LimitingParameterRequest request, CancellationToken token)
|
public async Task<IEnumerable<LimitingParameterDto>> GetStatAsync(LimitingParameterRequest request, CancellationToken token)
|
||||||
{
|
{
|
||||||
var well = await wellService.GetOrDefaultAsync(request.IdWell, token);
|
var well = await wellService.GetOrDefaultAsync(request.IdWell, token);
|
||||||
if (well?.IdTelemetry is null || well.Timezone is null)
|
if (well?.IdTelemetry is null || well.Timezone is null)
|
||||||
return null;
|
return Enumerable.Empty<LimitingParameterDto>();
|
||||||
|
|
||||||
var data = (await limitingParameterRepository.GetStatOrDefaultAsync(request, well, token))
|
var data = (await limitingParameterRepository.GetLimitingParametersAsync(request, well, token))
|
||||||
.GroupBy(x => x.IdFeedRegulator);
|
.GroupBy(x => x.IdFeedRegulator);
|
||||||
|
|
||||||
|
|
||||||
List<LimitingParameterDto> result = new List<LimitingParameterDto>();
|
List<LimitingParameterDto> result = new List<LimitingParameterDto>(data.Count());
|
||||||
foreach (var item in data)
|
foreach (var item in data)
|
||||||
{
|
{
|
||||||
var trimData = TrimLimitingParameters(item, request);
|
var trimData = TrimLimitingParameters(item, request);
|
||||||
@ -79,7 +79,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
x.DepthEnd = (float)request.LtDepth.Value;
|
x.DepthEnd = (float)request.LtDepth.Value;
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}).ToList();
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetList()
|
public async Task GetList()
|
||||||
{
|
{
|
||||||
var data = await limitingParameterService.GetStatOrDefaultAsync(limitingParameterRequest, CancellationToken.None);
|
var data = await limitingParameterService.GetStatAsync(limitingParameterRequest, CancellationToken.None);
|
||||||
Assert.NotNull(data);
|
Assert.NotNull(data);
|
||||||
Assert.Single(data);
|
Assert.Single(data);
|
||||||
Assert.Equal(1275, data.First().Depth);
|
Assert.Equal(1275, data.First().Depth);
|
||||||
|
@ -24,13 +24,19 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение статистики по ограничивающим параметрам
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpGet("stat")]
|
[HttpGet("stat")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<LimitingParameterDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<LimitingParameterDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetInfosAsync([FromQuery] LimitingParameterRequest request, CancellationToken token = default)
|
public async Task<IActionResult> GetStatAsync([FromQuery] LimitingParameterRequest request, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await UserHasAccesToWellAsync(request.IdWell, token))
|
if (!await UserHasAccesToWellAsync(request.IdWell, token))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
var subsystemResult = await limitingParameterService.GetStatOrDefaultAsync(request, token);
|
var subsystemResult = await limitingParameterService.GetStatAsync(request, token);
|
||||||
return Ok(subsystemResult);
|
return Ok(subsystemResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user