forked from ddrilling/AsbCloudServer
edit generic
This commit is contained in:
parent
75ae8485cb
commit
8e663e7bef
@ -4,13 +4,14 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace AsbCloudApp.Repositories
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// данные ГТИ
|
||||
/// </summary>
|
||||
public interface IGtrRepository
|
||||
public interface IGtrRepository<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// добавить данные (для панели бурильщика)
|
||||
|
@ -138,9 +138,9 @@ namespace AsbCloudInfrastructure
|
||||
services.AddTransient<IProcessMapReportService, ProcessMapReportService>();
|
||||
services.AddTransient<IProcessMapService, ProcessMapService>();
|
||||
services.AddTransient<ITrajectoryVisualizationService, TrajectoryVisualizationService>();
|
||||
services.AddTransient<IGtrRepository, GtrWitsRepository<WitsItemInt,int>>();
|
||||
services.AddTransient<IGtrRepository, GtrWitsRepository<WitsItemFloat, float>>();
|
||||
services.AddTransient<IGtrRepository, GtrWitsRepository<WitsItemString, string>>();
|
||||
services.AddTransient<IGtrRepository<int>, GtrWitsRepository<WitsItemInt,int>>();
|
||||
services.AddTransient<IGtrRepository<float>, GtrWitsRepository<WitsItemFloat, float>>();
|
||||
services.AddTransient<IGtrRepository<string>, GtrWitsRepository<WitsItemString, string>>();
|
||||
|
||||
// admin crud services:
|
||||
services.AddTransient<ICrudRepository<TelemetryDto>, CrudCacheRepositoryBase<TelemetryDto, Telemetry>>(s =>
|
||||
|
@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
#nullable enable
|
||||
public class GtrWitsRepository<TEntity, T> : IGtrRepository
|
||||
public class GtrWitsRepository<TEntity, T> : IGtrRepository <T>
|
||||
where TEntity : WitsItemBase<T>
|
||||
{
|
||||
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<WitsRecordDto>();
|
||||
//if (fullDataCount == 0)
|
||||
// return Enumerable.Empty<WitsRecordDto>();
|
||||
|
||||
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)
|
||||
|
@ -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<float> gtrRepository;
|
||||
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
||||
|
||||
//public string SirnalRMethodGetDataName { get; protected set; } = "ReceiveData";
|
||||
|
||||
public GtrWitsController(
|
||||
ITelemetryService telemetryService,
|
||||
IGtrRepository gtrRepository,
|
||||
// IGtrRepository<float> gtrRepository,
|
||||
IWellService wellService,
|
||||
IHubContext<TelemetryHub> telemetryHubContext)
|
||||
{
|
||||
this.telemetryService = telemetryService;
|
||||
this.gtrRepository = gtrRepository;
|
||||
//this.gtrRepository = gtrRepository;
|
||||
this.wellService = wellService;
|
||||
this.telemetryHubContext = telemetryHubContext;
|
||||
}
|
||||
@ -46,26 +47,26 @@ namespace AsbCloudWebApi.Controllers.GTR
|
||||
/// <param name="approxPointsCount">желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.</param>
|
||||
/// <param name="token">Токен завершения задачи</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{idWell}")]
|
||||
//[Permission]
|
||||
public virtual async Task<ActionResult<IEnumerable<WitsRecordDto>>> 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<ActionResult<IEnumerable<WitsRecordDto>>> 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);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user