diff --git a/AsbCloudApp/Services/IOperationsStatService.cs b/AsbCloudApp/Services/IOperationsStatService.cs index dddcb371..e1292855 100644 --- a/AsbCloudApp/Services/IOperationsStatService.cs +++ b/AsbCloudApp/Services/IOperationsStatService.cs @@ -7,8 +7,7 @@ namespace AsbCloudApp.Services { public interface IOperationsStatService { - Task GetRopStatByIdWellAsync(int idWell, CancellationToken token); - Task GetRopStatByUidAsync(string uid, CancellationToken token); + Task GetRopStatAsync(int idWell, CancellationToken token); Task GetStatClusterAsync(int idCluster, int idCompany, CancellationToken token = default); Task GetWellStatAsync(int idWell, CancellationToken token = default); Task>> GetTvdAsync(int idWell, CancellationToken token); diff --git a/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs b/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs index ae553adc..1a30c1d9 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs @@ -16,39 +16,19 @@ namespace AsbCloudInfrastructure.Services.WellOperationService { private readonly IAsbCloudDbContext db; private readonly IWellService wellService; - private readonly ITelemetryService telemetryService; private readonly CacheTable cacheSectionsTypes; private readonly CacheTable cacheWellType; private readonly CacheTable cacheCluster; - public OperationsStatService(IAsbCloudDbContext db, CacheDb cache, IWellService wellService, - ITelemetryService telemetryService) + public OperationsStatService(IAsbCloudDbContext db, CacheDb cache, IWellService wellService) { this.db = db; this.wellService = wellService; - this.telemetryService = telemetryService; cacheSectionsTypes = cache.GetCachedTable((DbContext)db); cacheWellType = cache.GetCachedTable((DbContext)db); cacheCluster = cache.GetCachedTable((DbContext)db); } - public async Task GetRopStatByIdWellAsync(int idWell, - CancellationToken token) - { - return await GetRopStatAsync(idWell, token).ConfigureAwait(false); - } - - public async Task GetRopStatByUidAsync(string uid, - CancellationToken token) - { - var idWell = telemetryService.GetIdWellByTelemetryUid(uid); - - if (idWell is null) - return null; - - return await GetRopStatAsync((int)idWell, token).ConfigureAwait(false); - } - public async Task GetStatClusterAsync(int idCluster, int idCompany, CancellationToken token = default) { var allWellsByCompany = await wellService.GetWellsByCompanyAsync(idCompany, token).ConfigureAwait(false); @@ -104,7 +84,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService return statWellDto; } - private async Task GetRopStatAsync(int idWell, CancellationToken token) + public async Task GetRopStatAsync(int idWell, CancellationToken token) { var clusterWellsIds = await wellService.GetClusterWellsIdsAsync(idWell, token) .ConfigureAwait(false); diff --git a/AsbCloudWebApi/Controllers/OperationStatController.cs b/AsbCloudWebApi/Controllers/OperationStatController.cs index a924f41b..35710c66 100644 --- a/AsbCloudWebApi/Controllers/OperationStatController.cs +++ b/AsbCloudWebApi/Controllers/OperationStatController.cs @@ -41,7 +41,7 @@ namespace AsbCloudWebApi.Controllers if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) return Forbid(); - var result = await operationsStatService.GetRopStatByIdWellAsync( + var result = await operationsStatService.GetRopStatAsync( idWell, token).ConfigureAwait(false); return Ok(result); @@ -59,8 +59,13 @@ namespace AsbCloudWebApi.Controllers public async Task GetClusterRopStatByUidAsync([FromRoute] string uid, CancellationToken token = default) { - var result = await operationsStatService.GetRopStatByUidAsync( - uid, token).ConfigureAwait(false); + var idWell = wellService.TelemetryService.GetIdWellByTelemetryUid(uid); + + if(idWell is null) + return NoContent(); + + var result = await operationsStatService.GetRopStatAsync( + (int)idWell, token).ConfigureAwait(false); return Ok(result); }