forked from ddrilling/AsbCloudServer
CS2-96: Added DrillParams methods to get composite well drill params
This commit is contained in:
parent
50c3cca8b8
commit
70ee22bccf
@ -12,5 +12,17 @@ namespace AsbCloudApp.Services
|
||||
|
||||
Task<IEnumerable<DrillParamsDto>> GetAllAsync(int idWell,
|
||||
CancellationToken token = default);
|
||||
|
||||
Task<IEnumerable<DrillParamsDto>> GetCompositeAllAsync(int idWell,
|
||||
CancellationToken token = default);
|
||||
|
||||
Task<int> InsertAsync(int idWell, DrillParamsDto dto,
|
||||
CancellationToken token = default);
|
||||
|
||||
Task<int> InsertRangeAsync(int idWell, IEnumerable<DrillParamsDto> dtos,
|
||||
CancellationToken token = default);
|
||||
|
||||
new Task<int> UpdateAsync(int idWell, DrillParamsDto dto,
|
||||
CancellationToken token = default);
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.Min)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
@ -51,6 +52,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.Min)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
@ -63,6 +65,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.Min)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
@ -75,6 +78,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.Min)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
@ -87,6 +91,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
})
|
||||
.AsNoTracking()
|
||||
.DefaultIfEmpty()
|
||||
.OrderBy(t => t.Min)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
@ -124,9 +129,58 @@ namespace AsbCloudInfrastructure.Services
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dto = entities.Select(entity => entity.Adapt<DrillParamsDto>());
|
||||
var dto = entities.Select(entity =>
|
||||
entity.Adapt<DrillParamsDto>());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<DrillParamsDto>> GetCompositeAllAsync(int idWell,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var compositeWellDrillParams =
|
||||
await (from p in db.DrillParams
|
||||
from c in db.WellComposites
|
||||
where c.IdWell == idWell &&
|
||||
p.IdWell == c.IdWellSrc &&
|
||||
p.IdWellSectionType == c.IdWellSectionType
|
||||
select p)
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var compositeDrillParamsDtos = compositeWellDrillParams.Select(c => c.Adapt<DrillParamsDto>());
|
||||
|
||||
return compositeDrillParamsDtos;
|
||||
}
|
||||
|
||||
public async Task<int> InsertAsync(int idWell, DrillParamsDto dto,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
dto.IdWell = idWell;
|
||||
|
||||
var result = await base.InsertAsync(dto, token);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<int> InsertRangeAsync(int idWell, IEnumerable<DrillParamsDto> dtos,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
foreach (var dto in dtos)
|
||||
dto.IdWell = idWell;
|
||||
|
||||
var result = await base.InsertRangeAsync(dtos, token);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task<int> UpdateAsync(int idWell, DrillParamsDto dto,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
dto.IdWell = idWell;
|
||||
|
||||
var result = await base.UpdateAsync(dto.Id, dto, token);
|
||||
return result;
|
||||
}
|
||||
|
||||
private IQueryable<IGrouping<int, TelemetryDataSaub>> GetTelemetryGroupQuery(int idTelemetry,
|
||||
double startDepth, double endDepth)
|
||||
|
@ -32,7 +32,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <param name="endDepth"> Конечная глубина </param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns> Значения по умолчанию для режимов бурения </returns>
|
||||
[HttpGet("/autoParams")]
|
||||
[HttpGet("autoParams")]
|
||||
[ProducesResponseType(typeof(DrillParamsDto), (int) System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetDefaultAsync(int idWell,
|
||||
double startDepth, double endDepth, CancellationToken token = default)
|
||||
@ -80,7 +80,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> SaveAsync(int idWell,
|
||||
public async Task<IActionResult> InsertAsync(int idWell,
|
||||
DrillParamsDto drillParamsDto, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
@ -89,11 +89,35 @@ namespace AsbCloudWebApi.Controllers
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await drillParamsService.InsertAsync(drillParamsDto, token);
|
||||
var result = await drillParamsService.InsertAsync(idWell, drillParamsDto, token);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавляет массив объектов режимов бурений
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="drillParams"> Массив объектов параметров режима бурений для секции</param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("range")]
|
||||
[ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> InsertRangeAsync(int idWell,
|
||||
IEnumerable<DrillParamsDto> drillParams, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await drillParamsService.InsertRangeAsync(idWell, drillParams,
|
||||
token);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Изменяет значения выбранного режима бурения
|
||||
/// </summary>
|
||||
@ -141,5 +165,26 @@ namespace AsbCloudWebApi.Controllers
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает значения для режимов бурения на композитной скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns> Список параметров для режимов бурения на композитной скважине </returns>
|
||||
[HttpGet("composite")]
|
||||
[ProducesResponseType(typeof(IEnumerable<DrillParamsDto>), (int) System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetCompositeAllAsync(int idWell, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var dto = await drillParamsService.GetCompositeAllAsync(idWell, token);
|
||||
|
||||
return Ok(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user