From cf8c61c1a77c8d4a5245ff43ed29e8b06a82f21a Mon Sep 17 00:00:00 2001 From: Lyudmila Romanova Date: Wed, 8 Jun 2022 14:37:05 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20dto=20=D0=B4=D0=BB=D1=8F=20=D0=B0=D0=BD=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Data/DetectedOperationDto.cs | 10 ++++++++ AsbCloudInfrastructure/DependencyInjection.cs | 1 + .../DetectedOperationService.cs | 23 ++++++++++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/AsbCloudApp/Data/DetectedOperationDto.cs b/AsbCloudApp/Data/DetectedOperationDto.cs index 0e5cdb8f..a28785cd 100644 --- a/AsbCloudApp/Data/DetectedOperationDto.cs +++ b/AsbCloudApp/Data/DetectedOperationDto.cs @@ -57,5 +57,15 @@ namespace AsbCloudApp.Data /// Пользователь панели оператора /// public string TelemetryUserName { get; set; } + + /// + /// Бурильщик + /// + public DrillerDto Driller { get; set; } + + /// + /// Целевые/нормативные показатели + /// + public OperationValueDto OperationValue { get; set; } } } diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index aff99304..97ae2dae 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -117,6 +117,7 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); // admin crud services: services.AddTransient, CrudServiceBase>(s => diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs index ca358a21..b206434d 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs @@ -17,11 +17,18 @@ namespace AsbCloudInfrastructure.Services.DetectOperations { private readonly IAsbCloudDbContext db; private readonly IWellService wellService; + private readonly IOperationValueService operationValueService; + private readonly IScheduleService scheduleService; - public DetectedOperationService(IAsbCloudDbContext db, IWellService wellService) + private IEnumerable operationValues; + + public DetectedOperationService(IAsbCloudDbContext db, IWellService wellService, + IOperationValueService operationValueService, IScheduleService scheduleService) { this.db = db; this.wellService = wellService; + this.operationValueService = operationValueService; + this.scheduleService = scheduleService; } public async Task> GetAsync(int idWell, DetectedOperationRequest request, CancellationToken token) @@ -34,7 +41,15 @@ namespace AsbCloudInfrastructure.Services.DetectOperations .AsNoTracking(); var data = await query.ToListAsync(token); - var dtos = data.Select(o => Convert(o, well)); + + operationValues = await operationValueService.GetAllAsync(token); + operationValues = operationValues.Where(o => o.IdWell == idWell); + + var dtos = data.Select(o => Convert(o, well, operationValues)); + foreach (var item in dtos) + { + item.Driller = await scheduleService.GetDrillerAsync(idWell, item.DateStart); + } return dtos; } @@ -97,12 +112,14 @@ namespace AsbCloudInfrastructure.Services.DetectOperations return query; } - private static DetectedOperationDto Convert(DetectedOperation operation, WellDto well) + private static DetectedOperationDto Convert(DetectedOperation operation, WellDto well, IEnumerable operationValues) { var dto = operation.Adapt(); dto.IdWell = well.Id; dto.DateStart = operation.DateStart.ToRemoteDateTime(well.Timezone.Hours); dto.DateEnd = operation.DateEnd.ToRemoteDateTime(well.Timezone.Hours); + dto.OperationValue = operationValues.FirstOrDefault(e => e.IdOperationCategory == dto.IdCategory + && e.DepthStart <= dto.DepthStart); return dto; }