forked from ddrilling/AsbCloudServer
Fixed WellSection service
This commit is contained in:
parent
ae3a5c1ac7
commit
8bcaf18cb1
@ -215,29 +215,19 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
private static IEnumerable<(double MechSpeedPlan, double MechSpeedFact)> GetWellMechSpeedPlanFact(
|
private static IEnumerable<(double MechSpeedPlan, double MechSpeedFact)> GetWellMechSpeedPlanFact(
|
||||||
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
|
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
|
||||||
{
|
{
|
||||||
var mechSpeedBase = groupedOperations.Select(g => new
|
var mechSpeedBase = GetParams(groupedOperations, 18);
|
||||||
{
|
|
||||||
DepthChangePlanSum = g.Where(o => o.Type == 0 && o.IdOperationCategory == 1)
|
|
||||||
.Select((el, i) => i > 0 ? el.WellDepth - g.ElementAt(i - 1).WellDepth : 0).Sum(),
|
|
||||||
DurationsPlanSum = g.Where(o => o.Type == 0 && o.IdOperationCategory == 1)
|
|
||||||
.Select(el => el.DurationHours).Sum(),
|
|
||||||
DepthChangeFactSum = g.Where(o => o.Type == 1 && o.IdOperationCategory == 1)
|
|
||||||
.Select((el, i) => i > 0 ? el.WellDepth - g.ElementAt(i - 1).WellDepth : 0).Sum(),
|
|
||||||
DurationsFactSum = g.Where(o => o.Type == 1 && o.IdOperationCategory == 1)
|
|
||||||
.Select(el => el.DurationHours).Sum()
|
|
||||||
});
|
|
||||||
|
|
||||||
return mechSpeedBase.Select(el =>
|
return mechSpeedBase.Select(el =>
|
||||||
(
|
(
|
||||||
MechSpeedPlan: el.DepthChangePlanSum / el.DurationsPlanSum,
|
MechSpeedPlan: el.DepthDifferencePlanSum / el.DurationDifferencePlanSum,
|
||||||
MechSpeedFact: el.DepthChangeFactSum / el.DurationsFactSum
|
MechSpeedFact: el.DepthDifferenceFactSum / el.DurationDifferenceFactSum
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<(double BhaUpSpeedPlan, double BhaUpSpeedFact)> GetWellBhaUpSpeedPlanFact(
|
private static IEnumerable<(double BhaUpSpeedPlan, double BhaUpSpeedFact)> GetWellBhaUpSpeedPlanFact(
|
||||||
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
|
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
|
||||||
{
|
{
|
||||||
var bhaUpSpeedBase = GetParams(groupedOperations, 2);
|
var bhaUpSpeedBase = GetParams(groupedOperations, 72);
|
||||||
|
|
||||||
return bhaUpSpeedBase.Select(el =>
|
return bhaUpSpeedBase.Select(el =>
|
||||||
(
|
(
|
||||||
@ -249,7 +239,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
private static IEnumerable<(double BhaDownSpeedPlan, double BhaDownSpeedFact)> GetWellBhaDownSpeedPlanFact(
|
private static IEnumerable<(double BhaDownSpeedPlan, double BhaDownSpeedFact)> GetWellBhaDownSpeedPlanFact(
|
||||||
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
|
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
|
||||||
{
|
{
|
||||||
var bhaDownSpeedBase = GetParams(groupedOperations, 3);
|
var bhaDownSpeedBase = GetParams(groupedOperations, 71);
|
||||||
|
|
||||||
return bhaDownSpeedBase.Select(el =>
|
return bhaDownSpeedBase.Select(el =>
|
||||||
(
|
(
|
||||||
@ -261,7 +251,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
private static IEnumerable<(double CasingDownSpeedPlan, double CasingDownSpeedFact)> GetWellCasingDownPlanFact(
|
private static IEnumerable<(double CasingDownSpeedPlan, double CasingDownSpeedFact)> GetWellCasingDownPlanFact(
|
||||||
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
|
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
|
||||||
{
|
{
|
||||||
var casingDownBase = GetParams(groupedOperations, 4);
|
var casingDownBase = GetParams(groupedOperations, 74);
|
||||||
|
|
||||||
return casingDownBase.Select(el =>
|
return casingDownBase.Select(el =>
|
||||||
(
|
(
|
||||||
@ -291,25 +281,27 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
private static IEnumerable<(double RouteSpeedPlan, double RouteSpeedFact)> GetWellRouteSpeedsPlanFact(
|
private static IEnumerable<(double RouteSpeedPlan, double RouteSpeedFact)> GetWellRouteSpeedsPlanFact(
|
||||||
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
|
IEnumerable<IGrouping<int, WellOperation>> groupedOperations)
|
||||||
{
|
{
|
||||||
var bhaRaiseDecreaseCollection = new List<(WellOperation FirstDecreasePlan, WellOperation LastIncreasePlan,
|
var bhaRaiseDecreaseCollection = new List<(WellOperation FirstBhaPositionDecreasePlan,
|
||||||
WellOperation FirstDecreaseFact, WellOperation LastIncreaseFact)>();
|
WellOperation LastBhaPositionIncreasePlan,
|
||||||
|
WellOperation FirstBhaPositionDecreaseFact,
|
||||||
|
WellOperation LastBhaPositionIncreaseFact)>();
|
||||||
|
|
||||||
foreach (var group in groupedOperations)
|
foreach (var group in groupedOperations)
|
||||||
{
|
{
|
||||||
var firstBhaPositionDecreasePlan = group.Any(o => o.IdOperationCategory == 5 && o.Type == 0)
|
var firstBhaPositionDecreasePlan = group.Any(o => o.IdOperationCategory == 71 && o.Type == 0)
|
||||||
? group.First(o => o.IdOperationCategory == 5 && o.Type == 0)
|
? group.First(o => o.IdOperationCategory == 71 && o.Type == 0)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var lastBhaPositionIncreasePlan = group.Any(o => o.IdOperationCategory == 6 && o.Type == 0)
|
var lastBhaPositionIncreasePlan = group.Any(o => o.IdOperationCategory == 72 && o.Type == 0)
|
||||||
? group.First(o => o.IdOperationCategory == 5 && o.Type == 0)
|
? group.First(o => o.IdOperationCategory == 72 && o.Type == 0)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var firstBhaPositionDecreaseFact = group.Any(o => o.IdOperationCategory == 5 && o.Type == 1)
|
var firstBhaPositionDecreaseFact = group.Any(o => o.IdOperationCategory == 71 && o.Type == 1)
|
||||||
? group.First(o => o.IdOperationCategory == 5 && o.Type == 1)
|
? group.First(o => o.IdOperationCategory == 71 && o.Type == 1)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var lastBhaPositionIncreaseFact = group.Any(o => o.IdOperationCategory == 6 && o.Type == 1)
|
var lastBhaPositionIncreaseFact = group.Any(o => o.IdOperationCategory == 71 && o.Type == 1)
|
||||||
? group.First(o => o.IdOperationCategory == 5 && o.Type == 1)
|
? group.First(o => o.IdOperationCategory == 71 && o.Type == 1)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
bhaRaiseDecreaseCollection.Add((firstBhaPositionDecreasePlan,
|
bhaRaiseDecreaseCollection.Add((firstBhaPositionDecreasePlan,
|
||||||
@ -317,16 +309,16 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
lastBhaPositionIncreaseFact));
|
lastBhaPositionIncreaseFact));
|
||||||
}
|
}
|
||||||
|
|
||||||
var routeSpeedsBase = bhaRaiseDecreaseCollection.Select(el => new // TODO: check value for null
|
var routeSpeedsBase = bhaRaiseDecreaseCollection.Select(el => new
|
||||||
{
|
{
|
||||||
RouteDepthPlan = el.FirstDecreasePlan.WellDepth - el.LastIncreasePlan.WellDepth,
|
RouteDepthPlan = (el.FirstBhaPositionDecreasePlan?.WellDepth - el.LastBhaPositionIncreasePlan?.WellDepth) ?? 0,
|
||||||
RouteDepthFact = el.FirstDecreaseFact.WellDepth - el.LastIncreaseFact.WellDepth,
|
RouteDepthFact = (el.FirstBhaPositionDecreaseFact?.WellDepth - el.LastBhaPositionIncreaseFact?.WellDepth) ?? 0,
|
||||||
RouteDurationPlan = (el.LastIncreasePlan.StartDate +
|
RouteDurationPlan = (el.LastBhaPositionIncreasePlan?.StartDate +
|
||||||
TimeSpan.FromHours(el.LastIncreasePlan.DurationHours) -
|
TimeSpan.FromHours(el.LastBhaPositionIncreasePlan?.DurationHours ?? 0) -
|
||||||
el.FirstDecreasePlan.StartDate).TotalHours,
|
el.FirstBhaPositionDecreasePlan?.StartDate)?.TotalHours ?? 0,
|
||||||
RouteDurationFact = (el.LastIncreaseFact.StartDate +
|
RouteDurationFact = (el.LastBhaPositionIncreaseFact?.StartDate +
|
||||||
TimeSpan.FromHours(el.LastIncreaseFact.DurationHours) -
|
TimeSpan.FromHours(el.LastBhaPositionIncreaseFact?.DurationHours ?? 0) -
|
||||||
el.FirstDecreaseFact.StartDate).TotalHours
|
el.FirstBhaPositionDecreaseFact?.StartDate)?.TotalHours ?? 0
|
||||||
});
|
});
|
||||||
|
|
||||||
return routeSpeedsBase.Select(el =>
|
return routeSpeedsBase.Select(el =>
|
||||||
|
Loading…
Reference in New Issue
Block a user