forked from ddrilling/AsbCloudServer
ProcessMapReport. Add GetTelemetryDataStatAsync(..) to TelemetryDataSaubService.
This commit is contained in:
parent
1a7d643c50
commit
9f996003eb
117
AsbCloudApp/Data/SAUB/TelemetryDataSaubStatDto.cs
Normal file
117
AsbCloudApp/Data/SAUB/TelemetryDataSaubStatDto.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data.SAUB
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
/// <summary>
|
||||||
|
/// Статистика телеметрии САУБ (усредненные значения) по интервалам глубины
|
||||||
|
/// </summary>
|
||||||
|
public class TelemetryDataSaubStatDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Кол-во записей в интервале
|
||||||
|
/// </summary>
|
||||||
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата начала интервала
|
||||||
|
/// </summary>
|
||||||
|
public DateTime DateMin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата окончания интервала
|
||||||
|
/// </summary>
|
||||||
|
public DateTime DateMax { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Глубина начала интервала
|
||||||
|
/// </summary>
|
||||||
|
public float WellDepthMin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Глубина окончания интервала
|
||||||
|
/// </summary>
|
||||||
|
public float WellDepthMax { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Давление
|
||||||
|
/// </summary>
|
||||||
|
public float Pressure { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// действующее задание давления
|
||||||
|
/// </summary>
|
||||||
|
public float PressureSp { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Давление при холостом ходе.
|
||||||
|
/// </summary>
|
||||||
|
public float PressureIdle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// задание давления для роторного режима
|
||||||
|
/// </summary>
|
||||||
|
public float PressureSpRotor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// задание давления для режима слайда
|
||||||
|
/// </summary>
|
||||||
|
public float PressureSpSlide { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ограничение макс перепада давления
|
||||||
|
/// </summary>
|
||||||
|
public float PressureDeltaLimitMax { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// осевая нагрузка
|
||||||
|
/// </summary>
|
||||||
|
public float AxialLoad { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// задание осевой нагрузки
|
||||||
|
/// </summary>
|
||||||
|
public float AxialLoadSp { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ограничение макс. осевой нагрузки
|
||||||
|
/// </summary>
|
||||||
|
public float AxialLoadLimitMax { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// момент ротора
|
||||||
|
/// </summary>
|
||||||
|
public float RotorTorque { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// задание момента ротора
|
||||||
|
/// </summary>
|
||||||
|
public float RotorTorqueSp { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// момент ротора на х.х.
|
||||||
|
/// </summary>
|
||||||
|
public float RotorTorqueLimitMax { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Талевый блок. Скорость
|
||||||
|
/// </summary>
|
||||||
|
public float BlockSpeed { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Талевый блок. Задание скорости
|
||||||
|
/// </summary>
|
||||||
|
public float BlockSpeedSp { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Талевый блок. Задание скорости для роторного бурения
|
||||||
|
/// </summary>
|
||||||
|
public float BlockSpeedSpRotor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Талевый блок. Задание скорости для режима слайда
|
||||||
|
/// </summary>
|
||||||
|
public float BlockSpeedSpSlide { get; set; }
|
||||||
|
}
|
||||||
|
#nullable disable
|
||||||
|
}
|
26
AsbCloudApp/Services/ITelemetryDataSaubService.cs
Normal file
26
AsbCloudApp/Services/ITelemetryDataSaubService.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
namespace AsbCloudApp.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Телеметрия САУБ
|
||||||
|
/// </summary>
|
||||||
|
public interface ITelemetryDataSaubService : ITelemetryDataService<TelemetryDataSaubDto>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// усредненная статистика по 1м за весь период
|
||||||
|
/// <para>
|
||||||
|
/// МЕДЛЕННЫЙ ЗАПРОС
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idTelemetry"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<TelemetryDataSaubStatDto>> GetTelemetryDataStatAsync(int idTelemetry, CancellationToken token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#nullable disable
|
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
@ -33,7 +34,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> UpdateDataAsync(string uid, IEnumerable<TDto> dtos, CancellationToken token = default);
|
Task<int> UpdateDataAsync(string uid, IEnumerable<TDto> dtos, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
@ -184,7 +184,7 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<ICrudRepository<PermissionDto>, CrudCacheRepositoryBase<PermissionDto, Permission>>();
|
services.AddTransient<ICrudRepository<PermissionDto>, CrudCacheRepositoryBase<PermissionDto, Permission>>();
|
||||||
|
|
||||||
// TelemetryData services
|
// TelemetryData services
|
||||||
services.AddTransient<ITelemetryDataService<TelemetryDataSaubDto>, TelemetryDataSaubService>();
|
services.AddTransient<ITelemetryDataSaubService, TelemetryDataSaubService>();
|
||||||
services.AddTransient<ITelemetryDataService<TelemetryDataSpinDto>, TelemetryDataSpinService>();
|
services.AddTransient<ITelemetryDataService<TelemetryDataSpinDto>, TelemetryDataSpinService>();
|
||||||
|
|
||||||
// Wits
|
// Wits
|
||||||
|
@ -30,16 +30,9 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
var stream = GetExcelTemplateStream();
|
var stream = GetExcelTemplateStream();
|
||||||
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
|
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
|
||||||
|
|
||||||
var data = processMapService.GetProcessMapAsync(idWell, token);
|
var data = await processMapService.GetProcessMapAsync(idWell, token);
|
||||||
|
|
||||||
//var dtos = await processMapRepository.GetByIdWellAsync(idWell, token).ConfigureAwait(false);
|
FillProcessMapToWorkbook(workbook, data);
|
||||||
//if (dtos is not null)
|
|
||||||
//{
|
|
||||||
// var processMapReportDto = await processMapService.GetProcessMapAsync(dtos, token).ConfigureAwait(false);
|
|
||||||
// FillProcessMapToWorkbook(workbook, processMapReportDto);
|
|
||||||
//}
|
|
||||||
|
|
||||||
FillProcessMapToWorkbook(workbook, new List<ProcessMapReportDto>());
|
|
||||||
|
|
||||||
MemoryStream memoryStream = new MemoryStream();
|
MemoryStream memoryStream = new MemoryStream();
|
||||||
workbook.SaveAs(memoryStream, new SaveOptions { });
|
workbook.SaveAs(memoryStream, new SaveOptions { });
|
||||||
|
@ -5,7 +5,6 @@ using AsbCloudApp.Repositories;
|
|||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -21,17 +20,23 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
private readonly IWellOperationRepository wellOperationRepository;
|
private readonly IWellOperationRepository wellOperationRepository;
|
||||||
private readonly IProcessMapRepository processMapRepository;
|
private readonly IProcessMapRepository processMapRepository;
|
||||||
private readonly ITelemetryService telemetryService;
|
private readonly ITelemetryService telemetryService;
|
||||||
|
private readonly ITelemetryDataSaubService telemetryDataSaubService;
|
||||||
|
private readonly ILimitingParameterRepository limitingParameterRepository;
|
||||||
|
|
||||||
public ProcessMapService(
|
public ProcessMapService(
|
||||||
IAsbCloudDbContext db,
|
IAsbCloudDbContext db,
|
||||||
IWellOperationRepository wellOperationService,
|
IWellOperationRepository wellOperationService,
|
||||||
IProcessMapRepository processMapRepository,
|
IProcessMapRepository processMapRepository,
|
||||||
ITelemetryService telemetryService)
|
ITelemetryService telemetryService,
|
||||||
|
ITelemetryDataSaubService telemetryDataSaubService,
|
||||||
|
ILimitingParameterRepository limitingParameterRepository)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.wellOperationRepository = wellOperationService;
|
this.wellOperationRepository = wellOperationService;
|
||||||
this.processMapRepository = processMapRepository;
|
this.processMapRepository = processMapRepository;
|
||||||
this.telemetryService = telemetryService;
|
this.telemetryService = telemetryService;
|
||||||
|
this.telemetryDataSaubService = telemetryDataSaubService;
|
||||||
|
this.limitingParameterRepository = limitingParameterRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<ProcessMapReportDto>> GetProcessMapAsync(int idWell, CancellationToken token)
|
public async Task<IEnumerable<ProcessMapReportDto>> GetProcessMapAsync(int idWell, CancellationToken token)
|
||||||
@ -49,7 +54,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
var processMapDtos = (await processMapRepository.GetByIdWellAsync(idWell, token))!;
|
var processMapDtos = (await processMapRepository.GetByIdWellAsync(idWell, token))!;
|
||||||
|
|
||||||
var idTelemetry = telemetryService.GetOrDefaultIdTelemetryByIdWell(idWell)!.Value;
|
var idTelemetry = telemetryService.GetOrDefaultIdTelemetryByIdWell(idWell)!.Value;
|
||||||
IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat = await GetTelemetryDataAsync(idTelemetry, token);
|
IEnumerable<TelemetryDataSaubStatDto> telemetryDataStat = await telemetryDataSaubService.GetTelemetryDataStatAsync(idTelemetry, token);
|
||||||
|
|
||||||
var result = allFactDrillingOperations
|
var result = allFactDrillingOperations
|
||||||
.GroupBy(o => o.IdWellSectionType)
|
.GroupBy(o => o.IdWellSectionType)
|
||||||
@ -63,59 +68,10 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IEnumerable<ProcessTelemetrySaubStat>> GetTelemetryDataAsync(int idTelemetry, CancellationToken token)
|
|
||||||
{
|
|
||||||
var timezone = telemetryService.GetTimezone(idTelemetry);
|
|
||||||
var timezoneOffset = TimeSpan.FromHours(timezone.Hours);
|
|
||||||
|
|
||||||
var query = db.Set<TelemetryDataSaub>()
|
|
||||||
.Where(t => t.IdTelemetry == idTelemetry)
|
|
||||||
.Where(t => t.BlockPosition > 0.0001)
|
|
||||||
.Where(t => t.WellDepth > 0.0001)
|
|
||||||
.Where(t => t.WellDepth - t.BitDepth < 0.01)
|
|
||||||
.GroupBy(t => new { H = t.DateTime.Hour, W = Math.Truncate(t.WellDepth!.Value) })
|
|
||||||
.Select(g => new ProcessTelemetrySaubStat
|
|
||||||
{
|
|
||||||
Count = g.Count(),
|
|
||||||
|
|
||||||
DateMin = g.Min(t => t.DateTime.UtcDateTime),
|
|
||||||
DateMax = g.Max(t => t.DateTime.UtcDateTime),
|
|
||||||
|
|
||||||
WellDepthMin = g.Min(t => t.WellDepth!.Value),
|
|
||||||
WellDepthMax = g.Max(t => t.WellDepth!.Value),
|
|
||||||
|
|
||||||
Pressure = g.Average(t => t.Pressure!.Value),
|
|
||||||
PressureSp = g.Average(t => t.PressureSp!.Value),
|
|
||||||
PressureSpRotor = g.Average(t => t.PressureSpRotor!.Value),
|
|
||||||
PressureSpSlide = g.Average(t => t.PressureSpSlide!.Value),
|
|
||||||
PressureIdle = g.Average(t => t.PressureIdle!.Value),
|
|
||||||
PressureDeltaLimitMax = g.Average(t => t.PressureDeltaLimitMax!.Value),
|
|
||||||
|
|
||||||
AxialLoad = g.Average(t => t.AxialLoad!.Value),
|
|
||||||
AxialLoadSp = g.Average(t => t.AxialLoadSp!.Value),
|
|
||||||
AxialLoadLimitMax = g.Average(t => t.AxialLoadLimitMax!.Value),
|
|
||||||
|
|
||||||
RotorTorque = g.Average(t => t.RotorTorque!.Value),
|
|
||||||
RotorTorqueSp = g.Average(t => t.RotorTorqueSp!.Value),
|
|
||||||
RotorTorqueLimitMax = g.Average(t => t.RotorTorqueLimitMax!.Value),
|
|
||||||
|
|
||||||
BlockSpeed = g.Average(t => t.BlockSpeed!.Value),
|
|
||||||
BlockSpeedSp = g.Average(t => t.BlockSpeedSp!.Value),
|
|
||||||
BlockSpeedSpRotor = g.Average(t => t.BlockSpeedSpRotor!.Value),
|
|
||||||
BlockSpeedSpSlide = g.Average(t => t.BlockSpeedSpSlide!.Value),
|
|
||||||
})
|
|
||||||
.Where(s => s.WellDepthMin != s.WellDepthMax)
|
|
||||||
.Where(s => s.Count > 3)
|
|
||||||
.OrderBy(t => t.DateMin);
|
|
||||||
|
|
||||||
var data = await query.ToArrayAsync(token);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IEnumerable<ProcessMapReportDto> HandleSections(
|
private static IEnumerable<ProcessMapReportDto> HandleSections(
|
||||||
IEnumerable<WellOperationDto> sectionOperations,
|
IEnumerable<WellOperationDto> sectionOperations,
|
||||||
IEnumerable<ProcessMapDto> sectionProcessMap,
|
IEnumerable<ProcessMapDto> sectionProcessMap,
|
||||||
IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat)
|
IEnumerable<TelemetryDataSaubStatDto> telemetryDataStat)
|
||||||
{
|
{
|
||||||
var minDepth = sectionOperations.Min(o => o.DepthStart);
|
var minDepth = sectionOperations.Min(o => o.DepthStart);
|
||||||
var maxDepth = sectionOperations.Max(o => o.DepthEnd);
|
var maxDepth = sectionOperations.Max(o => o.DepthEnd);
|
||||||
@ -133,7 +89,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
(double min, double max) depthInterval,
|
(double min, double max) depthInterval,
|
||||||
IEnumerable<WellOperationDto> sectionOperations,
|
IEnumerable<WellOperationDto> sectionOperations,
|
||||||
IEnumerable<ProcessMapDto> sectionProcessMap,
|
IEnumerable<ProcessMapDto> sectionProcessMap,
|
||||||
IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat)
|
IEnumerable<TelemetryDataSaubStatDto> telemetryDataStat)
|
||||||
{
|
{
|
||||||
var dto = new ProcessMapReportDto{
|
var dto = new ProcessMapReportDto{
|
||||||
DepthStart = depthInterval.min
|
DepthStart = depthInterval.min
|
||||||
@ -161,9 +117,9 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ProcessTelemetrySaubStat? CalcIntervalTelemetryDataStat((double min, double max) depthInterval, IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat)
|
private static TelemetryDataSaubStatDto? CalcIntervalTelemetryDataStat((double min, double max) depthInterval, IEnumerable<TelemetryDataSaubStatDto> telemetryDataStat)
|
||||||
{
|
{
|
||||||
ProcessTelemetrySaubStat[] data = telemetryDataStat
|
TelemetryDataSaubStatDto[] data = telemetryDataStat
|
||||||
.Where(d => d.WellDepthMin <= depthInterval.max && d.WellDepthMax >= depthInterval.min)
|
.Where(d => d.WellDepthMin <= depthInterval.max && d.WellDepthMax >= depthInterval.min)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
@ -173,8 +129,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
if (data.Length == 1)
|
if (data.Length == 1)
|
||||||
return data.First();
|
return data.First();
|
||||||
|
|
||||||
|
var result = new TelemetryDataSaubStatDto
|
||||||
var result = new ProcessTelemetrySaubStat
|
|
||||||
{
|
{
|
||||||
WellDepthMin = data.Min(d => d.WellDepthMin),
|
WellDepthMin = data.Min(d => d.WellDepthMin),
|
||||||
WellDepthMax = data.Max(d => d.WellDepthMax),
|
WellDepthMax = data.Max(d => d.WellDepthMax),
|
||||||
@ -200,7 +155,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
result.RotorTorque += item.RotorTorque * itemWeight;
|
result.RotorTorque += item.RotorTorque * itemWeight;
|
||||||
result.RotorTorqueSp += item.RotorTorqueSp * itemWeight;
|
result.RotorTorqueSp += item.RotorTorqueSp * itemWeight;
|
||||||
result.RotorTorqueLimitMax += item.RotorTorqueLimitMax * itemWeight;
|
result.RotorTorqueLimitMax += item.RotorTorqueLimitMax * itemWeight;
|
||||||
|
|
||||||
result.BlockSpeed += item.BlockSpeed * itemWeight;
|
result.BlockSpeed += item.BlockSpeed * itemWeight;
|
||||||
result.BlockSpeedSp += item.BlockSpeedSp * itemWeight;
|
result.BlockSpeedSp += item.BlockSpeedSp * itemWeight;
|
||||||
result.BlockSpeedSpRotor += item.BlockSpeedSpRotor * itemWeight;
|
result.BlockSpeedSpRotor += item.BlockSpeedSpRotor * itemWeight;
|
||||||
@ -214,7 +169,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
(double min, double max) depthInterval,
|
(double min, double max) depthInterval,
|
||||||
IEnumerable<WellOperationDto> intervalModeOperations,
|
IEnumerable<WellOperationDto> intervalModeOperations,
|
||||||
IEnumerable<ProcessMapDto> intervalProcessMap,
|
IEnumerable<ProcessMapDto> intervalProcessMap,
|
||||||
ProcessTelemetrySaubStat? telemetryDataStat)
|
TelemetryDataSaubStatDto? telemetryDataStat)
|
||||||
{
|
{
|
||||||
var dto = new ProcessMapReportRowDto();
|
var dto = new ProcessMapReportRowDto();
|
||||||
if (intervalModeOperations.Any())
|
if (intervalModeOperations.Any())
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.ProcessMap
|
|
||||||
{
|
|
||||||
#nullable enable
|
|
||||||
class ProcessTelemetrySaubStat {
|
|
||||||
public int Count { get; set; }
|
|
||||||
public DateTime DateMin { get; set; }
|
|
||||||
public DateTime DateMax { get; set; }
|
|
||||||
|
|
||||||
public float WellDepthMin { get; set; }
|
|
||||||
public float WellDepthMax { get; set; }
|
|
||||||
|
|
||||||
public float Pressure { get; set; }
|
|
||||||
public float PressureSp { get; set; }
|
|
||||||
public float PressureIdle { get; set; }
|
|
||||||
public float PressureSpRotor { get; set; }
|
|
||||||
public float PressureSpSlide { get; set; }
|
|
||||||
public float PressureDeltaLimitMax { get; set; }
|
|
||||||
|
|
||||||
public float AxialLoad { get; set; }
|
|
||||||
public float AxialLoadSp { get; set; }
|
|
||||||
public float AxialLoadLimitMax { get; set; }
|
|
||||||
|
|
||||||
public float RotorTorque { get; set; }
|
|
||||||
public float RotorTorqueSp { get; set; }
|
|
||||||
public float RotorTorqueLimitMax { get; set; }
|
|
||||||
|
|
||||||
public float BlockSpeed { get; set; }
|
|
||||||
public float BlockSpeedSp { get; set; }
|
|
||||||
public float BlockSpeedSpRotor { get; set; }
|
|
||||||
public float BlockSpeedSpSlide { get; set; }
|
|
||||||
}
|
|
||||||
#nullable disable
|
|
||||||
}
|
|
@ -17,8 +17,8 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
where TEntity : class, ITelemetryData
|
where TEntity : class, ITelemetryData
|
||||||
{
|
{
|
||||||
protected readonly IAsbCloudDbContext db;
|
protected readonly IAsbCloudDbContext db;
|
||||||
private readonly ITelemetryService telemetryService;
|
protected readonly ITelemetryService telemetryService;
|
||||||
private readonly TelemetryDataCache<TDto> telemetryDataCache;
|
protected readonly TelemetryDataCache<TDto> telemetryDataCache;
|
||||||
|
|
||||||
public TelemetryDataBaseService(
|
public TelemetryDataBaseService(
|
||||||
IAsbCloudDbContext db,
|
IAsbCloudDbContext db,
|
||||||
|
@ -2,12 +2,17 @@
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.SAUB
|
namespace AsbCloudInfrastructure.Services.SAUB
|
||||||
{
|
{
|
||||||
#nullable enable
|
#nullable enable
|
||||||
public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSaubDto, TelemetryDataSaub>
|
public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSaubDto, TelemetryDataSaub>, ITelemetryDataSaubService
|
||||||
{
|
{
|
||||||
private readonly ITelemetryUserService telemetryUserService;
|
private readonly ITelemetryUserService telemetryUserService;
|
||||||
|
|
||||||
@ -21,6 +26,54 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
this.telemetryUserService = telemetryUserService;
|
this.telemetryUserService = telemetryUserService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TelemetryDataSaubStatDto>> GetTelemetryDataStatAsync(int idTelemetry, CancellationToken token)
|
||||||
|
{
|
||||||
|
var timezone = telemetryService.GetTimezone(idTelemetry);
|
||||||
|
var timezoneOffset = TimeSpan.FromHours(timezone.Hours);
|
||||||
|
|
||||||
|
var query = db.Set<TelemetryDataSaub>()
|
||||||
|
.Where(t => t.IdTelemetry == idTelemetry)
|
||||||
|
.Where(t => t.BlockPosition > 0.0001)
|
||||||
|
.Where(t => t.WellDepth > 0.0001)
|
||||||
|
.Where(t => t.WellDepth - t.BitDepth < 0.01)
|
||||||
|
.GroupBy(t => new { H = t.DateTime.Hour, W = Math.Truncate(t.WellDepth!.Value) })
|
||||||
|
.Select(g => new TelemetryDataSaubStatDto
|
||||||
|
{
|
||||||
|
Count = g.Count(),
|
||||||
|
|
||||||
|
DateMin = g.Min(t => t.DateTime.UtcDateTime),
|
||||||
|
DateMax = g.Max(t => t.DateTime.UtcDateTime),
|
||||||
|
|
||||||
|
WellDepthMin = g.Min(t => t.WellDepth!.Value),
|
||||||
|
WellDepthMax = g.Max(t => t.WellDepth!.Value),
|
||||||
|
|
||||||
|
Pressure = g.Average(t => t.Pressure!.Value),
|
||||||
|
PressureSp = g.Average(t => t.PressureSp!.Value),
|
||||||
|
PressureSpRotor = g.Average(t => t.PressureSpRotor!.Value),
|
||||||
|
PressureSpSlide = g.Average(t => t.PressureSpSlide!.Value),
|
||||||
|
PressureIdle = g.Average(t => t.PressureIdle!.Value),
|
||||||
|
PressureDeltaLimitMax = g.Average(t => t.PressureDeltaLimitMax!.Value),
|
||||||
|
|
||||||
|
AxialLoad = g.Average(t => t.AxialLoad!.Value),
|
||||||
|
AxialLoadSp = g.Average(t => t.AxialLoadSp!.Value),
|
||||||
|
AxialLoadLimitMax = g.Average(t => t.AxialLoadLimitMax!.Value),
|
||||||
|
|
||||||
|
RotorTorque = g.Average(t => t.RotorTorque!.Value),
|
||||||
|
RotorTorqueSp = g.Average(t => t.RotorTorqueSp!.Value),
|
||||||
|
RotorTorqueLimitMax = g.Average(t => t.RotorTorqueLimitMax!.Value),
|
||||||
|
|
||||||
|
BlockSpeed = g.Average(t => t.BlockSpeed!.Value),
|
||||||
|
BlockSpeedSp = g.Average(t => t.BlockSpeedSp!.Value),
|
||||||
|
BlockSpeedSpRotor = g.Average(t => t.BlockSpeedSpRotor!.Value),
|
||||||
|
BlockSpeedSpSlide = g.Average(t => t.BlockSpeedSpSlide!.Value),
|
||||||
|
})
|
||||||
|
.Where(s => s.WellDepthMin != s.WellDepthMax)
|
||||||
|
.Where(s => s.Count > 3)
|
||||||
|
.OrderBy(t => t.DateMin);
|
||||||
|
|
||||||
|
return await query.ToArrayAsync(token);
|
||||||
|
}
|
||||||
|
|
||||||
public override TelemetryDataSaub Convert(TelemetryDataSaubDto src, double timezoneOffset)
|
public override TelemetryDataSaub Convert(TelemetryDataSaubDto src, double timezoneOffset)
|
||||||
{
|
{
|
||||||
var entity = src.Adapt<TelemetryDataSaub>();
|
var entity = src.Adapt<TelemetryDataSaub>();
|
||||||
|
Loading…
Reference in New Issue
Block a user