forked from ddrilling/AsbCloudServer
Добавил WellController.GetOrDefaultStatAsync(..) с расширенной статистикой по скважине.
This commit is contained in:
parent
b8c9c37b49
commit
0230432c8c
@ -102,5 +102,13 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<DepositBranchDto>> GetWellTreeAsync(int idCompany, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Статистика по скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<WellMapInfoWithTelemetryStat?> GetOrDefaultStatAsync(int idWell, CancellationToken token);
|
||||
}
|
||||
}
|
||||
|
@ -103,6 +103,23 @@ namespace AsbCloudInfrastructure.Services
|
||||
return depositTree;
|
||||
}
|
||||
|
||||
public async Task<WellMapInfoWithTelemetryStat?> GetOrDefaultStatAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var dto = wellInfoService.FirstOrDefault(well => well.Id == idWell);
|
||||
if (dto is not null)
|
||||
return dto;
|
||||
|
||||
var request = new WellRequest{Ids = new[] { idWell }};
|
||||
var entities = await GetEntitiesAsync(request, token);
|
||||
var entity = entities.FirstOrDefault();
|
||||
if (entity is null)
|
||||
return null;
|
||||
|
||||
dto = entity.Adapt<WellMapInfoWithTelemetryStat>();
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<WellDto>> GetAsync(WellRequest request, CancellationToken token)
|
||||
{
|
||||
var wells = await GetEntitiesAsync(request, token);
|
||||
|
@ -88,6 +88,28 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Ok(well);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает информацию о требуемой скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"> Id требуемой скважины </param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns>Информация о требуемой скважине </returns>
|
||||
[HttpGet("{idWell}/info")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(WellDto), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetStatAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync(idCompany ?? default, idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var well = await wellService.GetOrDefaultStatAsync(idWell,
|
||||
token);
|
||||
|
||||
return Ok(well);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Редактирует указанные поля скважины
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user