From 32a0678a56e22796447041e9048708e0213ace46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=94?= =?UTF-8?q?=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Wed, 7 Feb 2024 09:33:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B?= =?UTF-8?q?=20=D1=81=20excel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Использование новых методов расширения 2. Удалил неиспользуемый генератор файла DrillingProgramMaker 3. Поправлено название листа в ProcessMapReportTemplate --- .../DailyReport/DailyReportExportService.cs | 100 +++++++------ .../DetectedOperationExportService.cs | 51 ++++--- .../DrillTestReportMakerService.cs | 59 ++++---- .../DrillingProgram/DrillingProgramMaker.cs | 133 ------------------ .../Report/ProcessMapReportTemplate.xlsx | Bin 11880 -> 11896 bytes ...ocessMapReportWellDrillingExportService.cs | 85 ++++------- ...ProcessMapPlanImportWellDrillingService.cs | 54 +++---- .../Export/TrajectoryExportService.cs | 6 +- .../TrajectoryFactManualExportService.cs | 12 +- .../Export/TrajectoryFactNnbExportService.cs | 12 +- .../Export/TrajectoryPlanExportService.cs | 14 +- .../Parser/TrajectoryParserService.cs | 6 +- .../WellOperationDefaultExcelParser.cs | 6 +- .../WellOperationGazpromKhantosExcelParser.cs | 7 +- .../WellOperationExportService.cs | 34 +++-- .../ScheduleReportService.cs | 25 ++-- 16 files changed, 211 insertions(+), 393 deletions(-) delete mode 100644 AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramMaker.cs diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportExportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportExportService.cs index 3148fbf3..e593da8c 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportExportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportExportService.cs @@ -106,7 +106,7 @@ public class DailyReportExportService : IDailyReportExportService .GetExecutingAssembly() .GetTemplateCopyStreamAsync("DailyReportTemplate.xlsx", cancellationToken); - using var workbook = new XLWorkbook(excelTemplateStream, XLEventTracking.Disabled); + using var workbook = new XLWorkbook(excelTemplateStream); AddDailyReportToWorkBook(workbook, dailyReport); @@ -120,18 +120,17 @@ public class DailyReportExportService : IDailyReportExportService { const string sheetName = "Суточный отчёт"; - var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetName) - ?? throw new FileFormatException($"Книга excel не содержит листа {sheetName}."); + var sheet = workbook.GetWorksheet(sheetName);; - sheet.Cell(cellCustomer).Value = dailyReport.Customer; - sheet.Cell(cellContractor).Value = dailyReport.Contractor; - sheet.Cell(cellDeposit).Value = dailyReport.Deposit; - sheet.Cell(cellCluster).Value = dailyReport.Cluster; - sheet.Cell(cellWellCaption).Value = dailyReport.WellCaption; - sheet.Cell(cellWellType).Value = dailyReport.WellType; - sheet.Cell(cellDate).Value = dailyReport.Date; - sheet.Cell(cellDepthStart).Value = dailyReport.DepthStart; - sheet.Cell(cellDepthEnd).Value = dailyReport.DepthEnd; + sheet.Cell(cellCustomer).SetCellValue(dailyReport.Customer); + sheet.Cell(cellContractor).SetCellValue(dailyReport.Contractor); + sheet.Cell(cellDeposit).SetCellValue(dailyReport.Deposit); + sheet.Cell(cellCluster).SetCellValue(dailyReport.Cluster); + sheet.Cell(cellWellCaption).SetCellValue(dailyReport.WellCaption); + sheet.Cell(cellWellType).SetCellValue(dailyReport.WellType); + sheet.Cell(cellDate).SetCellValue(dailyReport.Date); + sheet.Cell(cellDepthStart).SetCellValue(dailyReport.DepthStart); + sheet.Cell(cellDepthEnd).SetCellValue(dailyReport.DepthEnd); if (dailyReport.TimeBalanceBlock is not null) AddTimeBalanceBlockToSheet(sheet, dailyReport.TimeBalanceBlock); @@ -150,10 +149,10 @@ public class DailyReportExportService : IDailyReportExportService private static void AddTrajectoryBlockToSheet(IXLWorksheet sheet, TrajectoryBlockDto trajectoryBlock) { - sheet.Cell(cellTrajectoryBlockWellboreDepth).Value = trajectoryBlock.WellboreDepth; - sheet.Cell(cellTrajectoryBlockVerticalDepth).Value = trajectoryBlock.VerticalDepth; - sheet.Cell(cellTrajectoryBlockZenithAngle).Value = trajectoryBlock.ZenithAngle; - sheet.Cell(cellTrajectoryBlockAzimuthGeo).Value = trajectoryBlock.AzimuthGeo; + sheet.Cell(cellTrajectoryBlockWellboreDepth).SetCellValue(trajectoryBlock.WellboreDepth); + sheet.Cell(cellTrajectoryBlockVerticalDepth).SetCellValue(trajectoryBlock.VerticalDepth); + sheet.Cell(cellTrajectoryBlockZenithAngle).SetCellValue(trajectoryBlock.ZenithAngle); + sheet.Cell(cellTrajectoryBlockAzimuthGeo).SetCellValue(trajectoryBlock.AzimuthGeo); } private static void AddTimeBalanceBlockToSheet(IXLWorksheet sheet, TimeBalanceBlockDto timeBalanceBlock) @@ -162,19 +161,19 @@ public class DailyReportExportService : IDailyReportExportService foreach (var wellOperation in timeBalanceBlock.WellOperations.OrderBy(w => w.IdWellOperation)) { - sheet.Cell(rowCurrent, columnTimeBalanceDurationPlan).Value = wellOperation.DurationHours.Plan; - sheet.Cell(rowCurrent, columnTimeBalanceDurationFact).Value = wellOperation.DurationHours.Fact; - sheet.Cell(rowCurrent, columnTimeBalanceReasonDeviation).Value = wellOperation.ReasonDeviation; - sheet.Cell(rowCurrent, columnTimeBalanceDrillingDeviationPerSection).Value = wellOperation.DrillingDeviationPerSection; - sheet.Cell(rowCurrent, columnTimeBalanceDrillingDeviationPerDay).Value = wellOperation.DrillingDeviationPerDay; + sheet.Cell(rowCurrent, columnTimeBalanceDurationPlan).SetCellValue(wellOperation.DurationHours.Plan); + sheet.Cell(rowCurrent, columnTimeBalanceDurationFact).SetCellValue(wellOperation.DurationHours.Fact); + sheet.Cell(rowCurrent, columnTimeBalanceReasonDeviation).SetCellValue(wellOperation.ReasonDeviation); + sheet.Cell(rowCurrent, columnTimeBalanceDrillingDeviationPerSection).SetCellValue(wellOperation.DrillingDeviationPerSection); + sheet.Cell(rowCurrent, columnTimeBalanceDrillingDeviationPerDay).SetCellValue(wellOperation.DrillingDeviationPerDay); rowCurrent++; } - sheet.Cell(cellTimeBalanceBlockSection).Value = timeBalanceBlock.SectionName; - sheet.Cell(cellTimeBalanceBlockWellDepthPlan).Value = timeBalanceBlock.WellDepth.Plan; - sheet.Cell(cellTimeBalanceBlockWellDepthFact).Value = timeBalanceBlock.WellDepth.Fact; - sheet.Cell(cellTimeBalanceBlockWellOperationSlipsTimeCount).Value = timeBalanceBlock.WellOperationSlipsTimeCount; + sheet.Cell(cellTimeBalanceBlockSection).SetCellValue(timeBalanceBlock.SectionName); + sheet.Cell(cellTimeBalanceBlockWellDepthPlan).SetCellValue(timeBalanceBlock.WellDepth.Plan); + sheet.Cell(cellTimeBalanceBlockWellDepthFact).SetCellValue(timeBalanceBlock.WellDepth.Fact); + sheet.Cell(cellTimeBalanceBlockWellOperationSlipsTimeCount).SetCellValue(timeBalanceBlock.WellOperationSlipsTimeCount); } private static void AddSubsystemBlockToSheet(IXLWorksheet sheet, SubsystemBlockDto subsystemBlock) @@ -183,24 +182,23 @@ public class DailyReportExportService : IDailyReportExportService foreach (var subsystem in subsystemBlock.Subsystems) { - sheet.Cell(rowСurrent, columnSubsystemName).Value = subsystem.Name; + sheet.Cell(rowСurrent, columnSubsystemName).SetCellValue(subsystem.Name); + sheet.Cell(rowСurrent, columnUseSubsystemPerDayUsedTimeHours).SetCellValue(subsystem.UsagePerDay?.UsedTimeHours); + sheet.Cell(rowСurrent, columnUseSubsystemPerDaySumDepthInterval).SetCellValue(subsystem.UsagePerDay?.SumDepthInterval); + sheet.Cell(rowСurrent, columnUseSubsystemPerDayKUsage).SetCellValue(subsystem.UsagePerDay?.KUsage); - sheet.Cell(rowСurrent, columnUseSubsystemPerDayUsedTimeHours).Value = subsystem.UsagePerDay?.UsedTimeHours; - sheet.Cell(rowСurrent, columnUseSubsystemPerDaySumDepthInterval).Value = subsystem.UsagePerDay?.SumDepthInterval; - sheet.Cell(rowСurrent, columnUseSubsystemPerDayKUsage).Value = subsystem.UsagePerDay?.KUsage; - - sheet.Cell(rowСurrent, columnUseSubsystemPerWellUsedTimeHours).Value = subsystem.UsagePerWell?.UsedTimeHours; - sheet.Cell(rowСurrent, columnUseSubsystemPerWellSumDepthInterval).Value = subsystem.UsagePerWell?.SumDepthInterval; - sheet.Cell(rowСurrent, columnUseSubsystemPerWellKUsage).Value = subsystem.UsagePerWell?.KUsage; + sheet.Cell(rowСurrent, columnUseSubsystemPerWellUsedTimeHours).SetCellValue(subsystem.UsagePerWell?.UsedTimeHours); + sheet.Cell(rowСurrent, columnUseSubsystemPerWellSumDepthInterval).SetCellValue(subsystem.UsagePerWell?.SumDepthInterval); + sheet.Cell(rowСurrent, columnUseSubsystemPerWellKUsage).SetCellValue(subsystem.UsagePerWell?.KUsage); rowСurrent++; } - sheet.Cell(cellSubsystemComment).Value = subsystemBlock.Comment; - sheet.Cell(cellSubsystemTvgLagDays).Value = subsystemBlock.TvgLagDays; - sheet.Cell(cellSubsystemMeasurementsPerDay).Value = subsystemBlock.MeasurementsPerDay; - sheet.Cell(cellSubsystemWellbore).Value = subsystemBlock.Wellbore; - sheet.Cell(cellSubsystemTotalRopPlan).Value = subsystemBlock.TotalRopPlan; + sheet.Cell(cellSubsystemComment).SetCellValue(subsystemBlock.Comment); + sheet.Cell(cellSubsystemTvgLagDays).SetCellValue(subsystemBlock.TvgLagDays); + sheet.Cell(cellSubsystemMeasurementsPerDay).SetCellValue(subsystemBlock.MeasurementsPerDay); + sheet.Cell(cellSubsystemWellbore).SetCellValue(subsystemBlock.Wellbore); + sheet.Cell(cellSubsystemTotalRopPlan).SetCellValue(subsystemBlock.TotalRopPlan); } private static void AddScheduleBlockToSheet(IXLWorksheet sheet, IEnumerable scheduleBlock) @@ -209,9 +207,9 @@ public class DailyReportExportService : IDailyReportExportService foreach (var schedule in scheduleBlock.OrderBy(s => s.ShiftStart)) { - sheet.Cell(rowCurrent, columnSheduleDriller).Value = $"{schedule.Surname} {schedule.Name} {schedule.Patronymic}"; - sheet.Cell(rowCurrent, columnSheduleShiftStart).Value = schedule.ShiftStart; - sheet.Cell(rowCurrent, columnSheduleShiftEnd).Value = schedule.ShiftEnd; + sheet.Cell(rowCurrent, columnSheduleDriller).SetCellValue($"{schedule.Surname} {schedule.Name} {schedule.Patronymic}"); + sheet.Cell(rowCurrent, columnSheduleShiftStart).SetCellValue(schedule.ShiftStart); + sheet.Cell(rowCurrent, columnSheduleShiftEnd).SetCellValue(schedule.ShiftEnd); rowCurrent++; } @@ -224,11 +222,11 @@ public class DailyReportExportService : IDailyReportExportService foreach (var processMapWellDrilling in processMapWellDrillingBlock.OrderBy(p => p.DrillingMode)) { - sheet.Cell(rowCurrent, columnProcessMapWellDrillingBlockDrillingMode).Value = processMapWellDrilling.DrillingMode; - sheet.Cell(rowCurrent, columnProcessMapWellDrillingBlockWellBoreDepth).Value = processMapWellDrilling.WellBoreDepth; - sheet.Cell(rowCurrent, columnProcessMapWellDrillingBlockMechDrillingHours).Value = processMapWellDrilling.MechDrillingHours; - sheet.Cell(rowCurrent, columnProcessMapWellDrillingBlockRopPlan).Value = processMapWellDrilling.Rop.Plan; - sheet.Cell(rowCurrent, columnProcessMapWellDrillingBlockRopFact).Value = processMapWellDrilling.Rop.Fact; + sheet.Cell(rowCurrent, columnProcessMapWellDrillingBlockDrillingMode).SetCellValue(processMapWellDrilling.DrillingMode); + sheet.Cell(rowCurrent, columnProcessMapWellDrillingBlockWellBoreDepth).SetCellValue(processMapWellDrilling.WellBoreDepth); + sheet.Cell(rowCurrent, columnProcessMapWellDrillingBlockMechDrillingHours).SetCellValue(processMapWellDrilling.MechDrillingHours); + sheet.Cell(rowCurrent, columnProcessMapWellDrillingBlockRopPlan).SetCellValue(processMapWellDrilling.Rop.Plan); + sheet.Cell(rowCurrent, columnProcessMapWellDrillingBlockRopFact).SetCellValue(processMapWellDrilling.Rop.Fact); rowCurrent++; } @@ -238,12 +236,12 @@ public class DailyReportExportService : IDailyReportExportService { var rowCurrent = rowStartFactWellOperationBlock; - sheet.Cell(cellSectionDrillingHours).Value = factWellOperationBlock.SectionDrillingHours; + sheet.Cell(cellSectionDrillingHours).SetCellValue(factWellOperationBlock.SectionDrillingHours); foreach (var factOperation in factWellOperationBlock.WellOperations.OrderBy(w => w.CategoryName)) { - sheet.Cell(rowCurrent, columnWellOperationCategory).Value = factOperation.CategoryName; - sheet.Cell(rowCurrent, columnWellOperationDurationHours).Value = factOperation.DurationHours; + sheet.Cell(rowCurrent, columnWellOperationCategory).SetCellValue(factOperation.CategoryName); + sheet.Cell(rowCurrent, columnWellOperationDurationHours).SetCellValue(factOperation.DurationHours); rowCurrent++; } @@ -251,7 +249,7 @@ public class DailyReportExportService : IDailyReportExportService private static void AddSignBlockToSheet(IXLWorksheet sheet, SignBlockDto signBlock) { - sheet.Cell(cellSignDrillingMaster).Value = signBlock.DrillingMaster?.ToString(); - sheet.Cell(cellSignSupervisor).Value = signBlock.Supervisor?.ToString(); + sheet.Cell(cellSignDrillingMaster).SetCellValue(signBlock.DrillingMaster?.ToString()); + sheet.Cell(cellSignSupervisor).SetCellValue(signBlock.Supervisor?.ToString()); } } \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs index b70f8cd4..ef781a1e 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs @@ -42,8 +42,9 @@ public class DetectedOperationExportService private const int columnIdReasonOfEnd = 9; private const int columnComment = 10; + //TODO: удалить неиспользуемую зависимость private readonly IAsbCloudDbContext dbContext; - private readonly IWellOperationRepository wellOperationRepository; + private readonly IWellOperationRepository wellOperationRepository; public DetectedOperationExportService(IAsbCloudDbContext dbContext, IWellOperationRepository wellOperationRepository) { @@ -82,7 +83,7 @@ public class DetectedOperationExportService { using var excelTemplateStream = await GetExcelTemplateStreamAsync(cancellationToken); - using var workbook = new XLWorkbook(excelTemplateStream, XLEventTracking.Disabled); + using var workbook = new XLWorkbook(excelTemplateStream); await AddToWorkbookAsync(workbook, well, host, operationDetectorResults, cancellationToken); @@ -100,8 +101,7 @@ public class DetectedOperationExportService if (!operationDetectorResults.Any()) return; - var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetName) - ?? throw new FileFormatException($"Книга excel не содержит листа {sheetName}."); + var sheet = workbook.GetWorksheet(sheetName); await AddToSheetAsync(sheet, well, host, operationDetectorResults .OrderBy(x => x.Operation.DateStart).ThenBy(x => x.Operation.DepthStart).ToArray(), @@ -113,10 +113,10 @@ public class DetectedOperationExportService { var wellOperationCategories = await dbContext.WellOperationCategories.ToListAsync(cancellationToken); - sheet.Cell(cellDepositName).Value = well.Cluster.Deposit.Caption; - sheet.Cell(cellClusterName).Value = well.Cluster.Caption; - sheet.Cell(cellWellName).Value = well.Caption; - sheet.Cell(cellDeltaDate).Value = operationDetectorResults.Max(o => o.Operation.DateEnd) - operationDetectorResults.Min(o => o.Operation.DateStart); + sheet.Cell(cellDepositName).SetCellValue(well.Cluster.Deposit.Caption); + sheet.Cell(cellClusterName).SetCellValue(well.Cluster.Caption); + sheet.Cell(cellWellName).SetCellValue(well.Caption); + sheet.Cell(cellDeltaDate).SetCellValue(operationDetectorResults.Max(o => o.Operation.DateEnd) - operationDetectorResults.Min(o => o.Operation.DateStart)); var detectedOperations = operationDetectorResults.Select(o => o.Operation).ToArray(); @@ -128,31 +128,38 @@ public class DetectedOperationExportService var row = sheet.Row(5 + i + headerRowsCount); - row.Cell(columnOperationName).Value = GetCategoryName(wellOperationCategories, current); - row.Cell(columnDateEnd).Value = dateEnd; - row.Cell(columnDuration).Value = (dateEnd - dateStart).TotalMinutes; - row.Cell(columnDepthStart).Value = current.DepthStart; - row.Cell(columnDepthEnd).Value = current.DepthEnd; - row.Cell(columnDepth).Value = current.DepthEnd - current.DepthStart; + var categoryName = GetCategoryName(wellOperationCategories, current); + + row.Cell(columnOperationName).SetCellValue(categoryName); + row.Cell(columnDateEnd).SetCellValue(dateEnd); + row.Cell(columnDuration).SetCellValue((dateEnd - dateStart).TotalMinutes); + row.Cell(columnDepthStart).SetCellValue(current.DepthStart); + row.Cell(columnDepthEnd).SetCellValue(current.DepthEnd); + row.Cell(columnDepth).SetCellValue(current.DepthEnd - current.DepthStart); - if (current.ExtraData.TryGetValue("IdReasonOfEnd", out object? idReasonOfEndObject) + if (current.ExtraData.TryGetValue("IdReasonOfEnd", out object? idReasonOfEndObject) && idReasonOfEndObject is int idReasonOfEnd) - row.Cell(columnIdReasonOfEnd).Value = GetIdReasonOfEnd(idReasonOfEnd); + { + var reasonOfEnd = GetIdReasonOfEnd(idReasonOfEnd); + row.Cell(columnIdReasonOfEnd).SetCellValue(reasonOfEnd); + } var query = new QueryBuilder(); query.Add("end", dateStart.AddSeconds(1800 * 0.9).ToString("yyyy-MM-ddTHH:mm:ss.fff")); query.Add("range", "1800"); + row.Cell(columnDateStart).SetCellValue(dateStart); + var link = $"{host}/well/{well.Id}/telemetry/monitoring{query}"; - - row.Cell(columnDateStart).Value = dateStart; - row.Cell(columnDateStart).SetHyperlink(new XLHyperlink(link)); - - row.Cell(columnDeltaDepth).Value = i > 0 && i + 1 < detectedOperations.Length + row.Cell(columnDateStart).SetHyperlink(link); + + var deltaDepth = i > 0 && i + 1 < detectedOperations.Length ? current.DepthStart - detectedOperations[i - 1].DepthEnd : 0; + row.Cell(columnDeltaDepth).SetCellValue(deltaDepth); - row.Cell(columnComment).Value = CreateComment(operationDetectorResults[i]); + var comment = CreateComment(operationDetectorResults[i]); + row.Cell(columnComment).SetCellValue(comment); } } diff --git a/AsbCloudInfrastructure/Services/DrillTestReport/DrillTestReportMakerService.cs b/AsbCloudInfrastructure/Services/DrillTestReport/DrillTestReportMakerService.cs index 27a01e85..d40ab302 100644 --- a/AsbCloudInfrastructure/Services/DrillTestReport/DrillTestReportMakerService.cs +++ b/AsbCloudInfrastructure/Services/DrillTestReport/DrillTestReportMakerService.cs @@ -1,5 +1,4 @@ using AsbCloudApp.Data.DrillTestReport; -using AsbCloudApp.Services; using ClosedXML.Excel; using System; using System.IO; @@ -7,6 +6,7 @@ using System.Linq; using System.Reflection; using System.Threading; using System.Threading.Tasks; +using AsbCloudApp.Services; namespace AsbCloudInfrastructure.Services.DrillTestReport { @@ -20,7 +20,7 @@ namespace AsbCloudInfrastructure.Services.DrillTestReport { using var excelTemplateStream = await Assembly.GetExecutingAssembly().GetTemplateCopyStreamAsync(templateName, cancellationToken); - using var workbook = new XLWorkbook(excelTemplateStream, XLEventTracking.Disabled); + using var workbook = new XLWorkbook(excelTemplateStream); AddToWorkbook(workbook, report); @@ -30,50 +30,39 @@ namespace AsbCloudInfrastructure.Services.DrillTestReport return memoryStream; } - - + private void AddToWorkbook(XLWorkbook workbook, DrillTestReportDataDto report) { - var drillTestEntities = report.Data.Params; - if (!drillTestEntities.Any()) + var drillTests = report.Data.Params; + + if (!drillTests.Any()) return; - var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetName) - ?? throw new FileFormatException($"Книга excel не содержит листа {sheetName}."); + var sheet = workbook.GetWorksheet(sheetName); - sheet.Cell(4, 2).Value = report.Caption; - sheet.Cell(5, 2)._SetValue(report.Date, setAllBorders: false); - - var rowNumber = startRowNumber; - - var stepWithMaxDepthSpeed = drillTestEntities.OrderByDescending(p => p.DepthSpeed).FirstOrDefault()!.Step; + sheet.Cell(4, 2).SetCellValue(report.Caption); + sheet.Cell(5, 2).SetCellValue(report.Date); + + var stepWithMaxDepthSpeed = drillTests.MaxBy(p => p.DepthSpeed)!.Step; var startDepth = report.Data.DepthStart; var startDate = report.Data.TimeStampStart; - foreach (var drillTestEntity in drillTestEntities) + var rowNumber = startRowNumber; + + foreach (var drillTestEntity in drillTests) { var endDepth = startDepth + (drillTestEntity.DepthDrillStep ?? 0); var endDateTime = startDate.AddSeconds(drillTestEntity.TimeDrillStep ?? 0); - - sheet.Cell(rowNumber, 2).Value = startDepth; - - sheet.Cell(rowNumber, 3).Value = endDepth; - - sheet.Cell(rowNumber, 4).Value = drillTestEntity.DepthDrillStep; - - sheet.Cell(rowNumber, 5).Value = drillTestEntity.Workload; - - sheet.Cell(rowNumber, 6).Value = drillTestEntity.Speed; - - var cell = sheet.Cell(rowNumber, 7); - cell._SetValue(startDate.DateTime); - - cell = sheet.Cell(rowNumber, 8); - cell._SetValue(endDateTime.DateTime); - - sheet.Cell(rowNumber, 9).Value = Math.Round((drillTestEntity.TimeDrillStep ?? 0) / (60 * 60), 2); - - sheet.Cell(rowNumber, 10).Value = drillTestEntity.DepthSpeed; + + sheet.Cell(rowNumber, 2).SetCellValue(startDepth); + sheet.Cell(rowNumber, 3).SetCellValue(endDepth); + sheet.Cell(rowNumber, 4).SetCellValue(drillTestEntity.DepthDrillStep); + sheet.Cell(rowNumber, 5).SetCellValue(drillTestEntity.Workload); + sheet.Cell(rowNumber, 6).SetCellValue(drillTestEntity.Speed); + sheet.Cell(rowNumber, 7).SetCellValue(startDate.DateTime); + sheet.Cell(rowNumber, 8).SetCellValue(endDateTime.DateTime); + sheet.Cell(rowNumber, 9).SetCellValue(Math.Round((drillTestEntity.TimeDrillStep ?? 0) / (60 * 60), 2)); + sheet.Cell(rowNumber, 10).SetCellValue(drillTestEntity.DepthSpeed); if (drillTestEntity.Step == stepWithMaxDepthSpeed) { diff --git a/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramMaker.cs b/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramMaker.cs deleted file mode 100644 index 7486ec59..00000000 --- a/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramMaker.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ClosedXML.Excel; -using ClosedXML.Excel.Drawings; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace AsbCloudInfrastructure.Services.DrillingProgram -{ - - internal class DrillingProgramMaker - { - private const int maxAllowedColumns = 256; - - public static void UniteExcelFiles(IEnumerable excelFilesNames, string resultExcelPath, IEnumerable parts, AsbCloudApp.Data.WellDto well) - { - var resultExcelFile = new XLWorkbook(XLEventTracking.Disabled); - - var titleSheet = resultExcelFile.AddWorksheet("Титульный лист"); - var marks = parts.SelectMany(p => p.File!.FileMarks); - var titleSheetMaker = new TitleListSheet(marks, well); - titleSheetMaker.Draw(titleSheet); - - var contentSheet = resultExcelFile.AddWorksheet("Содержание"); - var contentListSheetMaker = new ContentListSheet(parts); - contentListSheetMaker.Draw(contentSheet); - - var filteredFileNames = excelFilesNames.Distinct(); - - foreach (var excelFileName in filteredFileNames) - { - using var workbookSrc = new XLWorkbook(excelFileName, XLEventTracking.Disabled); - - foreach (var sheet in workbookSrc.Worksheets) - { - if (sheet.Visibility == XLWorksheetVisibility.Visible) - CopySheet(resultExcelFile, sheet); - } - } - - resultExcelFile.SaveAs(resultExcelPath, - new SaveOptions { EvaluateFormulasBeforeSaving = true }); - } - - private static void CopySheet(XLWorkbook workbookDst, IXLWorksheet sheetSrc) - { - var newSheetName = sheetSrc.Name; - var suffix = ""; - int index = 1; - - while (workbookDst.Worksheets.Contains(newSheetName)) - { - newSheetName = sheetSrc.Name; - suffix = $"_{index++}"; - if (newSheetName.Length + suffix.Length >= 31) - newSheetName = newSheetName[..(31 - suffix.Length)]; - newSheetName += suffix; - } - - var imagesInfos = sheetSrc.Pictures.Select(p => new ImageInfo - { - Id = p.Id, - Data = p.ImageStream.GetBuffer(), - Height = p.Height, - Width = p.Width, - TopLeftCellAddress = p.TopLeftCell.Address, - Left = p.Left, - Top = p.Top - }).ToList(); - - IXLWorksheet resultSheet; - - if (sheetSrc.Columns().Count() > maxAllowedColumns) - { - resultSheet = workbookDst.Worksheets.Add(newSheetName); - - var rngData = GetCellsRange(sheetSrc); - - rngData.CopyTo(resultSheet.Cell(1, 1)); - - var lastRowWithData = rngData.LastRowUsed().RangeAddress - .LastAddress.RowNumber; - - for (int i = 1; i < lastRowWithData; i++) - { - resultSheet.Row(i).Height = sheetSrc.Row(i).Height; - resultSheet.Column(i).Width = sheetSrc.Column(i).Width; - } - } - else - { - RemovePicturesFromSheet(sheetSrc); - resultSheet = sheetSrc.CopyTo(workbookDst, newSheetName); - } - CopyImagesToAnotherSheet(imagesInfos, resultSheet); - } - - private static IXLWorksheet CopyImagesToAnotherSheet(IEnumerable imagesInfos, - IXLWorksheet resultSheet) - { - foreach (var image in imagesInfos) - { - var stream = new MemoryStream(); - stream.Write(image.Data, 0, image.Data.Length); - - resultSheet.AddPicture(stream) - .WithPlacement(XLPicturePlacement.Move) - .WithSize(image.Width, image.Height) - .MoveTo(resultSheet.Cell(image.TopLeftCellAddress), - image.Left, image.Top); - } - - return resultSheet; - } - - private static void RemovePicturesFromSheet(IXLWorksheet sheet) - { - var filteredPics = sheet.Pictures.Select(p => p.Name).Distinct().ToList(); - - foreach (var n in filteredPics) - sheet.Pictures.Delete(n); - } - - private static IXLRange GetCellsRange(IXLWorksheet sheet) - { - var firstTableCell = sheet.FirstCellUsed(); - var lastTableCell = sheet.LastCellUsed(); - var rngData = sheet.Range(firstTableCell.Address, lastTableCell.Address); - - return rngData; - } - } - -} diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportTemplate.xlsx b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportTemplate.xlsx index dff707eb4b1baac2a92f67696cc47ea5fa4d4c0f..44d9714999bc99a3b745967c2ab6c687bee0ae84 100644 GIT binary patch delta 5865 zcmY+I2UHW=*2hB=q$8jRN(TedLMMPo4WT2wOP8)8^b(O?1WahskrFyWD1sCL5$V!9 zNGEiVUO&C>yYId`Yt5{E&TrPbDnOG>$Cu6TD=n#W-12mQNL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AnxvR&L&UN?}zSgiL zQ}f;+xAV7Ul|#0%7zXA(cih4S>v zFwoM*{K8eH%NF-();pwJko;-SrIUqEhi{2MAc<;bL2e?zO#P1{`H6Xri*)wBo{Futt-pg@1J;9KGnE|aO+eR5|pirTpq)14LZsw=~wM}msit- znoJ}YrsE+beBKpb8X`a8oD=Q;p(s? zc6Y6Gt*?M)VO7gj7TZ=-9V|IgUzp2A;`VCD`I~m8&toRJAD?rxGBR_Vqusq-e=x(# zvlF5f%JTwkxF2dKy1JUK>D9I+{In*e5j|PYvb^I+6?I`gigRTD(&EkUu8rYN=zphn zD>zCiM_Lg+rFWT{d4$3zlBR9Vx2;mG@I{)&&o*lyCV>WGlS_6Wj8eWnl?_gsPAg=% zcj>urf+l-L%Y<0os<^TE(8=5h=8Q|5&xz#_pRQCn&MN*`Lj=_ckzk2y8*?r)fqsOi zwl68YN~l_z?U)Z*_dWjp)wwmWvCsTGM(Svx+u~4)W78oN%VX;u8KWo=7JDS&cvn&Z zjqKs<(oUBhLub{iDIRX_knAjCMN|itICP}76OFSk$dJ>*UoZVFDkGakjEKsRRHEv{ ztu)95nyW~>C>{I%SMPocc>iASkcpz)?0@|!FM~j<5+D%Ef1tm1C1jtdF#BKc_4hy= l{noAN|AC7k>BJz{{vH?-5Qy#{_^%sC6ER-$QQ<${{{!3lJhcD- diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingExportService.cs b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingExportService.cs index e89d64ad..9e1cb6db 100644 --- a/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingExportService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMaps/Report/ProcessMapReportWellDrillingExportService.cs @@ -37,7 +37,7 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr return null; var stream = GetExcelTemplateStream(); - using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled); + using var workbook = new XLWorkbook(stream); var data = await processMapReportWellDrillingService.GetAsync(idWell, cancellationToken); @@ -55,9 +55,10 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr private static void FillProcessMapToWorkbook(XLWorkbook workbook, IEnumerable data) { - var sheet = workbook.Worksheets.FirstOrDefault(); - if (sheet is null) - return; + const string sheetName = "Отчёт"; + + var sheet = workbook.GetWorksheet(sheetName); + var dataBySections = data.GroupBy(p => p.IdWellSectionType); FillSheet(sheet, dataBySections); } @@ -83,7 +84,7 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr sheet.Range(row, firstColumn, row, lastColumn) .Merge() .FirstCell() - .SetVal(sectionName) + .SetCellValue(sectionName) .Style .Fill.SetBackgroundColor(XLColor.LightGray); row++; @@ -102,17 +103,10 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr const int columnRopTime = firstColumn + 3; const int columnMode = firstColumn + 4; - sheet.Cell(row, firstColumn) - .SetVal(interval.DepthStart, "0.0"); - - sheet.Cell(row, columnDepth) - .SetVal(interval.DepthEnd, "0.0"); - - sheet.Cell(row, columnDate) - .SetVal(interval.DateStart); - - sheet.Cell(row, columnRopTime) - .SetVal(interval.MechDrillingHours); + sheet.Cell(row, firstColumn).SetCellValue(interval.DepthStart); + sheet.Cell(row, columnDepth).SetCellValue(interval.DepthEnd); + sheet.Cell(row, columnDate).SetCellValue(interval.DateStart); + sheet.Cell(row, columnRopTime).SetCellValue(interval.MechDrillingHours); row = FillIntervalModeData(sheet, interval, columnMode, row); @@ -131,25 +125,18 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr int columnUsageFact = columnUsagePlan + 1; int columnRop = columnUsageFact + 12; - sheet.Cell(row, column) - .SetVal(modeData.DrillingMode); - - sheet.Cell(row, columnDeltaDepth) - .SetVal(modeData.DeltaDepth); + sheet.Cell(row, column).SetCellValue(modeData.DrillingMode); + sheet.Cell(row, columnDeltaDepth).SetCellValue(modeData.DeltaDepth); + FillIntervalModeDataParam(sheet, modeData.PressureDiff, columnPressure, row); FillIntervalModeDataParam(sheet, modeData.AxialLoad, columnLoad, row); FillIntervalModeDataParam(sheet, modeData.TopDriveTorque, columnTorque, row); FillIntervalModeDataSpeed(sheet, modeData.SpeedLimit, columnSpeed, row); - sheet.Cell(row, columnUsagePlan) - .SetVal(modeData.UsagePlan); - - sheet.Cell(row, columnUsageFact) - .SetVal(modeData.UsageFact); - - sheet.Cell(row, columnRop) - .SetVal(modeData.Rop.Fact); + sheet.Cell(row, columnUsagePlan).SetCellValue(modeData.UsagePlan); + sheet.Cell(row, columnUsageFact).SetCellValue(modeData.UsageFact); + sheet.Cell(row, columnRop).SetCellValue(modeData.Rop.Fact); return row + 1; } @@ -163,20 +150,11 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr const int columnOffsetLimit = 3; const int columnOffsetPercent = 4; - sheet.Cell(row, column + columnOffsetSpPlan) - .SetVal(dataParam.SetpointPlan); - - sheet.Cell(row, column + columnOffsetSpFact) - .SetVal(dataParam.SetpointFact); - - sheet.Cell(row, column + columnOffsetFact) - .SetVal(dataParam.Fact); - - sheet.Cell(row, column + columnOffsetLimit) - .SetVal(dataParam.Limit); - - sheet.Cell(row, column + columnOffsetPercent) - .SetVal(dataParam.SetpointUsage, format: "0.0"); + sheet.Cell(row, column + columnOffsetSpPlan).SetCellValue(dataParam.SetpointPlan); + sheet.Cell(row, column + columnOffsetSpFact).SetCellValue(dataParam.SetpointFact); + sheet.Cell(row, column + columnOffsetFact).SetCellValue(dataParam.Fact); + sheet.Cell(row, column + columnOffsetLimit).SetCellValue(dataParam.Limit); + sheet.Cell(row, column + columnOffsetPercent).SetCellValue(dataParam.SetpointUsage); } private static void FillIntervalModeDataSpeed(IXLWorksheet sheet, @@ -188,22 +166,14 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr const int columnOffsetLimit = 3; const int columnOffsetPercent = 4; - sheet.Cell(row, column + columnOffsetSpPlan) - .SetVal(dataParam.SetpointPlan); - - sheet.Cell(row, column + columnOffsetSpFact) - .SetVal(dataParam.SetpointFact); - - sheet.Cell(row, column + columnOffsetFact) - .SetVal(dataParam.Fact); - - sheet.Cell(row, column + columnOffsetLimit) - .SetVal(dataParam.Limit); - - sheet.Cell(row, column + columnOffsetPercent) - .SetVal(dataParam.SetpointUsage, format: "0.0"); + sheet.Cell(row, column + columnOffsetSpPlan).SetCellValue(dataParam.SetpointPlan); + sheet.Cell(row, column + columnOffsetSpFact).SetCellValue(dataParam.SetpointFact); + sheet.Cell(row, column + columnOffsetFact).SetCellValue(dataParam.Fact); + sheet.Cell(row, column + columnOffsetLimit).SetCellValue(dataParam.Limit); + sheet.Cell(row, column + columnOffsetPercent).SetCellValue(dataParam.SetpointUsage); } + //TODO: использовать метод расширения, избавиться от этого метода private static Stream GetExcelTemplateStream() { var stream = Assembly.GetExecutingAssembly() @@ -213,6 +183,7 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr return stream!; } + //TODO: нужен ли этот метод? Это можно настроить в шаблоне private static void SetBorders(IXLStyle style) { style.Border.RightBorder = XLBorderStyleValues.Thin; diff --git a/AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingService.cs b/AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingService.cs index c0bcf61d..f322c798 100644 --- a/AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMaps/WellDrilling/ProcessMapPlanImportWellDrillingService.cs @@ -28,7 +28,7 @@ public class ProcessMapPlanImportWellDrillingService : IProcessMapPlanImportServ private const int headerRowsCount = 2; - private const int columnWellSectionType = 1; + private const int columnSection = 1; private const int columnMode = 2; private const int columnDepthStart = 3; private const int columnDepthEnd = 4; @@ -116,9 +116,8 @@ public class ProcessMapPlanImportWellDrillingService : IProcessMapPlanImportServ private void AddToWorkbook(XLWorkbook workbook, IEnumerable processMapPlanWellDrillings) { - var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNamePlan) - ?? throw new FileFormatException($"Книга excel не содержит листа {sheetNamePlan}."); - + var sheet = workbook.GetWorksheet(sheetNamePlan); + AddToSheet(sheet, processMapPlanWellDrillings.ToArray()); } @@ -136,31 +135,32 @@ public class ProcessMapPlanImportWellDrillingService : IProcessMapPlanImportServ private void AddToRow(IXLRow row, ProcessMapPlanWellDrillingDto processMapPlanWellDrillings) { - row.Cell(columnWellSectionType).Value = sections.First(x => x.Id == processMapPlanWellDrillings.IdWellSectionType).Caption; - row.Cell(columnMode).Value = GetModeCaption(processMapPlanWellDrillings.IdMode); - row.Cell(columnDepthStart).Value = processMapPlanWellDrillings.DepthStart; - row.Cell(columnDepthEnd).Value = processMapPlanWellDrillings.DepthEnd; - row.Cell(columnPressurePlan).Value = processMapPlanWellDrillings.Pressure.Plan; - row.Cell(columnPressureLimitMax).Value = processMapPlanWellDrillings.Pressure.LimitMax; - row.Cell(columnAxialLoadPlan).Value = processMapPlanWellDrillings.AxialLoad.Plan; - row.Cell(columnAxialLoadLimitMax).Value = processMapPlanWellDrillings.AxialLoad.LimitMax; - row.Cell(columnTopDriveTorquePlan).Value = processMapPlanWellDrillings.TopDriveTorque.Plan; - row.Cell(columnTopDriveTorqueLimitMax).Value = processMapPlanWellDrillings.TopDriveTorque.LimitMax; - row.Cell(columnTopDriveSpeedPlan).Value = processMapPlanWellDrillings.TopDriveSpeed.Plan; - row.Cell(columnTopDriveSpeedLimitMax).Value = processMapPlanWellDrillings.TopDriveSpeed.LimitMax; - row.Cell(columnFlowPlan).Value = processMapPlanWellDrillings.Flow.Plan; - row.Cell(columnFlowLimitMax).Value = processMapPlanWellDrillings.Flow.LimitMax; - row.Cell(columnRopPlan).Value = processMapPlanWellDrillings.RopPlan; - row.Cell(columnUsageSaub).Value = processMapPlanWellDrillings.UsageSaub; - row.Cell(columnUsageSpin).Value = processMapPlanWellDrillings.UsageSpin; - row.Cell(columnComment).Value = processMapPlanWellDrillings.Comment; + var section = sections.First(x => x.Id == processMapPlanWellDrillings.IdWellSectionType).Caption; + var modeCaption = GetModeCaption(processMapPlanWellDrillings.IdMode); + + row.Cell(columnSection).SetCellValue(section); + row.Cell(columnMode).SetCellValue(modeCaption); + row.Cell(columnDepthStart).SetCellValue(processMapPlanWellDrillings.DepthStart); + row.Cell(columnDepthEnd).SetCellValue(processMapPlanWellDrillings.DepthEnd); + row.Cell(columnPressurePlan).SetCellValue(processMapPlanWellDrillings.Pressure.Plan); + row.Cell(columnPressureLimitMax).SetCellValue(processMapPlanWellDrillings.Pressure.LimitMax); + row.Cell(columnAxialLoadPlan).SetCellValue(processMapPlanWellDrillings.AxialLoad.Plan); + row.Cell(columnAxialLoadLimitMax).SetCellValue(processMapPlanWellDrillings.AxialLoad.LimitMax); + row.Cell(columnTopDriveTorquePlan).SetCellValue(processMapPlanWellDrillings.TopDriveTorque.Plan); + row.Cell(columnTopDriveTorqueLimitMax).SetCellValue(processMapPlanWellDrillings.TopDriveTorque.LimitMax); + row.Cell(columnTopDriveSpeedPlan).SetCellValue(processMapPlanWellDrillings.TopDriveSpeed.Plan); + row.Cell(columnTopDriveSpeedLimitMax).SetCellValue(processMapPlanWellDrillings.TopDriveSpeed.LimitMax); + row.Cell(columnFlowPlan).SetCellValue(processMapPlanWellDrillings.Flow.Plan); + row.Cell(columnFlowLimitMax).SetCellValue(processMapPlanWellDrillings.Flow.LimitMax); + row.Cell(columnRopPlan).SetCellValue(processMapPlanWellDrillings.RopPlan); + row.Cell(columnUsageSaub).SetCellValue(processMapPlanWellDrillings.UsageSaub); + row.Cell(columnUsageSpin).SetCellValue(processMapPlanWellDrillings.UsageSpin); + row.Cell(columnComment).SetCellValue(processMapPlanWellDrillings.Comment); } private IEnumerable ParseWorkBook(IXLWorkbook workbook) { - var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNamePlan) - ?? throw new FileFormatException($"Книга excel не содержит листа {sheetNamePlan}."); - + var sheet = workbook.GetWorksheet(sheetNamePlan); return ParseSheet(sheet); } @@ -202,7 +202,7 @@ public class ProcessMapPlanImportWellDrillingService : IProcessMapPlanImportServ private ProcessMapPlanWellDrillingDto ParseRow(IXLRow row) { - var wellSectionTypeCaption = row.Cell(columnWellSectionType).GetCellValue()?.Trim().ToLower(); + var wellSectionTypeCaption = row.Cell(columnSection).GetCellValue()?.Trim().ToLower(); var modeName = row.Cell(columnMode).GetCellValue()?.Trim().ToLower(); var depthStart = row.Cell(columnDepthStart).GetCellValue(); var depthEnd = row.Cell(columnDepthEnd).GetCellValue(); @@ -337,7 +337,7 @@ public class ProcessMapPlanImportWellDrillingService : IProcessMapPlanImportServ { using var excelTemplateStream = (await GetExcelTemplateStreamAsync(cancellationToken)).File; - using var workbook = new XLWorkbook(excelTemplateStream, XLEventTracking.Disabled); + using var workbook = new XLWorkbook(excelTemplateStream); AddToWorkbook(workbook, processMapPlanWellDrillings); diff --git a/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryExportService.cs b/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryExportService.cs index fc075d12..6ac2bf15 100644 --- a/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryExportService.cs +++ b/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryExportService.cs @@ -53,7 +53,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory.Export private Stream MakeExelFileStream(IEnumerable trajectories) { using Stream ecxelTemplateStream = GetTemplateFile(); - using var workbook = new XLWorkbook(ecxelTemplateStream, XLEventTracking.Disabled); + using var workbook = new XLWorkbook(ecxelTemplateStream); AddTrajecoryToWorkbook(workbook, trajectories); MemoryStream memoryStream = new MemoryStream(); workbook.SaveAs(memoryStream, new SaveOptions { }); @@ -65,9 +65,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory.Export { if (trajectories.Any()) { - var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetName); - if (sheet is null) - throw new FileFormatException($"Лист с именем {sheetName} отсутствует, либо имеет некорректное название"); + var sheet = workbook.GetWorksheet(sheetName); AddTrajecoryToSheet(sheet, trajectories); } } diff --git a/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryFactManualExportService.cs b/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryFactManualExportService.cs index 8484fd3f..2662d62a 100644 --- a/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryFactManualExportService.cs +++ b/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryFactManualExportService.cs @@ -23,12 +23,12 @@ namespace AsbCloudInfrastructure.Services.Trajectory.Export protected override void AddCoordinatesToRow(IXLRow row, TrajectoryGeoFactDto trajectory) { - row.Cell(1).Value = trajectory.WellboreDepth; - row.Cell(2).Value = trajectory.ZenithAngle; - row.Cell(3).Value = trajectory.AzimuthGeo; - row.Cell(4).Value = trajectory.AzimuthMagnetic; - row.Cell(5).Value = trajectory.VerticalDepth; - row.Cell(6).Value = trajectory.Comment; + row.Cell(1).SetCellValue(trajectory.WellboreDepth); + row.Cell(2).SetCellValue(trajectory.ZenithAngle); + row.Cell(3).SetCellValue(trajectory.AzimuthGeo); + row.Cell(4).SetCellValue(trajectory.AzimuthMagnetic); + row.Cell(5).SetCellValue(trajectory.VerticalDepth); + row.Cell(6).SetCellValue(trajectory.Comment); } } } diff --git a/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryFactNnbExportService.cs b/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryFactNnbExportService.cs index e4548599..c32e6cff 100644 --- a/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryFactNnbExportService.cs +++ b/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryFactNnbExportService.cs @@ -23,12 +23,12 @@ namespace AsbCloudInfrastructure.Services.Trajectory.Export protected override void AddCoordinatesToRow(IXLRow row, TrajectoryGeoFactDto trajectory) { - row.Cell(1).Value = trajectory.WellboreDepth; - row.Cell(2).Value = trajectory.ZenithAngle; - row.Cell(3).Value = trajectory.AzimuthGeo; - row.Cell(4).Value = trajectory.AzimuthMagnetic; - row.Cell(5).Value = trajectory.VerticalDepth; - row.Cell(6).Value = trajectory.Comment; + row.Cell(1).SetCellValue(trajectory.WellboreDepth); + row.Cell(2).SetCellValue(trajectory.ZenithAngle); + row.Cell(3).SetCellValue(trajectory.AzimuthGeo); + row.Cell(4).SetCellValue(trajectory.AzimuthMagnetic); + row.Cell(5).SetCellValue(trajectory.VerticalDepth); + row.Cell(6).SetCellValue(trajectory.Comment); } } } diff --git a/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryPlanExportService.cs b/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryPlanExportService.cs index 2d1c1689..403ceccc 100644 --- a/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryPlanExportService.cs +++ b/AsbCloudInfrastructure/Services/Trajectory/Export/TrajectoryPlanExportService.cs @@ -24,13 +24,13 @@ namespace AsbCloudInfrastructure.Services.Trajectory.Export protected override void AddCoordinatesToRow(IXLRow row, TrajectoryGeoPlanDto trajectory) { - row.Cell(1).Value = trajectory.WellboreDepth; - row.Cell(2).Value = trajectory.ZenithAngle; - row.Cell(3).Value = trajectory.AzimuthGeo; - row.Cell(4).Value = trajectory.AzimuthMagnetic; - row.Cell(5).Value = trajectory.VerticalDepth; - row.Cell(6).Value = trajectory.Radius; - row.Cell(7).Value = trajectory.Comment; + row.Cell(1).SetCellValue(trajectory.WellboreDepth); + row.Cell(2).SetCellValue(trajectory.ZenithAngle); + row.Cell(3).SetCellValue(trajectory.AzimuthGeo); + row.Cell(4).SetCellValue(trajectory.AzimuthMagnetic); + row.Cell(5).SetCellValue(trajectory.VerticalDepth); + row.Cell(6).SetCellValue(trajectory.Radius); + row.Cell(7).SetCellValue(trajectory.Comment); } } diff --git a/AsbCloudInfrastructure/Services/Trajectory/Parser/TrajectoryParserService.cs b/AsbCloudInfrastructure/Services/Trajectory/Parser/TrajectoryParserService.cs index d0afe513..b306e602 100644 --- a/AsbCloudInfrastructure/Services/Trajectory/Parser/TrajectoryParserService.cs +++ b/AsbCloudInfrastructure/Services/Trajectory/Parser/TrajectoryParserService.cs @@ -32,11 +32,9 @@ public abstract class TrajectoryParserService : ParserServiceBase Parse(Stream file, IParserOptionsRequest options) { - using var workbook = new XLWorkbook(file, XLEventTracking.Disabled); + using var workbook = new XLWorkbook(file); - var sheet = workbook.Worksheets.FirstOrDefault(ws => - ws.Name.ToLower().Trim() == SheetName.ToLower().Trim()) - ?? throw new FileFormatException($"Книга excel не содержит листа {SheetName}."); + var sheet = workbook.GetWorksheet(SheetName); var trajectoryRows = ParseExcelSheet(sheet, ParseRow, ColumnCount, HeaderRowsCount); return trajectoryRows; diff --git a/AsbCloudInfrastructure/Services/WellOperationImport/FileParser/WellOperationDefaultExcelParser.cs b/AsbCloudInfrastructure/Services/WellOperationImport/FileParser/WellOperationDefaultExcelParser.cs index 8fd86f2c..2996d642 100644 --- a/AsbCloudInfrastructure/Services/WellOperationImport/FileParser/WellOperationDefaultExcelParser.cs +++ b/AsbCloudInfrastructure/Services/WellOperationImport/FileParser/WellOperationDefaultExcelParser.cs @@ -15,7 +15,7 @@ public class WellOperationDefaultExcelParser : IWellOperationExcelParser - string.Equals(ws.Name, sheetName, StringComparison.CurrentCultureIgnoreCase)) - ?? throw new FileFormatException($"Книга excel не содержит листа '{sheetName}'"); + var sheet = workbook.GetWorksheet(sheetName); return ParseSheet(sheet); } diff --git a/AsbCloudInfrastructure/Services/WellOperationImport/FileParser/WellOperationGazpromKhantosExcelParser.cs b/AsbCloudInfrastructure/Services/WellOperationImport/FileParser/WellOperationGazpromKhantosExcelParser.cs index 1b41ebd3..7eb62839 100644 --- a/AsbCloudInfrastructure/Services/WellOperationImport/FileParser/WellOperationGazpromKhantosExcelParser.cs +++ b/AsbCloudInfrastructure/Services/WellOperationImport/FileParser/WellOperationGazpromKhantosExcelParser.cs @@ -38,7 +38,7 @@ public class WellOperationGazpromKhantosExcelParser : IWellOperationExcelParser< public SheetDto Parse(Stream stream, WellOperationImportGazpromKhantosOptionsDto options) { - using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled); + using var workbook = new XLWorkbook(stream); return ParseWorkBook(workbook, options); } @@ -54,10 +54,7 @@ public class WellOperationGazpromKhantosExcelParser : IWellOperationExcelParser< if (options.EndRow < options.StartRow) throw new ArgumentInvalidException(nameof(options.EndRow), "Конечный номер строки не может быть больше начального"); - var sheet = workbook.Worksheets.FirstOrDefault(ws => - string.Equals(ws.Name, options.SheetName, StringComparison.CurrentCultureIgnoreCase)) - ?? throw new FileFormatException($"Книга excel не содержит листа '{options.SheetName}'"); - + var sheet = workbook.GetWorksheet(options.SheetName); return ParseSheet(sheet, options.StartRow, options.EndRow); } diff --git a/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationExportService.cs b/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationExportService.cs index e4ffd14e..89cf1494 100644 --- a/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationExportService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationExportService.cs @@ -15,6 +15,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationImport; public class WellOperationExportService : IWellOperationExportService { + //TODO: удалить неиспользуемую зависимость private readonly IWellOperationRepository wellOperationRepository; private readonly IWellService wellService; private readonly IWellOperationImportTemplateService wellOperationImportTemplateService; @@ -42,7 +43,7 @@ public class WellOperationExportService : IWellOperationExportService { using Stream ecxelTemplateStream = wellOperationImportTemplateService.GetExcelTemplateStream(); - using var workbook = new XLWorkbook(ecxelTemplateStream, XLEventTracking.Disabled); + using var workbook = new XLWorkbook(ecxelTemplateStream); AddOperationsToWorkbook(workbook, operations); var memoryStream = new MemoryStream(); @@ -56,17 +57,17 @@ public class WellOperationExportService : IWellOperationExportService var planOperations = operations.Where(o => o.IdType == 0); if (planOperations.Any()) { - var sheetPlan = workbook.Worksheets.FirstOrDefault(ws => ws.Name == DefaultTemplateInfo.SheetNamePlan); - if (sheetPlan is not null) - AddOperationsToSheet(sheetPlan, planOperations); + var sheetPlan = workbook.GetWorksheet(DefaultTemplateInfo.SheetNamePlan); + + AddOperationsToSheet(sheetPlan, planOperations); } var factOperations = operations.Where(o => o.IdType == 1); if (factOperations.Any()) { - var sheetFact = workbook.Worksheets.FirstOrDefault(ws => ws.Name == DefaultTemplateInfo.SheetNameFact); - if (sheetFact is not null) - AddOperationsToSheet(sheetFact, factOperations); + var sheetFact = workbook.GetWorksheet(DefaultTemplateInfo.SheetNameFact); + + AddOperationsToSheet(sheetFact, factOperations); } } @@ -87,13 +88,16 @@ public class WellOperationExportService : IWellOperationExportService private static void AddOperationToRow(IXLRow row, WellOperationDto operation, IEnumerable sections, IEnumerable categories) { - row.Cell(DefaultTemplateInfo.ColumnSection).Value = sections.First(s => s.Id == operation.IdWellSectionType).Caption; - row.Cell(DefaultTemplateInfo.ColumnCategory).Value = categories.First(o => o.Id == operation.IdCategory).Name; - row.Cell(DefaultTemplateInfo.ColumnCategoryInfo).Value = operation.CategoryInfo; - row.Cell(DefaultTemplateInfo.ColumnDepthStart).Value = operation.DepthStart; - row.Cell(DefaultTemplateInfo.ColumnDepthEnd).Value = operation.DepthEnd; - row.Cell(DefaultTemplateInfo.ColumnDate).Value = operation.DateStart; - row.Cell(DefaultTemplateInfo.ColumnDuration).Value = operation.DurationHours; - row.Cell(DefaultTemplateInfo.ColumnComment).Value = operation.Comment; + var sectionCaption = sections.First(s => s.Id == operation.IdWellSectionType).Caption; + var categoryName = categories.First(o => o.Id == operation.IdCategory).Name; + + row.Cell(DefaultTemplateInfo.ColumnSection).SetCellValue(sectionCaption); + row.Cell(DefaultTemplateInfo.ColumnCategory).SetCellValue(categoryName); + row.Cell(DefaultTemplateInfo.ColumnCategoryInfo).SetCellValue(operation.CategoryInfo); + row.Cell(DefaultTemplateInfo.ColumnDepthStart).SetCellValue(operation.DepthStart); + row.Cell(DefaultTemplateInfo.ColumnDepthEnd).SetCellValue(operation.DepthEnd); + row.Cell(DefaultTemplateInfo.ColumnDate).SetCellValue(operation.DateStart); + row.Cell(DefaultTemplateInfo.ColumnDuration).SetCellValue(operation.DurationHours); + row.Cell(DefaultTemplateInfo.ColumnComment).SetCellValue(operation.Comment); } } \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportService.cs b/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportService.cs index f1c44ec3..39ad3cd6 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/ScheduleReportService.cs @@ -37,7 +37,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService ?? throw new ArgumentInvalidException(nameof(idWell), "idWell doesn`t exist"); var ecxelTemplateStream = GetExcelTemplateStream(); - using var workbook = new XLWorkbook(ecxelTemplateStream, XLEventTracking.Disabled); + using var workbook = new XLWorkbook(ecxelTemplateStream); FillScheduleSheetToWorkbook(workbook, tvd, well); FillTvdSheetToWorkbook(workbook, tvd, well); MemoryStream memoryStream = new MemoryStream(); @@ -72,9 +72,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService private static void FillCurrentScheduleSheet(XLWorkbook workbook, IEnumerable tvdList, string sheetName) { - var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetName); - if (sheet is null) - return; + var sheet = workbook.GetWorksheet(sheetName); const int headerRowsCount = 6; @@ -103,9 +101,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService private static void FillScheduleSheet(XLWorkbook workbook, IEnumerable> tvd, WellDto well) { - var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNameSchedule); - if (sheet is null) - return; + var sheet = workbook.GetWorksheet(sheetNameSchedule); const int headerRowsCount = 6; const int rowTitle = 3; @@ -132,7 +128,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService const int columnNpt = 21; var subTitle = $"на строительство скважины №{well.Caption}, куст: {well.Cluster}, м/р: {well.Deposit}"; - sheet.Row(rowTitle).Cell(3).Value = subTitle; + sheet.Row(rowTitle).Cell(3).SetCellValue(subTitle); var tvdList = tvd.ToList(); var facts = tvd @@ -228,7 +224,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService var rowSummary = sheet.Row(rowNumSummary); rowSummary.Style.Font.Bold = true; - rowSummary.Cell(columnCaption).Value = "Итого:"; + rowSummary.Cell(columnCaption).SetCellValue("Итого:"); AddRangeFormula(rowSummary, "sum", columnDeltaWellDepthPerDay); AddRangeFormula(rowSummary, "sum", columnDurationPlan); @@ -241,9 +237,8 @@ namespace AsbCloudInfrastructure.Services.WellOperationService SetBorder(rowSummary.Cells(true).Style); var rowSummary2 = sheet.Row(rowNumSummary + 1); - rowSummary2.DataType = XLDataType.Number; rowSummary2.Style.NumberFormat.Format = "0,00"; - rowSummary2.Cell(columnCaption).Value = "в сутках:"; + rowSummary2.Cell(columnCaption).SetCellValue("в сутках:"); rowSummary2.Cell(columnDurationPlan).FormulaA1 = $"={GetColunmLetter(columnDurationPlan)}{rowNumSummary}/24"; SetNumber(rowSummary2.Cell(columnDurationPlan)); rowSummary2.Cell(columnDurationFact).FormulaA1 = $"={GetColunmLetter(columnDurationFact)}{rowNumSummary}/24"; @@ -255,9 +250,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService private static void FillTvdSheetToWorkbook(XLWorkbook workbook, IEnumerable> tvd, WellDto well) { - var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNameTvd); - if (sheet is null) - return; + var sheet = workbook.GetWorksheet(sheetNameTvd); const int rowTitle = 2; const int rowSubtitle = 3; @@ -346,14 +339,12 @@ namespace AsbCloudInfrastructure.Services.WellOperationService private static IXLCell SetDateTime(IXLCell cell) { - cell.DataType = XLDataType.DateTime; cell.Style.DateFormat.Format = "DD.MM.YYYY HH:MM:SS"; return cell; } private static IXLCell SetNumber(IXLCell cell) { - cell.DataType = XLDataType.Number; cell.Style.NumberFormat.Format = "0.00"; return cell; } @@ -361,7 +352,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService private static IXLCell SetCell(IXLRow row, int colunm, object? value) { var cell = row.Cell(colunm); - cell.Value = value; + cell.SetCellValue(value); SetBorder(cell.Style); cell.Style.Alignment.WrapText = true;