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