forked from ddrilling/AsbCloudServer
Simplify dependencies
This commit is contained in:
parent
08d351a439
commit
c2a691f224
@ -7,8 +7,7 @@ namespace AsbCloudApp.Services
|
|||||||
{
|
{
|
||||||
public interface IOperationsStatService
|
public interface IOperationsStatService
|
||||||
{
|
{
|
||||||
Task<ClusterRopStatDto> GetRopStatByIdWellAsync(int idWell, CancellationToken token);
|
Task<ClusterRopStatDto> GetRopStatAsync(int idWell, CancellationToken token);
|
||||||
Task<ClusterRopStatDto> GetRopStatByUidAsync(string uid, CancellationToken token);
|
|
||||||
Task<StatClusterDto> GetStatClusterAsync(int idCluster, int idCompany, CancellationToken token = default);
|
Task<StatClusterDto> GetStatClusterAsync(int idCluster, int idCompany, CancellationToken token = default);
|
||||||
Task<StatWellDto> GetWellStatAsync(int idWell, CancellationToken token = default);
|
Task<StatWellDto> GetWellStatAsync(int idWell, CancellationToken token = default);
|
||||||
Task<IEnumerable<PlanFactPredictBase<WellOperationDto>>> GetTvdAsync(int idWell, CancellationToken token);
|
Task<IEnumerable<PlanFactPredictBase<WellOperationDto>>> GetTvdAsync(int idWell, CancellationToken token);
|
||||||
|
@ -16,39 +16,19 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly ITelemetryService telemetryService;
|
|
||||||
private readonly CacheTable<WellSectionType> cacheSectionsTypes;
|
private readonly CacheTable<WellSectionType> cacheSectionsTypes;
|
||||||
private readonly CacheTable<WellType> cacheWellType;
|
private readonly CacheTable<WellType> cacheWellType;
|
||||||
private readonly CacheTable<Cluster> cacheCluster;
|
private readonly CacheTable<Cluster> cacheCluster;
|
||||||
|
|
||||||
public OperationsStatService(IAsbCloudDbContext db, CacheDb cache, IWellService wellService,
|
public OperationsStatService(IAsbCloudDbContext db, CacheDb cache, IWellService wellService)
|
||||||
ITelemetryService telemetryService)
|
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
this.telemetryService = telemetryService;
|
|
||||||
cacheSectionsTypes = cache.GetCachedTable<WellSectionType>((DbContext)db);
|
cacheSectionsTypes = cache.GetCachedTable<WellSectionType>((DbContext)db);
|
||||||
cacheWellType = cache.GetCachedTable<WellType>((DbContext)db);
|
cacheWellType = cache.GetCachedTable<WellType>((DbContext)db);
|
||||||
cacheCluster = cache.GetCachedTable<Cluster>((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)
|
public async Task<StatClusterDto> GetStatClusterAsync(int idCluster, int idCompany, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var allWellsByCompany = await wellService.GetWellsByCompanyAsync(idCompany, token).ConfigureAwait(false);
|
var allWellsByCompany = await wellService.GetWellsByCompanyAsync(idCompany, token).ConfigureAwait(false);
|
||||||
@ -104,7 +84,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
return statWellDto;
|
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)
|
var clusterWellsIds = await wellService.GetClusterWellsIdsAsync(idWell, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
@ -41,7 +41,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await operationsStatService.GetRopStatByIdWellAsync(
|
var result = await operationsStatService.GetRopStatAsync(
|
||||||
idWell, token).ConfigureAwait(false);
|
idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
@ -59,8 +59,13 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public async Task<IActionResult> GetClusterRopStatByUidAsync([FromRoute] string uid,
|
public async Task<IActionResult> GetClusterRopStatByUidAsync([FromRoute] string uid,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var result = await operationsStatService.GetRopStatByUidAsync(
|
var idWell = wellService.TelemetryService.GetIdWellByTelemetryUid(uid);
|
||||||
uid, token).ConfigureAwait(false);
|
|
||||||
|
if(idWell is null)
|
||||||
|
return NoContent();
|
||||||
|
|
||||||
|
var result = await operationsStatService.GetRopStatAsync(
|
||||||
|
(int)idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user