Правки после ревью

This commit is contained in:
Olga Nemt 2024-02-16 15:21:01 +05:00
parent 30d8632dd7
commit 9b5bc227b0
4 changed files with 54 additions and 37 deletions

View File

@ -0,0 +1,26 @@
using AsbCloudApp.Requests;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudApp.Services.ProcessMaps.WellDrilling
{
/// <summary>
/// Сервис экспорт РТК
/// </summary>
public interface IProcessMapReportDataSaubStatExportService
{
/// <summary>
/// Сформировать файл с данными
/// </summary>
/// <param name="idWell"></param>
/// <param name="request">параметры запроса</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<(string Name, Stream File)?> ExportAsync(int idWell, DataSaubStatRequest request, CancellationToken cancellationToken);
}
}

View File

@ -202,7 +202,7 @@ namespace AsbCloudInfrastructure
services.AddScoped<IWellService, WellService>();
services.AddTransient<IWellOperationImportService, WellOperationImportService>();
services.AddTransient<IProcessMapReportWellDrillingExportService, ProcessMapReportWellDrillingExportService>();
services.AddTransient<IProcessMapReportWellDrillingExportService, ProcessMapReportDataSaubStatExportService>();
services.AddTransient<IProcessMapReportDataSaubStatExportService, ProcessMapReportDataSaubStatExportService>();
services.AddTransient<TrajectoryPlanExportService>();
services.AddTransient<TrajectoryFactManualExportService>();
services.AddTransient<TrajectoryFactNnbExportService>();

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
{
public class ProcessMapReportDataSaubStatExportService : IProcessMapReportWellDrillingExportService
public class ProcessMapReportDataSaubStatExportService : IProcessMapReportDataSaubStatExportService
{
const int firstColumn = 2;
const int lastColumn = 35;
@ -30,7 +30,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
this.processMapReportDataSaubStatService = processMapReportDataSaubStatService;
}
public async Task<(string Name, Stream File)?> ExportAsync(int idWell, CancellationToken cancellationToken)
public async Task<(string Name, Stream File)?> ExportAsync(int idWell, DataSaubStatRequest request, CancellationToken cancellationToken)
{
var well = await wellService.GetOrDefaultAsync(idWell, cancellationToken);
@ -40,7 +40,6 @@ namespace AsbCloudInfrastructure.Services.ProcessMaps.Report
var stream = Assembly.GetExecutingAssembly().GetTemplateCopyStream(TemplateName);
using var workbook = new XLWorkbook(stream);
var request = new DataSaubStatRequest();
var data = await processMapReportDataSaubStatService.GetAsync(idWell, request, cancellationToken);
FillProcessMapToWorkbook(workbook, data);

View File

@ -11,21 +11,13 @@ public static class XLExtentions
workbook.Worksheets.FirstOrDefault(ws => string.Equals(ws.Name.Trim(), sheetName.Trim(), StringComparison.CurrentCultureIgnoreCase))
?? throw new FileFormatException($"Книга excel не содержит листа {sheetName}.");
public static IXLCell SetCellValue<T>(this IXLCell cell, T value)
public static IXLCell SetCellValue<T>(this IXLCell cell, T value, string? format = null)
{
if (typeof(T) == typeof(DateTime))
cell.Style.DateFormat.Format = "DD.MM.YYYY HH:MM:SS";
cell.Value = XLCellValue.FromObject(value);
return cell;
{
cell.Style.DateFormat.Format = format ?? "DD.MM.YYYY HH:MM:SS";
}
public static IXLCell SetCellValue<T>(this IXLCell cell, T value, string format)
{
if (typeof(T) == typeof(DateTime))
cell.Style.DateFormat.Format = format;
cell.Value = XLCellValue.FromObject(value);
return cell;