diff --git a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj index fbba1731..36035215 100644 --- a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj +++ b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj @@ -12,6 +12,7 @@ + @@ -44,6 +45,7 @@ + diff --git a/AsbCloudInfrastructure/Services/DailyReport/BlockAbstract.cs b/AsbCloudInfrastructure/Services/DailyReport/BlockAbstract.cs index 48e7702b..2a8440c3 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/BlockAbstract.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/BlockAbstract.cs @@ -1,4 +1,5 @@ using AsbCloudApp.Data.DailyReportModel; +using AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks; using ClosedXML.Excel; using System.Linq; @@ -28,7 +29,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport public BlockHeader(CellAddress addressBlockBegin, DailyReportHeadDto blockDto) { AddressBlockBegin = addressBlockBegin.Copy(); - + this.blockDto = blockDto; AddressTitle = addressBlockBegin + (0, 0); AddressCustomer = addressBlockBegin + (1,0); @@ -64,7 +65,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport internal class BlockWithFormula : BlockAbstract { - private readonly BlockHeader blockHeader; + private readonly HeadBlock blockHeader; public override CellAddress AddressBlockBegin { get; } @@ -72,7 +73,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport public CellAddress AddressFomulaExample { get; set; } - public BlockWithFormula(CellAddress addressBlockBegin, BlockHeader blockHeader) + public BlockWithFormula(CellAddress addressBlockBegin, HeadBlock blockHeader) { AddressFomulaExample = addressBlockBegin + (0, 0); AddressBlockBegin = addressBlockBegin.Copy(); @@ -80,16 +81,16 @@ namespace AsbCloudInfrastructure.Services.DailyReport this.blockHeader = blockHeader; } - public override void Draw(IXLWorksheet sheet) + public override void Draw(IXLWorksheet sheet) { - var formula = string.Format("{0}/5", blockHeader.AddressExampleData1.ToString()); + // var formula = string.Format("{0}/5", blockHeader.AddressExampleData1.ToString()); - sheet.Cell(AddressFomulaExample) - .SetFormulaA1(formula); + // sheet.Cell(AddressFomulaExample) + // .SetFormulaA1(formula); } } - internal abstract class BlockAbstract + abstract class BlockAbstract { public abstract CellAddress AddressBlockBegin { get; } public abstract CellAddress AddressBlockEnd { get; } diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs new file mode 100644 index 00000000..36c1c935 --- /dev/null +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs @@ -0,0 +1,146 @@ +using System; +using AsbCloudApp.Data.DailyReportModel; +using ClosedXML.Excel; + +namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks +{ + + class BhaBlock : BlockAbstract + { + private readonly DailyReportBhaDto blockDto; + + public CellAddress AddressBhaDescription { get; } + + public CellAddress AddressOperationTitle { get; } + public CellAddress AddressDurationTitle { get; } + public CellAddress AddressTotalTitle { get; } + + public CellAddress[] AddressOperationData { get; } + public CellAddress[] AddressDurationDataStart { get; } + public CellAddress[] AddressDurationDataFinish { get; } + public CellAddress[] AddressTotaData { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockBegin { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockEnd { get; } + + public BhaBlock(CellAddress addressBlockBegin, DailyReportBhaDto blockDto) + { + this.blockDto = blockDto; + AddressBlockBegin = addressBlockBegin.Copy(); + AddressBlockBegin.ColumnNumber = 0; + AddressBhaDescription = addressBlockBegin + (1,0); + AddressOperationTitle = addressBlockBegin + (3, 0); + AddressDurationTitle = addressBlockBegin + (3, 5); + AddressTotalTitle = addressBlockBegin + (3, 7); + AddressOperationData = new CellAddress[5]; + + AddressOperationData[0] = addressBlockBegin + (4, 0); + AddressOperationData[1] = addressBlockBegin + (5, 0); + AddressOperationData[2] = addressBlockBegin + (6, 0); + AddressOperationData[3] = addressBlockBegin + (7, 0); + AddressOperationData[4] = addressBlockBegin + (8, 0); + + AddressDurationDataStart = new CellAddress[5]; + AddressDurationDataStart[0] = addressBlockBegin + (4, 5); + AddressDurationDataStart[1] = addressBlockBegin + (5, 5); + AddressDurationDataStart[2] = addressBlockBegin + (6, 5); + AddressDurationDataStart[3] = addressBlockBegin + (7, 5); + AddressDurationDataStart[4] = addressBlockBegin + (8, 5); + + AddressDurationDataFinish = new CellAddress[5]; + AddressDurationDataFinish[0] = addressBlockBegin + (4, 6); + AddressDurationDataFinish[1] = addressBlockBegin + (5, 6); + AddressDurationDataFinish[2] = addressBlockBegin + (6, 6); + AddressDurationDataFinish[3] = addressBlockBegin + (7, 6); + AddressDurationDataFinish[4] = addressBlockBegin + (8, 6); + + AddressTotaData = new CellAddress[5]; + AddressTotaData[0] = addressBlockBegin + (4, 7); + AddressTotaData[1] = addressBlockBegin + (5, 7); + AddressTotaData[2] = addressBlockBegin + (6, 7); + AddressTotaData[3] = addressBlockBegin + (7, 7); + AddressTotaData[4] = addressBlockBegin + (8, 7); + + + + AddressBlockEnd = AddressTotaData[4]; + } + + private string FormulaBhaBlock(CellAddress beginTime, CellAddress endTime ) + { + return $"IF({endTime}>0,({endTime}-{beginTime})*24, \"\")"; + } + + public override void Draw(IXLWorksheet sheet) + { + + sheet._Range(AddressBhaDescription, AddressBhaDescription + (0, 7)) + ._SetValue($"{blockDto.BHADescription}"); + + + sheet._Range(AddressOperationTitle, AddressOperationTitle + (0, 4)) + ._SetValue("Выполняемые операции в отчетный период, комментарии:"); + sheet._Range(AddressDurationTitle, AddressDurationTitle + (0, 1)) + ._SetValue("Продолжительность, ч. "); + sheet.Cell(AddressTotalTitle) + ._SetValue("Итого"); + + sheet._Range(AddressOperationData[0], AddressOperationData[0] + (0, 4)) + ._SetValue("Бурение с наращиваниями в инт. 2195-2763м."); + sheet.Cell(AddressDurationDataStart[0]) + ._SetValue($"{blockDto.ExtensionDrillingOneBegin}"); + sheet.Cell(AddressDurationDataFinish[0]) + ._SetValue($"{blockDto.ExtensionDrillingOneFinish}"); + sheet.Cell(AddressTotaData[0]) + .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[0], AddressDurationDataFinish[0])}"); + + sheet._Range(AddressOperationData[1], AddressOperationData[1] + (0, 4)) + ._SetValue("Промывка."); + sheet.Cell(AddressDurationDataStart[1]) + ._SetValue($"{blockDto.SluiceBegin}"); + sheet.Cell(AddressDurationDataFinish[1]) + ._SetValue($"{blockDto.SluiceBegin}"); + sheet.Cell(AddressTotaData[1]) + .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[1], AddressDurationDataFinish[1])}"); + + sheet._Range(AddressOperationData[2], AddressOperationData[2] + (0, 4)) + ._SetValue("Подъем КНБК в инт. 2763-2442м."); + sheet.Cell(AddressDurationDataStart[2]) + ._SetValue($"{blockDto.ClimbBegin}"); + sheet.Cell(AddressDurationDataFinish[2]) + ._SetValue($"{blockDto.ClimbFinish}"); + sheet.Cell(AddressTotaData[2]) + .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[2], AddressDurationDataFinish[2])}"); + + sheet._Range(AddressOperationData[3], AddressOperationData[3] + (0, 4)) + ._SetValue("Спуск КНБК в инт. 2442-2763м."); + sheet.Cell(AddressDurationDataStart[3]) + ._SetValue($"{blockDto.DescentBegin}"); + sheet.Cell(AddressDurationDataFinish[3]) + ._SetValue($"{blockDto.DescentFinish}"); + sheet.Cell(AddressTotaData[3]) + .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[3], AddressDurationDataFinish[3])}"); + + sheet._Range(AddressOperationData[4], AddressOperationData[4] + (0, 4)) + ._SetValue("Бурение с наращиваниями в инт. 2763-2850м."); + sheet.Cell(AddressDurationDataStart[4]) + ._SetValue($"{blockDto.ExtensionDrillingTwoBegin}"); + sheet.Cell(AddressDurationDataFinish[4]) + ._SetValue($"{blockDto.ExtensionDrillingTwoFinish}"); + sheet.Cell(AddressTotaData[4]) + .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[4], AddressDurationDataFinish[4])}"); + + + } + } +} + + + diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs new file mode 100644 index 00000000..d72f977a --- /dev/null +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs @@ -0,0 +1,60 @@ +using System; +using AsbCloudApp.Data.DailyReportModel; +using ClosedXML.Excel; + +namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks +{ + + internal class DimensionlessBlock : BlockAbstract + { + private readonly DailyReportDimensionlessDto blockDto; + + public CellAddress AddressBhaDescription { get; } + + + public CellAddress[] AddressPeriodTableDataArray { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockBegin { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockEnd { get; } + + public DimensionlessBlock(CellAddress addressBlockBegin, DailyReportDimensionlessDto blockDto) + { + AddressBlockBegin = addressBlockBegin.Copy(); + this.blockDto = blockDto; + AddressBhaDescription = addressBlockBegin + (0, 0); + + //AddressExampleData1 = addressBlockBegin + (5, 0); + + + + //AddressBlockEnd = AddressesExampleDataArray.Last(); + } + + public override void Draw(IXLWorksheet sheet) + { + + // sheet.Range(AddressBhaDescription, AddressBhaDescription + (0, 7)) + // ._SetValue($"{blockDto.BHADescription}"); + + + + + + + + + + // sheet._Range(AddressExampleData1, AddressExampleData1 + (0, 4)) + // ._SetValue(blockDto.BottomholeDepth); // для примера с будущей формулой + } + } + +} + diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/HeadBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/HeadBlock.cs new file mode 100644 index 00000000..28c0c688 --- /dev/null +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/HeadBlock.cs @@ -0,0 +1,218 @@ +using AsbCloudApp.Data.DailyReportModel; +using AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks; +using ClosedXML.Excel; +using System.Linq; + +namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks +{ + + class HeadBlock : BlockAbstract + { + private readonly DailyReportHeadDto blockDto; + + public CellAddress AddressTitle { get; } + public CellAddress AddressCustomer { get; } + public CellAddress AddressDriller { get; } + public CellAddress AddressPeriod { get; } + public CellAddress AddressSlaughter { get; } + public CellAddress AddressTrajectoryTableTitle { get; } + public CellAddress AddressDrillerOneTitle { get; } + public CellAddress AddressDrillerOne { get; } + public CellAddress AddressDrillerTwoTitle { get; } + public CellAddress AddressDrillerTwo { get; } + + public CellAddress AddressWorkSaubTitle { get; } + public CellAddress AddressWatchTitle { get; } + public CellAddress AddressMetreTitle { get; } + + public CellAddress[] AddressWorkSaubData { get; } + public CellAddress[] AddressWatchData { get; } + public CellAddress[] AddressMetreData { get; } + + + + public CellAddress[] AddressPeriodTableHeadArray { get; } + public CellAddress[] AddressPeriodTableDataArray { get; } + + public CellAddress[] AddressTrajectoryTableHeadArray { get; } + public CellAddress[] AddressTrajectoryTableDataArray { get; } + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockBegin { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockEnd { get; } + public void WriteRowToArray(CellAddress[] cellsArray, CellAddress startCells) + { + + } + public HeadBlock(CellAddress addressBlockBegin, DailyReportHeadDto blockDto) + { + AddressBlockBegin = addressBlockBegin.Copy(); + + this.blockDto = blockDto; + AddressTitle = addressBlockBegin + (0, 0); + AddressCustomer = addressBlockBegin + (1, 0); + AddressDriller = addressBlockBegin + (2, 0); + AddressPeriod = addressBlockBegin + (4, 0); + AddressSlaughter = addressBlockBegin + (4, 4); + AddressPeriodTableHeadArray = new CellAddress[4]; + AddressPeriodTableHeadArray[0]= addressBlockBegin + (5, 0); + AddressPeriodTableHeadArray[1] = addressBlockBegin + (5, 2); + AddressPeriodTableHeadArray[2] = addressBlockBegin + (5, 4); + AddressPeriodTableHeadArray[3] = addressBlockBegin + (5, 6); + AddressPeriodTableDataArray = new CellAddress[4]; + AddressPeriodTableDataArray[0] = addressBlockBegin + (6, 0); + AddressPeriodTableDataArray[1] = addressBlockBegin + (6, 2); + AddressPeriodTableDataArray[2] = addressBlockBegin + (6, 4); + AddressPeriodTableDataArray[3] = addressBlockBegin + (6, 6); + AddressTrajectoryTableTitle = addressBlockBegin + (8,0); + AddressTrajectoryTableHeadArray = new CellAddress[4]; + AddressTrajectoryTableHeadArray[0] = addressBlockBegin + (9, 0); + AddressTrajectoryTableHeadArray[1] = addressBlockBegin + (9, 2); + AddressTrajectoryTableHeadArray[2] = addressBlockBegin + (9, 4); + AddressTrajectoryTableHeadArray[3] = addressBlockBegin + (9, 6); + AddressTrajectoryTableDataArray = new CellAddress[4]; + AddressTrajectoryTableDataArray[0] = addressBlockBegin + (10, 0); + AddressTrajectoryTableDataArray[1] = addressBlockBegin + (10, 2); + AddressTrajectoryTableDataArray[2] = addressBlockBegin + (10, 4); + AddressTrajectoryTableDataArray[3] = addressBlockBegin + (10, 6); + AddressDrillerOneTitle = addressBlockBegin + (12, 0); + AddressDrillerOne = addressBlockBegin + (12, 2); + AddressDrillerTwoTitle = addressBlockBegin + (13, 0); + AddressDrillerTwo = addressBlockBegin + (13, 2); + AddressWorkSaubTitle = addressBlockBegin + (15, 0); + AddressWatchTitle = addressBlockBegin + (15, 3); + AddressMetreTitle = addressBlockBegin + (15, 4); + + AddressWorkSaubData = new CellAddress[4]; + AddressWorkSaubData[0] = addressBlockBegin + (16, 0); + AddressWorkSaubData[1] = addressBlockBegin + (17, 0); + AddressWorkSaubData[2] = addressBlockBegin + (18, 0); + AddressWorkSaubData[3] = addressBlockBegin + (19, 0); + + AddressWatchData = new CellAddress[4]; + AddressWatchData[0] = addressBlockBegin + (16, 3); + AddressWatchData[1] = addressBlockBegin + (17, 3); + AddressWatchData[2] = addressBlockBegin + (18, 3); + AddressWatchData[3] = addressBlockBegin + (19, 3); + + AddressMetreData = new CellAddress[4]; + AddressMetreData[0] = addressBlockBegin + (16, 4); + AddressMetreData[1] = addressBlockBegin + (17, 4); + AddressMetreData[2] = addressBlockBegin + (18, 4); + + AddressBlockEnd = AddressWatchData[3]+(0,1); + + } + + public override void Draw(IXLWorksheet sheet) + { + + sheet._Range(AddressTitle, AddressTitle + (0, 7)) + ._SetValue($"Суточная сводка бурения скважины: {blockDto.WellName}, куст: {blockDto.ClusterName}") + .Style.SetH1(); + + sheet._Range(AddressCustomer, AddressCustomer + (0, 7)) + ._SetValue($"Заказчик: {blockDto.Customer}") + .Style.SetH1(); + + sheet._Range(AddressDriller, AddressDriller + (0, 7)) + ._SetValue($"Подрядчик: {blockDto.Contractor}") + .Style.SetH1(); + + sheet._Range(AddressPeriod, AddressPeriod + (0, 3)) + ._SetValue("Отчетный период"); + + sheet._Range(AddressSlaughter, AddressSlaughter + (0, 3)) + ._SetValue("Забой за отчетный период, м"); + + sheet._Range(AddressPeriodTableHeadArray[0], AddressPeriodTableHeadArray[0] + (0, 1)) + ._SetValue("От (дата, время)"); + sheet._Range(AddressPeriodTableHeadArray[1], AddressPeriodTableHeadArray[1] + (0, 1)) + ._SetValue("До (дата, время)"); + sheet._Range(AddressPeriodTableHeadArray[2], AddressPeriodTableHeadArray[2] + (0, 1)) + ._SetValue("От"); + sheet._Range(AddressPeriodTableHeadArray[3], AddressPeriodTableHeadArray[3] + (0, 1)) + ._SetValue("До"); + + sheet._Range(AddressPeriodTableDataArray[0], AddressPeriodTableDataArray[0] + (0, 1)) + ._SetValue($"{blockDto.ReportDate}"); + sheet._Range(AddressPeriodTableDataArray[1], AddressPeriodTableDataArray[1] + (0, 1)) + ._SetValue("До (дата, время)"); + sheet._Range(AddressPeriodTableDataArray[2], AddressPeriodTableDataArray[2] + (0, 1)) + ._SetValue($"{blockDto.WellDepthIntervalStartDate}"); + sheet._Range(AddressPeriodTableDataArray[3], AddressPeriodTableDataArray[3] + (0, 1)) + ._SetValue($"{blockDto.WellDepthIntervalFinishDate}"); + + sheet._Range(AddressTrajectoryTableTitle, AddressTrajectoryTableTitle + (0, 7)) + ._SetValue("Данные по траектории скважины на конец суток"); + + sheet._Range(AddressTrajectoryTableHeadArray[0], AddressTrajectoryTableHeadArray[0] + (0, 1)) + ._SetValue("Глубина по стволу"); + sheet._Range(AddressTrajectoryTableHeadArray[1], AddressTrajectoryTableHeadArray[1] + (0, 1)) + ._SetValue("Глубина по вертикали"); + sheet._Range(AddressTrajectoryTableHeadArray[2], AddressTrajectoryTableHeadArray[2] + (0, 1)) + ._SetValue("Зенитный угол"); + sheet._Range(AddressTrajectoryTableHeadArray[3], AddressTrajectoryTableHeadArray[3] + (0, 1)) + ._SetValue("Азимут"); + + sheet._Range(AddressTrajectoryTableDataArray[0], AddressTrajectoryTableDataArray[0] + (0, 1)) + ._SetValue($"{blockDto.BottomholeDepth}"); + sheet._Range(AddressTrajectoryTableDataArray[1], AddressTrajectoryTableDataArray[1] + (0, 1)) + ._SetValue($"{blockDto.VerticalDepth}"); + sheet._Range(AddressTrajectoryTableDataArray[2], AddressTrajectoryTableDataArray[2] + (0, 1)) + ._SetValue($"{blockDto.ZenithAngle}"); + sheet._Range(AddressTrajectoryTableDataArray[3], AddressTrajectoryTableDataArray[3] + (0, 1)) + ._SetValue($"{blockDto.AzimuthAngle}"); + + sheet._Range(AddressDrillerOneTitle, AddressDrillerOneTitle + (0, 1)) + ._SetValue("Бурильщик 1 смена"); + sheet._Range(AddressDrillerOne, AddressDrillerOne + (0, 1)) + ._SetValue($"{blockDto.FirstDriller}"); + sheet._Range(AddressDrillerTwoTitle, AddressDrillerTwoTitle + (0, 1)) + ._SetValue("Бурильщик 2 смена"); + sheet._Range(AddressDrillerTwo, AddressDrillerTwo + (0, 1)) + ._SetValue($"{blockDto.SecondDriller}"); + + sheet._Range(AddressWorkSaubTitle, AddressWorkSaubTitle + (0, 2)) + ._SetValue("Работа модулей САУБ:"); + sheet.Cell(AddressWatchTitle) + ._SetValue("Часов:"); + sheet.Cell(AddressMetreTitle) + ._SetValue("Метров:"); + + sheet._Range(AddressWorkSaubData[0], AddressWorkSaubData[0] + (0, 2)) + ._SetValue("АПД (автоматическая подача долота), ч/м:"); + sheet.Cell(AddressWatchData[0]) + ._SetValue($"{blockDto.WorkTimeSAUB}"); + sheet.Cell(AddressMetreData[0]) + ._SetValue($"{blockDto.PenetrationSAUB}"); + + sheet._Range(AddressWorkSaubData[1], AddressWorkSaubData[1] + (0, 2)) + ._SetValue("Спин Мастер (осцилляция),ч/м:"); + sheet.Cell(AddressWatchData[1]) + ._SetValue($"{blockDto.WorkTimeSpinMaster}"); + sheet.Cell(AddressMetreData[1]) + ._SetValue($"{blockDto.PenetrationTorkMaster}"); + + sheet._Range(AddressWorkSaubData[2], AddressWorkSaubData[2] + (0, 2)) + ._SetValue("Торк Мастер (демпфирование), ч/:"); + sheet.Cell(AddressWatchData[2]) + ._SetValue($"{blockDto.WorkTimeTorkMaster}"); + sheet.Cell(AddressMetreData[2]) + ._SetValue($"{blockDto.PenetrationTorkMaster}"); + + sheet._Range(AddressWorkSaubData[3], AddressWorkSaubData[3] + (0, 2)) + ._SetValue("МСЕ, колличество запусков, раз:"); + sheet._Range(AddressWatchData[3], AddressWatchData[3] + (0, 1)) + ._SetValue($"{blockDto.CountLaunchesMSE}"); + + } + } +} + + diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs new file mode 100644 index 00000000..9e7508fe --- /dev/null +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs @@ -0,0 +1,60 @@ +using System; +using AsbCloudApp.Data.DailyReportModel; +using ClosedXML.Excel; + +namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks +{ + + internal class SaubBlock : BlockAbstract + { + private readonly DailyReportSaubDto blockDto; + + public CellAddress AddressBhaDescription { get; } + + + public CellAddress[] AddressPeriodTableDataArray { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockBegin { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockEnd { get; } + + public SaubBlock(CellAddress addressBlockBegin, DailyReportSaubDto blockDto) + { + AddressBlockBegin = addressBlockBegin.Copy(); + this.blockDto = blockDto; + AddressBhaDescription = addressBlockBegin + (0, 0); + + //AddressExampleData1 = addressBlockBegin + (5, 0); + + + + //AddressBlockEnd = AddressesExampleDataArray.Last(); + } + + public override void Draw(IXLWorksheet sheet) + { + + //sheet.Range(AddressBhaDescription, AddressBhaDescription + (0, 7)) + // ._SetValue($"{blockDto.BHADescription}"); + + + + + + + + + + // sheet._Range(AddressExampleData1, AddressExampleData1 + (0, 4)) + // ._SetValue(blockDto.BottomholeDepth); // для примера с будущей формулой + } + } + +} + diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs new file mode 100644 index 00000000..5fb02b9b --- /dev/null +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs @@ -0,0 +1,56 @@ +using System; +using AsbCloudApp.Data.DailyReportModel; +using ClosedXML.Excel; + +namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks +{ + + internal class SignBlock : BlockAbstract + { + private readonly DailyReportSignDto blockDto; + + public CellAddress AddressDrillMasterHead { get; } + public CellAddress AddressDrillMaster { get; } + public CellAddress AddressSupervisorHead { get; } + public CellAddress AddressSupervisor { get; } + public CellAddress[] AddressPeriodTableDataArray { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockBegin { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockEnd { get; } + + public SignBlock(CellAddress addressBlockBegin, DailyReportSignDto blockDto) + { + AddressBlockBegin = addressBlockBegin.Copy(); + this.blockDto = blockDto; + AddressDrillMasterHead = addressBlockBegin + (3, 0); + AddressDrillMaster = AddressDrillMasterHead + (0, 6); + AddressSupervisorHead = AddressDrillMasterHead + (2, 0); + AddressSupervisor = AddressSupervisorHead + (0, 6); + AddressBlockEnd = AddressSupervisor + (0,1); + } + + public override void Draw(IXLWorksheet sheet) + { + + sheet.Range(AddressDrillMasterHead, AddressDrillMasterHead + (0, 2)) + ._SetValue("Мастер буровой "); + sheet.Range(AddressDrillMaster, AddressDrillMaster + (0, 2)) + ._SetValue($"{blockDto.DrillingMaster}"); + sheet.Range(AddressSupervisorHead, AddressSupervisorHead + (0, 2)) + ._SetValue("Супервайзер "); + sheet.Range(AddressSupervisor, AddressSupervisor + (0, 2)) + ._SetValue($"{blockDto.Supervisor}"); + + } + } + +} + + diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/TimeBalanceBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/TimeBalanceBlock.cs new file mode 100644 index 00000000..0a3bef43 --- /dev/null +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/TimeBalanceBlock.cs @@ -0,0 +1,216 @@ +using System; +using AsbCloudApp.Data.DailyReport; +using ClosedXML.Excel; + +namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks +{ + + class TimeBalanceBlock : BlockAbstract + { + private readonly DailyReportTimeBalanceDto blockDto; + + public CellAddress AddressTitle { get; } + + public CellAddress AddressDrilling { get; set; } + public CellAddress AddressFlushing { get; set; } + public CellAddress AddressBuilding { get; set; } + public CellAddress AddressElaboration { get; set; } + public CellAddress AddressExtension { get; set; } + public CellAddress AddressRepair { get; set; } + + public CellAddress AddressDrillingValue { get; set; } + public CellAddress AddressFlushingValue { get; set; } + public CellAddress AddressBuildingValue { get; set; } + public CellAddress AddressElaborationValue { get; set; } + public CellAddress AddressExtensionValue { get; set; } + public CellAddress AddressRepairValue { get; set; } + + public CellAddress AddressKnbk { get; set; } + public CellAddress AddressSpo { get; set; } + public CellAddress AddressPzr { get; set; } + public CellAddress AddressPvo { get; set; } + public CellAddress AddressPgr { get; set; } + public CellAddress AddressGis { get; set; } + + public CellAddress AddressKnbkValue { get; set; } + public CellAddress AddressSpoValue { get; set; } + public CellAddress AddressPzrValue { get; set; } + public CellAddress AddressPvoValue { get; set; } + public CellAddress AddressPgrValue { get; set; } + public CellAddress AddressGisValue { get; set; } + + + + public CellAddress AddressOzc { get; set; } + public CellAddress AddressEngineeringWorks { get; set; } + public CellAddress AddressTakingMeasure { get; set; } + public CellAddress AddressCementing { get; set; } + public CellAddress AddressSimple { get; set; } + public CellAddress AddressNpv { get; set; } + + public CellAddress AddressOzcValue { get; set; } + public CellAddress AddressEngineeringWorksValue { get; set; } + public CellAddress AddressTakingMeasureValue { get; set; } + public CellAddress AddressCementingValue { get; set; } + public CellAddress AddressSimpleValue { get; set; } + public CellAddress AddressNpvValue { get; set; } + + + public CellAddress[] AddressPeriodTableDataArray { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockBegin { get; } + + /// + /// Значение нижняя правая ячейка блока + /// + public override CellAddress AddressBlockEnd { get; } + + public TimeBalanceBlock(CellAddress addressBlockBegin, DailyReportTimeBalanceDto blockDto) + { + AddressBlockBegin = addressBlockBegin.Copy(); + this.blockDto = blockDto; + AddressTitle = addressBlockBegin + (3, 0); + + AddressDrilling = addressBlockBegin + (4, 1); + AddressFlushing = addressBlockBegin + (5, 1); + AddressBuilding = addressBlockBegin + (6, 1); + AddressElaboration = addressBlockBegin + (7, 1); + AddressExtension = addressBlockBegin + (8, 1); + AddressRepair = addressBlockBegin + (9, 1); + + AddressDrillingValue = addressBlockBegin + (4, 2); + AddressFlushingValue = addressBlockBegin + (5, 2); + AddressBuildingValue = addressBlockBegin + (6, 2); + AddressElaborationValue = addressBlockBegin + (7, 2); + AddressExtensionValue = addressBlockBegin + (8, 2); + AddressRepairValue = addressBlockBegin + (9, 2); + + AddressKnbk = addressBlockBegin + (4, 3); + AddressSpo = addressBlockBegin + (5, 3); + AddressPzr = addressBlockBegin + (6, 3); + AddressPvo = addressBlockBegin + (7, 3); + AddressPgr = addressBlockBegin + (8, 3); + AddressGis = addressBlockBegin + (9, 3); + + AddressKnbkValue = addressBlockBegin + (4, 4); + AddressSpoValue = addressBlockBegin + (5, 4); + AddressPzrValue = addressBlockBegin + (6, 4); + AddressPvoValue = addressBlockBegin + (7, 4); + AddressPgrValue = addressBlockBegin + (8, 4); + AddressGisValue = addressBlockBegin + (9, 4); + + AddressOzc = addressBlockBegin + (4, 5); + AddressEngineeringWorks = addressBlockBegin + (5, 5); + AddressTakingMeasure = addressBlockBegin + (6, 5); + AddressCementing = addressBlockBegin + (7, 5); + AddressSimple = addressBlockBegin + (8, 5); + AddressNpv = addressBlockBegin + (9, 5); + + AddressOzcValue = addressBlockBegin + (4, 6); + AddressEngineeringWorksValue = addressBlockBegin + (5, 6); + AddressTakingMeasureValue = addressBlockBegin + (6, 6); + AddressCementingValue = addressBlockBegin + (7, 6); + AddressSimpleValue = addressBlockBegin + (8, 6); + AddressNpvValue = addressBlockBegin + (9, 6); + + AddressBlockEnd = AddressNpvValue; + } + + public override void Draw(IXLWorksheet sheet) + { + + sheet._Range(AddressTitle, AddressTitle + (0, 1)) + ._SetValue("БАЛАНС ВРЕМЕНИ"); + + sheet.Cell(AddressDrilling) + ._SetValue("Бурение"); + sheet.Cell(AddressFlushing) + ._SetValue("Промывка"); + sheet.Cell(AddressBuilding) + ._SetValue("Наращивание"); + sheet.Cell(AddressElaboration) + ._SetValue("Проработка"); + sheet.Cell(AddressExtension) + ._SetValue("Расширка"); + sheet.Cell(AddressRepair) + ._SetValue("Ремонт"); + sheet.Cell(AddressDrillingValue) + ._SetValue($"{blockDto.Drilling}"); + sheet.Cell(AddressFlushingValue) + ._SetValue($"{blockDto.Flushing}"); + sheet.Cell(AddressBuildingValue) + ._SetValue($"{blockDto.Building}"); + sheet.Cell(AddressElaborationValue) + ._SetValue($"{blockDto.Elaboration}"); + sheet.Cell(AddressExtensionValue) + ._SetValue($"{blockDto.Extension}"); + sheet.Cell(AddressRepairValue) + ._SetValue($"{blockDto.Repair}"); + + sheet.Cell(AddressKnbk) + ._SetValue("КНБК"); + sheet.Cell(AddressSpo) + ._SetValue("СПО"); + sheet.Cell(AddressPzr) + ._SetValue("ПЗР"); + sheet.Cell(AddressPvo) + ._SetValue("ПВО"); + sheet.Cell(AddressPgr) + ._SetValue("ПГР"); + sheet.Cell(AddressGis) + ._SetValue("ГИС"); + sheet.Cell(AddressKnbkValue) + ._SetValue($"{blockDto.Knbk}"); + sheet.Cell(AddressSpoValue) + ._SetValue($"{blockDto.Spo}"); + sheet.Cell(AddressPzrValue) + ._SetValue($"{blockDto.Pzr}"); + sheet.Cell(AddressPvoValue) + ._SetValue($"{blockDto.Pvo}"); + sheet.Cell(AddressPgrValue) + ._SetValue($"{blockDto.Pgr}"); + sheet.Cell(AddressGisValue) + ._SetValue($"{blockDto.Gis}"); + + sheet.Cell(AddressOzc) + ._SetValue("ОЗЦ"); + sheet.Cell(AddressEngineeringWorks) + ._SetValue("Тех. работы"); + sheet.Cell(AddressTakingMeasure) + ._SetValue("Снятие замера"); + sheet.Cell(AddressCementing) + ._SetValue("Цементирование"); + sheet.Cell(AddressSimple) + ._SetValue("Простой"); + sheet.Cell(AddressNpv) + ._SetValue("НПВ"); + sheet.Cell(AddressOzcValue) + ._SetValue($"{blockDto.Ozc}"); + sheet.Cell(AddressEngineeringWorksValue) + ._SetValue($"{blockDto.EngineeringWorks}"); + sheet.Cell(AddressTakingMeasureValue) + ._SetValue($"{blockDto.TakingMeasure}"); + sheet.Cell(AddressCementingValue) + ._SetValue($"{blockDto.Cementing}"); + sheet.Cell(AddressSimpleValue) + ._SetValue($"{blockDto.Simple}"); + sheet.Cell(AddressNpvValue) + ._SetValue($"{blockDto.Npv}"); + + + + + + + + + + + } + } + +} + diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs index fc0b3da2..0fabf266 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs @@ -1,5 +1,7 @@ using AsbCloudApp.Data; +using AsbCloudApp.Data.DailyReport; using AsbCloudApp.Data.DailyReportModel; +using AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks; using ClosedXML.Excel; using System; using System.IO; @@ -13,10 +15,10 @@ namespace AsbCloudInfrastructure.Services.DailyReport // черновик реализации отчета "по блокам" - public Stream MakeReportFromBlocks(DailyReportHeadDto blockHead, DailyReportBhaDto blockBha, DailyReportDimensionlessDto blockDimensionless, DailyReportSaubDto blockSaub, DailyReportSignDto blockSign) + public Stream MakeReportFromBlocks(DailyReportHeadDto blockHead, DailyReportBhaDto blockBha, DailyReportTimeBalanceDto blockBalance ,DailyReportDimensionlessDto blockDimensionless, DailyReportSaubDto blockSaub, DailyReportSignDto blockSign) { using var workbook = new XLWorkbook(); - FillExampleBlocks(workbook, blockHead); + FillExampleBlocks(workbook, blockHead, blockBha, blockBalance); //FillSheet6blocks(workbook, blockHead, blockBha, blockDimensionless, blockSaub, blockSign); MemoryStream memoryStream = new MemoryStream(); workbook.SaveAs(memoryStream, new SaveOptions { }); @@ -24,16 +26,20 @@ namespace AsbCloudInfrastructure.Services.DailyReport return memoryStream; } - private void FillExampleBlocks(XLWorkbook workbook, DailyReportHeadDto blockHeadDto) + private void FillExampleBlocks(XLWorkbook workbook, DailyReportHeadDto blockHeadDto, DailyReportBhaDto blockBhaDto, DailyReportTimeBalanceDto timeBalanceDto) { var sheet = workbook.Worksheets.Add(blockHeadDto.ReportDate.ToString("dd.MM.yyyy")); var addressStart = new CellAddress(sheet, 1, 1); - var blockHeader = new BlockHeader(addressStart, blockHeadDto); + var blockHeader = new HeadBlock(addressStart, blockHeadDto); addressStart = blockHeader.AddressBlockEnd + (1, 0); - var blockWithFormula = new BlockWithFormula(addressStart, blockHeader); + var blockBha = new BhaBlock(addressStart, blockBhaDto); + addressStart = blockBha.AddressBlockEnd + (1, 0); + var timeBalance = new TimeBalanceBlock(addressStart, timeBalanceDto); blockHeader.Draw(sheet); - blockWithFormula.Draw(sheet); + blockBha.Draw(sheet); + timeBalance.Draw(sheet); + //blockWithFormula.Draw(sheet); } private String converteCellCoordinate(int row, bool isCaps, int column) @@ -73,7 +79,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport sheet.Style.Font.FontName = "TimesNewRoman"; sheet.Style.Font.FontSize = 10; var tuple = (row: 3, column: 3); - tuple = (AddBlockHead1(sheet, blockHead,(tuple.row,tuple.column)).row , AddBlockHead1(sheet, blockHead, (tuple.row, tuple.column)).column); + tuple = (AddBlockHead1(sheet, blockHead,(tuple.row,tuple.column))); tuple = AddBlockBha(sheet, blockBha, tuple); tuple = AddBlockTimeBalance(sheet, tuple); tuple = AddBlockDimensionless(sheet, blockDimensionless, tuple); diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index 1945710d..0af2a8e5 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -10,6 +10,7 @@ using AsbCloudApp.Services; using AsbCloudDb.Model; using System.Collections.Generic; using AsbCloudApp.Data.DailyReportModel; +using AsbCloudApp.Data.DailyReport; namespace AsbCloudInfrastructure.Services.DailyReport { @@ -188,6 +189,8 @@ namespace AsbCloudInfrastructure.Services.DailyReport { BHADescription = dailyReportDto.BHADescription }; + var block3 = new DailyReportTimeBalanceDto(); + var block4 = new DailyReportDimensionlessDto() { ActualTimeBarrelPreparation = dailyReportDto.ActualTimeBarrelPreparation, @@ -219,7 +222,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport Supervisor = dailyReportDto.Supervisor }; - var memoryStream = dailyReportMaker.MakeReportFromBlocks(block1, block2, block4, block5, block6); + var memoryStream = dailyReportMaker.MakeReportFromBlocks(block1, block2, block3, block4, block5, block6); return memoryStream; } } diff --git a/ConsoleApp1/Program.cs b/ConsoleApp1/Program.cs index f9b90761..549bfc7a 100644 --- a/ConsoleApp1/Program.cs +++ b/ConsoleApp1/Program.cs @@ -1,4 +1,5 @@ -using AsbCloudApp.Data.DailyReportModel; +using AsbCloudApp.Data.DailyReport; +using AsbCloudApp.Data.DailyReportModel; using AsbCloudInfrastructure.EfCache; using AsbCloudInfrastructure.Services.DailyReport; using ClosedXML.Excel; @@ -28,10 +29,15 @@ namespace ConsoleApp1 WellDepthIntervalStartDate= 26.5, BottomholeDepth= 66.6 }; + var block2 = new DailyReportBhaDto() + { + BHADescription = "sadasdasdasdasdasdjlaskjdaksjdlasdlalskdklj" + }; + var block3 = new DailyReportTimeBalanceDto(); //------------- example ----------------- var service = new DailyReportMakerExcel(); - var stream = service.MakeReportFromBlocks(block, null, null, null, null); + var stream = service.MakeReportFromBlocks(block, block2, block3,null, null, null); var filename = "____.xlsx"; if (File.Exists(filename)) File.Delete(filename); @@ -41,20 +47,17 @@ namespace ConsoleApp1 return; //------------- end of example ----------------- - var block2 = new DailyReportBhaDto() - { - BHADescription="sadasdasdasdasdasdjlaskjdaksjdlasdlalskdklj" - }; + - var block3 = new DailyReportSaubDto(); + - var ms = MakeReportFromBlocks(block,block3); - //File.Create("", MakeReportFromBlocks(block)); - using var file = new FileStream("file.xlsx", FileMode.Create, System.IO.FileAccess.Write); - byte[] bytes = new byte[ms.Length]; - ms.Read(bytes, 0, (int)ms.Length); - file.Write(bytes, 0, bytes.Length); - ms.Close(); + //var ms = MakeReportFromBlocks(block,block3); + ////File.Create("", MakeReportFromBlocks(block)); + //using var file = new FileStream("file.xlsx", FileMode.Create, System.IO.FileAccess.Write); + //byte[] bytes = new byte[ms.Length]; + //ms.Read(bytes, 0, (int)ms.Length); + //file.Write(bytes, 0, bytes.Length); + //ms.Close(); } public static Stream MakeReportFromBlocks(DailyReportHeadDto blockHead, DailyReportSaubDto blockD)