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,
|
Task<IEnumerable<DepositDto>> GetDepositsAsync(int idCompany,
|
||||||
CancellationToken token);
|
CancellationToken token);
|
||||||
|
Task<IEnumerable<DepositDto>> GetDepositsDrillParamsAsync(int idCompany,
|
||||||
|
CancellationToken token = default);
|
||||||
Task<IEnumerable<ClusterDto>> GetClustersAsync(int idCompany,
|
Task<IEnumerable<ClusterDto>> GetClustersAsync(int idCompany,
|
||||||
int depositId, CancellationToken token);
|
int depositId, CancellationToken token);
|
||||||
Task<IEnumerable<ClusterDto>> GetClustersAsync(int idCompany,
|
Task<IEnumerable<ClusterDto>> GetClustersAsync(int idCompany,
|
||||||
|
@ -31,36 +31,30 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
select well).ToListAsync(token)
|
select well).ToListAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var gDepositEntities = wellEntities
|
var gDepositEntities = groupWells(wellEntities);
|
||||||
.GroupBy(w => w.Cluster)
|
|
||||||
.GroupBy(c => c.Key.Deposit);
|
|
||||||
|
|
||||||
var dtos = gDepositEntities.Select(gDeposit => new DepositDto
|
var dtos = CreateDepositDto(gDepositEntities);
|
||||||
|
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<DepositDto>> GetDepositsDrillParamsAsync(int idCompany,
|
||||||
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
Id = gDeposit.Key.Id,
|
var wellEntities = await (from well in db.Wells
|
||||||
Caption = gDeposit.Key.Caption,
|
.Include(w => w.RelationCompaniesWells)
|
||||||
Latitude = gDeposit.Key.Latitude,
|
.Include(w => w.WellType)
|
||||||
Longitude = gDeposit.Key.Longitude,
|
.Include(w => w.Cluster)
|
||||||
Description = "",
|
.ThenInclude(c => c.Deposit)
|
||||||
Clusters = gDeposit.Select(gCluster => new ClusterDto
|
from p in db.DrillParams
|
||||||
{
|
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany) &&
|
||||||
Id = gCluster.Key.Id,
|
well.Id == p.IdWell
|
||||||
Caption = gCluster.Key.Caption,
|
select well).ToListAsync(token)
|
||||||
Latitude = gCluster.Key.Latitude,
|
.ConfigureAwait(false);
|
||||||
Longitude = gCluster.Key.Longitude,
|
|
||||||
Description = "",
|
var gDepositEntities = groupWells(wellEntities);
|
||||||
Wells = gCluster.Select(well => new WellDto
|
|
||||||
{
|
var dtos = CreateDepositDto(gDepositEntities);
|
||||||
Id = well.Id,
|
|
||||||
Caption = well.Caption,
|
|
||||||
Latitude = well.Latitude,
|
|
||||||
Longitude = well.Longitude,
|
|
||||||
WellType = well.WellType?.Caption,
|
|
||||||
Cluster = gCluster.Key.Caption,
|
|
||||||
Deposit = gDeposit.Key.Caption,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
@ -117,5 +111,42 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
return dtos;
|
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);
|
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>
|
||||||
/// Получает список доступных пользователю кустов месторождения
|
/// Получает список доступных пользователю кустов месторождения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user