forked from ddrilling/AsbCloudServer
Added method for returning wells with drill params only (in DepositController)
This commit is contained in:
parent
03813b9403
commit
8e447a040f
@ -9,6 +9,8 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
Task<IEnumerable<DepositDto>> GetDepositsAsync(int idCompany,
|
||||
CancellationToken token);
|
||||
Task<IEnumerable<DepositDto>> GetDepositsDrillParamsAsync(int idCompany,
|
||||
CancellationToken token = default);
|
||||
Task<IEnumerable<ClusterDto>> GetClustersAsync(int idCompany,
|
||||
int depositId, CancellationToken token);
|
||||
Task<IEnumerable<ClusterDto>> GetClustersAsync(int idCompany,
|
||||
|
@ -31,36 +31,30 @@ namespace AsbCloudInfrastructure.Services
|
||||
select well).ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var gDepositEntities = wellEntities
|
||||
.GroupBy(w => w.Cluster)
|
||||
.GroupBy(c => c.Key.Deposit);
|
||||
var gDepositEntities = groupWells(wellEntities);
|
||||
|
||||
var dtos = gDepositEntities.Select(gDeposit => new DepositDto
|
||||
{
|
||||
Id = gDeposit.Key.Id,
|
||||
Caption = gDeposit.Key.Caption,
|
||||
Latitude = gDeposit.Key.Latitude,
|
||||
Longitude = gDeposit.Key.Longitude,
|
||||
Description = "",
|
||||
Clusters = gDeposit.Select(gCluster => new ClusterDto
|
||||
{
|
||||
Id = gCluster.Key.Id,
|
||||
Caption = gCluster.Key.Caption,
|
||||
Latitude = gCluster.Key.Latitude,
|
||||
Longitude = gCluster.Key.Longitude,
|
||||
Description = "",
|
||||
Wells = gCluster.Select(well => new WellDto
|
||||
{
|
||||
Id = well.Id,
|
||||
Caption = well.Caption,
|
||||
Latitude = well.Latitude,
|
||||
Longitude = well.Longitude,
|
||||
WellType = well.WellType?.Caption,
|
||||
Cluster = gCluster.Key.Caption,
|
||||
Deposit = gDeposit.Key.Caption,
|
||||
}),
|
||||
}),
|
||||
});
|
||||
var dtos = CreateDepositDto(gDepositEntities);
|
||||
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<DepositDto>> GetDepositsDrillParamsAsync(int idCompany,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var wellEntities = await (from well in db.Wells
|
||||
.Include(w => w.RelationCompaniesWells)
|
||||
.Include(w => w.WellType)
|
||||
.Include(w => w.Cluster)
|
||||
.ThenInclude(c => c.Deposit)
|
||||
from p in db.DrillParams
|
||||
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany) &&
|
||||
well.Id == p.IdWell
|
||||
select well).ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var gDepositEntities = groupWells(wellEntities);
|
||||
|
||||
var dtos = CreateDepositDto(gDepositEntities);
|
||||
|
||||
return dtos;
|
||||
}
|
||||
@ -117,5 +111,42 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
return dtos;
|
||||
}
|
||||
|
||||
private IEnumerable<IGrouping<Deposit, IGrouping<Cluster, Well>>> groupWells(IEnumerable<Well> wellEntities)
|
||||
{
|
||||
return wellEntities
|
||||
.GroupBy(w => w.Cluster)
|
||||
.GroupBy(c => c.Key.Deposit);
|
||||
}
|
||||
|
||||
private IEnumerable<DepositDto> CreateDepositDto(IEnumerable<IGrouping<Deposit,IGrouping<Cluster, Well>>>gDepositEntities)
|
||||
{
|
||||
return gDepositEntities.Select(gDeposit => new DepositDto
|
||||
{
|
||||
Id = gDeposit.Key.Id,
|
||||
Caption = gDeposit.Key.Caption,
|
||||
Latitude = gDeposit.Key.Latitude,
|
||||
Longitude = gDeposit.Key.Longitude,
|
||||
Description = "",
|
||||
Clusters = gDeposit.Select(gCluster => new ClusterDto
|
||||
{
|
||||
Id = gCluster.Key.Id,
|
||||
Caption = gCluster.Key.Caption,
|
||||
Latitude = gCluster.Key.Latitude,
|
||||
Longitude = gCluster.Key.Longitude,
|
||||
Description = "",
|
||||
Wells = gCluster.Select(well => new WellDto
|
||||
{
|
||||
Id = well.Id,
|
||||
Caption = well.Caption,
|
||||
Latitude = well.Latitude,
|
||||
Longitude = well.Longitude,
|
||||
WellType = well.WellType?.Caption,
|
||||
Cluster = gCluster.Key.Caption,
|
||||
Deposit = gDeposit.Key.Caption,
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,25 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получает список доступных пользователю месторождений (только скважины с параметрами бурения)
|
||||
/// </summary>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("drillParamsWells")]
|
||||
[ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetDepositsDrillParamsAsync(CancellationToken token = default)
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
var result = await clusterService.GetDepositsDrillParamsAsync((int)idCompany,
|
||||
token).ConfigureAwait(false);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получает список доступных пользователю кустов месторождения
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user