forked from ddrilling/AsbCloudServer
Merge branch 'dev' of https://bitbucket.org/autodrilling/asbcloudserver into dev
This commit is contained in:
commit
4892d76a90
@ -30,93 +30,40 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (idTelemetry is null)
|
||||
return null;
|
||||
|
||||
var axialLoads = await GetTelemetryGroupQuery(idWell, startDepth, endDepth)
|
||||
.Select(g => new
|
||||
{
|
||||
Min = g.Min(t=> t.AxialLoad),
|
||||
Avg = g.Average(t => t.AxialLoad),
|
||||
Max = g.Max(t => t.AxialLoad)
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.Min)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var pressures = await GetTelemetryGroupQuery(idWell, startDepth, endDepth)
|
||||
.Select(g => new
|
||||
{
|
||||
Min = g.Min(t=> t.Pressure),
|
||||
Avg = g.Average(t => t.Pressure),
|
||||
Max = g.Max(t => t.Pressure)
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.Min)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var rotorTorques = await GetTelemetryGroupQuery(idWell, startDepth, endDepth)
|
||||
.Select(g => new
|
||||
{
|
||||
Min = g.Min(t=> t.RotorTorque),
|
||||
Avg = g.Average(t => t.RotorTorque),
|
||||
Max = g.Max(t => t.RotorTorque)
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.Min)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var rotorSpeeds = await GetTelemetryGroupQuery(idWell, startDepth, endDepth)
|
||||
.Select(g => new
|
||||
{
|
||||
Min = g.Min(t=> t.RotorSpeed),
|
||||
Avg = g.Average(t => t.RotorSpeed),
|
||||
Max = g.Max(t => t.RotorSpeed)
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.Min)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var flows = await GetTelemetryGroupQuery(idWell, startDepth, endDepth)
|
||||
.Select(g => new
|
||||
var drillParamsDto = await (from telemetry in db.TelemetryDataSaub
|
||||
where telemetry.IdTelemetry == idTelemetry &&
|
||||
telemetry.WellDepth >= startDepth &&
|
||||
telemetry.WellDepth <= endDepth
|
||||
group telemetry by telemetry.IdTelemetry into g
|
||||
select new DrillParamsDto()
|
||||
{
|
||||
Min = g.Min(t=> t.Flow),
|
||||
Avg = g.Average(t => t.Flow),
|
||||
Max = g.Max(t => t.Flow)
|
||||
IdWell = idWell,
|
||||
DepthStart = startDepth,
|
||||
DepthEnd = endDepth,
|
||||
IdWellSectionType = 0,
|
||||
AxialLoadMin = g.Min(t=> t.AxialLoad) ?? double.NaN,
|
||||
AxialLoadAvg = g.Average(t => t.AxialLoad) ?? double.NaN,
|
||||
AxialLoadMax = g.Max(t => t.AxialLoad) ?? double.NaN,
|
||||
PressureMin = g.Min(t=> t.Pressure) ?? double.NaN,
|
||||
PressureAvg = g.Average(t => t.Pressure) ?? double.NaN,
|
||||
PressureMax = g.Max(t => t.Pressure) ?? double.NaN,
|
||||
RotorTorqueMin = g.Min(t=> t.RotorTorque) ?? double.NaN,
|
||||
RotorTorqueAvg = g.Average(t => t.RotorTorque) ?? double.NaN,
|
||||
RotorTorqueMax = g.Max(t => t.RotorTorque) ?? double.NaN,
|
||||
RotorSpeedMin = g.Min(t=> t.RotorSpeed) ?? double.NaN,
|
||||
RotorSpeedAvg = g.Average(t => t.RotorSpeed) ?? double.NaN,
|
||||
RotorSpeedMax = g.Max(t => t.RotorSpeed) ?? double.NaN,
|
||||
FlowMin = g.Min(t => t.Flow) ?? double.NaN,
|
||||
FlowAvg = g.Min(t => t.Flow) ?? double.NaN,
|
||||
FlowMax = g.Min(t => t.Flow) ?? double.NaN
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.Min)
|
||||
.OrderBy(t => t.AxialLoadMin)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return new DrillParamsDto()
|
||||
{
|
||||
IdWell = idWell,
|
||||
DepthStart = startDepth,
|
||||
DepthEnd = endDepth,
|
||||
IdWellSectionType = 0,
|
||||
AxialLoadMin = axialLoads.Min ?? 0,
|
||||
AxialLoadAvg = axialLoads.Avg ?? 0,
|
||||
AxialLoadMax = axialLoads.Max ?? 0,
|
||||
PressureMin = pressures.Min ?? 0,
|
||||
PressureAvg = pressures.Avg ?? 0,
|
||||
PressureMax = pressures.Max ?? 0,
|
||||
RotorTorqueMin = rotorTorques.Min ?? 0,
|
||||
RotorTorqueAvg = rotorTorques.Avg ?? 0,
|
||||
RotorTorqueMax = rotorTorques.Max ?? 0,
|
||||
RotorSpeedMin = rotorSpeeds.Min ?? 0,
|
||||
RotorSpeedAvg = rotorSpeeds.Avg ?? 0,
|
||||
RotorSpeedMax = rotorSpeeds.Max ?? 0,
|
||||
FlowMin = flows.Min ?? 0,
|
||||
FlowAvg = flows.Avg ?? 0,
|
||||
FlowMax = flows.Max ?? 0,
|
||||
};
|
||||
return drillParamsDto;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<DrillParamsDto>> GetAllAsync(int idWell,
|
||||
@ -126,11 +73,11 @@ namespace AsbCloudInfrastructure.Services
|
||||
where p.IdWell == idWell
|
||||
orderby p.Id
|
||||
select p)
|
||||
.AsNoTracking()
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dto = entities.Select(entity =>
|
||||
entity.Adapt<DrillParamsDto>());
|
||||
var dto = entities.Adapt<DrillParamsDto>();
|
||||
return dto;
|
||||
}
|
||||
|
||||
@ -144,10 +91,11 @@ namespace AsbCloudInfrastructure.Services
|
||||
p.IdWell == c.IdWellSrc &&
|
||||
p.IdWellSectionType == c.IdWellSectionType
|
||||
select p)
|
||||
.AsNoTracking()
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var compositeDrillParamsDtos = compositeWellDrillParams.Select(c => c.Adapt<DrillParamsDto>());
|
||||
var compositeDrillParamsDtos = compositeWellDrillParams.Adapt<DrillParamsDto>();
|
||||
|
||||
return compositeDrillParamsDtos;
|
||||
}
|
||||
@ -157,7 +105,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
dto.IdWell = idWell;
|
||||
|
||||
var result = await base.InsertAsync(dto, token);
|
||||
var result = await base.InsertAsync(dto, token).ConfigureAwait(false);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -168,28 +116,18 @@ namespace AsbCloudInfrastructure.Services
|
||||
foreach (var dto in dtos)
|
||||
dto.IdWell = idWell;
|
||||
|
||||
var result = await base.InsertRangeAsync(dtos, token);
|
||||
var result = await base.InsertRangeAsync(dtos, token).ConfigureAwait(false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task<int> UpdateAsync(int idWell, DrillParamsDto dto,
|
||||
public async Task<int> UpdateAsync(int idWell, int dtoId, DrillParamsDto dto,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
dto.IdWell = idWell;
|
||||
|
||||
var result = await base.UpdateAsync(dto.Id, dto, token);
|
||||
var result = await base.UpdateAsync(dtoId, dto, token).ConfigureAwait(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
private IQueryable<IGrouping<int, TelemetryDataSaub>> GetTelemetryGroupQuery(int idTelemetry,
|
||||
double startDepth, double endDepth)
|
||||
{
|
||||
return from telemetry in db.TelemetryDataSaub
|
||||
where telemetry.IdTelemetry == idTelemetry &&
|
||||
telemetry.WellDepth >= startDepth &&
|
||||
telemetry.WellDepth <= endDepth
|
||||
group telemetry by telemetry.IdTelemetry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,12 +122,13 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// Изменяет значения выбранного режима бурения
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="dtoId"> id dto для изменения </param>
|
||||
/// <param name="drillParamsDto"> Параметры режимов бурений для секции</param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> EditAsync(int idWell,
|
||||
public async Task<IActionResult> UpdateAsync(int idWell, int dtoId,
|
||||
DrillParamsDto drillParamsDto, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
@ -136,7 +137,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await drillParamsService.UpdateAsync(idWell,
|
||||
var result = await drillParamsService.UpdateAsync(idWell, dtoId,
|
||||
drillParamsDto, token);
|
||||
|
||||
return Ok(result);
|
||||
|
Loading…
Reference in New Issue
Block a user