diff --git a/AsbCloudApp/Data/DetectedOperationListDto.cs b/AsbCloudApp/Data/DetectedOperationListDto.cs new file mode 100644 index 00000000..1600c94c --- /dev/null +++ b/AsbCloudApp/Data/DetectedOperationListDto.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace AsbCloudApp.Data +{ + /// + /// Автоматически определяемая операция + /// + public class DetectedOperationListDto + { + public IEnumerable> test { get; set; } + /// + /// Список всех операций + /// + public IEnumerable List { get; set; } + + /// + /// Количество по + /// + public IDictionary Count { get; set; } + + /// + /// Среднее целевое + /// + public IDictionary Average { get; set; } + + /// + /// Коэффициент эффективности + /// + public IDictionary Efficiency { get; set; } + + /// + /// Среднее по ключевому показателю + /// + public IDictionary AverageByParam { get; set; } + + /// + /// Коэффициент потерь + /// + public IDictionary Loss { get; set; } + } +} diff --git a/AsbCloudApp/Services/IDetectedOperationService.cs b/AsbCloudApp/Services/IDetectedOperationService.cs index 143a1379..3b3bccf5 100644 --- a/AsbCloudApp/Services/IDetectedOperationService.cs +++ b/AsbCloudApp/Services/IDetectedOperationService.cs @@ -9,7 +9,7 @@ namespace AsbCloudApp.Services public interface IDetectedOperationService { Task> GetCategoriesAsync(CancellationToken token); - Task> GetAsync(int idWell, Requests.DetectedOperationRequest request, CancellationToken token); + Task GetAsync(int idWell, Requests.DetectedOperationRequest request, CancellationToken token); Task DeleteAsync(int idWell, DetectedOperationRequest request, CancellationToken token); } } diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs index b206434d..e293ae99 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs @@ -31,12 +31,13 @@ namespace AsbCloudInfrastructure.Services.DetectOperations this.scheduleService = scheduleService; } - public async Task> GetAsync(int idWell, DetectedOperationRequest request, CancellationToken token) + public async Task GetAsync(int idWell, DetectedOperationRequest request, CancellationToken token) { var well = await wellService.GetAsync(idWell, token); if (well?.IdTelemetry is null || well.Timezone is null) return null; + var res = new DetectedOperationListDto(); var query = BuildQuery(well, request) .AsNoTracking(); @@ -50,7 +51,12 @@ namespace AsbCloudInfrastructure.Services.DetectOperations { item.Driller = await scheduleService.GetDrillerAsync(idWell, item.DateStart); } - return dtos; + res.List = dtos; + res.Count = dtos.GroupBy(o => o.Driller==null?0:o.Driller.Id, + p=>p, + (key,gr)=>(key,gr.Count())).ToDictionary(e=>e.key,e=>e.Item2); + //res.test = g; + return res; } public async Task DeleteAsync(int idWell, DetectedOperationRequest request, CancellationToken token)