forked from ddrilling/AsbCloudServer
Fix DrillParamsService.GetAllAsync(..)
This commit is contained in:
parent
ed5f181754
commit
df5c98838d
@ -89,16 +89,31 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
public async Task<IEnumerable<DrillParamsDto>> GetAllAsync(int idWell,
|
public async Task<IEnumerable<DrillParamsDto>> GetAllAsync(int idWell,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var entities = await (from p in db.DrillParams
|
var entities = await db.DrillParams
|
||||||
where p.IdWell == idWell
|
.Where(p => p.IdWell == idWell)
|
||||||
orderby p.Id
|
.OrderBy(p=> p.Id)
|
||||||
select p)
|
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.ToListAsync(token)
|
.ToArrayAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var dto = entities.Adapt<IEnumerable<DrillParamsDto>>();
|
var dtos = entities.Select(p =>
|
||||||
|
{
|
||||||
|
var dto = new DrillParamsDto
|
||||||
|
{
|
||||||
|
IdWell = p.IdWell,
|
||||||
|
Id = p.Id,
|
||||||
|
IdWellSectionType = p.IdWellSectionType,
|
||||||
|
Depth = new MinMaxDto<double> { Max = p.PressureMax, Min = p.PressureMin },
|
||||||
|
Pressure = MakeMinMaxExtended(p.PressureAvg, p.PressureMax, p.PressureMin),
|
||||||
|
AxialLoad = MakeMinMaxExtended(p.AxialLoadAvg, p.AxialLoadMax, p.AxialLoadMin),
|
||||||
|
Flow = MakeMinMaxExtended(p.FlowAvg, p.FlowMax, p.FlowMin),
|
||||||
|
RotorSpeed = MakeMinMaxExtended(p.RotorSpeedAvg, p.RotorSpeedMax, p.RotorSpeedMin),
|
||||||
|
RotorTorque = MakeMinMaxExtended(p.RotorTorqueAvg, p.RotorTorqueMax, p.RotorTorqueMin)
|
||||||
|
};
|
||||||
return dto;
|
return dto;
|
||||||
|
});
|
||||||
|
|
||||||
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<DrillParamsDto>> GetCompositeAllAsync(int idWell,
|
public async Task<IEnumerable<DrillParamsDto>> GetCompositeAllAsync(int idWell,
|
||||||
@ -181,26 +196,26 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
IdWellSectionType = entity.IdWellSectionType,
|
IdWellSectionType = entity.IdWellSectionType,
|
||||||
AxialLoad = GetMinMaxExtended(entity.AxialLoadAvg, entity.AxialLoadMax, entity.AxialLoadMin, drillParams.Select(x => (x.AxialLoadMin, x.AxialLoadMax))),
|
AxialLoad = MakeMinMaxExtended(entity.AxialLoadAvg, entity.AxialLoadMax, entity.AxialLoadMin, drillParams.Select(x => (x.AxialLoadMin, x.AxialLoadMax))),
|
||||||
Depth = new MinMaxDto<double> {
|
Depth = new MinMaxDto<double> {
|
||||||
Min = entity.DepthEnd,
|
Min = entity.DepthEnd,
|
||||||
Max = entity.DepthStart
|
Max = entity.DepthStart
|
||||||
},
|
},
|
||||||
Flow = GetMinMaxExtended(entity.FlowAvg, entity.FlowMax, entity.FlowMin, drillParams.Select(x => (x.FlowMin, x.FlowMax))),
|
Flow = MakeMinMaxExtended(entity.FlowAvg, entity.FlowMax, entity.FlowMin, drillParams.Select(x => (x.FlowMin, x.FlowMax))),
|
||||||
IdWell = entity.IdWell,
|
IdWell = entity.IdWell,
|
||||||
Pressure = GetMinMaxExtended(entity.PressureAvg, entity.PressureMax, entity.PressureMin, drillParams.Select(x => (x.PressureMin, x.PressureMax))),
|
Pressure = MakeMinMaxExtended(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))),
|
RotorSpeed = MakeMinMaxExtended(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)))
|
RotorTorque = MakeMinMaxExtended(entity.RotorTorqueAvg, entity.RotorTorqueMax, entity.RotorTorqueMin, drillParams.Select(x => (x.RotorTorqueMin, x.RotorTorqueMax)))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MinMaxExtendedViewDto GetMinMaxExtended(double avg, double max, double min, IEnumerable<(double min, double max)> allDrillParams)
|
private static MinMaxExtendedViewDto MakeMinMaxExtended(double avg, double max, double min, IEnumerable<(double min, double max)>? allDrillParams = null)
|
||||||
=> new MinMaxExtendedViewDto {
|
=> new MinMaxExtendedViewDto {
|
||||||
Avg = avg,
|
Avg = avg,
|
||||||
Max = max,
|
Max = max,
|
||||||
Min = min,
|
Min = min,
|
||||||
IsMax = allDrillParams.Any(mx => mx.max > max),
|
IsMax = allDrillParams?.Any(mx => mx.max > max) ?? false,
|
||||||
IsMin = allDrillParams.Any(mn => mn.min < min)
|
IsMin = allDrillParams?.Any(mn => mn.min < min) ?? false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
Loading…
Reference in New Issue
Block a user