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