ScheduleReportService мелкие переделки.

This commit is contained in:
ngfrolov 2023-06-07 14:04:11 +05:00
parent 29e0829bda
commit d845f4c592
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7
2 changed files with 9 additions and 18 deletions

View File

@ -12,7 +12,6 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.WellOperationService
{
public class ScheduleReportService : IScheduleReportService
{
private readonly IOperationsStatService operationsStatService;
@ -57,27 +56,23 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
var plans = tvd
.Where(t => t.Plan is not null)
.Select(t => t.Plan!)
.OrderBy(t => t.DateStart)
.ToList();
.OrderBy(t => t.DateStart);
FillCurrentScheduleSheet(workbook, plans, sheetNameSchedulePlan);
var facts = tvd
.Where(t => t.Fact is not null)
.Select(t => t.Fact!)
.OrderBy(t => t.DateStart)
.ToList();
.OrderBy(t => t.DateStart);
FillCurrentScheduleSheet(workbook, facts, sheetNameScheduleFact);
var predictions = tvd
.Where(t => t.Predict is not null)
.Select(t => t.Predict!)
.OrderBy(t => t.DateStart)
.ToList();
.OrderBy(t => t.DateStart);
FillCurrentScheduleSheet(workbook, predictions, sheetNameSchedulePrediction);
}
private static void FillCurrentScheduleSheet(XLWorkbook workbook, List<WellOperationDto> tvdList, string sheetName)
private static void FillCurrentScheduleSheet(XLWorkbook workbook, IEnumerable<WellOperationDto> tvdList, string sheetName)
{
var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetName);
if (sheet is null)
@ -93,22 +88,18 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
const int columnDateStart = 7;
const int columnDateEnd = 8;
int i = 0;
for (; i < tvdList.Count; i++)
int i = 1;
foreach (var tvdItem in tvdList)
{
var tvdItem = tvdList[i];
if (tvdItem is null)
continue;
var row = sheet.Row(1 + i + headerRowsCount);
SetCell(row, columnRowNumber, $"{1 + i}");
var row = sheet.Row(i + headerRowsCount);
SetCell(row, columnRowNumber, $"{i}");
SetCell(row, columnCaption, $"{tvdItem.CategoryName} {tvdItem.CategoryInfo}".Trim());
SetCell(row, columnWellDepthStart, tvdItem.DepthStart);
SetCell(row, columnWellDepthEnd, tvdItem.DepthEnd);
SetCell(row, columnDuration, tvdItem.DurationHours);
SetCell(row, columnDateStart, tvdItem.DateStart);
SetCell(row, columnDateEnd, tvdItem.DateStart.AddHours(tvdItem.DurationHours));
i++;
}
}