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