forked from ddrilling/AsbCloudServer
AutoGeneratedDailyReportService фиксы фиксов
This commit is contained in:
parent
9d180d9b4b
commit
b63d1ebff8
@ -1,3 +1,6 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace AsbCloudApp.Data.AutogeneratedDailyReport;
|
namespace AsbCloudApp.Data.AutogeneratedDailyReport;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -14,15 +17,15 @@ public class AutoGeneratedDailyReportDto : AutoGeneratedDailyReportInfoDto
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Блок подсистем
|
/// Блок подсистем
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SubsystemRecordDto[] Subsystems { get; set; } = null!;
|
public IEnumerable<SubsystemRecordDto> Subsystems { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Блок ограничивающих параметров
|
/// Блок ограничивающих параметров
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LimitingParameterRecordDto[] LimitingParameters { get; set; } = null!;
|
public IEnumerable<LimitingParameterRecordDto> LimitingParameters { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Баланс времени
|
/// Баланс времени
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TimeBalanceRecordDto[] TimeBalance { get; set; } = null!;
|
public IEnumerable<TimeBalanceRecordDto> TimeBalance { get; set; } = null!;
|
||||||
}
|
}
|
@ -100,7 +100,7 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
{
|
{
|
||||||
FileName = string.Format(fileNameTemplate, well.Caption, well.Cluster, reportDate),
|
FileName = string.Format(fileNameTemplate, well.Caption, well.Cluster, reportDate),
|
||||||
ReportDate = reportDate,
|
ReportDate = reportDate,
|
||||||
FileSize = GetFileSize(reportDate, idWell) / 1024,
|
FileSize = GetFileSize(reportDate, idWell),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,13 +121,13 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
if (!well.IdTelemetry.HasValue)
|
if (!well.IdTelemetry.HasValue)
|
||||||
throw new ArgumentInvalidException("Телеметрия для скважины отсутствует", nameof(idWell));
|
throw new ArgumentInvalidException("Телеметрия для скважины отсутствует", nameof(idWell));
|
||||||
|
|
||||||
var factOperations = (await GetFactOperationsAsync(well.Id, startDate, finishDate,
|
var factOperations = await GetFactOperationsAsync(well.Id, startDate, finishDate,
|
||||||
cancellationToken)).ToArray();
|
cancellationToken);
|
||||||
|
|
||||||
var report = new AutoGeneratedDailyReportDto
|
var report = new AutoGeneratedDailyReportDto
|
||||||
{
|
{
|
||||||
FileName = string.Format(fileNameTemplate, well.Caption, well.Cluster, reportDate),
|
FileName = string.Format(fileNameTemplate, well.Caption, well.Cluster, reportDate),
|
||||||
FileSize = GetFileSize(reportDate, idWell) / 1024,
|
FileSize = GetFileSize(reportDate, idWell),
|
||||||
ReportDate = reportDate,
|
ReportDate = reportDate,
|
||||||
Head = CreateHeadBlock(well, factOperations),
|
Head = CreateHeadBlock(well, factOperations),
|
||||||
Subsystems = (await CreateSubsystemBlockAsync(idWell, startDate, finishDate, cancellationToken)).ToArray(),
|
Subsystems = (await CreateSubsystemBlockAsync(idWell, startDate, finishDate, cancellationToken)).ToArray(),
|
||||||
@ -144,18 +144,19 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
return (report.FileName, stream);
|
return (report.FileName, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HeadBlockDto CreateHeadBlock(WellDto well, WellOperationDto[] factOperations)
|
private HeadBlockDto CreateHeadBlock(WellDto well, IEnumerable<WellOperationDto> factOperations)
|
||||||
{
|
{
|
||||||
var customer = well.Companies.FirstOrDefault(company => company.IdCompanyType == 1);
|
var customer = well.Companies.FirstOrDefault(company => company.IdCompanyType == 1);
|
||||||
|
var sortedFactOperations = factOperations.OrderBy(o => o.DateStart);
|
||||||
|
|
||||||
return new HeadBlockDto
|
return new HeadBlockDto
|
||||||
{
|
{
|
||||||
Customer = customer?.Caption ?? string.Empty,
|
Customer = customer?.Caption ?? string.Empty,
|
||||||
Deposit = well.Deposit ?? string.Empty,
|
Deposit = well.Deposit ?? string.Empty,
|
||||||
Cluster = well.Cluster ?? string.Empty,
|
Cluster = well.Cluster ?? string.Empty,
|
||||||
Well = well.Caption,
|
Well = well.Caption,
|
||||||
DepthFrom = factOperations.FirstOrDefault()?.DepthStart ?? 0.00,
|
DepthFrom = sortedFactOperations.FirstOrDefault()?.DepthStart ?? 0.00,
|
||||||
DepthTo = factOperations.LastOrDefault()?.DepthEnd ?? 0.00
|
DepthTo = sortedFactOperations.LastOrDefault()?.DepthEnd ?? 0.00
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +243,7 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
private int GetFileSize(DateOnly reportDate, int idWell)
|
private int GetFileSize(DateOnly reportDate, int idWell)
|
||||||
{
|
{
|
||||||
const int fileSizeTemplate = 10240;
|
const int fileSizeTemplate = 10240;
|
||||||
long ticks = new DateTime(reportDate.Year, reportDate.Month, reportDate.Day).Ticks * idWell;
|
long ticks = 1L * reportDate.Year * reportDate.Month * reportDate.Day * idWell;
|
||||||
int remainder = (int)(ticks % (fileSizeTemplate / 10));
|
int remainder = (int)(ticks % (fileSizeTemplate / 10));
|
||||||
return fileSizeTemplate + remainder;
|
return fileSizeTemplate + remainder;
|
||||||
}
|
}
|
||||||
|
@ -15,17 +15,14 @@ public class LimitingParameterExcelBlockWriter : IExcelBlockWriter
|
|||||||
|
|
||||||
public void Write(IXLWorksheet sheet, AutoGeneratedDailyReportDto report)
|
public void Write(IXLWorksheet sheet, AutoGeneratedDailyReportDto report)
|
||||||
{
|
{
|
||||||
if(!report.LimitingParameters.Any())
|
var i = 1;
|
||||||
return;
|
foreach (var limitingParameter in report.LimitingParameters)
|
||||||
|
|
||||||
for (int i = 0; i < report.LimitingParameters.Length; i++)
|
|
||||||
{
|
{
|
||||||
var row = sheet.Row(1 + i + rowHeaderBlock);
|
var row = sheet.Row( i++ + rowHeaderBlock);
|
||||||
|
row.Cell(columnNameFeedRegulator).Value = limitingParameter.NameFeedRegulator;
|
||||||
row.Cell(columnNameFeedRegulator).Value = report.LimitingParameters[i].NameFeedRegulator;
|
row.Cell(columnDepth).Value = limitingParameter.Depth;
|
||||||
row.Cell(columnDepth).Value = report.LimitingParameters[i].Depth;
|
row.Cell(columnTotalHours).Value = limitingParameter.Hours;
|
||||||
row.Cell(columnTotalHours).Value = report.LimitingParameters[i].Hours;
|
row.Cell(columnPercentDepth).Value = limitingParameter.PercentDepth;
|
||||||
row.Cell(columnPercentDepth).Value = report.LimitingParameters[i].PercentDepth;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,17 +15,14 @@ public class SubsystemExcelBlockWriter : IExcelBlockWriter
|
|||||||
|
|
||||||
public void Write(IXLWorksheet sheet, AutoGeneratedDailyReportDto report)
|
public void Write(IXLWorksheet sheet, AutoGeneratedDailyReportDto report)
|
||||||
{
|
{
|
||||||
if(!report.Subsystems.Any())
|
var i = 1;
|
||||||
return;
|
foreach( var subsystem in report.Subsystems )
|
||||||
|
|
||||||
for (int i = 0; i < report.Subsystems.Length; i++)
|
|
||||||
{
|
{
|
||||||
var row = sheet.Row(1 + i + rowHeaderBlock);
|
var row = sheet.Row(i++ + rowHeaderBlock);
|
||||||
|
row.Cell(columnName).Value = subsystem.Name;
|
||||||
row.Cell(columnName).Value = report.Subsystems[i].Name;
|
row.Cell(columnKUsage).Value = subsystem.KUsage;
|
||||||
row.Cell(columnKUsage).Value = report.Subsystems[i].KUsage;
|
row.Cell(columnDepth).Value = subsystem.Depth;
|
||||||
row.Cell(columnDepth).Value = report.Subsystems[i].Depth;
|
row.Cell(columnUsedTimeHours).Value = subsystem.UsedTimeHours;
|
||||||
row.Cell(columnUsedTimeHours).Value = report.Subsystems[i].UsedTimeHours;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,22 +13,18 @@ public class TimeBalanceExcelBlockWriter : IExcelBlockWriter
|
|||||||
|
|
||||||
public void Write(IXLWorksheet sheet, AutoGeneratedDailyReportDto report)
|
public void Write(IXLWorksheet sheet, AutoGeneratedDailyReportDto report)
|
||||||
{
|
{
|
||||||
if(!report.TimeBalance.Any())
|
var i = 1;
|
||||||
return;
|
foreach(var timeBalance in report.TimeBalance)
|
||||||
|
|
||||||
for (int i = 0; i < report.TimeBalance.Length; i++)
|
|
||||||
{
|
{
|
||||||
var row = sheet.Row(1 + i + rowHeaderBlock);
|
var row = sheet.Row(i++ + rowHeaderBlock);
|
||||||
|
row.Cell(columnName).Value = timeBalance.Name;
|
||||||
row.Cell(columnName).Value = report.TimeBalance[i].Name;
|
row.Cell(columnDurationHours).Value = timeBalance.DurationHours;
|
||||||
row.Cell(columnDurationHours).Value = report.TimeBalance[i].DurationHours;
|
AddBorderToCell(row.Cell(columnName));
|
||||||
|
AddBorderToCell(row.Cell(columnDurationHours));
|
||||||
AddBorderToCell(row.Cell(columnName));
|
|
||||||
AddBorderToCell(row.Cell(columnDurationHours));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddBorderToCell(IXLCell cell)
|
private static void AddBorderToCell(IXLCell cell)
|
||||||
{
|
{
|
||||||
cell.Style.Border.TopBorder = XLBorderStyleValues.Thin;
|
cell.Style.Border.TopBorder = XLBorderStyleValues.Thin;
|
||||||
cell.Style.Border.BottomBorder = XLBorderStyleValues.Thin;
|
cell.Style.Border.BottomBorder = XLBorderStyleValues.Thin;
|
||||||
|
Loading…
Reference in New Issue
Block a user