CS2-70: Added wells with no operations into cluster info

This commit is contained in:
KharchenkoVV 2021-09-02 11:42:05 +05:00
parent 95733371a2
commit 81e765581c

View File

@ -82,18 +82,17 @@ namespace AsbCloudInfrastructure.Services
public async Task<StatClusterDto> GetStatClusterAsync(int idCluster, CancellationToken token = default)
{
var operations = await db.WellOperations
.Where(o => o.Well.IdCluster == idCluster)
.OrderBy(o => o.StartDate)
var wells = await db.Wells
.Include(w => w.WellOperations)
.Where(o => o.IdCluster == idCluster)
.AsNoTracking()
.ToListAsync(token);
if (!operations.Any())
return null;
var operations = wells.SelectMany(w => w.WellOperations).OrderBy(o => o.StartDate);
var cluster = await cacheCluster.FirstOrDefaultAsync(c => c.Id == idCluster, token);
var wellsIds = operations.Select(o => o.IdWell).Distinct();
var wellsIds = wells.Select(o => o.Id).Distinct();
var statsWells = new List<StatWellDto>(wellsIds.Count());
@ -137,6 +136,13 @@ namespace AsbCloudInfrastructure.Services
var well = await cacheWell.FirstOrDefaultAsync(w => w.Id == idWell, token);
var wellType = await cacheWellType.FirstOrDefaultAsync(t => t.Id == well.IdWellType, token);
if (!wellOperations.Any())
return new StatWellDto()
{
Caption = well.Caption,
WellType = wellType.Caption
};
var statWellDto = new StatWellDto
{
Id = idWell,