diff --git a/AsbCloudApp/Repositories/IGtrRepository.cs b/AsbCloudApp/Repositories/IGtrRepository.cs index c9dc64ce..d95d809d 100644 --- a/AsbCloudApp/Repositories/IGtrRepository.cs +++ b/AsbCloudApp/Repositories/IGtrRepository.cs @@ -4,13 +4,14 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; + namespace AsbCloudApp.Repositories { #nullable enable /// /// данные ГТИ /// - public interface IGtrRepository + public interface IGtrRepository { /// /// добавить данные (для панели бурильщика) diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index 1e499696..39ef6353 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -138,9 +138,9 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient>(); - services.AddTransient>(); - services.AddTransient>(); + services.AddTransient, GtrWitsRepository>(); + services.AddTransient, GtrWitsRepository>(); + services.AddTransient, GtrWitsRepository>(); // admin crud services: services.AddTransient, CrudCacheRepositoryBase>(s => diff --git a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs index 0113f3d2..a603c5a6 100644 --- a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs +++ b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs @@ -13,7 +13,7 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Repository { #nullable enable - public class GtrWitsRepository : IGtrRepository + public class GtrWitsRepository : IGtrRepository where TEntity : WitsItemBase { private readonly IAsbCloudDbContext db; @@ -72,15 +72,15 @@ namespace AsbCloudInfrastructure.Repository var fullDataCount = await query.CountAsync(token) .ConfigureAwait(false); - if (fullDataCount == 0) - return Enumerable.Empty(); + //if (fullDataCount == 0) + // return Enumerable.Empty(); - if (fullDataCount > 1.75 * approxPointsCount) - { - var m = (int)Math.Round(1d * fullDataCount / approxPointsCount); - if (m > 1) - query = query.Where((d) => (((d.DateTime.DayOfYear * 24 + d.DateTime.Hour) * 60 + d.DateTime.Minute) * 60 + d.DateTime.Second) % m == 0); - } + //if (fullDataCount > 1.75 * approxPointsCount) + //{ + // var m = (int)Math.Round(1d * fullDataCount / approxPointsCount); + // if (m > 1) + // query = query.Where((d) => (((d.DateTime.DayOfYear * 24 + d.DateTime.Hour) * 60 + d.DateTime.Minute) * 60 + d.DateTime.Second) % m == 0); + //} var entities = await query .OrderBy(d => d.DateTime) diff --git a/AsbCloudWebApi/Controllers/GTR/GtrWitsController.cs b/AsbCloudWebApi/Controllers/GTR/GtrWitsController.cs index f42f6950..0c5b3c37 100644 --- a/AsbCloudWebApi/Controllers/GTR/GtrWitsController.cs +++ b/AsbCloudWebApi/Controllers/GTR/GtrWitsController.cs @@ -16,22 +16,23 @@ namespace AsbCloudWebApi.Controllers.GTR [Route("api/[controller]")] [ApiController] public class GtrWitsController : ControllerBase + { protected readonly IWellService wellService; private readonly ITelemetryService telemetryService; - private readonly IGtrRepository gtrRepository; + //private readonly IGtrRepository gtrRepository; private readonly IHubContext telemetryHubContext; //public string SirnalRMethodGetDataName { get; protected set; } = "ReceiveData"; public GtrWitsController( ITelemetryService telemetryService, - IGtrRepository gtrRepository, + // IGtrRepository gtrRepository, IWellService wellService, IHubContext telemetryHubContext) { this.telemetryService = telemetryService; - this.gtrRepository = gtrRepository; + //this.gtrRepository = gtrRepository; this.wellService = wellService; this.telemetryHubContext = telemetryHubContext; } @@ -46,26 +47,26 @@ namespace AsbCloudWebApi.Controllers.GTR /// желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена. /// Токен завершения задачи /// - [HttpGet("{idWell}")] - //[Permission] - public virtual async Task>> GetDataAsync(int idWell, DateTime begin = default, - int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default) - { - //int? idCompany = User.GetCompanyId(); + //[HttpGet("{idWell}")] + ////[Permission] + //public async Task>> GetDataAsync(int idWell, DateTime begin = default, + // int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default) + //{ + // //int? idCompany = User.GetCompanyId(); - //if (idCompany is null) - // return Forbid(); + // //if (idCompany is null) + // // return Forbid(); - //bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, - // idWell, token).ConfigureAwait(false); + // //bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, + // // idWell, token).ConfigureAwait(false); - //if (!isCompanyOwnsWell) - // return Forbid(); + // //if (!isCompanyOwnsWell) + // // return Forbid(); - var content = await gtrRepository.GetAsync(idWell, begin, - intervalSec, approxPointsCount, token).ConfigureAwait(false); + // //var content = await gtrRepository.GetAsync(idWell, begin, + // // intervalSec, approxPointsCount, token).ConfigureAwait(false); - return Ok(content); - } + // //return Ok(content); + //} } }