forked from ddrilling/AsbCloudServer
расчет глубин для статистики по группам телеметрии выведен в отдельный метод сервиса DetectedOperations.
изменение метода статистики по активным скважинам
This commit is contained in:
parent
bcdfb1933e
commit
a51208cb1d
@ -10,27 +10,23 @@ namespace AsbCloudApp.Data.Subsystems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Активная скважина
|
/// Активная скважина
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public WellDto ActiveWell { get; set; }
|
public WellDto ActiveWell { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// Наработки подсистем
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<SubsystemStatDto> listSubsystemStat { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наработки подсистемы АКБ
|
/// Наработки подсистемы АКБ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SubsystemStatDto SubsystemAKB { get; set; }
|
public SubsystemStatDto? SubsystemAKB { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наработки подсистемы МСЕ
|
/// Наработки подсистемы МСЕ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SubsystemStatDto SubsystemMSE { get; set; }
|
public SubsystemStatDto? SubsystemMSE { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наработки подсистемы СПИН
|
/// Наработки подсистемы СПИН
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SubsystemStatDto SubsystemSpinMaster { get; set; }
|
public SubsystemStatDto? SubsystemSpinMaster { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наработки подсистемы ТОРК
|
/// Наработки подсистемы ТОРК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SubsystemStatDto SubsystemTorqueMaster { get; set; }
|
public SubsystemStatDto? SubsystemTorqueMaster { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,10 +45,9 @@ namespace AsbCloudApp.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gtDate"></param>
|
/// <param name="gtDate"></param>
|
||||||
/// <param name="ltDate"></param>
|
/// <param name="ltDate"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <param name="wellTimezoneHours"></param>
|
|
||||||
/// <returns>кортеж - ид телеметрии, интервалы глубины забоя </returns>
|
/// <returns>кортеж - ид телеметрии, интервалы глубины забоя </returns>
|
||||||
Task<IEnumerable<(int, double, double)>?> GetDepthIntervalAllOperationsAsync(DateTime gtDate, DateTime ltDate, double wellTimezoneHours, CancellationToken token);
|
Task<IEnumerable<(int,double, double)>?> GetDepthIntervalAllOperationsAsync(DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить операции
|
/// Удалить операции
|
||||||
|
@ -84,24 +84,28 @@ namespace AsbCloudInfrastructure.Services.DetectOperations
|
|||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<(int, double, double)>?> GetDepthIntervalAllOperationsAsync(DateTime gtDate, DateTime ltDate, double wellTimezoneHours ,CancellationToken token)
|
|
||||||
|
|
||||||
|
public async Task<IEnumerable<(int, double, double)>?> GetDepthIntervalAllOperationsAsync(DateTimeOffset gtDate, DateTimeOffset ltDate, CancellationToken token)
|
||||||
{
|
{
|
||||||
var query = db.Set<DetectedOperation>()
|
var query = db.Set<DetectedOperation>()
|
||||||
.Include(o => o.OperationCategory)
|
.Include(o => o.OperationCategory)
|
||||||
.Where(o => o.DateStart >= gtDate.ToUtcDateTimeOffset(wellTimezoneHours))
|
.Where(o => o.DateStart >= gtDate)
|
||||||
.Where(o => o.DateEnd <= ltDate.ToUtcDateTimeOffset(wellTimezoneHours));
|
.Where(o => o.DateEnd <= ltDate);
|
||||||
if (query is null)
|
|
||||||
return null;
|
|
||||||
var data = await query.ToListAsync(token);
|
var data = await query.ToListAsync(token);
|
||||||
var result = data.GroupBy(g => g.IdTelemetry)
|
if (data.Any())
|
||||||
.Select(g =>
|
{
|
||||||
(
|
var result = data.GroupBy(g => g.IdTelemetry)
|
||||||
g.Key,
|
.Select(g =>
|
||||||
g.Where(o => o.IdCategory == 1).Sum(o => o.DepthEnd - o.DepthStart),
|
(
|
||||||
g.Where(o => o.IdCategory == 3).Sum(o => o.DepthEnd - o.DepthStart)
|
g.Key,
|
||||||
));
|
g.Where(o => o.IdCategory == 1).Sum(o => o.DepthEnd - o.DepthStart),
|
||||||
return result;
|
g.Where(o => o.IdCategory == 3).Sum(o => o.DepthEnd - o.DepthStart)
|
||||||
}
|
));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private static IEnumerable<DetectedOperationDrillersStatDto> GetOperationsDrillersStat(IEnumerable<DetectedOperationDto> operations)
|
private static IEnumerable<DetectedOperationDrillersStatDto> GetOperationsDrillersStat(IEnumerable<DetectedOperationDto> operations)
|
||||||
{
|
{
|
||||||
@ -320,6 +324,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations
|
|||||||
var exportService = new DetectedOperationExportService(db, wellService);
|
var exportService = new DetectedOperationExportService(db, wellService);
|
||||||
return exportService.ExportAsync(idsWells, token);
|
return exportService.ExportAsync(idsWells, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,10 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly ICrudService<SubsystemDto> subsystemService;
|
private readonly ICrudService<SubsystemDto> subsystemService;
|
||||||
private readonly IDetectedOperationService detectedOperationService;
|
private readonly IDetectedOperationService detectedOperationService;
|
||||||
|
public const int IdSubsystemAKB = 1;
|
||||||
|
public const int IdSubsystemMSE = 2;
|
||||||
|
public const int IdSubsystemSpin = 65536;
|
||||||
|
public const int IdSubsystemTorque = 65537;
|
||||||
public SubsystemOperationTimeService(IAsbCloudDbContext db, IWellService wellService, ICrudService<SubsystemDto> subsystemService, IDetectedOperationService detectedOperationService)
|
public SubsystemOperationTimeService(IAsbCloudDbContext db, IWellService wellService, ICrudService<SubsystemDto> subsystemService, IDetectedOperationService detectedOperationService)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
@ -202,30 +206,19 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
|
|
||||||
var query = db.SubsystemOperationTimes
|
var query = db.SubsystemOperationTimes
|
||||||
.Where(o => telemetryIds.Contains(o.IdTelemetry))
|
.Where(o => telemetryIds.Contains(o.IdTelemetry))
|
||||||
.AsNoTracking();
|
.AsNoTracking();
|
||||||
|
|
||||||
|
var beginUTC = DateTime.Today.AddDays(-1).ToUtcDateTimeOffset(firstWell.Timezone.Hours);
|
||||||
|
var endUTC = DateTime.Today.ToUtcDateTimeOffset(firstWell.Timezone.Hours);
|
||||||
if (gtDate is not null)
|
if (gtDate is not null)
|
||||||
{
|
{
|
||||||
var beginUTC = gtDate.Value.ToUtcDateTimeOffset(firstWell.Timezone.Hours);
|
beginUTC = gtDate.Value.ToUtcDateTimeOffset(firstWell.Timezone.Hours);
|
||||||
query = query.Where(d => d.DateStart >= beginUTC);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var beginUTC = DateTime.Today.AddDays(-1).ToUtcDateTimeOffset(firstWell.Timezone.Hours);
|
|
||||||
query = query.Where(o => o.DateStart >= beginUTC );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ltDate is not null)
|
|
||||||
{
|
|
||||||
var endUTC = ltDate.Value.ToUtcDateTimeOffset(firstWell.Timezone.Hours);
|
|
||||||
query = query.Where(d => d.DateEnd <= endUTC);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var endUTC = DateTime.Today.ToUtcDateTimeOffset(firstWell.Timezone.Hours);
|
|
||||||
query = query.Where(o => o.DateEnd <= endUTC);
|
|
||||||
}
|
}
|
||||||
|
query = query.Where(d => d.DateStart >= beginUTC);
|
||||||
|
query = query.Where(o => o.DateEnd <= endUTC);
|
||||||
|
|
||||||
|
|
||||||
|
var depthIntervals = await detectedOperationService.GetDepthIntervalAllOperationsAsync(beginUTC, endUTC, token);
|
||||||
var result = new List<SubsystemActiveWellStatDto>();
|
var result = new List<SubsystemActiveWellStatDto>();
|
||||||
|
|
||||||
var subsystemsOperationTime = await query.ToListAsync(token);
|
var subsystemsOperationTime = await query.ToListAsync(token);
|
||||||
@ -238,33 +231,21 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
{
|
{
|
||||||
var wellStat = new SubsystemActiveWellStatDto()
|
var wellStat = new SubsystemActiveWellStatDto()
|
||||||
{
|
{
|
||||||
ActiveWell = well,
|
ActiveWell = well
|
||||||
listSubsystemStat = new List<SubsystemStatDto>()
|
|
||||||
|
|
||||||
};
|
};
|
||||||
var detectedOperationsRequest = new DetectedOperationRequest()
|
if (depthIntervals is not null)
|
||||||
{
|
{
|
||||||
IdWell = well.Id,
|
var depthInterval = depthIntervals.Where(o => o.Item1 == well.IdTelemetry).Select(o => (o.Item2, o.Item3)).FirstOrDefault();
|
||||||
IdsCategories = new List<int>() { 1, 3 },
|
//var groupSubsystem = group.GroupBy(g => g.IdSubsystem);
|
||||||
LtDate = ltDate,
|
var dto = group.Select(s => s.Adapt<SubsystemOperationTimeDto>());
|
||||||
GtDate = gtDate,
|
var subsystemStat = CalcStat(dto, depthInterval);
|
||||||
};
|
wellStat.SubsystemAKB = subsystemStat.FirstOrDefault(s => s.IdSubsystem == IdSubsystemAKB);
|
||||||
var detectedOperations = await detectedOperationService.GetOperationsAsync(detectedOperationsRequest, token);
|
wellStat.SubsystemMSE = subsystemStat.FirstOrDefault(s => s.IdSubsystem == IdSubsystemMSE);
|
||||||
if (detectedOperations is not null && detectedOperations.Any())
|
wellStat.SubsystemSpinMaster = subsystemStat.FirstOrDefault(s => s.IdSubsystem == IdSubsystemSpin);
|
||||||
{
|
wellStat.SubsystemTorqueMaster = subsystemStat.FirstOrDefault(s => s.IdSubsystem == IdSubsystemTorque);
|
||||||
var depthInterval = GetDepthInterval(detectedOperations);
|
|
||||||
var groupSubsystem = group.GroupBy(g => g.IdSubsystem);
|
|
||||||
|
|
||||||
foreach (var subsystem in groupSubsystem)
|
|
||||||
{
|
|
||||||
var dto = subsystem.Select(s => s.Adapt<SubsystemOperationTimeDto>());
|
|
||||||
var subsystemStat = CalcStat(dto, depthInterval);
|
|
||||||
wellStat.listSubsystemStat.Concat(subsystemStat);
|
|
||||||
//wellStat.Saub = subsystemStat.FirstOrDefault(s=>s.IdSubsystem == idSubsystemSaub)
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Add(wellStat);
|
result.Add(wellStat);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user