forked from ddrilling/AsbCloudServer
Правки после ревью
This commit is contained in:
parent
d2beb250d6
commit
b7f5739d8c
@ -1,27 +1,10 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Data.AutogeneratedDailyReport;
|
namespace AsbCloudApp.Data.AutogeneratedDailyReport;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DTO авто-сгенерированного суточного отчёта
|
/// DTO авто-сгенерированного суточного отчёта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AutoGeneratedDailyReportDto
|
public class AutoGeneratedDailyReportDto : AutoGeneratedDailyReportInfoDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Дата формирования отчёта
|
|
||||||
/// </summary>
|
|
||||||
public DateOnly ReportDate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Название файла
|
|
||||||
/// </summary>
|
|
||||||
public string FileName { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Размер файла
|
|
||||||
/// </summary>
|
|
||||||
public int FileSize { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Блок заголовка
|
/// Блок заголовка
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data.AutogeneratedDailyReport;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Базовая информация о суточном отчёте
|
||||||
|
/// </summary>
|
||||||
|
public class AutoGeneratedDailyReportInfoDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Дата формирования отчёта
|
||||||
|
/// </summary>
|
||||||
|
public DateOnly ReportDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Название файла
|
||||||
|
/// </summary>
|
||||||
|
public string FileName { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Размер файла
|
||||||
|
/// </summary>
|
||||||
|
public int FileSize { get; set; }
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,3 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Data.AutogeneratedDailyReport;
|
namespace AsbCloudApp.Data.AutogeneratedDailyReport;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -10,12 +8,12 @@ public class HeadBlockDto
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Название скважины
|
/// Название скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string WellName { get; set; } = null!;
|
public string Well { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Название куста
|
/// Название куста
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ClusterName { get; set; } = null!;
|
public string Cluster { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Заказчик
|
/// Заказчик
|
||||||
@ -26,24 +24,14 @@ public class HeadBlockDto
|
|||||||
/// Месторождение
|
/// Месторождение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Deposit { get; set; } = null!;
|
public string Deposit { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Начальная дата
|
|
||||||
/// </summary>
|
|
||||||
public DateOnly From { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конечная дата
|
|
||||||
/// </summary>
|
|
||||||
public DateOnly To => From.AddDays(1);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Глубина забоя на дату начала интервала
|
/// Глубина забоя на дату начала интервала
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double WellDepthIntervalStartDate { get; set; }
|
public double DepthFrom { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Глубина забоя на дату окончания интервала
|
/// Глубина забоя на дату окончания интервала
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double WellDepthIntervalFinishDate { get; set; }
|
public double DepthTo { get; set; }
|
||||||
}
|
}
|
@ -8,10 +8,10 @@ public class LimitingParameterRecordDto
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Время использования, мин
|
/// Время использования, мин
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double TotalHours { get; set; }
|
public double Hours { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Проходка
|
/// Проходка, м
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Depth { get; set; }
|
public double Depth { get; set; }
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public interface IAutoGeneratedDailyReportService
|
|||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<PaginationContainer<AutoGeneratedDailyReportDto>> GetListAsync(int idWell,
|
Task<PaginationContainer<AutoGeneratedDailyReportInfoDto>> GetListAsync(int idWell,
|
||||||
AutoGeneratedDailyReportRequest request,
|
AutoGeneratedDailyReportRequest request,
|
||||||
CancellationToken cancellationToken);
|
CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
@ -48,17 +48,18 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
this.autoGeneratedDailyReportMakerService = autoGeneratedDailyReportMakerService;
|
this.autoGeneratedDailyReportMakerService = autoGeneratedDailyReportMakerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PaginationContainer<AutoGeneratedDailyReportDto>> GetListAsync(int idWell,
|
public async Task<PaginationContainer<AutoGeneratedDailyReportInfoDto>> GetListAsync(int idWell,
|
||||||
AutoGeneratedDailyReportRequest request,
|
AutoGeneratedDailyReportRequest request,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var result = new PaginationContainer<AutoGeneratedDailyReportDto>
|
var result = new PaginationContainer<AutoGeneratedDailyReportInfoDto>
|
||||||
{
|
{
|
||||||
Skip = request.Skip ?? 0,
|
Skip = request.Skip ?? 0,
|
||||||
Take = request.Take ?? 10,
|
Take = request.Take ?? 10,
|
||||||
|
Items = Enumerable.Empty<AutoGeneratedDailyReportInfoDto>()
|
||||||
};
|
};
|
||||||
|
|
||||||
var reports = new List<AutoGeneratedDailyReportDto>();
|
var reports = new List<AutoGeneratedDailyReportInfoDto>();
|
||||||
|
|
||||||
var well = await wellService.GetOrDefaultAsync(idWell, cancellationToken)
|
var well = await wellService.GetOrDefaultAsync(idWell, cancellationToken)
|
||||||
?? throw new ArgumentInvalidException("Скважина не найдена", nameof(idWell));
|
?? throw new ArgumentInvalidException("Скважина не найдена", nameof(idWell));
|
||||||
@ -75,8 +76,9 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
{
|
{
|
||||||
var startDate = new DateTime(request.StartDate.Value.Year, request.StartDate.Value.Month,
|
var startDate = new DateTime(request.StartDate.Value.Year, request.StartDate.Value.Month,
|
||||||
request.StartDate.Value.Day);
|
request.StartDate.Value.Day);
|
||||||
|
|
||||||
datesRange.From = startDate;
|
if(startDate.Date >= datesRange.From.Date)
|
||||||
|
datesRange.From = startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.FinishDate.HasValue)
|
if (request.FinishDate.HasValue)
|
||||||
@ -84,11 +86,14 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
var finishDate = new DateTime(request.FinishDate.Value.Year, request.FinishDate.Value.Month,
|
var finishDate = new DateTime(request.FinishDate.Value.Year, request.FinishDate.Value.Month,
|
||||||
request.FinishDate.Value.Day);
|
request.FinishDate.Value.Day);
|
||||||
|
|
||||||
datesRange.To = finishDate;
|
if (finishDate.Date <= datesRange.To.Date)
|
||||||
|
datesRange.To = finishDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var dateFrom = datesRange.From; dateFrom <= datesRange.To; dateFrom = dateFrom.AddDays(1))
|
for (int day = result.Skip; (day - result.Skip) < result.Take && (datesRange.From.AddDays(day)) <= datesRange.To; day++)
|
||||||
{
|
{
|
||||||
|
var dateFrom = datesRange.From.AddDays(day);
|
||||||
|
|
||||||
reports.Add(new AutoGeneratedDailyReportDto
|
reports.Add(new AutoGeneratedDailyReportDto
|
||||||
{
|
{
|
||||||
FileName = string.Format(fileNameTemplate, well.Caption, well.Cluster, DateOnly.FromDateTime(dateFrom)),
|
FileName = string.Format(fileNameTemplate, well.Caption, well.Cluster, DateOnly.FromDateTime(dateFrom)),
|
||||||
@ -96,9 +101,10 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
FileSize = GetFileSize() / 1024,
|
FileSize = GetFileSize() / 1024,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Items = reports.Skip(result.Skip).Take(result.Take);
|
|
||||||
|
|
||||||
|
result.Items = reports;
|
||||||
|
result.Count = reports.Count;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,13 +149,12 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
|
|
||||||
return new HeadBlockDto
|
return new HeadBlockDto
|
||||||
{
|
{
|
||||||
From = reportDate,
|
|
||||||
Customer = customer?.Caption ?? string.Empty,
|
Customer = customer?.Caption ?? string.Empty,
|
||||||
Deposit = well.Deposit ?? string.Empty,
|
Deposit = well.Deposit ?? string.Empty,
|
||||||
ClusterName = well.Cluster ?? string.Empty,
|
Cluster = well.Cluster ?? string.Empty,
|
||||||
WellName = well.Caption,
|
Well = well.Caption,
|
||||||
WellDepthIntervalStartDate = factOperations.FirstOrDefault()?.DepthStart ?? 0.00,
|
DepthFrom = factOperations.FirstOrDefault()?.DepthStart ?? 0.00,
|
||||||
WellDepthIntervalFinishDate = factOperations.LastOrDefault()?.DepthEnd ?? 0.00
|
DepthTo = factOperations.LastOrDefault()?.DepthEnd ?? 0.00
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +191,7 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
return limitingParameterStats.Select(l => new LimitingParameterRecordDto
|
return limitingParameterStats.Select(l => new LimitingParameterRecordDto
|
||||||
{
|
{
|
||||||
NameFeedRegulator = l.NameFeedRegulator,
|
NameFeedRegulator = l.NameFeedRegulator,
|
||||||
TotalHours = l.TotalMinutes,
|
Hours = l.TotalMinutes,
|
||||||
PercentDepth = l.Depth / sumDepths,
|
PercentDepth = l.Depth / sumDepths,
|
||||||
Depth = l.Depth,
|
Depth = l.Depth,
|
||||||
});
|
});
|
||||||
@ -235,7 +240,7 @@ public class AutoGeneratedDailyReportService : IAutoGeneratedDailyReportService
|
|||||||
|
|
||||||
private int GetFileSize()
|
private int GetFileSize()
|
||||||
{
|
{
|
||||||
const int fileSizeTemplate = 8192;
|
const int fileSizeTemplate = 10240;
|
||||||
|
|
||||||
return new Random().Next(1, 8193) + fileSizeTemplate;
|
return new Random().Next(1, 8193) + fileSizeTemplate;
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,13 @@ public class HeadExcelBlockWriter : IExcelBlockWriter
|
|||||||
{
|
{
|
||||||
sheet.Cell(customerCell.Item1, customerCell.Item2).Value = report.Head.Customer;
|
sheet.Cell(customerCell.Item1, customerCell.Item2).Value = report.Head.Customer;
|
||||||
sheet.Cell(depositCell.Item1, depositCell.Item2).Value = report.Head.Deposit;
|
sheet.Cell(depositCell.Item1, depositCell.Item2).Value = report.Head.Deposit;
|
||||||
sheet.Cell(clusterCell.Item1, clusterCell.Item2).Value = report.Head.ClusterName;
|
sheet.Cell(clusterCell.Item1, clusterCell.Item2).Value = report.Head.Cluster;
|
||||||
sheet.Cell(wellCell.Item1, wellCell.Item2).Value = report.Head.WellName;
|
sheet.Cell(wellCell.Item1, wellCell.Item2).Value = report.Head.Well;
|
||||||
|
|
||||||
sheet.Cell(dateRow, dateFromColumn).Value = report.Head.From;
|
sheet.Cell(dateRow, dateFromColumn).Value = report.ReportDate;
|
||||||
sheet.Cell(dateRow, dateFromToColumn).Value = report.Head.To;
|
sheet.Cell(dateRow, dateFromToColumn).Value = report.ReportDate.AddDays(1);
|
||||||
|
|
||||||
sheet.Cell(depthRow, depthFromColumn).Value = report.Head.WellDepthIntervalStartDate;
|
sheet.Cell(depthRow, depthFromColumn).Value = report.Head.DepthFrom;
|
||||||
sheet.Cell(depthRow, depthToColumn).Value = report.Head.WellDepthIntervalFinishDate;
|
sheet.Cell(depthRow, depthToColumn).Value = report.Head.DepthTo;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ public class LimitingParameterExcelBlockWriter : IExcelBlockWriter
|
|||||||
|
|
||||||
row.Cell(columnNameFeedRegulator).Value = report.LimitingParameters[i].NameFeedRegulator;
|
row.Cell(columnNameFeedRegulator).Value = report.LimitingParameters[i].NameFeedRegulator;
|
||||||
row.Cell(columnDepth).Value = report.LimitingParameters[i].Depth;
|
row.Cell(columnDepth).Value = report.LimitingParameters[i].Depth;
|
||||||
row.Cell(columnTotalHours).Value = report.LimitingParameters[i].TotalHours;
|
row.Cell(columnTotalHours).Value = report.LimitingParameters[i].Hours;
|
||||||
row.Cell(columnPercentDepth).Value = report.LimitingParameters[i].PercentDepth;
|
row.Cell(columnPercentDepth).Value = report.LimitingParameters[i].PercentDepth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,8 @@ public class AutoGeneratedDailyReportController : ControllerBase
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(typeof(PaginationContainer<AutoGeneratedDailyReportDto>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PaginationContainer<AutoGeneratedDailyReportInfoDto>), (int)HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetListAsync([FromRoute][Required] int idWell,
|
public async Task<IActionResult> GetListAsync([FromRoute][Required] int idWell,
|
||||||
[FromQuery] AutoGeneratedDailyReportRequest request,
|
[FromQuery] AutoGeneratedDailyReportRequest request,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user