forked from ddrilling/AsbCloudServer
Merge pull request 'Сортировка операций в сетевом графике' (#59) from fix/shedule-report-template into dev
Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/59
This commit is contained in:
commit
0858651fdc
@ -12,12 +12,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
{
|
||||
|
||||
public class ScheduleReportService : IScheduleReportService
|
||||
{
|
||||
private readonly IOperationsStatService operationsStatService;
|
||||
private readonly IWellService wellService;
|
||||
const string sheetNameSchedule = "Сетевой график";
|
||||
const string sheetNameSchedulePlan = "План";
|
||||
const string sheetNameScheduleFact = "Факт";
|
||||
const string sheetNameSchedulePrediction = "Прогноз";
|
||||
const string sheetNameTvd = "ГГД";
|
||||
const int maxChartsToWrap = 88;
|
||||
|
||||
@ -47,6 +49,61 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
}
|
||||
|
||||
private static void FillScheduleSheetToWorkbook(XLWorkbook workbook, IEnumerable<PlanFactPredictBase<WellOperationDto>> tvd, WellDto well)
|
||||
{
|
||||
FillScheduleSheet(workbook, tvd, well);
|
||||
|
||||
var tvdList = tvd.ToList();
|
||||
var plans = tvd
|
||||
.Where(t => t.Plan is not null)
|
||||
.Select(t => t.Plan!)
|
||||
.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);
|
||||
FillCurrentScheduleSheet(workbook, facts, sheetNameScheduleFact);
|
||||
|
||||
var predictions = tvd
|
||||
.Where(t => t.Predict is not null)
|
||||
.Select(t => t.Predict!)
|
||||
.OrderBy(t => t.DateStart);
|
||||
FillCurrentScheduleSheet(workbook, predictions, sheetNameSchedulePrediction);
|
||||
}
|
||||
|
||||
private static void FillCurrentScheduleSheet(XLWorkbook workbook, IEnumerable<WellOperationDto> tvdList, string sheetName)
|
||||
{
|
||||
var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetName);
|
||||
if (sheet is null)
|
||||
return;
|
||||
|
||||
const int headerRowsCount = 6;
|
||||
|
||||
const int columnRowNumber = 2;
|
||||
const int columnCaption = 3;
|
||||
const int columnWellDepthStart = 4;
|
||||
const int columnWellDepthEnd = 5;
|
||||
const int columnDuration = 6;
|
||||
const int columnDateStart = 7;
|
||||
const int columnDateEnd = 8;
|
||||
|
||||
int i = 1;
|
||||
foreach (var tvdItem in tvdList)
|
||||
{
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void FillScheduleSheet(XLWorkbook workbook, IEnumerable<PlanFactPredictBase<WellOperationDto>> tvd, WellDto well)
|
||||
{
|
||||
var sheet = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNameSchedule);
|
||||
if (sheet is null)
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user