From 7d9a969ca6523dcc49fd3bc1e52ba01d70e6307d Mon Sep 17 00:00:00 2001 From: IvanovEugeniy Date: Tue, 5 Jul 2022 11:30:25 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=D0=B5=D1=80=D0=B2=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Data/DailyReportDto.cs | 12 ++--- AsbCloudDb/Model/DailyReportDB/DailyReport.cs | 21 ++------ .../Model/DailyReportDB/DailyReportInfo.cs | 12 ++--- .../DailyReport/DailyReportBlocks/BhaBlock.cs | 7 +-- .../DailyReportBlocks/DimensionlessBlock.cs | 6 ++- .../DailyReportBlocks/SaubBlock.cs | 23 +++++---- .../DailyReportBlocks/SignBlock.cs | 8 +-- .../DailyReportBlocks/TimeBalanceBlock.cs | 2 +- .../DailyReport/DailyReportMakerExcel.cs | 15 +++--- .../DailyReport/DailyReportService.cs | 50 ++++++++----------- ConsoleApp1/Program.cs | 4 +- 11 files changed, 69 insertions(+), 91 deletions(-) diff --git a/AsbCloudApp/Data/DailyReportDto.cs b/AsbCloudApp/Data/DailyReportDto.cs index f9bf7e36..63b22dd2 100644 --- a/AsbCloudApp/Data/DailyReportDto.cs +++ b/AsbCloudApp/Data/DailyReportDto.cs @@ -11,12 +11,12 @@ namespace AsbCloudApp.Data public class DailyReportDto { - public DailyReportHeadDto HeadDto { get; set; } - public DailyReportBhaDto BhaDto { get; set; } - public DailyReportDimensionlessDto DimensionlessDto { get; set; } - public DailyReportTimeBalanceDto TimeBalanceDto { get; set; } - public DailyReportSaubDto SaubDto { get; set; } - public DailyReportSignDto SignDto { get; set; } + public DailyReportHeadDto Head { get; set; } + public DailyReportBhaDto Bha { get; set; } + public DailyReportDimensionlessDto Dimensionless { get; set; } + public DailyReportTimeBalanceDto TimeBalance { get; set; } + public DailyReportSaubDto Saub { get; set; } + public DailyReportSignDto Sign { get; set; } } diff --git a/AsbCloudDb/Model/DailyReportDB/DailyReport.cs b/AsbCloudDb/Model/DailyReportDB/DailyReport.cs index 0d43f1a9..7d985a03 100644 --- a/AsbCloudDb/Model/DailyReportDB/DailyReport.cs +++ b/AsbCloudDb/Model/DailyReportDB/DailyReport.cs @@ -5,7 +5,7 @@ using System.ComponentModel.DataAnnotations.Schema; namespace AsbCloudDb.Model.DailyReportDB { #nullable disable - [Table("t_daily_report_mod"), Comment("Ежедневные отчёты")] + [Table("t_daily_report"), Comment("Ежедневные отчёты")] public class DailyReport { [Column("id_well"), Comment("ID скважины")] @@ -14,23 +14,8 @@ namespace AsbCloudDb.Model.DailyReportDB [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("blockTimeBalance", TypeName = "jsonb"), Comment("2 блок параметров для отчёта")] - public DailyReportTimeBalance BlockTimeBalance { 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; } + [Column("info", TypeName = "jsonb"), Comment("Список параметров для отчёта")] + public DailyReportInfo Info { get; set; } [ForeignKey(nameof(IdWell))] public virtual Well Well { get; set; } diff --git a/AsbCloudDb/Model/DailyReportDB/DailyReportInfo.cs b/AsbCloudDb/Model/DailyReportDB/DailyReportInfo.cs index 40833d8d..7d288da9 100644 --- a/AsbCloudDb/Model/DailyReportDB/DailyReportInfo.cs +++ b/AsbCloudDb/Model/DailyReportDB/DailyReportInfo.cs @@ -7,12 +7,12 @@ namespace AsbCloudDb.Model #nullable disable public class DailyReportInfo { - public DailyReportHead HeadInfo { get; set; } - public DailyReportBha BhaDto { get; set; } - public DailyReportDimensionless DimensionlessInfo { get; set; } - public DailyReportTimeBalance TimeBalanceInfo { get; set; } - public DailyReportSaub SaubInfo { get; set; } - public DailyReportSign SignInfo { get; set; } + public DailyReportHead Head { get; set; } + public DailyReportBha Bha { get; set; } + public DailyReportDimensionless Dimensionless { get; set; } + public DailyReportTimeBalance TimeBalance { get; set; } + public DailyReportSaub Saub { get; set; } + public DailyReportSign Sign { get; set; } } } diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs index b52bcdab..65ef2307 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs @@ -55,14 +55,11 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks private string FormulaBhaBlock(CellAddress beginTime, CellAddress endTime) { - return string.Format("IF({0}>0,({1}-{2})*24, \"\")", endTime.ToString(), endTime.ToString(), beginTime.ToString()); - } - - + return string.Format("IF({0}>0,({0}-{1})*24, \"\")", endTime.ToString(), beginTime.ToString()); + } public override void Draw(IXLWorksheet sheet) { - sheet._Range(AddressBhaDescription, AddressBhaDescription + (0, 7)) ._SetValue($"{blockDto.BHADescription}"); sheet._Range(AddressOperationTitle, AddressOperationTitle + (0, 4)) diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs index a53a7dbb..4c3b4cfc 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs @@ -8,7 +8,8 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks { private readonly DailyReportDimensionlessDto blockDto; - private readonly SaubBlock saubBlock; + public SaubBlock SaubBlock { get; set; } + public CellAddress AddressDimensionTitle { get; } public CellAddress AddressPreparationTitle { get; } public CellAddress AddressExtensionTitle { get; } @@ -25,6 +26,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks { AddressBlockBegin = addressBlockBegin.Copy(); this.blockDto = blockDto; + AddressDimensionTitle = addressBlockBegin + (2, 3); AddressPreparationTitle = addressBlockBegin + (3, 1); AddressExtensionTitle = addressBlockBegin + (3, 4); @@ -55,7 +57,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks private string FormulaBlockPlan(CellAddress cellTarget) { - return $"={cellTarget}/60*{saubBlock.ExtensionsCount}"; + return $"={cellTarget}/60*{SaubBlock.ExtensionsCountValue}"; } private string FormulaBlockExcess(CellAddress cellFact, CellAddress cellPlan) diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs index 0f6d45db..7494db18 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs @@ -208,16 +208,19 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks ._SetValue("Проходка за секцию"); sheet._Range(SectionPenetrationTotalValue, SectionPenetrationTotalValue + (0, 3)) ._SetValue($"{blockDto.SectionPenetrationTotal}"); - sheet._Range(ExtensionsCount, ExtensionsCount + (0, 3)) - ._SetValue("Кол- во наращиваний"); - sheet._Range(ExtensionsCountValue, ExtensionsCountValue + (0, 3)) - ._SetValue($"{blockDto.ExtensionsCount}"); - sheet._Range(DeviationFromTVD, DeviationFromTVD + (0, 3)) - ._SetValue("Отклонение от ГГД +/-, сут"); - sheet._Range(DeviationFromTVDValue, DeviationFromTVDValue + (0, 3)) - ._SetValue($"{blockDto.DeviationFromTVD}"); - sheet._Range(DeclinesReasonsROP, DeclinesReasonsROP + (1, 7)) - ._SetValue($"Примечание: {blockDto.DeclinesReasonsROP}"); + + //var test = ExtensionsCount + (0, 3); + + //sheet._Range(ExtensionsCount, test) + // ._SetValue("Кол- во наращиваний"); + //sheet._Range(ExtensionsCountValue, ExtensionsCountValue + (0, 3)) + // ._SetValue($"{blockDto.ExtensionsCount}"); + //sheet._Range(DeviationFromTVD, DeviationFromTVD + (0, 3)) + // ._SetValue("Отклонение от ГГД +/-, сут"); + //sheet._Range(DeviationFromTVDValue, DeviationFromTVDValue + (0, 3)) + // ._SetValue($"{blockDto.DeviationFromTVD}"); + //sheet._Range(DeclinesReasonsROP, DeclinesReasonsROP + (1, 7)) + // ._SetValue($"Примечание: {blockDto.DeclinesReasonsROP}"); } } diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs index 729a3e08..b110abaa 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs @@ -27,13 +27,13 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks public override void Draw(IXLWorksheet sheet) { - sheet.Range(AddressDrillMasterHead, AddressDrillMasterHead + (0, 2)) + sheet._Range(AddressDrillMasterHead, AddressDrillMasterHead + (0, 2)) ._SetValue("Мастер буровой "); - sheet.Range(AddressDrillMaster, AddressDrillMaster + (0, 2)) + sheet._Range(AddressDrillMaster, AddressDrillMaster + (0, 2)) ._SetValue($"{blockDto.DrillingMaster}"); - sheet.Range(AddressSupervisorHead, AddressSupervisorHead + (0, 2)) + sheet._Range(AddressSupervisorHead, AddressSupervisorHead + (0, 2)) ._SetValue("Супервайзер "); - sheet.Range(AddressSupervisor, AddressSupervisor + (0, 2)) + 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 index af81792b..76498934 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/TimeBalanceBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/TimeBalanceBlock.cs @@ -51,7 +51,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks { AddressBlockBegin = addressBlockBegin.Copy(); this.blockDto = blockDto; - AddressTitle = addressBlockBegin + (3, 0); + AddressTitle = addressBlockBegin + (1, 3); AddressDrilling = addressBlockBegin + (4, 1); AddressFlushing = addressBlockBegin + (5, 1); AddressBuilding = addressBlockBegin + (6, 1); diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs index 0655dfc4..8085b11b 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs @@ -18,24 +18,25 @@ namespace AsbCloudInfrastructure.Services.DailyReport private void FillExampleBlocks(XLWorkbook workbook, DailyReportDto dto) { - var sheet = workbook.Worksheets.Add(dto.HeadDto.ReportDate.ToString("dd.MM.yyyy")); + var sheet = workbook.Worksheets.Add(dto.Head.ReportDate.ToString("dd.MM.yyyy")); var addressStart = new CellAddress(sheet, 1, 1); - var blockHeader = new HeadBlock(addressStart, dto.HeadDto); + var blockHeader = new HeadBlock(addressStart, dto.Head); addressStart = blockHeader.AddressBlockEnd + (1, 0); addressStart.ColumnNumber = 1; - var blockBha = new BhaBlock(addressStart, dto.BhaDto); + var blockBha = new BhaBlock(addressStart, dto.Bha); addressStart = blockBha.AddressBlockEnd + (1, 0); addressStart.ColumnNumber = 1; - var timeBalance = new TimeBalanceBlock(addressStart, dto.TimeBalanceDto); + var timeBalance = new TimeBalanceBlock(addressStart, dto.TimeBalance); addressStart = timeBalance.AddressBlockEnd + (1, 0); addressStart.ColumnNumber = 1; - var blockDimensionless = new DimensionlessBlock(addressStart, dto.DimensionlessDto); + var blockDimensionless = new DimensionlessBlock(addressStart, dto.Dimensionless); addressStart = blockDimensionless.AddressBlockEnd + (1, 0); addressStart.ColumnNumber = 1; - var blockSaub = new SaubBlock(addressStart, dto.SaubDto); + var blockSaub = new SaubBlock(addressStart, dto.Saub); addressStart = blockSaub.AddressBlockEnd + (1, 0); + blockDimensionless.SaubBlock = blockSaub; addressStart.ColumnNumber = 1; - var blockSign = new SignBlock(addressStart, dto.SignDto); + var blockSign = new SignBlock(addressStart, dto.Sign); addressStart = blockSign.AddressBlockEnd + (1, 0); addressStart.ColumnNumber = 1; blockHeader.Draw(sheet); diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index 0dbb4636..c61c22b9 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -9,7 +9,6 @@ using AsbCloudApp.Data; using AsbCloudApp.Services; using AsbCloudDb.Model; using System.Collections.Generic; -using AsbCloudDb.Model.DailyReportDB; using AsbCloudApp.Data.DailyReport; namespace AsbCloudInfrastructure.Services.DailyReport @@ -62,19 +61,13 @@ namespace AsbCloudInfrastructure.Services.DailyReport public async Task AddAsync(int idWell, DailyReportDto dto, CancellationToken token = default) { var offsetHours = wellService.GetTimezone(idWell).Hours; - var reportDateOffset = dto.HeadDto.ReportDate.ToUtcDateTimeOffset(offsetHours); + var reportDateOffset = dto.Head.ReportDate.ToUtcDateTimeOffset(offsetHours); var info = Convert(dto, offsetHours); var entity = new AsbCloudDb.Model.DailyReportDB.DailyReport { IdWell = idWell, StartDate = reportDateOffset, - BlockHead = info.HeadInfo, - BlockBha = info.BhaDto, - BlockDimensionless = info.DimensionlessInfo, - BlockTimeBalance = info.TimeBalanceInfo, - BlockSaub = info.SaubInfo, - BlockSign = info.SignInfo - + Info = info }; db.DailyReports.Add(entity); var result = await db.SaveChangesAsync(token); @@ -94,10 +87,8 @@ namespace AsbCloudInfrastructure.Services.DailyReport if (entity is null) return 0; - var convertEntity = Convert(dto, offsetHours); - entity.BlockHead = convertEntity.HeadInfo; + entity.Info = Convert(dto, offsetHours); db.DailyReports.Update(entity); - var result = await db.SaveChangesAsync(token); return result; } @@ -134,33 +125,32 @@ namespace AsbCloudInfrastructure.Services.DailyReport { var well = await wellService.GetAsync(idWell, token); var offsetHours = wellService.GetTimezone(idWell).Hours; - var headDto = new DailyReportHeadDto() - { - ReportDate = date, - WellName = well.Caption, - ClusterName = well.Cluster, - }; var dto = new DailyReportDto() { - HeadDto = headDto + Head=new DailyReportHeadDto() + { + ReportDate = DateTimeOffset.UtcNow.ToRemoteDateTime(offsetHours), + WellName = well.Caption, + ClusterName = well.Cluster + } }; - DailyReportDto result = dto; - return result; + + return dto; } private static DailyReportDto Convert(AsbCloudDb.Model.DailyReportDB.DailyReport entity, double offsetHours) { var dto = new DailyReportDto() - { - BhaDto = entity.BlockBha.Adapt(), - HeadDto = entity.BlockHead.Adapt(), - TimeBalanceDto = entity.BlockTimeBalance.Adapt(), - DimensionlessDto = entity.BlockDimensionless.Adapt(), - SaubDto = entity.BlockSaub.Adapt(), - SignDto = entity.BlockSign.Adapt() + { + Bha = entity.Info.Bha.Adapt(), + Head = entity.Info.Head.Adapt(), + TimeBalance = entity.Info.TimeBalance.Adapt(), + Dimensionless = entity.Info.Dimensionless.Adapt(), + Saub = entity.Info.Saub.Adapt(), + Sign = entity.Info.Sign.Adapt() }; - dto.HeadDto.ReportDate = entity.StartDate + dto.Head.ReportDate = entity.StartDate .ToRemoteDateTime(offsetHours); return dto; } @@ -168,7 +158,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport private static DailyReportInfo Convert(DailyReportDto dto, double offsetHours) { var entity = dto.Adapt(); - entity.HeadInfo.ReportDate = dto.HeadDto.ReportDate + entity.Head.ReportDate = dto.Head.ReportDate .ToUtcDateTimeOffset(offsetHours) .Date; return entity; diff --git a/ConsoleApp1/Program.cs b/ConsoleApp1/Program.cs index 14b28e95..e70f4f76 100644 --- a/ConsoleApp1/Program.cs +++ b/ConsoleApp1/Program.cs @@ -35,8 +35,8 @@ namespace ConsoleApp1 var block3 = new DailyReportSaubDto(); var bloks = new DailyReportDto() { - HeadDto = block, - SaubDto = block3 + Head = block, + Saub = block3 };