parent
4f87a288e0
commit
09acc207fc
@ -0,0 +1,13 @@ |
||||
namespace CORRESPONSALBackend.Contracts.Reportes.Newell.Mensual |
||||
{ |
||||
public interface IReporteMensualRepository |
||||
{ |
||||
public Task CrearTablasReporteMensual(); |
||||
public Task<DTOTrailas> PopulateTrailasTable(DTOTrailas record); |
||||
public Task<DTOOperacionesCdAcuna> PopulateOperacionesCdAcunaTable(DTOOperacionesCdAcuna record); |
||||
public Task<DTOOperacionesLazaroCardenas> PopulateOperacionesLazaroCardenasTable(DTOOperacionesLazaroCardenas record); |
||||
public Task<IEnumerable<DTOReporteMensualCdAcuna>> GetRptMensualCdAcuna(); |
||||
public Task<IEnumerable<DTOOperacionesLazaroCardenas>> GetRptMensualLazaroCardenas(); |
||||
public Task DropTempTables(); |
||||
} |
||||
} |
@ -0,0 +1,5 @@ |
||||
namespace CORRESPONSALBackend.Contracts.Reportes.Newell.Mensual{ |
||||
public interface IReporteMensualService{ |
||||
public Task<MemoryStream> GetReporteMensual(int idTrailasFile, int idRptCdAcunaFile, int idRptLazaroCardenasFile); |
||||
} |
||||
} |
@ -0,0 +1,41 @@ |
||||
using Microsoft.AspNetCore.Mvc; |
||||
using Microsoft.AspNetCore.Authorization; |
||||
using CORRESPONSALBackend.Contracts.Utils; |
||||
using CORRESPONSALBackend.Models.Utils; |
||||
using OfficeOpenXml; |
||||
using OfficeOpenXml.Table; |
||||
using OfficeOpenXml.Style; |
||||
using CORRESPONSALBackend.Contracts.Reportes.Newell.Mensual; |
||||
|
||||
namespace CORRESPONSALBackend.Controllers.Reportes{ |
||||
[Authorize] |
||||
[Route("api/[controller]")]
|
||||
[ApiController] |
||||
public class ReportesNewellController : ControllerBase |
||||
{ |
||||
private readonly IReporteMensualRepository _reporteMensualRepository; |
||||
private readonly IReporteMensualService _reporteMensualService; |
||||
public ReportesNewellController(IReporteMensualRepository reporteMensualRepository, IReporteMensualService reporteMensualService){ |
||||
_reporteMensualRepository = reporteMensualRepository; |
||||
_reporteMensualService = reporteMensualService; |
||||
} |
||||
|
||||
[HttpGet("ReporteMensual")] |
||||
public async Task<IActionResult> GetReporteMensual([FromQuery] int idTrailasFile, int idRptCdAcunaFile, int idRptLazaroCardenasFile){ |
||||
try{ |
||||
await _reporteMensualRepository.CrearTablasReporteMensual(); |
||||
var stream = await _reporteMensualService.GetReporteMensual(idTrailasFile, idRptCdAcunaFile, idRptLazaroCardenasFile); |
||||
if(stream.Length > 0){ |
||||
stream.Position = 0; |
||||
await _reporteMensualRepository.DropTempTables(); |
||||
return File(stream,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", $"ReporteMensual.xlsx"); |
||||
}else{ |
||||
throw new Exception("Ocurrio un error al generar el reporte, intentelo de nuevo"); |
||||
} |
||||
}catch(Exception ex){ |
||||
await _reporteMensualRepository.DropTempTables(); |
||||
return StatusCode(500,ex.Message); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
public class DTOOperacionesCdAcuna{ |
||||
public string? Aduana { get; set; } |
||||
public string? Patente { get; set; } |
||||
public string? Pedimento { get; set; } |
||||
/*public DateTime? FechaEntrega { get; set; } |
||||
public DateTime? FechaPago { get; set; } |
||||
public string ValorComercialMxn { get; set; } |
||||
public string ValorComercialDlls { get; set; } |
||||
public string ValorAduana { get; set; }*/ |
||||
public string? Clave { get; set; } |
||||
/*public string Iva { get; set; } |
||||
public string Dta { get; set; } |
||||
public string Prv { get; set; } |
||||
public string Lgi { get; set; }*/ |
||||
public string? Factura { get; set; } |
||||
public string? Tc { get; set; } |
||||
public string? Proveedor { get; set; } |
||||
public string? TaxId { get; set; } |
||||
public string? Producto { get; set; } |
||||
} |
@ -0,0 +1,18 @@ |
||||
public class DTOOperacionesLazaroCardenas{ |
||||
public string? Pedimento { get; set; } |
||||
public string? NoContenedor { get; set; } |
||||
public int? CantidadContenedores { get; set; } |
||||
public string? Soia { get; set; } |
||||
public int? TiempoDespacho { get; set; } |
||||
public string? Clave { get; set; } |
||||
public string? PedimentoRectificado { get; set; } |
||||
public string? Causa { get; set; } |
||||
public string? CargoA { get; set; } |
||||
public int? TiempoProceso { get; set; } |
||||
public int? TiempoCruce { get; set; } |
||||
public string? Cumple { get; set; } |
||||
public string? NoCumple { get; set; } |
||||
public string? RazonNoCumple { get; set; } |
||||
public string? CargoDe { get; set; } |
||||
public string? MedioSalida { get; set; } |
||||
} |
@ -0,0 +1,11 @@ |
||||
public class DTOReporteMensualCdAcuna{ |
||||
public string Pedimento { get; set; } |
||||
public string Traila { get; set; } |
||||
public int NoContenedores { get; set; } |
||||
public string Soia { get; set; } |
||||
public int TiempoDespacho { get; set; } |
||||
public string Clave { get; set; } |
||||
public string PedimentoRectificado { get; set; } |
||||
public string Causa { get; set; } |
||||
public string CargoA { get; set; } |
||||
} |
@ -0,0 +1,8 @@ |
||||
public class DTOTrailas{ |
||||
public DateTime? Fecha { get; set; } |
||||
public string? Traila { get; set; } |
||||
public string? Pedimento { get; set; } |
||||
public string? Candado { get; set; } |
||||
public string? Doda { get; set; } |
||||
public string? Soia { get; set; } |
||||
} |
@ -0,0 +1,112 @@ |
||||
using System.Data; |
||||
using CORRESPONSALBackend.Context; |
||||
using CORRESPONSALBackend.Contracts.Reportes.Newell.Mensual; |
||||
using Dapper; |
||||
|
||||
namespace CORRESPONSALBackend.Repository.Reportes |
||||
{ |
||||
public class ReporteMensualRepository : IReporteMensualRepository |
||||
{ |
||||
private readonly DapperContext _context; |
||||
public ReporteMensualRepository(DapperContext context) { _context = context; } |
||||
|
||||
public async Task CrearTablasReporteMensual() |
||||
{ |
||||
var query = "[Reportes.Newell.CreateTempTables]"; |
||||
using var connection = _context.CreateConnection(); |
||||
await connection.QueryAsync(query, new { }, commandType: CommandType.StoredProcedure); |
||||
return; |
||||
} |
||||
|
||||
public async Task<DTOTrailas> PopulateTrailasTable(DTOTrailas record) |
||||
{ |
||||
var query = "[Reportes.Newell.PopulateTrailas]"; |
||||
using var connection = _context.CreateConnection(); |
||||
var entrada = await connection.QueryAsync<DTOTrailas>(query, new |
||||
{ |
||||
@fecha = record.Fecha, |
||||
@traila = record.Traila, |
||||
@pedimento = record.Pedimento, |
||||
@candado = record.Candado, |
||||
@doda = record.Doda, |
||||
@estado = record.Soia |
||||
}, |
||||
commandType: CommandType.StoredProcedure); |
||||
|
||||
return entrada.FirstOrDefault(); |
||||
} |
||||
|
||||
public async Task<DTOOperacionesCdAcuna> PopulateOperacionesCdAcunaTable(DTOOperacionesCdAcuna record) |
||||
{ |
||||
var query = "[Reportes.Newell.PopulateOperacionesCdAcuna]"; |
||||
using var connection = _context.CreateConnection(); |
||||
var entrada = await connection.QueryAsync<DTOOperacionesCdAcuna>(query, new |
||||
{ |
||||
@aduana = record.Aduana, |
||||
@patente = record.Patente, |
||||
@pedimento = record.Pedimento, |
||||
@clave = record.Clave, |
||||
@factura = record.Factura, |
||||
@tc = record.Tc, |
||||
@proveedor = record.Proveedor, |
||||
@taxId = record.TaxId, |
||||
@producto = record.Producto |
||||
}, |
||||
commandType: CommandType.StoredProcedure); |
||||
|
||||
return entrada.FirstOrDefault(); |
||||
} |
||||
|
||||
public async Task<DTOOperacionesLazaroCardenas> PopulateOperacionesLazaroCardenasTable(DTOOperacionesLazaroCardenas record) |
||||
{ |
||||
var query = "[Reportes.Newell.PopulateOperacionesLazaroCardenas]"; |
||||
using var connection = _context.CreateConnection(); |
||||
var entrada = await connection.QueryAsync<DTOOperacionesLazaroCardenas>(query, new |
||||
{ |
||||
@pedimento = record.Pedimento, |
||||
@noContenedor = record.NoContenedor, |
||||
@cantidadContenedores = record.CantidadContenedores, |
||||
@soia = record.Soia, |
||||
@tiempodespacho = record.TiempoDespacho, |
||||
@clave = record.Clave, |
||||
@pedimentoRectificado = record.PedimentoRectificado, |
||||
@causa = record.Causa, |
||||
@cargoA = record.CargoA, |
||||
@tiempoProceso = record.TiempoProceso, |
||||
@tiempoCruce = record.TiempoCruce, |
||||
@cumple = record.Cumple, |
||||
@noCumple = record.NoCumple, |
||||
@razonNoCumple = record.RazonNoCumple, |
||||
@cargoDe = record.CargoDe, |
||||
@medioSalida = record.MedioSalida |
||||
}, |
||||
commandType: CommandType.StoredProcedure); |
||||
|
||||
return entrada.FirstOrDefault(); |
||||
} |
||||
|
||||
public async Task<IEnumerable<DTOReporteMensualCdAcuna>> GetRptMensualCdAcuna() |
||||
{ |
||||
var query = "[Reportes.Newell.GetReporteMensualCdAcuna]"; |
||||
using var connection = _context.CreateConnection(); |
||||
var entrada = await connection.QueryAsync<DTOReporteMensualCdAcuna>(query, new {}, commandType: CommandType.StoredProcedure); |
||||
return entrada.ToList(); |
||||
} |
||||
|
||||
public async Task<IEnumerable<DTOOperacionesLazaroCardenas>> GetRptMensualLazaroCardenas() |
||||
{ |
||||
var query = "[Reportes.Newell.GetReporteMensualLazaroCardenas]"; |
||||
using var connection = _context.CreateConnection(); |
||||
var entrada = await connection.QueryAsync<DTOOperacionesLazaroCardenas>(query, new {}, commandType: CommandType.StoredProcedure); |
||||
return entrada.ToList(); |
||||
} |
||||
|
||||
public async Task DropTempTables() |
||||
{ |
||||
var query = "[Reportes.Newell.DropReporteMensualTempTables]"; |
||||
using var connection = _context.CreateConnection(); |
||||
await connection.QueryAsync(query, new { }, commandType: CommandType.StoredProcedure); |
||||
return; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,193 @@ |
||||
using CORRESPONSALBackend.Contracts.Reportes.Newell.Mensual; |
||||
using CORRESPONSALBackend.Contracts.Utils; |
||||
using CORRESPONSALBackend.Models.Utils; |
||||
using OfficeOpenXml; |
||||
using OfficeOpenXml.Style; |
||||
using OfficeOpenXml.Table; |
||||
|
||||
namespace CORRESPONSALBackend.Services.Reportes.Newell.Mensual{ |
||||
public class ReporteMensualService : IReporteMensualService |
||||
{ |
||||
private readonly IFileManagerRepository _Repo; |
||||
private readonly IReporteMensualRepository _reporteMensualRepository; |
||||
private readonly IFilePaths4ProcessRepository _RepoRelativePath; |
||||
private readonly IConfiguration _config; |
||||
private readonly string RootPathCorresponsales; |
||||
public ReporteMensualService(IReporteMensualRepository reporteMensualRepository, IFilePaths4ProcessRepository RepoRelativePath, IConfiguration config, IFileManagerRepository Repo){ |
||||
_reporteMensualRepository = reporteMensualRepository; |
||||
_RepoRelativePath = RepoRelativePath; |
||||
_config = config; |
||||
_Repo = Repo; |
||||
RootPathCorresponsales = _config.GetValue<string>("AllFiles"); |
||||
} |
||||
|
||||
public async Task<MemoryStream> GetReporteMensual(int idTrailasFile, int idRptCdAcunaFile, int idRptLazaroCardenasFile){ |
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial; |
||||
//Comienza la lectura de los archivos cargados. |
||||
await PopulateTrailasTable(idTrailasFile); |
||||
await PopulateOperacionesCdAcunaTable(idRptCdAcunaFile); |
||||
await PopulateOperacionesLazaroCardenasTable(idRptLazaroCardenasFile); |
||||
//Comienza la escritura del reporte mensual. |
||||
using(ExcelPackage package = new ExcelPackage()){ |
||||
//Se obtienen los datos del reporte. |
||||
var rptCdAcuna = await _reporteMensualRepository.GetRptMensualCdAcuna(); |
||||
var rptLazaroCardenas = await _reporteMensualRepository.GetRptMensualLazaroCardenas(); |
||||
if(rptCdAcuna.Count() <= 0 || rptLazaroCardenas.Count() <= 0) throw new Exception("No se encontraron los datos necesarios para generar el reporte, intentelo de nuevo."); |
||||
//Se crea la primer hoja del reporte. |
||||
{ |
||||
var totalRows = rptCdAcuna.Count(); |
||||
var worksheetCdAcuna = package.Workbook.Worksheets.Add("Cd. Acuña"); |
||||
//Se crean los encabezados de la primer hoja. |
||||
worksheetCdAcuna.Cells["A1"].Value = "PEDIMENTO"; |
||||
worksheetCdAcuna.Cells["B1"].Value = "TRAILA"; |
||||
worksheetCdAcuna.Cells["C1"].Value = "NUMERO DE CONTENEDORES"; |
||||
worksheetCdAcuna.Cells["D1"].Value = "SOIA"; |
||||
worksheetCdAcuna.Cells["E1"].Value = "TIEMPO DE DESPACHO DIAS DE ARRIBO VS DESADUANADO"; |
||||
worksheetCdAcuna.Cells["F1"].Value = "CLAVE"; |
||||
worksheetCdAcuna.Cells["G1"].Value = "PEDIMENTO RECTIFICADO"; |
||||
worksheetCdAcuna.Cells["H1"].Value = "CAUSA"; |
||||
worksheetCdAcuna.Cells["I1"].Value = "CARGO A"; |
||||
//Se crea el rango de celdas que abarcara la tabla. |
||||
ExcelRange range = worksheetCdAcuna.Cells[1, 1,rptCdAcuna.Count() + 1, 9]; |
||||
//Se vacian los datos obtenidos en el excel. |
||||
worksheetCdAcuna.Cells["A2"].LoadFromCollection(rptCdAcuna, false); |
||||
ExcelTable tab = worksheetCdAcuna.Tables.Add(range, "Table1"); |
||||
//tab.TableStyle = TableStyles.Light1; |
||||
worksheetCdAcuna.Cells[$"A{totalRows+2}"].Value = $"{totalRows} PEDIMENTOS"; |
||||
worksheetCdAcuna.Cells[$"C{totalRows+2}"].Value = $"{totalRows} CONTENEDORES"; |
||||
worksheetCdAcuna.Cells[$"D{totalRows+2}"].Value = $"{rptCdAcuna.Where(x => x.Soia.ToUpper() == "ROJO").ToList().Count()} ROJOS"; |
||||
worksheetCdAcuna.Cells[$"E{totalRows+2}"].Value = $"1 DIA PROMEDIO"; |
||||
worksheetCdAcuna.Cells[worksheetCdAcuna.Dimension.Address].AutoFitColumns(); |
||||
worksheetCdAcuna.Cells[worksheetCdAcuna.Dimension.Address].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; |
||||
} |
||||
{ |
||||
var totalRows = rptLazaroCardenas.Count(); |
||||
var worksheetLazaroCardenas = package.Workbook.Worksheets.Add("Lazaro Cardenas"); |
||||
//Se crean los encabezados de la segunda hoja. |
||||
worksheetLazaroCardenas.Cells["A1"].Value = "PEDIMENTO"; |
||||
worksheetLazaroCardenas.Cells["B1"].Value = "NO.CONTEN"; |
||||
worksheetLazaroCardenas.Cells["C1"].Value = "CANTIDAD DE CONTENEDORES"; |
||||
worksheetLazaroCardenas.Cells["D1"].Value = "SOIA ROJO"; |
||||
worksheetLazaroCardenas.Cells["E1"].Value = "TIEMPO DE DESPACHO DIAS DE ARRIBO VS DESADUANAMIENTO"; |
||||
worksheetLazaroCardenas.Cells["F1"].Value = "CLAVE"; |
||||
worksheetLazaroCardenas.Cells["G1"].Value = "PEDIMENTO RECTIFICADO"; |
||||
worksheetLazaroCardenas.Cells["H1"].Value = "CAUSA"; |
||||
worksheetLazaroCardenas.Cells["I1"].Value = "CARGO A"; |
||||
worksheetLazaroCardenas.Cells["J1"].Value = "TIEMPOS DE PROCESO"; |
||||
worksheetLazaroCardenas.Cells["K1"].Value = "TIEMPOS DE CRUCE"; |
||||
worksheetLazaroCardenas.Cells["L1"].Value = "1 A 3 DIAS CUMPLE"; |
||||
worksheetLazaroCardenas.Cells["M1"].Value = "3 A 5 DIAS NO CUMPLE"; |
||||
worksheetLazaroCardenas.Cells["N1"].Value = "RAZON POR LA QUE NO CUMPLE"; |
||||
worksheetLazaroCardenas.Cells["O1"].Value = "A CARGO DE"; |
||||
worksheetLazaroCardenas.Cells["P1"].Value = "MEDIO DE SALIDA"; |
||||
//Se crea el rango de celdas que abarcara la tabla. |
||||
ExcelRange range = worksheetLazaroCardenas.Cells[1, 1,rptLazaroCardenas.Count() + 1, 16]; |
||||
//Se vacian los datos obtenidos en el excel. |
||||
worksheetLazaroCardenas.Cells["A2"].LoadFromCollection(rptLazaroCardenas, false); |
||||
ExcelTable tab = worksheetLazaroCardenas.Tables.Add(range, "Table2"); |
||||
//tab.TableStyle = TableStyles.Light1; |
||||
worksheetLazaroCardenas.Cells[$"A{totalRows+2}"].Value = $"{totalRows} PEDIMENTOS"; |
||||
worksheetLazaroCardenas.Cells[$"C{totalRows+2}"].Value = $"{rptLazaroCardenas.Sum(x => Convert.ToInt32(x.CantidadContenedores))} CONTENEDORES"; |
||||
worksheetLazaroCardenas.Cells[$"D{totalRows+2}"].Value = $"{rptLazaroCardenas.Where(x => !string.IsNullOrWhiteSpace(x.Soia) && x.Soia.ToUpper() == "ROJO").ToList().Count()} ROJOS"; |
||||
worksheetLazaroCardenas.Cells[$"E{totalRows+2}"].Value = $"{Math.Round(rptLazaroCardenas.Average(x => Convert.ToInt32(x.TiempoDespacho)),0)} DIAS PROMEDIO"; |
||||
worksheetLazaroCardenas.Cells[$"J{totalRows+2}"].Value = $"{Math.Round(rptLazaroCardenas.Average(x => Convert.ToInt32(x.TiempoProceso)),0)} DIAS PROMEDIO"; |
||||
worksheetLazaroCardenas.Cells[$"K{totalRows+2}"].Value = $"{Math.Round(rptLazaroCardenas.Average(x => Convert.ToInt32(x.TiempoCruce)),0)} DIAS PROMEDIO"; |
||||
worksheetLazaroCardenas.Cells[worksheetLazaroCardenas.Dimension.Address].AutoFitColumns(); |
||||
worksheetLazaroCardenas.Cells[worksheetLazaroCardenas.Dimension.Address].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; |
||||
} |
||||
package.Workbook.Calculate(); |
||||
var stream = new MemoryStream(); |
||||
package.SaveAs(stream); |
||||
return stream; |
||||
} |
||||
} |
||||
private async Task<string> getFilePath(int id){ |
||||
//Se obtiene la ruta del archivo |
||||
FileManager recFound = await _Repo.getFileById(id); |
||||
FilePaths4Process RelativePath = await _RepoRelativePath.getPaths4ProcessById(recFound.Proceso); |
||||
return RootPathCorresponsales + RelativePath.Path + recFound.NombreArchivo; |
||||
} |
||||
private async Task PopulateTrailasTable(int fileId){ |
||||
//Se obtiene la ruta del archivo |
||||
string targetFile = await getFilePath(fileId); |
||||
//Aqui comienza la lectura del archivo. |
||||
var file = new FileInfo(targetFile); |
||||
using(ExcelPackage package = new ExcelPackage(file)){ |
||||
var worksheet = package.Workbook.Worksheets.FirstOrDefault(); |
||||
int rowCount = 2; |
||||
while(string.IsNullOrWhiteSpace(worksheet?.Cells[rowCount, 3].Value?.ToString()) == false){//Se valida si la columna del pedimento no esta vacia. |
||||
var resp = await _reporteMensualRepository.PopulateTrailasTable(new DTOTrailas(){ |
||||
Fecha = worksheet.Cells[rowCount, 1].Value != null ? DateTime.FromOADate(long.Parse(worksheet.Cells[rowCount, 1].Value?.ToString())) : null, |
||||
Traila = worksheet.Cells[rowCount, 2].Value != null ? worksheet.Cells[rowCount, 2].Value?.ToString() : null, |
||||
Pedimento = worksheet.Cells[rowCount, 3].Value != null ? worksheet.Cells[rowCount, 3].Value?.ToString() : null, |
||||
Candado = worksheet.Cells[rowCount, 4].Value != null ? worksheet.Cells[rowCount, 4].Value?.ToString() : null, |
||||
Doda = worksheet.Cells[rowCount, 5].Value != null ? worksheet.Cells[rowCount, 5].Value?.ToString() : null, |
||||
Soia = worksheet.Cells[rowCount, 6].Value != null ? worksheet.Cells[rowCount, 6].Value?.ToString() : null, |
||||
}); |
||||
if(resp == null) throw new Exception("Ocurrio un error al generar el reporte. Asegurese que los datos del archivo sean correctors."); |
||||
rowCount++; |
||||
} |
||||
if(System.IO.File.Exists(targetFile)) System.IO.File.Delete(targetFile); |
||||
} |
||||
} |
||||
private async Task PopulateOperacionesCdAcunaTable(int fileId){ |
||||
//Se obtiene la ruta del archivo |
||||
string targetFile = await getFilePath(fileId); |
||||
//Aqui comienza la lectura del archivo. |
||||
var file = new FileInfo(targetFile); |
||||
using(ExcelPackage package = new ExcelPackage(file)){ |
||||
var worksheet = package.Workbook.Worksheets.FirstOrDefault(); |
||||
int rowCount = 2; |
||||
while(string.IsNullOrWhiteSpace(worksheet?.Cells[rowCount, 3].Value?.ToString()) == false){//Se valida si la columna del pedimento no esta vacia. |
||||
var resp = await _reporteMensualRepository.PopulateOperacionesCdAcunaTable(new DTOOperacionesCdAcuna(){ |
||||
Aduana = worksheet.Cells[rowCount, 1].Value != null ? worksheet.Cells[rowCount, 1].Value?.ToString() : null, |
||||
Patente = worksheet.Cells[rowCount, 2].Value != null ? worksheet.Cells[rowCount, 2].Value?.ToString() : null, |
||||
Pedimento = worksheet.Cells[rowCount, 3].Value != null ? worksheet.Cells[rowCount, 3].Value?.ToString() : null, |
||||
Clave = worksheet.Cells[rowCount, 9].Value != null ? worksheet.Cells[rowCount, 9].Value?.ToString() : null, |
||||
Factura = worksheet.Cells[rowCount, 14].Value != null ? worksheet.Cells[rowCount, 14].Value?.ToString() : null, |
||||
Tc = worksheet.Cells[rowCount, 15].Value != null ? worksheet.Cells[rowCount, 15].Value?.ToString() : null, |
||||
Proveedor = worksheet.Cells[rowCount, 16].Value != null ? worksheet.Cells[rowCount, 16].Value?.ToString() : null, |
||||
TaxId = worksheet.Cells[rowCount, 17].Value != null ? worksheet.Cells[rowCount, 17].Value?.ToString() : null, |
||||
Producto = worksheet.Cells[rowCount, 18].Value != null ? worksheet.Cells[rowCount, 18].Value?.ToString() : null, |
||||
}); |
||||
if(resp == null) throw new Exception("Ocurrio un error al generar el reporte. Asegurese que los datos del archivo sean correctors."); |
||||
rowCount++; |
||||
} |
||||
if(System.IO.File.Exists(targetFile)) System.IO.File.Delete(targetFile); |
||||
} |
||||
} |
||||
private async Task PopulateOperacionesLazaroCardenasTable(int fileId){ |
||||
//Se obtiene la ruta del archivo |
||||
string targetFile = await getFilePath(fileId); |
||||
//Aqui comienza la lectura del archivo. |
||||
var file = new FileInfo(targetFile); |
||||
using(ExcelPackage package = new ExcelPackage(file)){ |
||||
var worksheet = package.Workbook.Worksheets.FirstOrDefault(); |
||||
int rowCount = 7; |
||||
while(string.IsNullOrWhiteSpace(worksheet?.Cells[rowCount, 4].Value?.ToString()) == false){ |
||||
var resp = await _reporteMensualRepository.PopulateOperacionesLazaroCardenasTable(new DTOOperacionesLazaroCardenas(){ |
||||
Pedimento = worksheet.Cells[rowCount, 4].Value != null ? worksheet.Cells[rowCount, 4].Value?.ToString() : null, |
||||
NoContenedor = worksheet.Cells[rowCount, 8].Value != null ? worksheet.Cells[rowCount, 8].Value?.ToString() : null, |
||||
CantidadContenedores = worksheet.Cells[rowCount, 9].Value != null ? int.Parse(worksheet.Cells[rowCount, 9].Value?.ToString()) : null, |
||||
Soia = worksheet.Cells[rowCount, 10].Value != null ? worksheet.Cells[rowCount, 10].Value?.ToString() : null, |
||||
TiempoDespacho = worksheet.Cells[rowCount, 11].Value != null ? int.Parse(worksheet.Cells[rowCount, 11].Value?.ToString()) : null, |
||||
Clave = worksheet.Cells[rowCount, 14].Value != null ? worksheet.Cells[rowCount, 14].Value?.ToString() : null, |
||||
PedimentoRectificado = worksheet.Cells[rowCount, 15].Value != null ? worksheet.Cells[rowCount, 15].Value?.ToString() : null, |
||||
Causa = worksheet.Cells[rowCount, 16].Value != null ? worksheet.Cells[rowCount, 16].Value?.ToString() : null, |
||||
CargoA = worksheet.Cells[rowCount, 17].Value != null ? worksheet.Cells[rowCount, 17].Value?.ToString() : null, |
||||
TiempoProceso = worksheet.Cells[rowCount, 18].Value != null ? int.Parse(worksheet.Cells[rowCount, 18].Value?.ToString()) : null, |
||||
TiempoCruce = worksheet.Cells[rowCount, 19].Value != null ? int.Parse(worksheet.Cells[rowCount, 19].Value?.ToString()) : null, |
||||
Cumple = worksheet.Cells[rowCount, 20].Value != null ? worksheet.Cells[rowCount, 20].Value?.ToString() : null, |
||||
NoCumple = worksheet.Cells[rowCount, 21].Value != null ? worksheet.Cells[rowCount, 21].Value?.ToString() : null, |
||||
RazonNoCumple = worksheet.Cells[rowCount, 22].Value != null ? worksheet.Cells[rowCount, 22].Value?.ToString() : null, |
||||
CargoDe = worksheet.Cells[rowCount, 23].Value != null ? worksheet.Cells[rowCount, 23].Value?.ToString() : null, |
||||
MedioSalida = worksheet.Cells[rowCount, 24].Value != null ? worksheet.Cells[rowCount, 24].Value?.ToString() : null, |
||||
}); |
||||
if(resp == null) throw new Exception("Ocurrio un error al generar el reporte. Asegurese que los datos del archivo sean correctors."); |
||||
rowCount++; |
||||
} |
||||
if(System.IO.File.Exists(targetFile)) System.IO.File.Delete(targetFile); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue