Simplify dependencies

This commit is contained in:
ngfrolov 2022-03-16 16:07:37 +05:00
parent 08d351a439
commit c2a691f224
3 changed files with 11 additions and 27 deletions

View File

@ -7,8 +7,7 @@ namespace AsbCloudApp.Services
{
public interface IOperationsStatService
{
Task<ClusterRopStatDto> GetRopStatByIdWellAsync(int idWell, CancellationToken token);
Task<ClusterRopStatDto> GetRopStatByUidAsync(string uid, CancellationToken token);
Task<ClusterRopStatDto> GetRopStatAsync(int idWell, CancellationToken token);
Task<StatClusterDto> GetStatClusterAsync(int idCluster, int idCompany, CancellationToken token = default);
Task<StatWellDto> GetWellStatAsync(int idWell, CancellationToken token = default);
Task<IEnumerable<PlanFactPredictBase<WellOperationDto>>> GetTvdAsync(int idWell, CancellationToken token);

View File

@ -16,39 +16,19 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
{
private readonly IAsbCloudDbContext db;
private readonly IWellService wellService;
private readonly ITelemetryService telemetryService;
private readonly CacheTable<WellSectionType> cacheSectionsTypes;
private readonly CacheTable<WellType> cacheWellType;
private readonly CacheTable<Cluster> 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<WellSectionType>((DbContext)db);
cacheWellType = cache.GetCachedTable<WellType>((DbContext)db);
cacheCluster = cache.GetCachedTable<Cluster>((DbContext)db);
}
public async Task<ClusterRopStatDto> GetRopStatByIdWellAsync(int idWell,
CancellationToken token)
{
return await GetRopStatAsync(idWell, token).ConfigureAwait(false);
}
public async Task<ClusterRopStatDto> 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<StatClusterDto> 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<ClusterRopStatDto> GetRopStatAsync(int idWell, CancellationToken token)
public async Task<ClusterRopStatDto> GetRopStatAsync(int idWell, CancellationToken token)
{
var clusterWellsIds = await wellService.GetClusterWellsIdsAsync(idWell, token)
.ConfigureAwait(false);

View File

@ -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<IActionResult> 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);
}