diff --git a/AsbCloudApp/Services/IWellService.cs b/AsbCloudApp/Services/IWellService.cs
index eb8d9f37..7c1cc8fd 100644
--- a/AsbCloudApp/Services/IWellService.cs
+++ b/AsbCloudApp/Services/IWellService.cs
@@ -102,5 +102,13 @@ namespace AsbCloudApp.Services
///
///
Task> GetWellTreeAsync(int idCompany, CancellationToken token);
+
+ ///
+ /// Статистика по скважине
+ ///
+ ///
+ ///
+ ///
+ Task GetOrDefaultStatAsync(int idWell, CancellationToken token);
}
}
diff --git a/AsbCloudInfrastructure/Services/WellService.cs b/AsbCloudInfrastructure/Services/WellService.cs
index 6d70dd9c..4cf88d82 100644
--- a/AsbCloudInfrastructure/Services/WellService.cs
+++ b/AsbCloudInfrastructure/Services/WellService.cs
@@ -103,6 +103,23 @@ namespace AsbCloudInfrastructure.Services
return depositTree;
}
+ public async Task 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();
+
+ return dto;
+ }
+
public async Task> GetAsync(WellRequest request, CancellationToken token)
{
var wells = await GetEntitiesAsync(request, token);
diff --git a/AsbCloudWebApi/Controllers/WellController.cs b/AsbCloudWebApi/Controllers/WellController.cs
index db69f959..30b259c8 100644
--- a/AsbCloudWebApi/Controllers/WellController.cs
+++ b/AsbCloudWebApi/Controllers/WellController.cs
@@ -88,6 +88,28 @@ namespace AsbCloudWebApi.Controllers
return Ok(well);
}
+ ///
+ /// Возвращает информацию о требуемой скважине
+ ///
+ /// Id требуемой скважины
+ /// Токен отмены задачи
+ /// Информация о требуемой скважине
+ [HttpGet("{idWell}/info")]
+ [Permission]
+ [ProducesResponseType(typeof(WellDto), (int)System.Net.HttpStatusCode.OK)]
+ public async Task 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);
+ }
+
///
/// Редактирует указанные поля скважины
///