diff --git a/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportService.cs b/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportService.cs index b22ce6ff..e847179d 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportService.cs @@ -12,12 +12,14 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Services.WellOperationService { - public class ScheduleReportService : IScheduleReportService { private readonly IOperationsStatService operationsStatService; private readonly IWellService wellService; const string sheetNameSchedule = "Сетевой график"; + const string sheetNameSchedulePlan = "План"; + const string sheetNameScheduleFact = "Факт"; + const string sheetNameSchedulePrediction = "Прогноз"; const string sheetNameTvd = "ГГД"; const int maxChartsToWrap = 88; @@ -47,6 +49,61 @@ namespace AsbCloudInfrastructure.Services.WellOperationService } private static void FillScheduleSheetToWorkbook(XLWorkbook workbook, IEnumerable> tvd, WellDto well) + { + FillScheduleSheet(workbook, tvd, well); + + var tvdList = tvd.ToList(); + var plans = tvd + .Where(t => t.Plan is not null) + .Select(t => t.Plan!) + .OrderBy(t => t.DateStart); + FillCurrentScheduleSheet(workbook, plans, sheetNameSchedulePlan); + + var facts = tvd + .Where(t => t.Fact is not null) + .Select(t => t.Fact!) + .OrderBy(t => t.DateStart); + FillCurrentScheduleSheet(workbook, facts, sheetNameScheduleFact); + + var predictions = tvd + .Where(t => t.Predict is not null) + .Select(t => t.Predict!) + .OrderBy(t => t.DateStart); + FillCurrentScheduleSheet(workbook, predictions, sheetNameSchedulePrediction); + } + + private static void FillCurrentScheduleSheet(XLWorkbook workbook, IEnumerable tvdList, string sheetName) + { + var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetName); + if (sheet is null) + return; + + const int headerRowsCount = 6; + + const int columnRowNumber = 2; + const int columnCaption = 3; + const int columnWellDepthStart = 4; + const int columnWellDepthEnd = 5; + const int columnDuration = 6; + const int columnDateStart = 7; + const int columnDateEnd = 8; + + int i = 1; + foreach (var tvdItem in tvdList) + { + var row = sheet.Row(i + headerRowsCount); + SetCell(row, columnRowNumber, $"{i}"); + SetCell(row, columnCaption, $"{tvdItem.CategoryName} {tvdItem.CategoryInfo}".Trim()); + SetCell(row, columnWellDepthStart, tvdItem.DepthStart); + SetCell(row, columnWellDepthEnd, tvdItem.DepthEnd); + SetCell(row, columnDuration, tvdItem.DurationHours); + SetCell(row, columnDateStart, tvdItem.DateStart); + SetCell(row, columnDateEnd, tvdItem.DateStart.AddHours(tvdItem.DurationHours)); + i++; + } + } + + private static void FillScheduleSheet(XLWorkbook workbook, IEnumerable> tvd, WellDto well) { var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNameSchedule); if (sheet is null) diff --git a/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportTemplate.xlsx b/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportTemplate.xlsx index 5f86498d..7dc25b91 100644 Binary files a/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportTemplate.xlsx and b/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportTemplate.xlsx differ