Изменение dto для анализа

This commit is contained in:
Lyudmila Romanova 2022-06-08 14:37:05 +05:00
parent 6d44dadb27
commit cf8c61c1a7
3 changed files with 31 additions and 3 deletions

View File

@ -57,5 +57,15 @@ namespace AsbCloudApp.Data
/// Пользователь панели оператора
/// </summary>
public string TelemetryUserName { get; set; }
/// <summary>
/// Бурильщик
/// </summary>
public DrillerDto Driller { get; set; }
/// <summary>
/// Целевые/нормативные показатели
/// </summary>
public OperationValueDto OperationValue { get; set; }
}
}

View File

@ -117,6 +117,7 @@ namespace AsbCloudInfrastructure
services.AddTransient<IDetectedOperationService, DetectedOperationService>();
services.AddTransient<IDrillerService, DrillerService>();
services.AddTransient<IScheduleService, ScheduleService>();
services.AddTransient<IOperationValueService, OperationValueService>();
// admin crud services:
services.AddTransient<ICrudService<TelemetryDto>, CrudServiceBase<TelemetryDto, Telemetry>>(s =>

View File

@ -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<OperationValueDto> 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<IEnumerable<DetectedOperationDto>> 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<OperationValueDto> operationValues)
{
var dto = operation.Adapt<DetectedOperationDto>();
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;
}