From 1bf746dff28cdf10661951bc9e7727a0cd5ce54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Mon, 13 Sep 2021 12:28:57 +0500 Subject: [PATCH] Fix operations order --- .../Services/WellOperationsStatService.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/AsbCloudInfrastructure/Services/WellOperationsStatService.cs b/AsbCloudInfrastructure/Services/WellOperationsStatService.cs index a6dc0df7..e45294d9 100644 --- a/AsbCloudInfrastructure/Services/WellOperationsStatService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationsStatService.cs @@ -88,7 +88,10 @@ namespace AsbCloudInfrastructure.Services .AsNoTracking() .ToListAsync(token); - var operations = wells.SelectMany(w => w.WellOperations).OrderBy(o => o.StartDate); + var operations = wells + .SelectMany(w => w.WellOperations) + .OrderBy(o => o.StartDate) + .ThenBy(o => o.WellDepth); var cluster = await cacheCluster.FirstOrDefaultAsync(c => c.Id == idCluster, token); @@ -117,6 +120,7 @@ namespace AsbCloudInfrastructure.Services var operations = await db.WellOperations .Where(o => o.IdWell == idWell) .OrderBy(o => o.StartDate) // ускорит дальнейшие сортировки + .ThenBy(o => o.WellDepth) .AsNoTracking() .ToListAsync(token); @@ -348,17 +352,20 @@ namespace AsbCloudInfrastructure.Services .Include(o => o.WellSectionType) .Where(o => o.IdWell == idWell) .OrderBy(o => o.StartDate) + .ThenBy(o => o.WellDepth) .AsNoTracking() .ToListAsync(token) .ConfigureAwait(false); var wellOperationsPlan = wellOperations .Where(o => o.IdType == idOperationTypePlan) - .OrderBy(o => o.StartDate); + .OrderBy(o => o.StartDate) + .ThenBy(o => o.WellDepth); var wellOperationsFact = wellOperations .Where(o => o.IdType == idOperationTypeFact) - .OrderBy(o => o.StartDate); + .OrderBy(o => o.StartDate) + .ThenBy(o => o.WellDepth); if (!wellOperationsPlan.Any()) return null; @@ -481,7 +488,9 @@ namespace AsbCloudInfrastructure.Services if (operations.Any()) { - var sortedOperations = operations.OrderBy(o => o.StartDate); + var sortedOperations = operations + .OrderBy(o => o.StartDate) + .ThenBy(o => o.WellDepth); var count = operations.Count(); ops = new List(count); var item = operations.ElementAt(0);