forked from ddrilling/AsbCloudServer
Merge branch 'dev' into fix/#33685682
This commit is contained in:
commit
27edec6091
@ -19,15 +19,6 @@ namespace AsbCloudApp.Repositories
|
|||||||
Task<IEnumerable<DepositDto>> GetAsync(int idCompany,
|
Task<IEnumerable<DepositDto>> GetAsync(int idCompany,
|
||||||
CancellationToken token);
|
CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Список месторождений/кустов/скважин у которых заполненны параметры бурения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="idCompany"></param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<DepositDto>> GetAllWithDrillParamsAsync(int idCompany,
|
|
||||||
CancellationToken token = default);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Список кустов месторождения доступных компании
|
/// Список кустов месторождения доступных компании
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -10,11 +10,10 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Repository
|
namespace AsbCloudInfrastructure.Repository;
|
||||||
{
|
|
||||||
|
|
||||||
public class DepositRepository : IDepositRepository
|
public class DepositRepository : IDepositRepository
|
||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
private readonly ITelemetryService telemetryService;
|
private readonly ITelemetryService telemetryService;
|
||||||
|
|
||||||
@ -28,38 +27,19 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
public async Task<IEnumerable<DepositDto>> GetAsync(int idCompany,
|
public async Task<IEnumerable<DepositDto>> GetAsync(int idCompany,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var wellEntities = await (from well in db.Wells
|
var wellsQuery = db.Set<Well>()
|
||||||
.Include(w => w.RelationCompaniesWells)
|
.Include(w => w.RelationCompaniesWells)
|
||||||
.Include(w => w.WellType)
|
.Include(w => w.WellType)
|
||||||
.Include(w => w.Cluster)
|
.Include(w => w.Cluster)
|
||||||
.ThenInclude(c => c.Deposit)
|
.ThenInclude(c => c.Deposit)
|
||||||
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany)
|
.Where(well => well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany));
|
||||||
select well).ToListAsync(token)
|
|
||||||
.ConfigureAwait(false);
|
var wellEntities = await wellsQuery.ToArrayAsync(token);
|
||||||
|
|
||||||
var gDepositEntities = GroupWells(wellEntities);
|
var gDepositEntities = GroupWells(wellEntities);
|
||||||
|
|
||||||
var dtos = CreateDepositDto(gDepositEntities);
|
var dtos = CreateDepositDto(gDepositEntities)
|
||||||
|
.ToArray();
|
||||||
return dtos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public async Task<IEnumerable<DepositDto>> GetAllWithDrillParamsAsync(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)
|
|
||||||
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany)
|
|
||||||
select well).ToListAsync(token)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
var gDepositEntities = GroupWells(wellEntities);
|
|
||||||
|
|
||||||
var dtos = CreateDepositDto(gDepositEntities);
|
|
||||||
|
|
||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
@ -87,7 +67,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
.GroupBy(c => c.Key.Deposit);
|
.GroupBy(c => c.Key.Deposit);
|
||||||
|
|
||||||
private IQueryable<Well> GetWellsForCompany(int idCompany)
|
private IQueryable<Well> GetWellsForCompany(int idCompany)
|
||||||
=> db.Wells
|
=> db.Set<Well>()
|
||||||
.Include(w => w.RelationCompaniesWells)
|
.Include(w => w.RelationCompaniesWells)
|
||||||
.ThenInclude(r => r.Company)
|
.ThenInclude(r => r.Company)
|
||||||
.Include(w => w.Cluster)
|
.Include(w => w.Cluster)
|
||||||
@ -126,6 +106,4 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
});
|
});
|
||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,26 +43,6 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получает список доступных пользователю месторождений (только скважины с параметрами бурения)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="token"> Токен отмены задачи </param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("drillParamsWells")]
|
|
||||||
[Permission]
|
|
||||||
[ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
||||||
public async Task<IActionResult> GetDepositsDrillParamsAsync(CancellationToken token)
|
|
||||||
{
|
|
||||||
int? idCompany = User.GetCompanyId();
|
|
||||||
|
|
||||||
if (idCompany is null)
|
|
||||||
return Forbid();
|
|
||||||
|
|
||||||
var result = await depositService.GetAllWithDrillParamsAsync((int)idCompany,
|
|
||||||
token).ConfigureAwait(false);
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получает список доступных пользователю кустов месторождения
|
/// Получает список доступных пользователю кустов месторождения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -44,6 +44,9 @@ namespace AsbCloudWebApi.Middlewares
|
|||||||
}
|
}
|
||||||
catch (Exception ex) // TODO: find explicit exception. Use Trace. Add body size to message.
|
catch (Exception ex) // TODO: find explicit exception. Use Trace. Add body size to message.
|
||||||
{
|
{
|
||||||
|
if (context.Response.HasStarted)
|
||||||
|
throw;
|
||||||
|
|
||||||
context.Response.Clear();
|
context.Response.Clear();
|
||||||
context.Response.StatusCode = 500;
|
context.Response.StatusCode = 500;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user