diff --git a/AsbCloudApp/Data/StatOperationsDto.cs b/AsbCloudApp/Data/StatOperationsDto.cs index ac4496f1..90f221ac 100644 --- a/AsbCloudApp/Data/StatOperationsDto.cs +++ b/AsbCloudApp/Data/StatOperationsDto.cs @@ -7,12 +7,12 @@ namespace AsbCloudApp.Data /// /// Дата и время начала /// - public DateTime Start { get; set; } + public DateTime? Start { get; set; } /// /// Дата и время окончания /// - public DateTime End { get; set; } + public DateTime? End { get; set; } /// /// Глубина, м diff --git a/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs b/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs index 687788c7..4ec0ddd9 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs @@ -186,7 +186,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService return statWellDto; statWellDto.Sections = CalcSectionsStats(wellOperations); - statWellDto.Total = GetStatTotal(wellOperations); + statWellDto.Total = GetStatTotal(wellOperations, well.IdState); return statWellDto; } @@ -219,14 +219,18 @@ namespace AsbCloudInfrastructure.Services.WellOperationService return sections; } - private static PlanFactBase GetStatTotal(IEnumerable operations) + private static PlanFactBase GetStatTotal(IEnumerable operations, + int idWellState) { var operationsPlan = operations.Where(o => o.IdType == idOperationTypePlan); var operationsFact = operations.Where(o => o.IdType == idOperationTypeFact); + var factEnd = CalcStat(operationsFact); + if (idWellState != 2) + factEnd.End = null; var section = new PlanFactBase { Plan = CalcStat(operationsPlan), - Fact = CalcStat(operationsFact), + Fact = factEnd, }; return section; } @@ -240,7 +244,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService return CalcStat(sectionOperations); } - + private static StatOperationsDto CalcStat(IEnumerable operations) { if (!operations.Any()) @@ -250,8 +254,8 @@ namespace AsbCloudInfrastructure.Services.WellOperationService var section = new StatOperationsDto { - Start = operations.First().DateStart, - End = operations.Max(o => (o.DateStart.AddHours(o.DurationHours))), + Start = operations.FirstOrDefault()?.DateStart, + End = operations.Max(o => o.DateStart.AddHours(o.DurationHours)), WellDepthStart = operations.Min(o => o.DepthStart), WellDepthEnd = operations.Max(o => o.DepthStart), Rop = CalcROP(operations),