Рефакторинг WellInfoService и WellCompositeController

This commit is contained in:
Степанов Дмитрий 2023-10-12 15:47:26 +05:00
parent 2f2599f9ab
commit 6556a03bb5
2 changed files with 14 additions and 14 deletions

View File

@ -34,7 +34,7 @@ public class WellInfoService
{
var wellService = services.GetRequiredService<IWellService>();
var operationsStatService = services.GetRequiredService<IOperationsStatService>();
var wellDrillingProcessMapRepository = services.GetRequiredService<IWellDrillingProcessMapRepository>();
var processMapPlanWellDrillingRepository = services.GetRequiredService<IProcessMapPlanRepository<ProcessMapPlanWellDrillingDto>>();
var subsystemOperationTimeService = services.GetRequiredService<ISubsystemOperationTimeService>();
var telemetryDataSaubCache = services.GetRequiredService<TelemetryDataCache<TelemetryDataSaubDto>>();
var messageHub = services.GetRequiredService<IIntegrationEventHandler<UpdateWellInfoEvent>>();
@ -44,10 +44,10 @@ public class WellInfoService
var wellsIds = activeWells.Select(w => w.Id);
var wellDrillingProcessMapRequests = wellsIds.Select(id => new WellDrillingProcessMapRequest { IdWell = id });
var wellDrillingProcessMaps = await wellDrillingProcessMapRepository.GetAsync(wellDrillingProcessMapRequests, token);
var processMapPlanWellDrillingRequests = wellsIds.Select(id => new ProcessMapPlanRequest { IdWell = id });
var processMapPlanWellDrillings = await processMapPlanWellDrillingRepository.GetAsync(processMapPlanWellDrillingRequests, token);
var wellDepthByProcessMap = wellDrillingProcessMaps
var wellDepthByProcessMap = processMapPlanWellDrillings
.GroupBy(p => p.IdWell)
.Select(g => new
{
@ -85,20 +85,20 @@ public class WellInfoService
var wellLastFactSection = wellOperationsStat?.Sections.LastOrDefault(s => s.Fact is not null);
currentDepth ??= wellLastFactSection?.Fact?.WellDepthEnd;
var wellProcessMaps = wellDrillingProcessMaps
var wellProcessMaps = processMapPlanWellDrillings
.Where(p => p.IdWell == well.Id)
.OrderBy(p => p.DepthEnd);
int? idSection = wellLastFactSection?.Id;
WellDrillingProcessMapDto? wellDrillingProcessMap = null;
ProcessMapPlanWellDrillingDto? processMapPlanWellDrilling = null;
if (idSection.HasValue)
{
wellDrillingProcessMap = wellProcessMaps.FirstOrDefault(p => p.IdWellSectionType == idSection);
processMapPlanWellDrilling = wellProcessMaps.FirstOrDefault(p => p.IdWellSectionType == idSection);
}
else if (currentDepth.HasValue)
{
wellDrillingProcessMap = wellProcessMaps.FirstOrDefault(p => p.DepthStart <= currentDepth.Value && p.DepthEnd >= currentDepth.Value);
processMapPlanWellDrilling = wellProcessMaps.FirstOrDefault(p => p.DepthStart <= currentDepth.Value && p.DepthEnd >= currentDepth.Value);
}
double? planTotalDepth = null;
@ -114,25 +114,25 @@ public class WellInfoService
wellMapInfo.AxialLoad = new()
{
Plan = wellDrillingProcessMap?.AxialLoad.Plan,
Plan = processMapPlanWellDrilling?.AxialLoad.Plan,
Fact = lastSaubTelemetry?.AxialLoad
};
wellMapInfo.TopDriveSpeed = new()
{
Plan = wellDrillingProcessMap?.TopDriveSpeed.Plan,
Plan = processMapPlanWellDrilling?.TopDriveSpeed.Plan,
Fact = lastSaubTelemetry?.RotorSpeed
};
wellMapInfo.TopDriveTorque = new()
{
Plan = wellDrillingProcessMap?.TopDriveTorque.Plan,
Plan = processMapPlanWellDrilling?.TopDriveTorque.Plan,
Fact = lastSaubTelemetry?.RotorTorque
};
wellMapInfo.Pressure = new()
{
Plan = wellDrillingProcessMap?.Pressure.Plan,
Plan = processMapPlanWellDrilling?.Pressure.Plan,
Fact = lastSaubTelemetry?.Pressure
};
@ -146,7 +146,7 @@ public class WellInfoService
wellMapInfo.ROP = new()
{
Plan = wellDrillingProcessMap?.RopPlan,
Plan = processMapPlanWellDrilling?.RopPlan,
Fact = wellOperationsStat?.Total.Fact?.Rop,
};

View File

@ -73,7 +73,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns>
[HttpGet("compositeProcessMap")]
[Permission]
[ProducesResponseType(typeof(IEnumerable<WellDrillingProcessMapDto>), (int)System.Net.HttpStatusCode.OK)]
[ProducesResponseType(typeof(IEnumerable<ProcessMapPlanWellDrillingDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetCompositeProcessMap(int idWell, CancellationToken token)
{
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))