forked from ddrilling/AsbCloudServer
Автоопределяемые операции
1. Удалил неиспользуемые DTO и метод из сервиса 2. Рефакторинг Requests
This commit is contained in:
parent
a915e8365a
commit
697d1061f7
@ -12,6 +12,11 @@ namespace AsbCloudApp.Data.DetectedOperation
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id телеметрии
|
||||
/// </summary>
|
||||
public int IdTelemetry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id названия/описания операции
|
||||
@ -34,9 +39,9 @@ namespace AsbCloudApp.Data.DetectedOperation
|
||||
public DateTime DateEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Продолжительность операции в минутах
|
||||
/// Продолжительность операции в часах
|
||||
/// </summary>
|
||||
public double DurationMinutes => (DateEnd - DateStart).TotalMinutes;
|
||||
public double DurationHours => (DateEnd - DateStart).TotalHours;
|
||||
|
||||
/// <summary>
|
||||
/// глубина на начало операции, м
|
||||
@ -72,5 +77,10 @@ namespace AsbCloudApp.Data.DetectedOperation
|
||||
/// Ключевой параметр операции
|
||||
/// </summary>
|
||||
public double Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Флаг включенной подсистемы
|
||||
/// </summary>
|
||||
public int EnabledSubsystems { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
namespace AsbCloudApp.Data.DetectedOperation;
|
||||
|
||||
/// <summary>
|
||||
/// Статистика по операциям
|
||||
/// </summary>
|
||||
public class OperationsSummaryDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Id телеметрии
|
||||
/// </summary>
|
||||
public int IdTelemetry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id названия/описания операции
|
||||
/// </summary>
|
||||
public int IdCategory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Количество операций
|
||||
/// </summary>
|
||||
public int Count { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cумма проходок операций
|
||||
/// </summary>
|
||||
public double SumDepthIntervals { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cумма продолжительностей операций
|
||||
/// </summary>
|
||||
public double SumDurationHours { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Флаг включенной подсистемы
|
||||
/// </summary>
|
||||
public int EnabledSubsystems { get; set; }
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
|
||||
namespace AsbCloudApp.Requests
|
||||
{
|
||||
@ -14,31 +15,37 @@ namespace AsbCloudApp.Requests
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Список id телеметрий
|
||||
/// пустой список - нет фильтрации
|
||||
/// </summary>
|
||||
public IEnumerable<int> IdsTelemetries { get; set; } = Enumerable.Empty<int>();
|
||||
|
||||
/// <summary>
|
||||
/// категории операций
|
||||
/// </summary>
|
||||
public IEnumerable<int>? IdsCategories { get; set; }
|
||||
public IEnumerable<int> IdsCategories { get; set; } = Enumerable.Empty<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Больше или равно дате
|
||||
/// </summary>
|
||||
public DateTime? GtDate { get; set; }
|
||||
public DateTimeOffset? GeDateStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно дате
|
||||
/// </summary>
|
||||
public DateTime? LtDate { get; set; }
|
||||
public DateTimeOffset? LeDateEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Больше или равно глубины забоя
|
||||
/// </summary>
|
||||
public double? GtDepth { get; set; }
|
||||
public double? GeDepth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно глубины забоя
|
||||
/// </summary>
|
||||
public double? LtDepth { get; set; }
|
||||
public double? LeDepth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Фильтр по пользователю панели
|
||||
|
@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AsbCloudApp.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// Запрос на получение обобщенных данных по операцим
|
||||
/// </summary>
|
||||
public class DetectedOperationSummaryRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Список id телеметрий
|
||||
/// пустой список - нет фильтрации
|
||||
/// </summary>
|
||||
public IEnumerable<int> IdsTelemetries { get;set;} = Enumerable.Empty<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Список id категорий операций
|
||||
/// пустой список - нет фильтрации
|
||||
/// </summary>
|
||||
public IEnumerable<int> IdsOperationCategories { get; set; } = Enumerable.Empty<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Больше или равно даты начала операции
|
||||
/// </summary>
|
||||
public DateTimeOffset? GeDateStart {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно даты начала операции
|
||||
/// </summary>
|
||||
public DateTimeOffset? LeDateStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно даты окончания операции
|
||||
/// </summary>
|
||||
public DateTimeOffset? LeDateEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Больше или равно глубины начала операции
|
||||
/// </summary>
|
||||
public double? GeDepthStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно глубины начала операции
|
||||
/// </summary>
|
||||
public double? LeDepthStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно глубины окончания операции
|
||||
/// </summary>
|
||||
public double? LeDepthEnd { get; set; }
|
||||
}
|
@ -37,14 +37,6 @@ namespace AsbCloudApp.Services
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<DetectedOperationDto>?> GetOperationsAsync(DetectedOperationRequest request, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получить интервалы глубин по всем скважинам
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns>кортеж - ид телеметрии, интервалы глубины забоя (ротор,слайд) </returns>
|
||||
Task<IEnumerable<OperationsSummaryDto>> GetOperationSummaryAsync(DetectedOperationSummaryRequest request, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Удалить операции
|
||||
/// </summary>
|
||||
|
@ -263,8 +263,8 @@ public class DailyReportService : IDailyReportService
|
||||
{
|
||||
IdsCategories = new[] { idWellOperationSlipsTime },
|
||||
IdWell = dailyReport.IdWell,
|
||||
GtDate = dailyReport.Date,
|
||||
LtDate = dailyReport.Date.AddHours(24)
|
||||
GeDateStart = dailyReport.Date,
|
||||
LeDateEnd = dailyReport.Date.AddHours(24)
|
||||
}, cancellationToken))?.Stats.Sum(s => s.Count);
|
||||
|
||||
dailyReport.TimeBalanceBlock.WellDepth.Fact = factWellOperations
|
||||
|
@ -65,62 +65,6 @@ namespace AsbCloudInfrastructure.Services.DetectOperations
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<OperationsSummaryDto>> GetOperationSummaryAsync(DetectedOperationSummaryRequest request, CancellationToken token)
|
||||
{
|
||||
var query = db.Set<DetectedOperation>()
|
||||
.AsNoTracking();
|
||||
|
||||
if (request.IdsTelemetries.Any())
|
||||
query = query.Where(operation => request.IdsTelemetries.Contains(operation.IdTelemetry));
|
||||
|
||||
if (request.IdsOperationCategories.Any())
|
||||
query = query.Where(operation => request.IdsOperationCategories.Contains(operation.IdCategory));
|
||||
|
||||
if (request.GeDateStart.HasValue)
|
||||
{
|
||||
var geDateStart = request.GeDateStart.Value.ToUniversalTime();
|
||||
query = query.Where(operation => operation.DateStart >= geDateStart);
|
||||
}
|
||||
|
||||
if (request.LeDateStart.HasValue)
|
||||
{
|
||||
var leDateStart = request.LeDateStart.Value.ToUniversalTime();
|
||||
query = query.Where(operation => operation.DateStart <= leDateStart);
|
||||
}
|
||||
|
||||
if (request.LeDateEnd.HasValue)
|
||||
{
|
||||
var leDateEnd = request.LeDateEnd.Value.ToUniversalTime();
|
||||
query = query.Where(operation => operation.DateEnd <= leDateEnd);
|
||||
}
|
||||
|
||||
if (request.GeDepthStart.HasValue)
|
||||
query = query.Where(operation => operation.DepthStart >= request.GeDepthStart.Value);
|
||||
|
||||
if (request.LeDepthStart.HasValue)
|
||||
query = query.Where(operation => operation.DepthStart <= request.LeDepthStart.Value);
|
||||
|
||||
if (request.LeDepthEnd.HasValue)
|
||||
query = query.Where(operation => operation.DepthEnd <= request.LeDepthEnd.Value);
|
||||
|
||||
var queryGroup = query
|
||||
.GroupBy(operation => new { operation.IdTelemetry, operation.IdCategory, operation.EnabledSubsystems })
|
||||
.Select(group => new OperationsSummaryDto
|
||||
{
|
||||
IdTelemetry = group.Key.IdTelemetry,
|
||||
IdCategory = group.Key.IdCategory,
|
||||
EnabledSubsystems = group.Key.EnabledSubsystems,
|
||||
Count = group.Count(),
|
||||
SumDepthIntervals = group.Sum(operation => operation.DepthEnd - operation.DepthStart),
|
||||
SumDurationHours = group.Sum(operation => (operation.DateEnd - operation.DateStart).TotalHours),
|
||||
})
|
||||
.OrderBy(summ => summ.IdTelemetry)
|
||||
.ThenBy(summ => summ.IdCategory);
|
||||
|
||||
var result = await queryGroup.ToArrayAsync(token);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static IEnumerable<DetectedOperationDrillersStatDto> GetOperationsDrillersStat(IEnumerable<DetectedOperationDto> operations)
|
||||
{
|
||||
var groups = operations.GroupBy(o => o.Driller);
|
||||
@ -241,20 +185,23 @@ namespace AsbCloudInfrastructure.Services.DetectOperations
|
||||
|
||||
if (request is not null)
|
||||
{
|
||||
if (request.IdsCategories?.Any() == true)
|
||||
if (request.IdsTelemetries.Any())
|
||||
query = query.Where(o => request.IdsTelemetries.Contains(o.IdTelemetry));
|
||||
|
||||
if (request.IdsCategories.Any())
|
||||
query = query.Where(o => request.IdsCategories.Contains(o.IdCategory));
|
||||
|
||||
if (request.GtDate is not null)
|
||||
query = query.Where(o => o.DateStart >= request.GtDate.Value.ToUtcDateTimeOffset(well.Timezone.Hours));
|
||||
if (request.GeDateStart is not null)
|
||||
query = query.Where(o => o.DateStart >= request.GeDateStart.Value.Date.ToUtcDateTimeOffset(well.Timezone.Hours));
|
||||
|
||||
if (request.LtDate is not null)
|
||||
query = query.Where(o => o.DateEnd <= request.LtDate.Value.ToUtcDateTimeOffset(well.Timezone.Hours));
|
||||
if (request.LeDateEnd is not null)
|
||||
query = query.Where(o => o.DateEnd <= request.LeDateEnd.Value.Date.ToUtcDateTimeOffset(well.Timezone.Hours));
|
||||
|
||||
if (request.GtDepth is not null)
|
||||
query = query.Where(o => o.DepthStart >= request.GtDepth);
|
||||
if (request.GeDepth is not null)
|
||||
query = query.Where(o => o.DepthStart >= request.GeDepth);
|
||||
|
||||
if (request.LtDepth is not null)
|
||||
query = query.Where(o => o.DepthEnd <= request.LtDepth);
|
||||
if (request.LeDepth is not null)
|
||||
query = query.Where(o => o.DepthEnd <= request.LeDepth);
|
||||
|
||||
if (request.EqIdTelemetryUser is not null)
|
||||
query = query.Where(o => o.IdUsersAtStart == request.EqIdTelemetryUser);
|
||||
|
Loading…
Reference in New Issue
Block a user