Edit daily report MakerExcel - изменение логики построения отчета

модели ДТО и БД разбиты на 6 блоков
изменен сервис DailyReport

Тестовая таблица в консольном проекте
This commit is contained in:
IvanovEugeniy 2022-06-17 13:20:48 +05:00
parent 9146be1d3f
commit 94ebf6bfb9
17 changed files with 1327 additions and 52 deletions

View File

@ -10,4 +10,10 @@
<PackageReference Include="System.Linq" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<None Remove="Data\DailyReport\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data\DailyReport\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,12 @@
using System;
namespace AsbCloudApp.Data.DailyReportModel
{
public class DailyReportBhaDto
{
/// <summary>
/// КНБК описание
/// </summary>
public string BHADescription { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using System;
namespace AsbCloudApp.Data.DailyReportModel
{
public class DailyReportDimensionlessDto
{
/// <summary>
/// Нормативное время на одну операцию по подготовке ствола скважины к наращиванию
/// </summary>
public double? StandardTimeBarrelPreparation { get; set; }
/// <summary>
/// Нормативное время на одну операцию по наращиванию
/// </summary>
public double? StandardTimeExtension { get; set; }
/// <summary>
/// Фактическое время проработок при подготовке ствола скважины к наращиванию.
/// </summary>
public double? ActualTimeBarrelPreparation { get; set; }
/// <summary>
/// Фактическое время наращиваний
/// </summary>
public double? ActualTimeExtension { get; set; }
}
}

View File

@ -0,0 +1,110 @@
using System;
namespace AsbCloudApp.Data.DailyReportModel
{
/// <summary>
///
/// </summary>
public class DailyReportHeadDto
{
/// <summary>
/// название скважины
/// </summary>
public string WellName { get; set; }
/// <summary>
/// название куста
/// </summary>
public string ClusterName { get; set; }
/// <summary>
/// заказчик
/// </summary>
public string Customer { get; set; }
/// <summary>
/// подрядчик
/// </summary>
public string Contractor { get; set; }
/// <summary>
/// дата рапорта
/// </summary>
public DateTime ReportDate { get; set; }
/// <summary>
/// глубина забоя на дату начала интервала
/// </summary>
public double? WellDepthIntervalStartDate { get; set; }
/// <summary>
/// глубина забоя на дату окончания интервала
/// </summary>
public double? WellDepthIntervalFinishDate { get; set; }
/// <summary>
/// Глубина забоя по стволу на окончание отчетного периода
/// </summary>
public double? BottomholeDepth { get; set; }
/// <summary>
/// Глубина забоя по вертикали на дату окончания отчетного периода
/// </summary>
public double? VerticalDepth { get; set; }
/// <summary>
/// Зенитный угол на дату окончания отчетного периода
/// </summary>
public double? ZenithAngle { get; set; }
/// <summary>
/// Азимутальный угол на дату окончания отчетного периода
/// </summary>
public double? AzimuthAngle { get; set; }
/// <summary>
/// ФИО бурильщиков
/// </summary>
public string FirstDriller { get; set; }
/// <summary>
/// ФИО бурильщиков
/// </summary>
public string SecondDriller { get; set; }
/// <summary>
/// Время работы АПД
/// </summary>
public double? WorkTimeSAUB { get; set; }
/// <summary>
/// Время работы спин мастер
/// </summary>
public double? WorkTimeSpinMaster { get; set; }
/// <summary>
/// Время работы torqueMaster
/// </summary>
public double? WorkTimeTorkMaster { get; set; }
/// <summary>
/// количество метров пробуренных с включенным АПД
/// </summary>
public double? PenetrationSAUB { get; set; }
/// <summary>
/// количество метров пробуренных с включенным Спин мастер
/// </summary>
public double? PenetrationSpinMaster { get; set; }
/// <summary>
/// количество метров пробуренных с включенным torqueMaster
/// </summary>
public double? PenetrationTorkMaster { get; set; }
/// <summary>
/// Количество запусков МСЕ
/// </summary>
public int CountLaunchesMSE { get; set; }
}
}

View File

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
namespace AsbCloudApp.Data.DailyReportModel
{
public class DailyReportSaubDto
{
/// <summary>
/// Режимы бурения в роторе
/// </summary>
public IEnumerable<string> RotorDrillingModes { get; set; }
/// <summary>
/// режимы бурения в слайде
/// </summary>
public IEnumerable<string> SlideDrillingModes { get; set; }
/// <summary>
/// Количество метров пробуренных в роторе за отчетный период
/// </summary>
public double? PenetrationInRotor { get; set; }
/// <summary>
/// Количество часов бурения в роторе за отчетный период
/// </summary>
public double? NumberDrillingHours { get; set; }
/// <summary>
/// средний диф перепад в роторе за отчетный период
/// </summary>
public double? AVGDiffDropRotor { get; set; }
/// <summary>
/// количество метров пробуренных в слайде за отчетный период
/// </summary>
public double? PenetrationInSlide { get; set; }
/// <summary>
/// время бурения в роторе за отчетный период
/// </summary>
public double? DrillingTimeInRotor { get; set; }
/// <summary>
/// средний диф. перепад в слайде за отчетный период
/// </summary>
public double? AVGDiffPressureSlide { get; set; }
/// <summary>
/// Плановая МСП за секцию
/// </summary>
public double? SectionROPPlan { get; set; }
/// <summary>
/// Общее время бурения за секцию
/// </summary>
public double? SectionDrillingTimeTotal { get; set; }
/// <summary>
/// Общая проходка за секцию
/// </summary>
public double? SectionPenetrationTotal { get; set; }
/// <summary>
/// Количество наращиваний за отчетный период
/// </summary>
public int ExtensionsCount { get; set; }
/// <summary>
/// Отклонение относительно ГГД
/// </summary>
public double? DeviationFromTVD { get; set; }
/// <summary>
/// указываются все причины, которые влияют на снижение МСП.
/// </summary>
public string DeclinesReasonsROP { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
namespace AsbCloudApp.Data.DailyReportModel
{
public class DailyReportSignDto
{
/// <summary>
/// ФИО Мастера буровой
/// </summary>
public string DrillingMaster { get; set; }
/// <summary>
/// ФИО супервайзера
/// </summary>
public string Supervisor { get; set; }
}
}

View File

@ -17,4 +17,7 @@
<Folder Include="Model\WITS\" />
</ItemGroup>
<ItemGroup>
<None Remove="Model\DailyReport\" />
</ItemGroup>
</Project>

View File

@ -7,6 +7,7 @@ namespace AsbCloudDb.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_t_user_t_user_role_id_role",
table: "t_user");

View File

@ -0,0 +1,12 @@
using System;
namespace AsbCloudApp.Data.DailyReportModel
{
public class DailyReportBha
{
/// <summary>
/// КНБК описание
/// </summary>
public string BHADescription { get; set; }
}
}

View File

@ -0,0 +1,45 @@
using System;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
using AsbCloudApp.Data.DailyReportModel;
namespace AsbCloudDb.Model.DailyReportDB
{
#nullable disable
[Table("t_daily_report"), Comment("Ежедневные отчёты")]
public class DailyReportDb
{
[Column("id_well"), Comment("ID скважины")]
public int IdWell { get; set; }
[Column("start_date", TypeName = "timestamp with time zone"), Comment("Дата отчёта")]
public DateTimeOffset StartDate { get; set; }
[Column("blockHead", TypeName = "jsonb"), Comment("1 блок параметров для отчёта")]
public DailyReportHead BlockHead { get; set; }
[Column("blockBha", TypeName = "jsonb"), Comment("2 блок параметров для отчёта")]
public DailyReportBha BlockBha { get; set; }
[Column("blockDimensionless", TypeName = "jsonb"), Comment("4 блок параметров для отчёта")]
public DailyReportDimensionless BlockDimensionless { get; set; }
[Column("blockSaub", TypeName = "jsonb"), Comment("5 блок параметров для отчёта")]
public DailyReportSaub BlockSaub { get; set; }
[Column("blockSign", TypeName = "jsonb"), Comment("6 блок параметров для отчёта")]
public DailyReportSign BlockSign { get; set; }
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using System;
namespace AsbCloudApp.Data.DailyReportModel
{
public class DailyReportDimensionless
{
/// <summary>
/// Нормативное время на одну операцию по подготовке ствола скважины к наращиванию
/// </summary>
public double? StandardTimeBarrelPreparation { get; set; }
/// <summary>
/// Нормативное время на одну операцию по наращиванию
/// </summary>
public double? StandardTimeExtension { get; set; }
/// <summary>
/// Фактическое время проработок при подготовке ствола скважины к наращиванию.
/// </summary>
public double? ActualTimeBarrelPreparation { get; set; }
/// <summary>
/// Фактическое время наращиваний
/// </summary>
public double? ActualTimeExtension { get; set; }
}
}

View File

@ -0,0 +1,107 @@
using System;
namespace AsbCloudApp.Data.DailyReportModel
{
public class DailyReportHead
{
/// <summary>
/// название скважины
/// </summary>
public string WellName { get; set; }
/// <summary>
/// название куста
/// </summary>
public string ClusterName { get; set; }
/// <summary>
/// заказчик
/// </summary>
public string Customer { get; set; }
/// <summary>
/// подрядчик
/// </summary>
public string Contractor { get; set; }
/// <summary>
/// дата рапорта
/// </summary>
public DateTime ReportDate { get; set; }
/// <summary>
/// глубина забоя на дату начала интервала
/// </summary>
public double? WellDepthIntervalStartDate { get; set; }
/// <summary>
/// глубина забоя на дату окончания интервала
/// </summary>
public double? WellDepthIntervalFinishDate { get; set; }
/// <summary>
/// Глубина забоя по стволу на окончание отчетного периода
/// </summary>
public double? BottomholeDepth { get; set; }
/// <summary>
/// Глубина забоя по вертикали на дату окончания отчетного периода
/// </summary>
public double? VerticalDepth { get; set; }
/// <summary>
/// Зенитный угол на дату окончания отчетного периода
/// </summary>
public double? ZenithAngle { get; set; }
/// <summary>
/// Азимутальный угол на дату окончания отчетного периода
/// </summary>
public double? AzimuthAngle { get; set; }
/// <summary>
/// ФИО бурильщиков
/// </summary>
public string FirstDriller { get; set; }
/// <summary>
/// ФИО бурильщиков
/// </summary>
public string SecondDriller { get; set; }
/// <summary>
/// Время работы АПД
/// </summary>
public double? WorkTimeSAUB { get; set; }
/// <summary>
/// Время работы спин мастер
/// </summary>
public double? WorkTimeSpinMaster { get; set; }
/// <summary>
/// Время работы torqueMaster
/// </summary>
public double? WorkTimeTorkMaster { get; set; }
/// <summary>
/// количество метров пробуренных с включенным АПД
/// </summary>
public double? PenetrationSAUB { get; set; }
/// <summary>
/// количество метров пробуренных с включенным Спин мастер
/// </summary>
public double? PenetrationSpinMaster { get; set; }
/// <summary>
/// количество метров пробуренных с включенным torqueMaster
/// </summary>
public double? PenetrationTorkMaster { get; set; }
/// <summary>
/// Количество запусков МСЕ
/// </summary>
public int CountLaunchesMSE { get; set; }
}
}

View File

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
namespace AsbCloudApp.Data.DailyReportModel
{
public class DailyReportSaub
{
/// <summary>
/// Режимы бурения в роторе
/// </summary>
public IEnumerable<string> RotorDrillingModes { get; set; }
/// <summary>
/// режимы бурения в слайде
/// </summary>
public IEnumerable<string> SlideDrillingModes { get; set; }
/// <summary>
/// Количество метров пробуренных в роторе за отчетный период
/// </summary>
public double? PenetrationInRotor { get; set; }
/// <summary>
/// Количество часов бурения в роторе за отчетный период
/// </summary>
public double? NumberDrillingHours { get; set; }
/// <summary>
/// средний диф перепад в роторе за отчетный период
/// </summary>
public double? AVGDiffDropRotor { get; set; }
/// <summary>
/// количество метров пробуренных в слайде за отчетный период
/// </summary>
public double? PenetrationInSlide { get; set; }
/// <summary>
/// время бурения в роторе за отчетный период
/// </summary>
public double? DrillingTimeInRotor { get; set; }
/// <summary>
/// средний диф. перепад в слайде за отчетный период
/// </summary>
public double? AVGDiffPressureSlide { get; set; }
/// <summary>
/// Плановая МСП за секцию
/// </summary>
public double? SectionROPPlan { get; set; }
/// <summary>
/// Общее время бурения за секцию
/// </summary>
public double? SectionDrillingTimeTotal { get; set; }
/// <summary>
/// Общая проходка за секцию
/// </summary>
public double? SectionPenetrationTotal { get; set; }
/// <summary>
/// Количество наращиваний за отчетный период
/// </summary>
public int ExtensionsCount { get; set; }
/// <summary>
/// Отклонение относительно ГГД
/// </summary>
public double? DeviationFromTVD { get; set; }
/// <summary>
/// указываются все причины, которые влияют на снижение МСП.
/// </summary>
public string DeclinesReasonsROP { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
namespace AsbCloudApp.Data.DailyReportModel
{
public class DailyReportSign
{
/// <summary>
/// ФИО Мастера буровой
/// </summary>
public string DrillingMaster { get; set; }
/// <summary>
/// ФИО супервайзера
/// </summary>
public string Supervisor { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.DailyReportModel;
using ClosedXML.Excel;
using System;
using System.IO;
@ -8,6 +9,585 @@ 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()
@ -54,6 +634,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport
sheet.Cell(startRow + 2, 3).Value =
$"Подрядчик: {reportDto.Contractor}";
return startRow + 2;
}
@ -165,6 +746,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport
return startRow + 9;
}
//
private int AddBlockDrillingModes(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 2, 6).Value =
@ -222,6 +804,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport
return startRow + 13;
}
//
private int AddBlockSubscribes(IXLWorksheet sheet, int startRow, DailyReportDto reportDto)
{
sheet.Cell(startRow + 3, 9).Value =
@ -297,3 +880,4 @@ namespace AsbCloudInfrastructure.Services.DailyReport
}
}
}

View File

@ -1,14 +1,15 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Mapster;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Mapster;
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using System.Collections.Generic;
using AsbCloudApp.Data.DailyReportModel;
namespace AsbCloudInfrastructure.Services.DailyReport
{
@ -103,6 +104,8 @@ namespace AsbCloudInfrastructure.Services.DailyReport
return memoryStream;
}
private async Task<DailyReportDto?> GetAsync(int idWell, DateTime date, CancellationToken token)
{
var offsetHours = wellService.GetTimezone(idWell).Hours;
@ -149,6 +152,77 @@ namespace AsbCloudInfrastructure.Services.DailyReport
.Date;
return entity;
}
// черновик реализации "по блокам"
public async Task<Stream?> MakeReportFromBlocksAsync(int idWell, DateTime date, CancellationToken token = default)
{
var dailyReportDto = await GetAsync(idWell, date, token);
if (dailyReportDto is null)
return null;
var block1 = new DailyReportHeadDto()
{
WellName = dailyReportDto.WellName,
ClusterName = dailyReportDto.ClusterName,
Customer = dailyReportDto.Customer,
Contractor = dailyReportDto.Contractor,
ReportDate = dailyReportDto.ReportDate,
WellDepthIntervalStartDate = dailyReportDto.WellDepthIntervalStartDate,
WellDepthIntervalFinishDate = dailyReportDto.WellDepthIntervalFinishDate,
BottomholeDepth = dailyReportDto.BottomholeDepth,
VerticalDepth = dailyReportDto.VerticalDepth,
ZenithAngle = dailyReportDto.ZenithAngle,
AzimuthAngle = dailyReportDto.AzimuthAngle,
FirstDriller = dailyReportDto.FirstDriller,
SecondDriller = dailyReportDto.SecondDriller,
WorkTimeSAUB = dailyReportDto.WorkTimeSAUB,
WorkTimeSpinMaster = dailyReportDto.WorkTimeSpinMaster,
WorkTimeTorkMaster = dailyReportDto.WorkTimeTorkMaster,
PenetrationSAUB = dailyReportDto.PenetrationSAUB,
PenetrationSpinMaster = dailyReportDto.PenetrationSpinMaster,
PenetrationTorkMaster = dailyReportDto.PenetrationTorkMaster,
CountLaunchesMSE = dailyReportDto.CountLaunchesMSE
};
var block2 = new DailyReportBhaDto()
{
BHADescription = dailyReportDto.BHADescription
};
var block4 = new DailyReportDimensionlessDto()
{
ActualTimeBarrelPreparation = dailyReportDto.ActualTimeBarrelPreparation,
ActualTimeExtension = dailyReportDto.ActualTimeExtension,
StandardTimeBarrelPreparation = dailyReportDto.StandardTimeBarrelPreparation,
StandardTimeExtension = dailyReportDto.StandardTimeExtension
};
var block5 = new DailyReportSaubDto()
{
AVGDiffDropRotor = dailyReportDto.AVGDiffDropRotor,
AVGDiffPressureSlide = dailyReportDto.AVGDiffPressureSlide,
DeclinesReasonsROP = dailyReportDto.DeclinesReasonsROP,
DeviationFromTVD = dailyReportDto.DeviationFromTVD,
DrillingTimeInRotor = dailyReportDto.DrillingTimeInRotor,
NumberDrillingHours = dailyReportDto.NumberDrillingHours,
ExtensionsCount = dailyReportDto.ExtensionsCount,
PenetrationInRotor = dailyReportDto.PenetrationInRotor,
PenetrationInSlide = dailyReportDto.PenetrationInSlide,
RotorDrillingModes = dailyReportDto.RotorDrillingModes,
SectionDrillingTimeTotal = dailyReportDto.SectionDrillingTimeTotal,
SectionPenetrationTotal = dailyReportDto.SectionPenetrationTotal,
SectionROPPlan = dailyReportDto.SectionROPPlan,
SlideDrillingModes = dailyReportDto.SlideDrillingModes
};
var block6 = new DailyReportSignDto()
{
DrillingMaster = dailyReportDto.DrillingMaster,
Supervisor = dailyReportDto.Supervisor
};
var memoryStream = dailyReportMaker.MakeReportFromBlocks(block1, block2, block4, block5, block6);
return memoryStream;
}
}
#nullable disable
}

View File

@ -1,5 +1,8 @@
using AsbCloudInfrastructure.EfCache;
using AsbCloudApp.Data.DailyReportModel;
using AsbCloudInfrastructure.EfCache;
using ClosedXML.Excel;
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -12,59 +15,129 @@ namespace ConsoleApp1
// use ServiceFactory to make services
static void Main(/*string[] args*/)
{
Console.WriteLine("hit keyboard to start");
Console.ReadLine();
for (int i = 0; i < 24; i++)
var block = new DailyReportHeadDto()
{
var t = new Thread(_ =>
{
for (int j = 0; j < 32; j++)
//Task.Run(GetDataAsync).Wait();
GetData();
});
t.Start();
}
AzimuthAngle=12,
WellName= "WellName",
ClusterName= "clusterName",
Customer="customer",
Contractor="Contractor",
ReportDate = DateTime.Now,
WellDepthIntervalFinishDate= 27.5,
WellDepthIntervalStartDate= 26.5,
BottomholeDepth= 66.6
};
Console.WriteLine("End of Test");
Console.ReadLine();
var ms = MakeReportFromBlocks(block);
//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();
}
static TimeSpan obso = TimeSpan.FromSeconds(5);
static (long, long) GetData()
public static Stream MakeReportFromBlocks(DailyReportHeadDto blockHead)
{
using var db = ServiceFactory.MakeContext();
var sw = System.Diagnostics.Stopwatch.StartNew();
var cs = db.TelemetryDataSaub
.Where(t => t.IdTelemetry == 135)
.OrderBy(t => t.DateTime)
.Take(100_000)
.FromCache("tds", obso, r => new { r.Pressure, r.HookWeight })
.ToList();
sw.Stop();
Console.WriteLine($"{DateTime.Now}\tth: {Thread.CurrentThread.ManagedThreadId}\ttime {sw.ElapsedMilliseconds}\tcount {cs.Count}");
GC.Collect();
Thread.Sleep(10);
return (cs.Count, sw.ElapsedMilliseconds);
using var workbook = new XLWorkbook();
FillSheet6blocks(workbook, blockHead);
MemoryStream memoryStream = new MemoryStream();
workbook.SaveAs(memoryStream, new SaveOptions { });
memoryStream.Seek(0, SeekOrigin.Begin);
return memoryStream;
}
static async Task<(long, long)> GetDataAsync()
private static String converteCellCoordinate(int row, bool isCaps, int column)
{
using var db = ServiceFactory.MakeContext();
var sw = System.Diagnostics.Stopwatch.StartNew();
var cs = (await db.TelemetryDataSaub
.Where(t => t.IdTelemetry == 135)
.OrderBy(t => t.DateTime)
.Take(100_000)
.FromCacheDictionaryAsync("tds", obso, r => (r.IdTelemetry, r.DateTime), r => new { r.Pressure, r.HookWeight }))
.ToList();
sw.Stop();
Console.WriteLine($"{DateTime.Now}\tth: {Thread.CurrentThread.ManagedThreadId}\ttime {sw.ElapsedMilliseconds}\tcount {cs.Count}");
var c = (Char)((isCaps ? 65 : 97) + (column - 1));
string convertColumn = c.ToString();
return $"{convertColumn}{row}";
}
public static void FillSheet6blocks(XLWorkbook workbook, DailyReportHeadDto blockHead)
{
var sheet = workbook.Worksheets.Add(blockHead.ReportDate.ToString("dd.MM.yyyy"));
//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);
//sheet.Columns().AdjustToContents();
}
//
private static (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-2)}-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
return (tuple.Item1, tuple.Item2);
GC.Collect();
Thread.Sleep(10);
return (cs.Count, sw.ElapsedMilliseconds);
}
}
struct CellAddress
{
public int Col { get; set; }
public int Row { get; set; }
//public string GetExcelAddress()
//{
//}
}
}