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; }