DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs
IvanovEugeniy 94ebf6bfb9 Edit daily report MakerExcel - изменение логики построения отчета
модели ДТО и БД разбиты на 6 блоков
изменен сервис DailyReport

Тестовая таблица в консольном проекте
2022-06-17 13:20:48 +05:00

884 lines
38 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using AsbCloudApp.Data;
using AsbCloudApp.Data.DailyReportModel;
using ClosedXML.Excel;
using System;
using System.IO;
using System.Linq;
namespace AsbCloudInfrastructure.Services.DailyReport
{
public class DailyReportMakerExcel
{
// черновик реализации отчета "по блокам"
public Stream MakeReportFromBlocks(DailyReportHeadDto blockHead, DailyReportBhaDto blockBha, DailyReportDimensionlessDto blockDimensionless, DailyReportSaubDto blockSaub, DailyReportSignDto blockSign)
{
using var workbook = new XLWorkbook();
FillSheet6blocks(workbook, blockHead, blockBha, blockDimensionless, blockSaub, blockSign);
MemoryStream memoryStream = new MemoryStream();
workbook.SaveAs(memoryStream, new SaveOptions { });
memoryStream.Seek(0, SeekOrigin.Begin);
return memoryStream;
}
private String converteCellCoordinate(int row, bool isCaps, int column)
{
var c = (Char)((isCaps ? 65 : 97) + (column - 1));
string convertColumn = c.ToString();
return $"{convertColumn}{row}";
}
public void FillSheet6blocks(XLWorkbook workbook, DailyReportHeadDto blockHead, DailyReportBhaDto blockBha, DailyReportDimensionlessDto blockDimensionless, DailyReportSaubDto blockSaub, DailyReportSignDto blockSign)
{
var sheet = workbook.Worksheets.First();
sheet.Name = blockHead.ReportDate.ToString("dd.MM.yyyy");
var tuple = (row: 3, column: 3);
tuple = (AddBlockHead1(sheet, blockHead,(tuple.row,tuple.column)).row , AddBlockHead1(sheet, blockHead, (tuple.row, tuple.column)).column);
AddBlockBha(sheet, blockBha);
AddBlockTimeBalance(sheet);
AddBlockDimensionless(sheet, blockDimensionless);
AddBlockSaub(sheet, blockSaub);
AddBlockSign(sheet, blockSign);
}
//
private (int row, int column) AddBlockHead1(IXLWorksheet sheet, DailyReportHeadDto blockDto, (int row, int column) tupleStart)
{
var tuple = (row: tupleStart.row, column: tupleStart.column);
sheet.Cell(tuple.row, tuple.column).Value =
$"Суточная сводка бурения скважины: {blockDto.WellName}, куст: {blockDto.ClusterName}";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 7).Merge();
//4
tuple.row += 1;
sheet.Cell(tuple.row, tuple.column).Value =
$"Заказчик: {blockDto.Customer}";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 7).Merge();
tuple.row += 1;
sheet.Cell(tuple.row, tuple.column).Value =
$"Подрядчик: {blockDto.Contractor}";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 7).Merge();
tuple.row += 2;
//7,3
sheet.Cell(tuple.row, tuple.column).Value = "Отчетный период";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 3).Merge();
tuple.column += 4;
sheet.Cell(tuple.row, tuple.column).Value = "Забой за отчетный период, м";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 3).Merge();
tuple.column = tupleStart.column;
tuple.row += 1;
//8,3
sheet.Cell(tuple.row, tuple.column).Value = "От (дата, время)";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 1).Merge();
tuple.column += 2; //8,5
sheet.Cell(tuple.row, tuple.column).Value = "До (дата, время)";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 1).Merge();
tuple.column += 2; //8,7
sheet.Cell(tuple.row, tuple.column).Value = "От";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 1).Merge();
tuple.column += 2; //8,9
sheet.Cell(tuple.row, tuple.column).Value = "До";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 1).Merge();
tuple.column = tupleStart.column;
tuple.row += 1; //9,3
sheet.Cell(tuple.row, tuple.column).Value = $"{blockDto.ReportDate}";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column+2).Merge();
tuple.column += 2;
//согласно формуле в шаблоне - ячейка С9
sheet.Cell(tuple.row, tuple.column).FormulaA1 = $"={converteCellCoordinate(tuple.row , true, tuple.column)}-1";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 2).Merge();
tuple.column += 2;
sheet.Cell(tuple.row, tuple.column).Value = $"{blockDto.WellDepthIntervalStartDate}";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 2).Merge();
tuple.column += 2;
sheet.Cell(tuple.row, tuple.column).Value = $"{blockDto.WellDepthIntervalFinishDate}";
sheet.Range(tuple.row, tuple.column, tuple.row, tuple.column + 2).Merge();
tuple.column = tupleStart.column;
tuple.row += 2; //11,3
sheet.Cell(tuple.Item1 + 8, tuple.Item2).Value = "Данные по траектории скважины на конец суток";
sheet.Range(tuple.Item1 + 8, tuple.Item2, tuple.Item1 + 8, tuple.Item2+7).Merge();
sheet.Cell(tuple.Item1 + 9, tuple.Item2).Value = "Глубина по стволу";
sheet.Range(tuple.Item1 + 9, tuple.Item2, tuple.Item1 + 9, tuple.Item2+1).Merge();
sheet.Cell(13, 3).Value = $"{blockDto.BottomholeDepth}";
sheet.Range(13, 3, 13, 4).Merge();
sheet.Cell(12, 5).Value = "Глубина по вертикали";
sheet.Range(12, 5, 12, 6).Merge();
sheet.Cell(13, 5).Value = $"{blockDto.VerticalDepth}";
sheet.Range(13, 5, 13, 6).Merge();
sheet.Cell(12, 7).Value = "Зенитный угол";
sheet.Range(12, 7, 12, 8).Merge();
sheet.Cell(13, 7).Value = $"{blockDto.ZenithAngle}";
sheet.Range(13, 7, 13, 8).Merge();
sheet.Cell(12, 9).Value = "Азимут";
sheet.Range(12, 9, 12, 10).Merge();
sheet.Cell(13, 9).Value = $"{blockDto.AzimuthAngle}";
sheet.Range(13, 9, 13, 10).Merge();
sheet.Cell(15, 3).Value = "Бурильщик 1 смена";
sheet.Range(15, 3, 15, 4).Merge();
sheet.Cell(15, 5).Value = $"{blockDto.FirstDriller}";
sheet.Range(15, 6, 15, 7).Merge();
sheet.Cell(16, 3).Value = "Бурильщик 2 смена";
sheet.Range(16, 3, 16, 4).Merge();
sheet.Cell(16, 5).Value = $"{blockDto.SecondDriller}";
sheet.Range(16, 6, 16, 7).Merge();
sheet.Cell(18, 3).Value = "Работа модулей САУБ:";
sheet.Range(18, 3, 15, 5).Merge();
sheet.Cell(18, 6).Value = "Часов:";
sheet.Cell(18, 7).Value = "Метров:";
sheet.Cell(19, 3).Value = "АПД (автоматическая подача долота), ч/м:";
sheet.Range(19, 3, 19, 5).Merge();
sheet.Cell(19, 6).Value = $"{blockDto.WorkTimeSAUB}";
sheet.Cell(19, 7).Value = $"{blockDto.PenetrationSAUB}";
sheet.Cell(20, 3).Value = "Спин Мастер (осцилляция),ч/м:";
sheet.Range(20, 3, 20, 5).Merge();
sheet.Cell(20, 6).Value = $"{blockDto.WorkTimeSpinMaster}";
sheet.Cell(20, 7).Value = $"{blockDto.PenetrationSpinMaster}";
sheet.Cell(21, 3).Value = "Торк Мастер (демпфирование), ч/:";
sheet.Range(21, 3, 21, 5).Merge();
sheet.Cell(21, 6).Value = $"{blockDto.WorkTimeTorkMaster}";
sheet.Cell(21, 7).Value = $"{blockDto.PenetrationTorkMaster}";
sheet.Cell(22, 3).Value = "МСЕ, колличество запусков, раз:";
sheet.Range(22, 3, 22, 5).Merge();
sheet.Cell(22, 6).Value = $"{blockDto.CountLaunchesMSE}";
sheet.Range(22, 6, 22, 7).Merge();
return (tuple.row, tuple.column);
}
//
private void AddBlockHead(IXLWorksheet sheet, DailyReportHeadDto blockDto)
{
sheet.Cell(3, 3).Value =
$"Суточная сводка бурения скважины №{blockDto.WellName}, куст: {blockDto.ClusterName}";
sheet.Cell(4, 3).Value =
$"Заказчик: {blockDto.Customer}";
sheet.Cell(5, 3).Value =
$"Подрядчик: {blockDto.Contractor}";
sheet.Cell(7, 3).Value = "Отчетный период";
sheet.Range(7, 3, 7, 6).Merge();
sheet.Cell(7, 7).Value = "Забой за отчетный период, м";
sheet.Range(7, 7, 7, 10).Merge();
sheet.Cell(8, 3).Value = "От (дата, время)";
sheet.Range(8, 3, 8, 4).Merge();
sheet.Cell(9, 3).Value = $"{blockDto.ReportDate}";
sheet.Range(9, 3, 9, 4).Merge();
sheet.Cell(8, 5).Value = "До (дата, время)";
sheet.Range(8, 5, 8, 6).Merge();
sheet.Cell(9, 5).Value = "=C9+1";
sheet.Range(9, 5, 9, 6).Merge();
sheet.Cell(8, 7).Value = "От";
sheet.Range(8, 7, 8, 8).Merge();
sheet.Cell(9, 7).Value = $"{blockDto.WellDepthIntervalStartDate}";
sheet.Range(9, 7, 9, 8).Merge();
sheet.Cell(8, 9).Value = "До";
sheet.Range(8, 9, 8, 10).Merge();
sheet.Cell(9, 9).Value = $"{blockDto.WellDepthIntervalFinishDate}";
sheet.Range(9, 9, 9, 10).Merge();
sheet.Cell(11, 3).Value = "Данные по траектории скважины на конец суток";
sheet.Range(11, 3, 11, 10).Merge();
sheet.Cell(12, 3).Value = "Глубина по стволу";
sheet.Range(12, 3, 12, 4).Merge();
sheet.Cell(13, 3).Value = $"{blockDto.BottomholeDepth}";
sheet.Range(13, 3, 13, 4).Merge();
sheet.Cell(12, 5).Value = "Глубина по вертикали";
sheet.Range(12, 5, 12, 6).Merge();
sheet.Cell(13, 5).Value = $"{blockDto.VerticalDepth}";
sheet.Range(13, 5, 13, 6).Merge();
sheet.Cell(12, 7).Value = "Зенитный угол";
sheet.Range(12, 7, 12, 8).Merge();
sheet.Cell(13, 7).Value = $"{blockDto.ZenithAngle}";
sheet.Range(13, 7, 13, 8).Merge();
sheet.Cell(12, 9).Value = "Азимут";
sheet.Range(12, 9, 12, 10).Merge();
sheet.Cell(13, 9).Value = $"{blockDto.AzimuthAngle}";
sheet.Range(13, 9, 13, 10).Merge();
sheet.Cell(15, 3).Value = "Бурильщик 1 смена";
sheet.Range(15, 3, 15, 4).Merge();
sheet.Cell(15, 5).Value = $"{blockDto.FirstDriller}";
sheet.Range(15, 6, 15, 7).Merge();
sheet.Cell(16, 3).Value = "Бурильщик 2 смена";
sheet.Range(16, 3, 16, 4).Merge();
sheet.Cell(16, 5).Value = $"{blockDto.SecondDriller}";
sheet.Range(16, 6, 16, 7).Merge();
sheet.Cell(18, 3).Value = "Работа модулей САУБ:";
sheet.Range(18, 3, 15, 5).Merge();
sheet.Cell(18, 6).Value = "Часов:";
sheet.Cell(18, 7).Value = "Метров:";
sheet.Cell(19, 3).Value = "АПД (автоматическая подача долота), ч/м:";
sheet.Range(19, 3, 19, 5).Merge();
sheet.Cell(19, 6).Value = $"{blockDto.WorkTimeSAUB}";
sheet.Cell(19, 7).Value = $"{blockDto.PenetrationSAUB}";
sheet.Cell(20, 3).Value = "Спин Мастер (осцилляция),ч/м:";
sheet.Range(20, 3, 20, 5).Merge();
sheet.Cell(20, 6).Value = $"{blockDto.WorkTimeSpinMaster}";
sheet.Cell(20, 7).Value = $"{blockDto.PenetrationSpinMaster}";
sheet.Cell(21, 3).Value = "Торк Мастер (демпфирование), ч/:";
sheet.Range(21, 3, 21, 5).Merge();
sheet.Cell(21, 6).Value = $"{blockDto.WorkTimeTorkMaster}";
sheet.Cell(21, 7).Value = $"{blockDto.PenetrationTorkMaster}";
sheet.Cell(22, 3).Value = "МСЕ, колличество запусков, раз:";
sheet.Range(22, 3, 22, 5).Merge();
sheet.Cell(22, 6).Value = $"{blockDto.CountLaunchesMSE}";
sheet.Range(22, 6, 22, 7).Merge();
}
private void AddBlockBha(IXLWorksheet sheet, DailyReportBhaDto blockDto)
{
sheet.Cell(24, 3).Value =
$"{blockDto.BHADescription}";
sheet.Range(24, 3, 24, 10).Merge();
sheet.Cell(26, 3).Value =
"Выполняемые операции в отчетный период, комментарии:";
sheet.Range(26, 3, 26, 7).Merge();
sheet.Cell(26, 8).Value = "Продолжительность, ч. ";
sheet.Range(26, 8, 26, 9).Merge();
sheet.Cell(26, 10).Value = "Итого";
sheet.Cell(27, 3).Value =
"Бурение с наращиваниями в инт. 2195-2763м.";
sheet.Range(27, 3, 27, 7).Merge();
sheet.Cell(27, 8).Value = "";
sheet.Cell(27, 9).Value = "";
sheet.Cell(27, 10).Value = "=IF(I27>0;(I27-H27)*24;\"\")";
sheet.Cell(28, 3).Value =
"Промывка.";
sheet.Range(28, 3, 28, 7).Merge();
sheet.Cell(28, 8).Value = "";
sheet.Cell(28, 9).Value = "";
sheet.Cell(28, 10).Value = "=IF(I28>0;(I28-H28)*24;\"\")";
sheet.Cell(29, 3).Value =
"Подъем КНБК в инт. 2763-2442м.";
sheet.Range(29, 3, 29, 7).Merge();
sheet.Cell(29, 8).Value = "";
sheet.Cell(29, 9).Value = "";
sheet.Cell(29, 10).Value = "=IF(I29>0;(I29-H29)*24;\"\")";
sheet.Cell(30, 3).Value =
"Спуск КНБК в инт. 2442-2763м.";
sheet.Range(30, 3, 30, 7).Merge();
sheet.Cell(30, 8).Value = "";
sheet.Cell(30, 9).Value = "";
sheet.Cell(30, 10).Value = "=IF(I30>0;(I30-H30)*24;\"\")";
sheet.Cell(27, 3).Value =
"Бурение с наращиваниями в инт. 2763-2850м.";
sheet.Range(31, 3, 31, 7).Merge();
sheet.Cell(31, 8).Value = "";
sheet.Cell(31, 9).Value = "";
sheet.Cell(31, 10).Value = "=IF(I31>0;(I31-H31)*24;\"\")";
}
private void AddBlockTimeBalance(IXLWorksheet sheet)
{
sheet.Cell(33, 6).Value =
"БАЛАНС ВРЕМЕНИ";
sheet.Range(33, 6, 33, 7).Merge();
sheet.Cell(34, 4).Value =
"Бурение";
sheet.Cell(34, 5).Value =
"";
sheet.Cell(34, 6).Value =
"КНБК";
sheet.Cell(34, 7).Value =
"";
sheet.Cell(34, 8).Value =
"ОЗЦ";
sheet.Cell(34, 9).Value =
"";
sheet.Cell(35, 4).Value =
"Промывка";
sheet.Cell(35, 5).Value =
"";
sheet.Cell(35, 6).Value =
"СПО";
sheet.Cell(35, 7).Value =
"";
sheet.Cell(35, 8).Value =
"Тех. работы";
sheet.Cell(35, 9).Value =
"";
sheet.Cell(36, 4).Value =
"Наращивание";
sheet.Cell(36, 5).Value =
"";
sheet.Cell(36, 6).Value =
"ПЗР";
sheet.Cell(36, 7).Value =
"";
sheet.Cell(36, 8).Value =
"Снятие замера";
sheet.Cell(36, 9).Value =
"";
sheet.Cell(37, 4).Value =
"Проработка";
sheet.Cell(37, 5).Value =
"";
sheet.Cell(37, 6).Value =
"ПВО";
sheet.Cell(37, 7).Value =
"";
sheet.Cell(37, 8).Value =
"Цементирование";
sheet.Cell(37, 9).Value =
"";
sheet.Cell(38, 4).Value =
"Расширка";
sheet.Cell(38, 5).Value =
"";
sheet.Cell(38, 6).Value =
"ПГР";
sheet.Cell(38, 7).Value =
"";
sheet.Cell(38, 8).Value =
"Простой";
sheet.Cell(38, 9).Value =
"";
sheet.Cell(39, 4).Value =
"Ремонт ";
sheet.Cell(39, 5).Value =
"";
sheet.Cell(39, 6).Value =
"ГИС";
sheet.Cell(39, 7).Value =
"";
sheet.Cell(39, 8).Value =
"НПВ";
sheet.Cell(39, 9).Value =
"";
}
private void AddBlockDimensionless(IXLWorksheet sheet, DailyReportDimensionlessDto blockDto)
{
sheet.Cell(41, 6).Value =
"БЕЗМЕТРАЖНЫЕ РАБОТЫ";
sheet.Range(41, 6, 41, 7).Merge();
sheet.Cell(42, 4).Value =
"Подготовка ствола скв. к наращиванию";
sheet.Range(42, 4, 42, 6).Merge();
sheet.Cell(42, 7).Value =
"Наращивание";
sheet.Range(42, 7, 42, 9).Merge();
sheet.Cell(43, 4).Value =
"Норматив на одну операцию, (мин):";
sheet.Range(43, 4, 43, 5).Merge();
sheet.Cell(43, 6).Value =
$"{blockDto.StandardTimeBarrelPreparation}";
sheet.Cell(43, 7).Value =
"Норматив на одну операцию, (мин):";
sheet.Range(43, 7, 43, 8).Merge();
sheet.Cell(43, 9).Value =
$"{blockDto.StandardTimeExtension}";
sheet.Cell(44, 4).Value =
"Проработка при бур, план (ч):";
sheet.Range(44, 4, 44, 5).Merge();
sheet.Cell(44, 6).Value =
"=F43/60*G72";
sheet.Cell(44, 7).Value =
"Наращивание, план (ч):";
sheet.Range(44, 7, 44, 8).Merge();
sheet.Cell(44, 9).Value =
"=I43/60*G72";
sheet.Cell(45, 4).Value =
"Проработка при бур, факт (ч):";
sheet.Range(45, 4, 45, 5).Merge();
sheet.Cell(45, 6).Value =
$"{blockDto.ActualTimeBarrelPreparation}";
sheet.Cell(45, 7).Value =
"Наращивание, факт (ч):";
sheet.Range(45, 7, 45, 8).Merge();
sheet.Cell(45, 9).Value =
$"{blockDto.ActualTimeExtension}";
sheet.Cell(46, 4).Value =
"Превышение плановых норм, (ч):";
sheet.Range(46, 4, 46, 5).Merge();
sheet.Cell(46, 6).Value =
"=F45-F44";
sheet.Cell(46, 7).Value =
"Превышение плановых норм, (ч):";
sheet.Range(46, 7, 46, 8).Merge();
sheet.Cell(46, 9).Value =
"=I45-I44";
sheet.Cell(47, 4).Value =
"Краткие причины: доп проработки при переходе из слайда в ротор, в середине свечи.";
sheet.Range(47, 4, 48, 6).Merge();
sheet.Cell(47, 7).Value =
"Краткие причины: нехватка пальцев на обоих руках у первого помощника бурильщика.";
sheet.Range(47, 7, 48, 9).Merge();
}
//private (int,int) AddBlockSaub(IXLWorksheet sheet, Tuple<int,int> startRow, DailyReportBlock5 blockDto)
private void AddBlockSaub(IXLWorksheet sheet, DailyReportSaubDto blockDto)
{
sheet.Cell(50, 3).Value =
$"Бурение в роторе : {blockDto.RotorDrillingModes}";
sheet.Range(50, 4, 50, 10).Merge();
sheet.Cell(50, 3).Value =
$"Бурение в слайде : {blockDto.SlideDrillingModes}";
sheet.Range(50, 4, 50, 10).Merge();
sheet.Cell(53, 3).Value = "Бурение в роторе (за отчетный период) с использование САУБ-1";
sheet.Range(53, 3, 53, 10).Merge();
sheet.Cell(54, 3).Value = "Проходка";
sheet.Range(54, 3, 54, 4).Merge();
sheet.Cell(55, 3).Value = $"{blockDto.PenetrationInRotor}";
sheet.Range(55, 3, 55, 4).Merge();
sheet.Cell(54, 5).Value = "Часы бурения";
sheet.Range(54, 5, 54, 6).Merge();
sheet.Cell(55, 5).Value = $"{blockDto.NumberDrillingHours}";
sheet.Range(55, 5, 55, 6).Merge();
sheet.Cell(54, 7).Value = "Мех. скорость";
sheet.Range(54, 7, 54, 8).Merge();
sheet.Cell(55, 7).Value = "=IF(E55>0;C55/E55;0)";
sheet.Range(55, 7, 55, 8).Merge();
sheet.Cell(54, 9).Value = "Среднее диф. Давление";
sheet.Range(54, 9, 54, 10).Merge();
sheet.Cell(55, 9).Value = $"{blockDto.AVGDiffDropRotor}";
sheet.Range(55, 9, 55, 10).Merge();
sheet.Cell(57, 3).Value = "Бурение в слайде (за отчетный период) с использование САУБ-1";
sheet.Range(57, 3, 57, 10).Merge();
sheet.Cell(58, 3).Value = "Проходка";
sheet.Range(58, 3, 58, 4).Merge();
sheet.Cell(59, 3).Value = $"{blockDto.PenetrationInSlide}";
sheet.Range(59, 3, 59, 4).Merge();
sheet.Cell(58, 5).Value = "Часы бурения";
sheet.Range(58, 5, 58, 6).Merge();
sheet.Cell(59, 5).Value = $"{blockDto.DrillingTimeInRotor}";
sheet.Range(59, 5, 59, 6).Merge();
sheet.Cell(58, 7).Value = "Мех. скорость";
sheet.Range(58, 7, 58, 8).Merge();
sheet.Cell(59, 7).Value = "=IF(E59>0;C59/E59;0)";
sheet.Range(59, 7, 59, 8).Merge();
sheet.Cell(58, 9).Value = "Среднее диф. Давление";
sheet.Range(58, 9, 58, 10).Merge();
sheet.Cell(59, 9).Value = $"{blockDto.AVGDiffPressureSlide}";
sheet.Range(59, 9, 59, 10).Merge();
sheet.Cell(61, 3).Value = "Итого за отчетный период, использование САУБ-1";
sheet.Range(61, 3, 61, 8).Merge();
sheet.Cell(62, 3).Value = "Проходка";
sheet.Range(62, 3, 62, 4).Merge();
sheet.Cell(63, 3).Value = "=IF((C59+C55)<>(I9-G9);\"ОШИБКА\";C55+C59)";
sheet.Range(63, 3, 63, 4).Merge();
sheet.Cell(62, 5).Value = "Часы бурения";
sheet.Range(62, 5, 62, 6).Merge();
sheet.Cell(63, 5).Value = "=E55+E59";
sheet.Range(63, 5, 63, 6).Merge();
sheet.Cell(62, 7).Value = "Мех. скорость";
sheet.Range(62, 7, 62, 8).Merge();
sheet.Cell(63, 7).Value = "";
sheet.Range(63, 7, 63, 8).Merge();
sheet.Cell(61, 9).Value = "Плановая мех скорость";
sheet.Range(61, 9, 62, 10).Merge();
sheet.Cell(63, 9).Value = $"{blockDto.SectionROPPlan}";
sheet.Range(63, 9, 63, 10).Merge();
sheet.Cell(65, 3).Value = "Увеличение мех скорости за секцию %";
sheet.Range(65, 3, 65, 6).Merge();
sheet.Cell(65, 7).Value = "";
sheet.Range(65, 7, 65, 10).Merge();
sheet.Cell(66, 3).Value = "Увеличение мех скорости за сутки %";
sheet.Range(66, 3, 66, 6).Merge();
sheet.Cell(66, 7).Value = "";
sheet.Range(66, 7, 66, 10).Merge();
sheet.Cell(67, 3).Value = "Сокращение времени бурения за секцию, ч";
sheet.Range(67, 3, 67, 6).Merge();
sheet.Cell(67, 7).Value = "";
sheet.Range(67, 7, 67, 10).Merge();
sheet.Cell(68, 3).Value = "Ротор / слайд, %";
sheet.Range(68, 3, 68, 6).Merge();
sheet.Cell(68, 7).Value = "";
sheet.Range(68, 7, 68, 10).Merge();
sheet.Cell(69, 3).Value = "МСП за секцию м/ч.";
sheet.Range(69, 3, 69, 6).Merge();
sheet.Cell(69, 7).Value = "";
sheet.Range(69, 7, 69, 10).Merge();
sheet.Cell(70, 3).Value = "Время бурения за секцию";
sheet.Range(70, 3, 70, 6).Merge();
sheet.Cell(70, 7).Value = $"{blockDto.SectionDrillingTimeTotal}";
sheet.Range(70, 7, 70, 10).Merge();
sheet.Cell(71, 3).Value = "Проходка за секцию";
sheet.Range(71, 3, 71, 6).Merge();
sheet.Cell(71, 7).Value = $"{blockDto.SectionPenetrationTotal}";
sheet.Range(71, 7, 71, 10).Merge();
sheet.Cell(72, 3).Value = "Кол- во наращиваний";
sheet.Range(72, 3, 72, 6).Merge();
sheet.Cell(72, 7).Value = $"{blockDto.ExtensionsCount}";
sheet.Range(72, 7, 72, 10).Merge();
sheet.Cell(73, 3).Value = "Отклонение от ГГД +/-, сут";
sheet.Range(73, 3, 73, 6).Merge();
sheet.Cell(73, 7).Value = $"{blockDto.DeviationFromTVD}";
sheet.Range(73, 7, 73, 10).Merge();
sheet.Cell(74, 3).Value = $"Примечание: {blockDto.DeclinesReasonsROP}";
sheet.Range(74, 3, 75, 10).Merge();
}
private void AddBlockSign(IXLWorksheet sheet, DailyReportSignDto blockDto)
{
sheet.Cell(78, 3).Value =
"Мастер буровой ";
sheet.Range(78, 3, 78, 4).Merge();
sheet.Cell(78, 9).Value =
$"{blockDto.DrillingMaster}";
sheet.Range(78, 9, 78, 10).Merge();
sheet.Cell(80, 3).Value =
"Супервайзер ";
sheet.Range(80, 3, 80, 4).Merge();
sheet.Cell(80, 9).Value =
$"{blockDto.Supervisor}";
sheet.Range(80, 9, 80, 10).Merge();
}
// реализация "как есть"
public Stream MakeReport(DailyReportDto dailyReportDto)
{
using var templateStream = System.Reflection.Assembly.GetExecutingAssembly()
.GetManifestResourceStream("AsbCloudInfrastructure.Services.DailyReport.DailyReportTemplate.xlsx");
using var workbook = new XLWorkbook(templateStream, XLEventTracking.Disabled);
FillSheet(workbook, dailyReportDto);
MemoryStream memoryStream = new MemoryStream();
workbook.SaveAs(memoryStream, new SaveOptions { });
memoryStream.Seek(0, SeekOrigin.Begin);
return memoryStream;
}
public void FillSheet(XLWorkbook workbook, DailyReportDto reportParams)
{
var sheet = workbook.Worksheets.First();//.Add(reportParams.ReportDate.ToString("dd.MM.yyyy"));
sheet.Name = reportParams.ReportDate.ToString("dd.MM.yyyy");
var activeRow = 3;
activeRow = AddBlockHead(sheet, activeRow, reportParams);
activeRow = AddBlockSlaughtersReport(sheet, activeRow, reportParams);
activeRow = AddBlockTrajectoryReport(sheet, activeRow, reportParams);
activeRow = AddBlockDrillers(sheet, activeRow, reportParams);
activeRow = AddBlockSAUB(sheet, activeRow, reportParams);
activeRow = AddBlockBHA(sheet, activeRow, reportParams);
activeRow = AddBlockBHADescription(sheet, activeRow, reportParams);
activeRow = AddBlockOperations(sheet, activeRow, reportParams);
activeRow = AddBlockTimeBalans(sheet, activeRow, reportParams);
activeRow = AddBlockMeterlessWorks(sheet, activeRow, reportParams);
activeRow = AddBlockDrillingModes(sheet, activeRow, reportParams);
activeRow = AddBlockRotorDrilling(sheet, activeRow, reportParams);
activeRow = AddBlockSlideDrilling(sheet, activeRow, reportParams);
activeRow = AddBlockROPPlan(sheet, activeRow, reportParams);
activeRow = AddBlockSummary(sheet, activeRow, reportParams);
activeRow = AddBlockSubscribes(sheet, activeRow, reportParams);
}
private int AddBlockHead(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow, 3).Value =
$"Суточная сводка бурения скважины №{reportDto.WellName}, куст: {reportDto.ClusterName}";
sheet.Cell(startRow + 1, 3).Value =
$"Заказчик: {reportDto.Customer}";
sheet.Cell(startRow + 2, 3).Value =
$"Подрядчик: {reportDto.Contractor}";
return startRow + 2;
}
private int AddBlockSlaughtersReport(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 4, 3).Value =
$"{reportDto.ReportDate}";
sheet.Cell(startRow + 4, 5).Value =
$"{reportDto.WellDepthIntervalStartDate}";
sheet.Cell(startRow + 4, 6).Value =
$"{reportDto.WellDepthIntervalFinishDate}";
return startRow + 4;
}
private int AddBlockTrajectoryReport(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 4, 3).Value =
$"{reportDto.BottomholeDepth}";
sheet.Cell(startRow + 4, 4).Value =
$"{reportDto.VerticalDepth}";
sheet.Cell(startRow + 4, 5).Value =
$"{reportDto.ZenithAngle}";
sheet.Cell(startRow + 4, 6).Value =
$"{reportDto.AzimuthAngle}";
return startRow + 4;
}
private int AddBlockDrillers(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 2, 4).Value =
$"{reportDto.FirstDriller}";
sheet.Cell(startRow + 3, 4).Value =
$"{reportDto.SecondDriller}";
return startRow + 3;
}
private int AddBlockSAUB(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 3, 6).Value =
$"{reportDto.WorkTimeSAUB}";
sheet.Cell(startRow + 4, 6).Value =
$"{reportDto.WorkTimeSpinMaster}";
sheet.Cell(startRow + 5, 6).Value =
$"{reportDto.WorkTimeTorkMaster}";
sheet.Cell(startRow + 3, 7).Value =
$"{reportDto.PenetrationSAUB}";
sheet.Cell(startRow + 4, 7).Value =
$"{reportDto.PenetrationSpinMaster}";
sheet.Cell(startRow + 5, 7).Value =
$"{reportDto.PenetrationTorkMaster}";
sheet.Cell(startRow + 6, 6).Value =
$"{reportDto.CountLaunchesMSE}";
return startRow + 6;
}
private int AddBlockBHA(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 3, 6).Value =
$"{reportDto.WorkTimeSAUB}";
sheet.Cell(startRow + 4, 6).Value =
$"{reportDto.WorkTimeSpinMaster}";
sheet.Cell(startRow + 5, 6).Value =
$"{reportDto.WorkTimeTorkMaster}";
sheet.Cell(startRow + 3, 7).Value =
$"{reportDto.PenetrationSAUB}";
sheet.Cell(startRow + 4, 7).Value =
$"{reportDto.PenetrationSpinMaster}";
sheet.Cell(startRow + 5, 7).Value =
$"{reportDto.PenetrationTorkMaster}";
sheet.Cell(startRow + 6, 6).Value =
$"{reportDto.CountLaunchesMSE}";
return startRow + 6;
}
private int AddBlockBHADescription(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 2, 3).Value =
$"{reportDto.BHADescription}";
return startRow + 6;
}
private int AddBlockOperations(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
return startRow + 7;
}
private int AddBlockTimeBalans(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
return startRow + 8;
}
private int AddBlockMeterlessWorks(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 4, 6).Value =
$"{reportDto.StandardTimeBarrelPreparation}";
sheet.Cell(startRow + 4, 9).Value =
$"{reportDto.StandardTimeExtension}";
sheet.Cell(startRow + 6, 6).Value =
$"{reportDto.ActualTimeBarrelPreparation}";
sheet.Cell(startRow + 6, 9).Value =
$"{reportDto.ActualTimeExtension}";
return startRow + 9;
}
//
private int AddBlockDrillingModes(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 2, 6).Value =
$"{string.Join(", ", reportDto.RotorDrillingModes)}";
sheet.Cell(startRow + 3, 9).Value =
$"{string.Join(", ", reportDto.SlideDrillingModes)}";
return startRow + 3;
}
private int AddBlockRotorDrilling(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 3, 3).Value =
$"{reportDto.PenetrationInRotor}";
sheet.Cell(startRow + 3, 5).Value =
$"{reportDto.NumberDrillingHours}";
sheet.Cell(startRow + 3, 9).Value =
$"{reportDto.AVGDiffDropRotor}";
return startRow + 3;
}
private int AddBlockSlideDrilling(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 3, 3).Value =
$"{reportDto.PenetrationInSlide}";
sheet.Cell(startRow + 3, 5).Value =
$"{reportDto.DrillingTimeInRotor}";
sheet.Cell(startRow + 3, 9).Value =
$"{reportDto.AVGDiffPressureSlide}";
return startRow + 3;
}
private int AddBlockROPPlan(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 3, 9).Value =
$"{reportDto.SectionROPPlan}";
return startRow + 3;
}
private int AddBlockSummary(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 7, 7).Value =
$"{reportDto.SectionDrillingTimeTotal}";
sheet.Cell(startRow + 8, 7).Value =
$"{reportDto.SectionPenetrationTotal}";
sheet.Cell(startRow + 9, 7).Value =
$"{reportDto.ExtensionsCount}";
sheet.Cell(startRow + 10, 7).Value =
$"{reportDto.DeviationFromTVD}";
sheet.Cell(startRow + 11, 3).Value =
$"{reportDto.DeclinesReasonsROP}";
return startRow + 13;
}
//
private int AddBlockSubscribes(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 3, 9).Value =
$"{reportDto.DrillingMaster}";
sheet.Cell(startRow + 5, 9).Value =
$"{reportDto.Supervisor}";
return startRow + 5;
}
private static string GetColunmLetter(int columnNumber)
{
string letter = "";
while (columnNumber > 0)
{
int modulo = (columnNumber - 1) % 26;
letter = Convert.ToChar('A' + modulo) + letter;
columnNumber = (columnNumber - modulo) / 26;
}
return letter;
}
private static IXLStyle SetBorder(IXLStyle style)
{
style.Border.RightBorder = XLBorderStyleValues.Thin;
style.Border.LeftBorder = XLBorderStyleValues.Thin;
style.Border.TopBorder = XLBorderStyleValues.Thin;
style.Border.BottomBorder = XLBorderStyleValues.Thin;
style.Border.InsideBorder = XLBorderStyleValues.Thin;
return style;
}
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;
}
private static IXLCell SetCell(IXLRow row, int colunm, object value, int maxChartsToWrap = 88)
{
var cell = row.Cell(colunm);
cell.Value = value;
SetBorder(cell.Style);
cell.Style.Alignment.WrapText = true;
if (value is string valueString && valueString.Length > maxChartsToWrap)
{
var baseHeight = row.Height;
row.Height = 0.82d * baseHeight * Math.Ceiling(1d + valueString.Length / maxChartsToWrap);
}
if (value is DateTime)
{
SetDateTime(cell);
}
else if (value is IFormattable)
{
SetNumber(cell);
}
return cell;
}
}
}