Правка работы сервиса

Исправление ошибок формирования документа
This commit is contained in:
IvanovEugeniy 2022-07-05 11:30:25 +05:00
parent 71ace34ec9
commit 7d9a969ca6
11 changed files with 69 additions and 91 deletions

View File

@ -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; }
}

View File

@ -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; }

View File

@ -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; }
}
}

View File

@ -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))

View File

@ -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)

View File

@ -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}");
}
}

View File

@ -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}");
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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<int> 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<DailyReportBhaDto>(),
HeadDto = entity.BlockHead.Adapt<DailyReportHeadDto>(),
TimeBalanceDto = entity.BlockTimeBalance.Adapt<DailyReportTimeBalanceDto>(),
DimensionlessDto = entity.BlockDimensionless.Adapt<DailyReportDimensionlessDto>(),
SaubDto = entity.BlockSaub.Adapt<DailyReportSaubDto>(),
SignDto = entity.BlockSign.Adapt<DailyReportSignDto>()
{
Bha = entity.Info.Bha.Adapt<DailyReportBhaDto>(),
Head = entity.Info.Head.Adapt<DailyReportHeadDto>(),
TimeBalance = entity.Info.TimeBalance.Adapt<DailyReportTimeBalanceDto>(),
Dimensionless = entity.Info.Dimensionless.Adapt<DailyReportDimensionlessDto>(),
Saub = entity.Info.Saub.Adapt<DailyReportSaubDto>(),
Sign = entity.Info.Sign.Adapt<DailyReportSignDto>()
};
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<DailyReportInfo>();
entity.HeadInfo.ReportDate = dto.HeadDto.ReportDate
entity.Head.ReportDate = dto.Head.ReportDate
.ToUtcDateTimeOffset(offsetHours)
.Date;
return entity;

View File

@ -35,8 +35,8 @@ namespace ConsoleApp1
var block3 = new DailyReportSaubDto();
var bloks = new DailyReportDto()
{
HeadDto = block,
SaubDto = block3
Head = block,
Saub = block3
};