CS2-65: Fixed well section calculation

This commit is contained in:
KharchenkoVV 2021-08-23 14:52:34 +05:00
parent 791f72cbdb
commit 31fd4bda1a
2 changed files with 149 additions and 223 deletions

View File

@ -399,47 +399,47 @@ namespace AsbCloudDb.Model
DurationHours = 1.2}, DurationHours = 1.2},
new WellOperation{ Id = 2, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 2, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1001, IdType = 0, IdCategory = 1001, IdType = 0,
WellDepth = 300, StartDate = DateTime.Now.AddHours(2.5), WellDepth = 210, StartDate = DateTime.Now.AddHours(2),
DurationHours = 1.5}, DurationHours = 1.2},
new WellOperation{ Id = 3, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 3, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1001, IdType = 1, IdCategory = 1001, IdType = 1,
WellDepth = 210, StartDate = DateTime.Now.AddHours(1.5), WellDepth = 200, StartDate = DateTime.Now.AddHours(1.5),
DurationHours = 1}, DurationHours = 1},
new WellOperation{ Id = 4, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 4, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1001, IdType = 1, IdCategory = 1001, IdType = 1,
WellDepth = 310, StartDate = DateTime.Now.AddHours(2), WellDepth = 220, StartDate = DateTime.Now.AddHours(2),
DurationHours = 1.5}, DurationHours = 1.5},
new WellOperation{ Id = 5, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 5, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1001, IdType = 0, IdCategory = 1001, IdType = 0,
WellDepth = 200, StartDate = DateTime.Now.AddHours(1), WellDepth = 300, StartDate = DateTime.Now.AddHours(1),
DurationHours = 1.2}, DurationHours = 1.2},
new WellOperation{ Id = 6, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 6, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1001, IdType = 0, IdCategory = 1001, IdType = 0,
WellDepth = 300, StartDate = DateTime.Now.AddHours(2.5), WellDepth = 310, StartDate = DateTime.Now.AddHours(2),
DurationHours = 1.5}, DurationHours = 1.2},
new WellOperation{ Id = 7, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 7, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1001, IdType = 1, IdCategory = 1001, IdType = 1,
WellDepth = 210, StartDate = DateTime.Now.AddHours(1.5), WellDepth = 300, StartDate = DateTime.Now.AddHours(1.5),
DurationHours = 1}, DurationHours = 1},
new WellOperation{ Id = 8, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 8, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1001, IdType = 1, IdCategory = 1001, IdType = 1,
WellDepth = 310, StartDate = DateTime.Now.AddHours(2), WellDepth = 320, StartDate = DateTime.Now.AddHours(2),
DurationHours = 1.5}, DurationHours = 1.5},
new WellOperation{ Id = 9, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 9, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1001, IdType = 0, IdCategory = 1001, IdType = 0,
WellDepth = 500, StartDate = DateTime.Now.AddHours(1), WellDepth = 400, StartDate = DateTime.Now.AddHours(1),
DurationHours = 1.2}, DurationHours = 1.2},
new WellOperation{ Id = 10, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 10, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1001, IdType = 0, IdCategory = 1001, IdType = 0,
WellDepth = 510, StartDate = DateTime.Now.AddHours(2), WellDepth = 420, StartDate = DateTime.Now.AddHours(2),
DurationHours = 1.2}, DurationHours = 1.2},
new WellOperation{ Id = 11, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 11, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1001, IdType = 1, IdCategory = 1001, IdType = 1,
WellDepth = 510, StartDate = DateTime.Now.AddHours(1.5), WellDepth = 410, StartDate = DateTime.Now.AddHours(1.5),
DurationHours = 1}, DurationHours = 1},
new WellOperation{ Id = 12, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 12, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1001, IdType = 1, IdCategory = 1001, IdType = 1,
WellDepth = 520, StartDate = DateTime.Now.AddHours(2), WellDepth = 420, StartDate = DateTime.Now.AddHours(2),
DurationHours = 1.5}, DurationHours = 1.5},
@ -457,144 +457,140 @@ namespace AsbCloudDb.Model
DurationHours = 15.2}, DurationHours = 15.2},
new WellOperation{ Id = 16, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 16, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1046, IdType = 1, IdCategory = 1046, IdType = 1,
WellDepth = 230, StartDate = DateTime.Now.AddHours(3.1), WellDepth = 220, StartDate = DateTime.Now.AddHours(3.1),
DurationHours = 17.8}, DurationHours = 17.8},
new WellOperation{ Id = 17, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 17, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1046, IdType = 0, IdCategory = 1046, IdType = 0,
WellDepth = 200, StartDate = DateTime.Now.AddHours(2.5), WellDepth = 300, StartDate = DateTime.Now.AddHours(2.5),
DurationHours = 15.5}, DurationHours = 16.2},
new WellOperation{ Id = 18, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 18, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1046, IdType = 0, IdCategory = 1046, IdType = 0,
WellDepth = 210, StartDate = DateTime.Now.AddHours(3), WellDepth = 320, StartDate = DateTime.Now.AddHours(3.5),
DurationHours = 17.2}, DurationHours = 17.2},
new WellOperation{ Id = 19, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 19, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1046, IdType = 1, IdCategory = 1046, IdType = 1,
WellDepth = 220, StartDate = DateTime.Now.AddHours(2.7), WellDepth = 315, StartDate = DateTime.Now.AddHours(2.7),
DurationHours = 15.2}, DurationHours = 15.2},
new WellOperation{ Id = 20, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 20, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1046, IdType = 1, IdCategory = 1046, IdType = 1,
WellDepth = 230, StartDate = DateTime.Now.AddHours(3.1), WellDepth = 320, StartDate = DateTime.Now.AddHours(3),
DurationHours = 17.8}, DurationHours = 18.2},
new WellOperation{ Id = 21, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 21, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1046, IdType = 0, IdCategory = 1046, IdType = 0,
WellDepth = 700, StartDate = DateTime.Now.AddHours(2.5), WellDepth = 410, StartDate = DateTime.Now.AddHours(2.5),
DurationHours = 16.2}, DurationHours = 16.2},
new WellOperation{ Id = 22, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 22, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1046, IdType = 0, IdCategory = 1046, IdType = 0,
WellDepth = 720, StartDate = DateTime.Now.AddHours(3.5), WellDepth = 420, StartDate = DateTime.Now.AddHours(3.5),
DurationHours = 17.2}, DurationHours = 17.2},
new WellOperation{ Id = 23, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 23, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1046, IdType = 1, IdCategory = 1046, IdType = 1,
WellDepth = 715, StartDate = DateTime.Now.AddHours(2.7), WellDepth = 415, StartDate = DateTime.Now.AddHours(2.7),
DurationHours = 15.2}, DurationHours = 15.2},
new WellOperation{ Id = 24, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 24, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1046, IdType = 1, IdCategory = 1046, IdType = 1,
WellDepth = 720, StartDate = DateTime.Now.AddHours(3), WellDepth = 420, StartDate = DateTime.Now.AddHours(3),
DurationHours = 18.2}, DurationHours = 18.2},
new WellOperation{ Id = 25, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 25, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1047, IdType = 0, IdCategory = 1047, IdType = 0,
WellDepth = 600, StartDate = DateTime.Now.AddHours(4), WellDepth = 200, StartDate = DateTime.Now.AddHours(5.25),
DurationHours = 5}, DurationHours = 2.1},
new WellOperation{ Id = 26, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 26, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1047, IdType = 0, IdCategory = 1047, IdType = 0,
WellDepth = 650, StartDate = DateTime.Now.AddHours(4.5), WellDepth = 220, StartDate = DateTime.Now.AddHours(7.5),
DurationHours = 5.5}, DurationHours = 2},
new WellOperation{ Id = 27, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 27, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1047, IdType = 1, IdCategory = 1047, IdType = 1,
WellDepth = 700, StartDate = DateTime.Now.AddHours(5.5), WellDepth = 200, StartDate = DateTime.Now.AddHours(5.15),
DurationHours = 8}, DurationHours = 2.75},
new WellOperation{ Id = 28, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 28, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1047, IdType = 1, IdCategory = 1047, IdType = 1,
WellDepth = 710, StartDate = DateTime.Now.AddHours(5.7), WellDepth = 250, StartDate = DateTime.Now.AddHours(6.5),
DurationHours = 7.2}, DurationHours = 3.5},
new WellOperation{ Id = 29, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 29, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1047, IdType = 0, IdCategory = 1047, IdType = 0,
WellDepth = 600, StartDate = DateTime.Now.AddHours(4), WellDepth = 300, StartDate = DateTime.Now.AddHours(5.25),
DurationHours = 5}, DurationHours = 2.1},
new WellOperation{ Id = 30, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 30, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1047, IdType = 0, IdCategory = 1047, IdType = 0,
WellDepth = 650, StartDate = DateTime.Now.AddHours(4.5), WellDepth = 310, StartDate = DateTime.Now.AddHours(7.5),
DurationHours = 5.5}, DurationHours = 2},
new WellOperation{ Id = 31, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 31, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1047, IdType = 1, IdCategory = 1047, IdType = 1,
WellDepth = 700, StartDate = DateTime.Now.AddHours(5.5), WellDepth = 300, StartDate = DateTime.Now.AddHours(5.15),
DurationHours = 8}, DurationHours = 2.75},
new WellOperation{ Id = 32, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 32, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1047, IdType = 1, IdCategory = 1047, IdType = 1,
WellDepth = 710, StartDate = DateTime.Now.AddHours(5.7), WellDepth = 330, StartDate = DateTime.Now.AddHours(6.5),
DurationHours = 7.2}, DurationHours = 3.5},
new WellOperation{ Id = 33, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 33, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1047, IdType = 0, IdCategory = 1047, IdType = 0,
WellDepth = 1000, StartDate = DateTime.Now.AddHours(5.25), WellDepth = 400, StartDate = DateTime.Now.AddHours(5.25),
DurationHours = 2.1}, DurationHours = 2.1},
new WellOperation{ Id = 34, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 34, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1047, IdType = 0, IdCategory = 1047, IdType = 0,
WellDepth = 1100, StartDate = DateTime.Now.AddHours(7.5), WellDepth = 410, StartDate = DateTime.Now.AddHours(7.5),
DurationHours = 2}, DurationHours = 2},
new WellOperation{ Id = 35, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 35, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1047, IdType = 1, IdCategory = 1047, IdType = 1,
WellDepth = 1000, StartDate = DateTime.Now.AddHours(5.15), WellDepth = 400, StartDate = DateTime.Now.AddHours(5.15),
DurationHours = 2.75}, DurationHours = 2.75},
new WellOperation{ Id = 36, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 36, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1047, IdType = 1, IdCategory = 1047, IdType = 1,
WellDepth = 1250, StartDate = DateTime.Now.AddHours(6.5), WellDepth = 420, StartDate = DateTime.Now.AddHours(6.5),
DurationHours = 3.5}, DurationHours = 3.5},
new WellOperation{ Id = 37, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 41, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1048, IdType = 0, IdCategory = 1048, IdType = 0,
WellDepth = 600, StartDate = DateTime.Now.AddHours(4), WellDepth = 210, StartDate = DateTime.Now.AddHours(5),
DurationHours = 5}, DurationHours = 2},
new WellOperation{ Id = 38, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 42, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1048, IdType = 0, IdCategory = 1048, IdType = 0,
WellDepth = 650, StartDate = DateTime.Now.AddHours(4.2), WellDepth = 250, StartDate = DateTime.Now.AddHours(7.5),
DurationHours = 5.5}, DurationHours = 2},
new WellOperation{ Id = 39, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 43, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1048, IdType = 1, IdCategory = 1048, IdType = 1,
WellDepth = 700, StartDate = DateTime.Now.AddHours(5.5), WellDepth = 210, StartDate = DateTime.Now.AddHours(5),
DurationHours = 7}, DurationHours = 2.5},
new WellOperation{ Id = 40, IdWell = 1, IdWellSectionType = 2, new WellOperation{ Id = 44, IdWell = 1, IdWellSectionType = 2,
IdCategory = 1048, IdType = 1, IdCategory = 1048, IdType = 1,
WellDepth = 710, StartDate = DateTime.Now.AddHours(5.7), WellDepth = 220, StartDate = DateTime.Now.AddHours(6.5),
DurationHours = 7.5}, DurationHours = 2.5},
new WellOperation{ Id = 41, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 45, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1048, IdType = 0, IdCategory = 1048, IdType = 0,
WellDepth = 600, StartDate = DateTime.Now.AddHours(4), WellDepth = 310, StartDate = DateTime.Now.AddHours(5),
DurationHours = 5}, DurationHours = 2},
new WellOperation{ Id = 42, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 46, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1048, IdType = 0, IdCategory = 1048, IdType = 0,
WellDepth = 650, StartDate = DateTime.Now.AddHours(4.2), WellDepth = 350, StartDate = DateTime.Now.AddHours(7.5),
DurationHours = 5.5}, DurationHours = 2},
new WellOperation{ Id = 43, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 47, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1048, IdType = 1, IdCategory = 1048, IdType = 1,
WellDepth = 700, StartDate = DateTime.Now.AddHours(5.5), WellDepth = 300, StartDate = DateTime.Now.AddHours(5),
DurationHours = 7}, DurationHours = 2.5},
new WellOperation{ Id = 44, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1048, IdType = 1,
WellDepth = 710, StartDate = DateTime.Now.AddHours(5.7),
DurationHours = 7.5},
new WellOperation{ Id = 48, IdWell = 1, IdWellSectionType = 3, new WellOperation{ Id = 48, IdWell = 1, IdWellSectionType = 3,
IdCategory = 1048, IdType = 0, IdCategory = 1048, IdType = 1,
WellDepth = 910, StartDate = DateTime.Now.AddHours(5), WellDepth = 310, StartDate = DateTime.Now.AddHours(6.5),
DurationHours = 12}, DurationHours = 2.5},
new WellOperation{ Id = 49, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 49, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1048, IdType = 0, IdCategory = 1048, IdType = 0,
WellDepth = 910, StartDate = DateTime.Now.AddHours(5), WellDepth = 410, StartDate = DateTime.Now.AddHours(5),
DurationHours = 2}, DurationHours = 2},
new WellOperation{ Id = 50, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 50, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1048, IdType = 0, IdCategory = 1048, IdType = 0,
WellDepth = 950, StartDate = DateTime.Now.AddHours(7.5), WellDepth = 450, StartDate = DateTime.Now.AddHours(7.5),
DurationHours = 2}, DurationHours = 2},
new WellOperation{ Id = 51, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 51, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1048, IdType = 1, IdCategory = 1048, IdType = 1,
WellDepth = 980, StartDate = DateTime.Now.AddHours(5), WellDepth = 400, StartDate = DateTime.Now.AddHours(5),
DurationHours = 2.5}, DurationHours = 2.5},
new WellOperation{ Id = 52, IdWell = 1, IdWellSectionType = 4, new WellOperation{ Id = 52, IdWell = 1, IdWellSectionType = 4,
IdCategory = 1048, IdType = 1, IdCategory = 1048, IdType = 1,
WellDepth = 1010, StartDate = DateTime.Now.AddHours(6.5), WellDepth = 410, StartDate = DateTime.Now.AddHours(6.5),
DurationHours = 2.5}, DurationHours = 2.5},
}); });

