forked from ddrilling/AsbCloudServer
#5996638 Исправление замечаний
This commit is contained in:
parent
c87acfdd59
commit
07eb1bd878
@ -24,7 +24,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
this.telemetryService = telemetryService;
|
||||
}
|
||||
|
||||
public async Task<DrillParamsDto> GetDefaultDrillParamsAsync(int idWell,
|
||||
public async Task<DrillParamsDto?> GetDefaultDrillParamsAsync(int idWell,
|
||||
double startDepth, double endDepth, CancellationToken token = default)
|
||||
{
|
||||
var idTelemetry = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||
@ -40,32 +40,38 @@ namespace AsbCloudInfrastructure.Services
|
||||
select new DrillParamsDto()
|
||||
{
|
||||
IdWell = idWell,
|
||||
Depth = new MinMaxDto<double> {
|
||||
Depth = new MinMaxDto<double>
|
||||
{
|
||||
Min = endDepth,
|
||||
Max = startDepth
|
||||
},
|
||||
IdWellSectionType = 0,
|
||||
AxialLoad = new MinMaxExtendedViewDto {
|
||||
AxialLoad = new MinMaxExtendedViewDto
|
||||
{
|
||||
Min = g.Min(t => t.AxialLoad) ?? double.NaN,
|
||||
Avg = g.Average(t => t.AxialLoad) ?? double.NaN,
|
||||
Max = g.Max(t => t.AxialLoad) ?? double.NaN
|
||||
},
|
||||
Pressure = new MinMaxExtendedViewDto {
|
||||
Pressure = new MinMaxExtendedViewDto
|
||||
{
|
||||
Min = g.Min(t => t.Pressure) ?? double.NaN,
|
||||
Avg = g.Average(t => t.Pressure) ?? double.NaN,
|
||||
Max = g.Max(t => t.Pressure) ?? double.NaN
|
||||
},
|
||||
RotorTorque = new MinMaxExtendedViewDto {
|
||||
RotorTorque = new MinMaxExtendedViewDto
|
||||
{
|
||||
Min = g.Min(t => t.RotorTorque) ?? double.NaN,
|
||||
Avg = g.Average(t => t.RotorTorque) ?? double.NaN,
|
||||
Max = g.Max(t => t.RotorTorque) ?? double.NaN
|
||||
},
|
||||
RotorSpeed = new MinMaxExtendedViewDto {
|
||||
RotorSpeed = new MinMaxExtendedViewDto
|
||||
{
|
||||
Min = g.Min(t => t.RotorSpeed) ?? double.NaN,
|
||||
Avg = g.Average(t => t.RotorSpeed) ?? double.NaN,
|
||||
Max = g.Max(t => t.RotorSpeed) ?? double.NaN
|
||||
},
|
||||
Flow = new MinMaxExtendedViewDto {
|
||||
Flow = new MinMaxExtendedViewDto
|
||||
{
|
||||
Min = g.Min(t => t.Flow) ?? double.NaN,
|
||||
Avg = g.Min(t => t.Flow) ?? double.NaN,
|
||||
Max = g.Min(t => t.Flow) ?? double.NaN
|
||||
@ -170,31 +176,27 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
Id = entity.Id,
|
||||
IdWellSectionType = entity.IdWellSectionType,
|
||||
AxialLoad = GetMinMaxExtended(entity, drillParams.Select(x => (x.AxialLoadMin, x.AxialLoadMax))),
|
||||
Depth = new MinMaxDto<double>
|
||||
{
|
||||
AxialLoad = GetMinMaxExtended(entity.AxialLoadAvg, entity.AxialLoadMax, entity.AxialLoadMin, drillParams.Select(x => (x.AxialLoadMin, x.AxialLoadMax))),
|
||||
Depth = new MinMaxDto<double> {
|
||||
Min = entity.DepthEnd,
|
||||
Max = entity.DepthStart
|
||||
},
|
||||
Flow = GetMinMaxExtended(entity, drillParams.Select(x => (x.FlowMin, x.FlowMax))),
|
||||
Flow = GetMinMaxExtended(entity.FlowAvg, entity.FlowMax, entity.FlowMin, drillParams.Select(x => (x.FlowMin, x.FlowMax))),
|
||||
IdWell = entity.IdWell,
|
||||
Pressure = GetMinMaxExtended(entity, drillParams.Select(x => (x.PressureMin, x.PressureMax))),
|
||||
RotorSpeed = GetMinMaxExtended(entity, drillParams.Select(x => (x.RotorSpeedMin, x.RotorSpeedMax))),
|
||||
RotorTorque = GetMinMaxExtended(entity, drillParams.Select(x => (x.RotorTorqueMin, x.RotorTorqueMax)))
|
||||
Pressure = GetMinMaxExtended(entity.PressureAvg, entity.PressureMax, entity.PressureMin, drillParams.Select(x => (x.PressureMin, x.PressureMax))),
|
||||
RotorSpeed = GetMinMaxExtended(entity.RotorSpeedAvg, entity.RotorSpeedMax, entity.RotorSpeedMin, drillParams.Select(x => (x.RotorSpeedMin, x.RotorSpeedMax))),
|
||||
RotorTorque = GetMinMaxExtended(entity.RotorTorqueAvg, entity.RotorTorqueMax, entity.RotorTorqueMin, drillParams.Select(x => (x.RotorTorqueMin, x.RotorTorqueMax)))
|
||||
};
|
||||
}
|
||||
|
||||
private static MinMaxExtendedViewDto GetMinMaxExtended(DrillParams x, IEnumerable<(double min, double max)> allDrillParams)
|
||||
{
|
||||
return new MinMaxExtendedViewDto
|
||||
{
|
||||
Avg = x.AxialLoadAvg,
|
||||
Max = x.AxialLoadMax,
|
||||
Min = x.AxialLoadMin,
|
||||
IsMax = allDrillParams.Max(mx => mx.max) < x.AxialLoadMax,
|
||||
IsMin = allDrillParams.Min(mn => mn.min) > x.AxialLoadMin
|
||||
};
|
||||
}
|
||||
private static MinMaxExtendedViewDto GetMinMaxExtended(double avg, double max, double min, IEnumerable<(double min, double max)> allDrillParams)
|
||||
=> new MinMaxExtendedViewDto {
|
||||
Avg = avg,
|
||||
Max = max,
|
||||
Min = min,
|
||||
IsMax = allDrillParams.Any(mx => mx.max > max),
|
||||
IsMin = allDrillParams.Any(mn => mn.min < min)
|
||||
};
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user