View File

@ -51,19 +51,33 @@ namespace AsbCloudInfrastructure.Services
wellOperationsGroupedBySections.Add(groupedWellOperationsClone.First()); wellOperationsGroupedBySections.Add(groupedWellOperationsClone.First());
var depthsPlanFactList = GetWellDepthPlanFact(wellOperationsGroupedBySections).ToList(); var depthsPlanList = GetWellDepthStats(wellOperationsGroupedBySections, 0).ToList();
var durationsPlanFactList = GetWellDurationPlanFact(wellOperationsGroupedBySections).ToList(); var depthsFactList = GetWellDepthStats(wellOperationsGroupedBySections, 1).ToList();
var mechSpeedsList = GetWellMechSpeedPlanFact(wellOperationsGroupedBySections).ToList(); var durationsPlanList = GetWellDurationStats(wellOperationsGroupedBySections, 0).ToList();
var bhaUpSpeedList = GetWellBhaUpSpeedPlanFact(wellOperationsGroupedBySections).ToList(); var durationsFactList = GetWellDurationStats(wellOperationsGroupedBySections, 1).ToList();
var bhaDownSpeedList = GetWellBhaDownSpeedPlanFact(wellOperationsGroupedBySections).ToList(); var mechSpeedsPlanList = GetWellStats(wellOperationsGroupedBySections, 1001, 0).ToList();
var casingDownList = GetWellCasingDownPlanFact(wellOperationsGroupedBySections).ToList(); var mechSpeedsFactList = GetWellStats(wellOperationsGroupedBySections, 1001, 1).ToList();
var routeSpeeds = GetWellRouteSpeedsPlanFact(wellOperationsGroupedBySections).ToList(); var bhaUpSpeedPlanList = GetWellStats(wellOperationsGroupedBySections, 1046, 0).ToList();
var bhaUpSpeedFactList = GetWellStats(wellOperationsGroupedBySections, 1046, 1).ToList();
var bhaDownSpeedPlanList = GetWellStats(wellOperationsGroupedBySections, 1047, 0).ToList();
var bhaDownSpeedFactList = GetWellStats(wellOperationsGroupedBySections, 1047, 1).ToList();
var casingDownPlanList = GetWellStats(wellOperationsGroupedBySections, 1048, 0).ToList();
var casingDownFactList = GetWellStats(wellOperationsGroupedBySections, 1048, 1).ToList();
var routeSpeedsPlan = GetWellRouteSpeedStats(wellOperationsGroupedBySections, 0).ToList();
var routeSpeedsFact = GetWellRouteSpeedStats(wellOperationsGroupedBySections, 1).ToList();
var dtos = new List<WellSectionDto>(); var dtos = new List<WellSectionDto>();
@ -73,20 +87,20 @@ namespace AsbCloudInfrastructure.Services
{ {
SectionType = wellOperationsGroupedBySections[i] SectionType = wellOperationsGroupedBySections[i]
.FirstOrDefault().WellSectionType.Caption, .FirstOrDefault().WellSectionType.Caption,
WellDepthPlan = depthsPlanFactList[i].DepthPlan, WellDepthPlan = depthsPlanList[i],
WellDepthFact = depthsPlanFactList[i].DepthFact, WellDepthFact = depthsFactList[i],
DurationPlan = durationsPlanFactList[i].DurationPlan, DurationPlan = durationsPlanList[i],
DurationFact = durationsPlanFactList[i].DurationFact, DurationFact = durationsFactList[i],
MechSpeedPlan = mechSpeedsList[i].MechSpeedPlan, MechSpeedPlan = mechSpeedsPlanList[i],
MechSpeedFact = mechSpeedsList[i].MechSpeedFact, MechSpeedFact = mechSpeedsFactList[i],
BhaUpSpeedPlan = bhaUpSpeedList[i].BhaUpSpeedPlan, BhaUpSpeedPlan = bhaUpSpeedPlanList[i],
BhaUpSpeedFact = bhaUpSpeedList[i].BhaUpSpeedFact, BhaUpSpeedFact = bhaUpSpeedFactList[i],
BhaDownSpeedPlan = bhaDownSpeedList[i].BhaDownSpeedPlan, BhaDownSpeedPlan = bhaDownSpeedPlanList[i],
BhaDownSpeedFact = bhaDownSpeedList[i].BhaDownSpeedFact, BhaDownSpeedFact = bhaDownSpeedFactList[i],
CasingDownSpeedPlan = casingDownList[i].CasingDownSpeedPlan, CasingDownSpeedPlan = casingDownPlanList[i],
CasingDownSpeedFact = casingDownList[i].CasingDownSpeedFact, CasingDownSpeedFact = casingDownFactList[i],
RouteSpeedPlan = routeSpeeds[i].RouteSpeedPlan, RouteSpeedPlan = routeSpeedsPlan[i],
RouteSpeedFact = routeSpeeds[i].RouteSpeedFact RouteSpeedFact = routeSpeedsFact[i]
}; };
dtos.Add(dto); dtos.Add(dto);
@ -110,166 +124,82 @@ namespace AsbCloudInfrastructure.Services
return dto; return dto;
} }
private static PaginationContainer<Tdto> PaginateData<Tdto, TEntity>(IEnumerable<IGrouping<int, TEntity>> groupedCollection, private static IEnumerable<double> GetWellDepthStats(
int skip, int take) IEnumerable<IGrouping<int, WellOperation>> groupedOperations, int type)
{ {
if (skip > 0) return groupedOperations.Select(group => group.Where(o => o.IdType == type)
groupedCollection = groupedCollection.Skip(skip).ToList(); .DefaultIfEmpty().Max(w => w?.WellDepth ?? 0.0));
groupedCollection = groupedCollection.Take(take).ToList();
var result = new PaginationContainer<Tdto>
{
Skip = skip,
Take = take,
Count = groupedCollection.Count()
};
return result;
} }
private static IEnumerable<(double DepthPlan, double DepthFact)> GetWellDepthPlanFact( private static IEnumerable<double> GetWellDurationStats(
IEnumerable<IGrouping<int, WellOperation>> groupedOperations) IEnumerable<IGrouping<int, WellOperation>> groupedOperations, int type)
{
return groupedOperations
.Select(group =>
(
DepthPlan: group.Where(o => o.IdType == 0).Max(w => w.WellDepth),
DepthFact: group.Where(o => o.IdType == 1).Max(w => w.WellDepth)
));
}
private static IEnumerable<(double DurationPlan, double DurationFact)> GetWellDurationPlanFact(
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
{ {
var durationsPlanFactsBase = groupedOperations.Select(group => new var durationsPlanFactsBase = groupedOperations.Select(group => new
{ {
DurationMaxPlan = group.Where(o => o.IdType == 0).Select(op => op.StartDate + DurationMax = group.Where(o => o.IdType == type).DefaultIfEmpty()
TimeSpan.FromHours(op.DurationHours)).Max(), .Max(op => op?.StartDate + TimeSpan.FromHours(op?.DurationHours ?? 0)) ?? default,
DurationMinPlan = group.Where(o => o.IdType == 0).Min(i => i.StartDate), DurationMin = group.Where(o => o.IdType == type).DefaultIfEmpty()
.Min(op => op?.StartDate) ?? default
DurationMaxFact = group.Where(o => o.IdType == 1).Select(op => op.StartDate +
TimeSpan.FromHours(op.DurationHours)).Max(),
DurationMinFact = group.Where(o => o.IdType == 1).Min(i => i.StartDate)
}); });
return durationsPlanFactsBase.Select(o => return durationsPlanFactsBase.Select(o =>
( (o.DurationMax - o.DurationMin).TotalHours);
DurationPlan: (o.DurationMaxPlan - o.DurationMinPlan).TotalHours,
DurationFact: (o.DurationMaxFact - o.DurationMinFact).TotalHours
));
} }
private static IEnumerable<(double MechSpeedPlan, double MechSpeedFact)> GetWellMechSpeedPlanFact( private static IEnumerable<double> GetWellStats(
IEnumerable<IGrouping<int, WellOperation>> groupedOperations) IEnumerable<IGrouping<int, WellOperation>> groupedOperations, int idCategory, int type)
{ {
var mechSpeedBase = GetParams(groupedOperations, 1001); var mechSpeedBase = groupedOperations.Select(g =>
(
DepthDifferenceSum: g.Where(o => o.IdType == type && o.IdCategory == idCategory)
.Select((el, i) => i > 0 ? el.WellDepth - g.ElementAt(i - 1).WellDepth : 0).Sum(),
DurationDifferenceSum: g.Where(o => o.IdType == type && o.IdCategory == idCategory)
.Select(el => el.DurationHours).Sum()
));
return CalculateResult(mechSpeedBase); return CalculateResult(mechSpeedBase);
} }
private static IEnumerable<(double BhaDownSpeedPlan, double BhaDownSpeedFact)> GetWellBhaDownSpeedPlanFact( private static IEnumerable<double> GetWellRouteSpeedStats(
IEnumerable<IGrouping<int, WellOperation>> groupedOperations) IEnumerable<IGrouping<int, WellOperation>> groupedOperations, int type)
{ {
var bhaDownSpeedBase = GetParams(groupedOperations, 1046); var bhaRaiseDecreaseCollection = new List<(WellOperation FirstBhaPositionDecrease,
WellOperation LastBhaPositionIncrease)>();
return CalculateResult(bhaDownSpeedBase);
}
private static IEnumerable<(double BhaUpSpeedPlan, double BhaUpSpeedFact)> GetWellBhaUpSpeedPlanFact(
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
{
var bhaUpSpeedBase = GetParams(groupedOperations, 1047);
return CalculateResult(bhaUpSpeedBase);
}
private static IEnumerable<(double CasingDownSpeedPlan, double CasingDownSpeedFact)> GetWellCasingDownPlanFact(
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
{
var casingDownBase = GetParams(groupedOperations, 1048);
return CalculateResult(casingDownBase);
}
private static IEnumerable<(double RouteSpeedPlan, double RouteSpeedFact)> GetWellRouteSpeedsPlanFact(
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
{
var bhaRaiseDecreaseCollection = new List<(WellOperation FirstBhaPositionDecreasePlan,
WellOperation LastBhaPositionIncreasePlan,
WellOperation FirstBhaPositionDecreaseFact,
WellOperation LastBhaPositionIncreaseFact)>();
foreach (var group in groupedOperations) foreach (var group in groupedOperations)
{ {
var firstBhaPositionDecreasePlan = group.Any(o => o.IdCategory == 1046 && o.IdType == 0) var firstBhaPositionDecrease = group.Any(o => o.IdCategory == 1046 && o.IdType == type)
? group.First(o => o.IdCategory == 1046 && o.IdType == 0) ? group.First(o => o.IdCategory == 1046 && o.IdType == type)
: null; : null;
var lastBhaPositionIncreasePlan = group.Any(o => o.IdCategory == 1047 && o.IdType == 0) var lastBhaPositionIncrease = group.Any(o => o.IdCategory == 1047 && o.IdType == type)
? group.Last(o => o.IdCategory == 1047 && o.IdType == 0) ? group.Last(o => o.IdCategory == 1047 && o.IdType == type)
: null; : null;
var firstBhaPositionDecreaseFact = group.Any(o => o.IdCategory == 1046 && o.IdType == 1) bhaRaiseDecreaseCollection.Add((firstBhaPositionDecrease, lastBhaPositionIncrease));
? group.First(o => o.IdCategory == 1046 && o.IdType == 1)
: null;
var lastBhaPositionIncreaseFact = group.Any(o => o.IdCategory == 1047 && o.IdType == 1)
? group.Last(o => o.IdCategory == 1047 && o.IdType == 1)
: null;
bhaRaiseDecreaseCollection.Add((firstBhaPositionDecreasePlan,
lastBhaPositionIncreasePlan, firstBhaPositionDecreaseFact,
lastBhaPositionIncreaseFact));
} }
var routeSpeedsBase = bhaRaiseDecreaseCollection.Select(el => var routeSpeedsBase = bhaRaiseDecreaseCollection.Select(el =>
( (
RouteDepthPlan: (el.LastBhaPositionIncreasePlan?.WellDepth - el.FirstBhaPositionDecreasePlan?.WellDepth) ?? 0, RouteDepth: (el.LastBhaPositionIncrease?.WellDepth - el.FirstBhaPositionDecrease?.WellDepth) ?? 0,
RouteDepthFact: (el.LastBhaPositionIncreaseFact?.WellDepth - el.FirstBhaPositionDecreaseFact?.WellDepth) ?? 0, RouteDuration: (el.LastBhaPositionIncrease?.StartDate +
RouteDurationPlan: (el.LastBhaPositionIncreasePlan?.StartDate + TimeSpan.FromHours(el.LastBhaPositionIncrease?.DurationHours ?? 0) -
TimeSpan.FromHours(el.LastBhaPositionIncreasePlan?.DurationHours ?? 0) - el.FirstBhaPositionDecrease?.StartDate)?.TotalHours ?? 0
el.FirstBhaPositionDecreasePlan?.StartDate)?.TotalHours ?? 0,
RouteDurationFact: (el.LastBhaPositionIncreaseFact?.StartDate +
TimeSpan.FromHours(el.LastBhaPositionIncreaseFact?.DurationHours ?? 0) -
el.FirstBhaPositionDecreaseFact?.StartDate)?.TotalHours ?? 0
)); ));
return CalculateResult(routeSpeedsBase); return CalculateResult(routeSpeedsBase);
} }
private static IEnumerable<(double DepthDifferencePlanSum, private static IEnumerable<double> CalculateResult(IEnumerable<(double,
double DurationDifferencePlanSum, double DepthDifferenceFactSum, double)> rawData)
double DurationDifferenceFactSum)> GetParams(IEnumerable<IGrouping<int, WellOperation>> items,
int IdCategory)
{
return items.Select(g =>
(
DepthDifferencePlanSum: g.Where(o => o.IdType == 0 && o.IdCategory == IdCategory)
.Select((el, i) => i > 0 ? el.WellDepth - g.ElementAt(i - 1).WellDepth : 0).Sum(),
DurationDifferencePlanSum: g.Where(o => o.IdType == 0 && o.IdCategory == IdCategory)
.Select(el => el.DurationHours).Sum(),
DepthDifferenceFactSum: g.Where(o => o.IdType == 1 && o.IdCategory == IdCategory)
.Select((el, i) => i > 0 ? el.WellDepth - g.ElementAt(i - 1).WellDepth : 0).Sum(),
DurationDifferenceFactSum: g.Where(o => o.IdType == 1 && o.IdCategory == IdCategory)
.Select(el => el.DurationHours).Sum()
));
}
private static IEnumerable<(double DataPlan, double DataFact)> CalculateResult(IEnumerable<(double Item1Plan,
double Item1Fact, double Item2Plan, double Item2Fact)> rawData)
{ {
return rawData.Select(el => return rawData.Select(el =>
( (el.Item1 / el.Item2) is double.NaN
RouteSpeedPlan: (el.Item1Plan / el.Item2Plan) is double.NaN ? 0
? 0 : (el.Item1 / el.Item2)
: (el.Item1Plan / el.Item2Plan), );
RouteSpeedFact: (el.Item1Fact / el.Item2Fact) is double.NaN
? 0
: (el.Item1Fact / el.Item2Fact)
));
} }
private async Task<WellSectionType> GetWellSectionTypeFromCacheAndAssertAsync(string wellSectionType, CancellationToken token = default) private async Task<WellSectionType> GetWellSectionTypeFromCacheAndAssertAsync(string wellSectionType, CancellationToken token = default)