quitar generacion de reportes de los controladores y migragar al backend la creacion del reporte semanal de newell
parent
196cc6d4b3
commit
660fb99b8b
@ -0,0 +1,7 @@ |
|||||||
|
using CORRESPONSALBackend.DTO.Corresponsales; |
||||||
|
|
||||||
|
namespace CORRESPONSALBackend.Contracts.Corresponsalias.Anticipos{ |
||||||
|
public interface ICorresponsaliasAnticiposService{ |
||||||
|
public Task<byte[]> GetPdf(DTOPdfAnticipo anticipo, string imageFile); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
using CORRESPONSALBackend.DTO.Reportes.Embarques; |
||||||
|
|
||||||
|
namespace CORRESPONSALBackend.Contracts.Reportes.Embarques{ |
||||||
|
public interface IReportesEmbarquesService{ |
||||||
|
public Task<MemoryStream> GetExcelEmbarquesPorImportar(IEnumerable<DTOEmbarquesPorImportar> embarques, string filePath); |
||||||
|
public Task<MemoryStream> GetExcelEmbarquesDespachados(IEnumerable<DTOEmbarquesDespachados> embarques, string filePath); |
||||||
|
public Task<MemoryStream> GetExcelBusquedaEmbarques(IEnumerable<DTOBuscarEmbarques> embarques, string filePath); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
using CORRESPONSALBackend.DTO.Reportes.GC50; |
||||||
|
|
||||||
|
namespace CORRESPONSALBackend.Contracts.Reportes.GC50{ |
||||||
|
public interface IReporteGC50Service{ |
||||||
|
public Task<MemoryStream> GetExcel(IEnumerable<DTOReporteGC50> traficos); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
namespace CORRESPONSALBackend.Contracts.Reportes.Newell.Semanal{ |
||||||
|
public interface IReporteSemanalService{ |
||||||
|
public Task<MemoryStream> GetReporteSemanal(int idRptSemanalFile); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,88 @@ |
|||||||
|
using CORRESPONSALBackend.Contracts.Corresponsalias.Anticipos; |
||||||
|
using CORRESPONSALBackend.DTO.Corresponsales; |
||||||
|
using iText.IO.Font.Constants; |
||||||
|
using iText.IO.Image; |
||||||
|
using iText.Kernel.Colors; |
||||||
|
using iText.Kernel.Font; |
||||||
|
using iText.Kernel.Geom; |
||||||
|
using iText.Kernel.Pdf; |
||||||
|
using iText.Layout; |
||||||
|
using iText.Layout.Borders; |
||||||
|
using iText.Layout.Element; |
||||||
|
using iText.Layout.Properties; |
||||||
|
|
||||||
|
namespace CORRESPONSALBackend.Services.Corresponsalias.Anticipos{ |
||||||
|
public class CorresponsaliasAnticiposService : ICorresponsaliasAnticiposService |
||||||
|
{ |
||||||
|
public async Task<byte[]> GetPdf(DTOPdfAnticipo anticipo, string imageFile) |
||||||
|
{ |
||||||
|
try{ |
||||||
|
MemoryStream ms = new MemoryStream(); |
||||||
|
PdfWriter pw = new PdfWriter(ms); |
||||||
|
PdfDocument pdfDocument = new PdfDocument(pw); |
||||||
|
Document doc = new Document(pdfDocument, PageSize.LETTER);//En este punto ya se tiene creado un docuento en blanco |
||||||
|
PdfFont font = PdfFontFactory.CreateFont(StandardFonts.TIMES_ROMAN); |
||||||
|
doc.SetFont(font); |
||||||
|
doc.SetMargins(25, 25, 25, 25); |
||||||
|
#region Encabezado |
||||||
|
|
||||||
|
ImageData data = ImageDataFactory.Create(imageFile); |
||||||
|
Image img = new Image(data); |
||||||
|
Table headerTable = new Table(3).UseAllAvailableWidth(); |
||||||
|
headerTable.AddCell(new Cell(2,1).Add(img.SetAutoScale(true).SetWidth(30).SetHeight(20)).SetBorder(Border.NO_BORDER)); |
||||||
|
headerTable.AddCell( |
||||||
|
new Cell(2,2) |
||||||
|
.Add( |
||||||
|
new Paragraph("ANTICIPO PARA CORRESPONSALIAS") |
||||||
|
.SetTextAlignment(TextAlignment.CENTER).SetPaddingRight(30) |
||||||
|
) |
||||||
|
.SetVerticalAlignment(VerticalAlignment.BOTTOM) |
||||||
|
.SetBorder(Border.NO_BORDER) |
||||||
|
); |
||||||
|
headerTable.SetBorderBottom(new SolidBorder(ColorConstants.BLACK, 2)); |
||||||
|
doc.Add(headerTable); |
||||||
|
#endregion |
||||||
|
#region datos de la cuenta |
||||||
|
Table accountTable = new Table(1).UseAllAvailableWidth().SetMarginTop(15); |
||||||
|
accountTable.AddCell(new Cell().Add(new Paragraph("NUMERO DE CHEQUE:")).SetBorder(Border.NO_BORDER)); |
||||||
|
accountTable.AddCell(new Cell().Add(new Paragraph($"SOLICITUD: ").Add(new Text($"{anticipo.Id}").SetItalic())).SetBorder(Border.NO_BORDER)); |
||||||
|
accountTable.AddCell(new Cell().Add(new Paragraph("DEPENDENCIA: ").Add(new Text("CORRESPONSALIA").SetItalic())).SetBorder(Border.NO_BORDER)); |
||||||
|
accountTable.AddCell(new Cell().Add(new Paragraph($"IMPRESION: ").Add(new Text($"{DateTime.Now}").SetItalic())).SetVerticalAlignment(VerticalAlignment.BOTTOM).SetBorder(Border.NO_BORDER)); |
||||||
|
doc.Add(accountTable); |
||||||
|
#endregion |
||||||
|
#region datos del anticipo |
||||||
|
Table dataTable = new Table(7).UseAllAvailableWidth().SetMarginTop(15).SetFontSize(8f); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph("GEMCO"))); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph("PEDIMENTO"))); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph("CLIENTE"))); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph("PRODUCTO"))); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph("FECHA DE CRUCE"))); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph("PROVEEDOR"))); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph("IMPORTE"))); |
||||||
|
|
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph(anticipo.FolioGemco)).SetBorder(Border.NO_BORDER)); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph(anticipo.Pedimento)).SetBorder(Border.NO_BORDER)); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph(anticipo.Cliente.Substring(0, anticipo.Cliente.Length - 7))).SetBorder(Border.NO_BORDER)); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph("")).SetBorder(Border.NO_BORDER)); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph(anticipo.FechaCruce != null && anticipo.FechaCruce != "" ? anticipo.FechaCruce.Substring(0,10) : "")).SetBorder(Border.NO_BORDER)); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph("CORRESPONSAL")).SetBorder(Border.NO_BORDER)); |
||||||
|
dataTable.AddCell(new Cell().Add(new Paragraph($"{anticipo.Anticipo}")).SetBorder(Border.NO_BORDER)); |
||||||
|
dataTable.SetBorderBottom(new SolidBorder(ColorConstants.BLACK, 2)); |
||||||
|
doc.Add(dataTable); |
||||||
|
#endregion |
||||||
|
#region Importe final |
||||||
|
Table importeTable = new Table(7).UseAllAvailableWidth(); |
||||||
|
importeTable.AddCell(new Cell(1,7) |
||||||
|
.Add(new Paragraph($"SUMA IMPORTE: $ {anticipo.Anticipo}").SetTextAlignment(TextAlignment.RIGHT).SetFontSize(10f)).SetBorder(Border.NO_BORDER) |
||||||
|
); |
||||||
|
doc.Add(importeTable); |
||||||
|
#endregion |
||||||
|
doc.Close();//Aqui se cierra el documento para poder enviarlo al front para ser descargado. |
||||||
|
var bytesStream = ms.ToArray(); |
||||||
|
return bytesStream; |
||||||
|
}catch(Exception ex){ |
||||||
|
throw new Exception(ex.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,496 @@ |
|||||||
|
using System.Drawing; |
||||||
|
using CORRESPONSALBackend.Contracts.Reportes.Embarques; |
||||||
|
using CORRESPONSALBackend.DTO.Reportes.Embarques; |
||||||
|
using OfficeOpenXml; |
||||||
|
using OfficeOpenXml.Drawing; |
||||||
|
using OfficeOpenXml.Style; |
||||||
|
using OfficeOpenXml.Table; |
||||||
|
|
||||||
|
namespace CORRESPONSALBackend.Services.Reportes.Embarques{ |
||||||
|
public class ReportesEmbarquesService : IReportesEmbarquesService |
||||||
|
{ |
||||||
|
public async Task<MemoryStream> GetExcelBusquedaEmbarques(IEnumerable<DTOBuscarEmbarques> embarques, string filePath) |
||||||
|
{ |
||||||
|
try{ |
||||||
|
ExcelPackage.LicenseContext = LicenseContext.NonCommercial; |
||||||
|
using (ExcelPackage excelPackage = new ExcelPackage()){ |
||||||
|
var today = DateTime.Now; |
||||||
|
var worksheet = excelPackage.Workbook.Worksheets.Add($"EmbarquesPorImportar_{today.Day}-{today.Month}-{today.Year}"); |
||||||
|
//Se crean los encabezados |
||||||
|
#region Encabezados |
||||||
|
worksheet.Cells["A7"].Value = "ADUANA"; |
||||||
|
worksheet.Cells["B7"].Value = "TIPO DE EMBARQUE"; |
||||||
|
worksheet.Cells["C7"].Value = "DESTINO"; |
||||||
|
worksheet.Cells["D7"].Value = "DIAS EN ADUANA"; |
||||||
|
worksheet.Cells["E7"].Value = "NOMBRE"; |
||||||
|
worksheet.Cells["F7"].Value = "TIPO"; |
||||||
|
worksheet.Cells["G7"].Value = "NO DE PEDIMENTO"; |
||||||
|
worksheet.Cells["H7"].Value = "ORDEN DE COMPRA"; |
||||||
|
worksheet.Cells["I7"].Value = "FACTURA"; |
||||||
|
worksheet.Cells["J7"].Value = "PROVEEDOR"; |
||||||
|
worksheet.Cells["K7"].Value = "DESCRIPCION"; |
||||||
|
worksheet.Cells["L7"].Value = "BULTOS"; |
||||||
|
worksheet.Cells["M7"].Value = "CANTIDAD CONTENEDORES"; |
||||||
|
worksheet.Cells["N7"].Value = "PESO NETO"; |
||||||
|
worksheet.Cells["O7"].Value = "INCOTERM"; |
||||||
|
worksheet.Cells["P7"].Value = "FECHA ETA"; |
||||||
|
worksheet.Cells["Q7"].Value = "ESTATUS"; |
||||||
|
worksheet.Cells["R7"].Value = "OBSERVACIONES"; |
||||||
|
worksheet.Cells["S7"].Value = "FECHA DE INICIO DE GASTOS DE ALMACENAJE"; |
||||||
|
worksheet.Cells["T7"].Value = "COSTO DIARIO ALMACENAJE"; |
||||||
|
worksheet.Cells["U7"].Value = "COSTO DIARIO CONEXION"; |
||||||
|
worksheet.Cells["V7"].Value = "TOTAL A PAGAR ALMACENAJE"; |
||||||
|
worksheet.Cells["W7"].Value = "TOTAL A PAGAR CONEXION"; |
||||||
|
worksheet.Cells["X7"].Value = "FECHA DE DESPACHO"; |
||||||
|
worksheet.Cells["Y7"].Value = "NOMBRE DE PAQUETERIA O TRANPORTISTA"; |
||||||
|
worksheet.Cells["Z7"].Value = "NO. DE GUIA DE EMBARQUE A DESTINO"; |
||||||
|
worksheet.Cells["AA7"].Value = "FECHA DE ENTREGA EN DESTINO FINAL"; |
||||||
|
worksheet.Cells["AB7"].Value = "FACTURA CORREPSONSAL"; |
||||||
|
worksheet.Cells["AC7"].Value = "CERTIFICADO DE CALIDAD"; |
||||||
|
worksheet.Cells["AD7"].Value = "PACKING LIST"; |
||||||
|
worksheet.Cells["AE7"].Value = "HOJA TECNICA"; |
||||||
|
worksheet.Cells["AF7"].Value = "BL"; |
||||||
|
worksheet.Cells["AG7"].Value = "PEDIMENTO INFORMATIVO"; |
||||||
|
worksheet.Cells["AH7"].Value = "PEDIMENTO SIMPLIFICADO"; |
||||||
|
worksheet.Cells["AI7"].Value = "DODA"; |
||||||
|
worksheet.Cells["AJ7"].Value = "HONORARIOS AA"; |
||||||
|
worksheet.Cells["AK7"].Value = "TOTAL HONORARIOS AA"; |
||||||
|
worksheet.Cells["AL7"].Value = "GASTOS A TERCEROS"; |
||||||
|
worksheet.Cells["AM7"].Value = "TOTAL GASTOS A TERCEROS"; |
||||||
|
worksheet.Cells["AN7"].Value = "COMPROBANTES GASTOS A TERCEROS"; |
||||||
|
#endregion |
||||||
|
#region Llenado de datos |
||||||
|
int currentRow = 8; |
||||||
|
foreach(var embarque in embarques){ |
||||||
|
worksheet.Cells[$"A{currentRow}"].Value = embarque.Aduana; |
||||||
|
worksheet.Cells[$"B{currentRow}"].Value = embarque.TipoEmbarque; |
||||||
|
worksheet.Cells[$"C{currentRow}"].Value = embarque.Destino; |
||||||
|
worksheet.Cells[$"D{currentRow}"].Value = embarque.DiasEnAduana; |
||||||
|
worksheet.Cells[$"E{currentRow}"].Value = embarque.Nombre; |
||||||
|
worksheet.Cells[$"F{currentRow}"].Value = embarque.Tipo; |
||||||
|
worksheet.Cells[$"G{currentRow}"].Value = embarque.NoPedimento; |
||||||
|
worksheet.Cells[$"H{currentRow}"].Value = embarque.OrdenCompra; |
||||||
|
worksheet.Cells[$"I{currentRow}"].Value = embarque.Factura; |
||||||
|
worksheet.Cells[$"J{currentRow}"].Value = embarque.Proveedor; |
||||||
|
worksheet.Cells[$"K{currentRow}"].Value = embarque.DescripcionMercancia; |
||||||
|
worksheet.Cells[$"L{currentRow}"].Value = embarque.Bultos; |
||||||
|
worksheet.Cells[$"M{currentRow}"].Value = embarque.CantidadContenedores; |
||||||
|
worksheet.Cells[$"N{currentRow}"].Value = embarque.PesoNeto; |
||||||
|
worksheet.Cells[$"O{currentRow}"].Value = embarque.Incoterm; |
||||||
|
worksheet.Cells[$"P{currentRow}"].Value = embarque.FechaETA; |
||||||
|
worksheet.Cells[$"Q{currentRow}"].Value = embarque.Estatus; |
||||||
|
worksheet.Cells[$"R{currentRow}"].Value = embarque.Observaciones; |
||||||
|
worksheet.Cells[$"S{currentRow}"].Value = embarque.FechaInicioGastosAlmacenaje; |
||||||
|
worksheet.Cells[$"T{currentRow}"].Value = embarque.CostoDiarioAlmacenaje; |
||||||
|
worksheet.Cells[$"U{currentRow}"].Value = embarque.CostoDiarioConexion; |
||||||
|
worksheet.Cells[$"V{currentRow}"].Value = embarque.TotalPagar; |
||||||
|
worksheet.Cells[$"W{currentRow}"].Value = embarque.TotalPagarConexion; |
||||||
|
worksheet.Cells[$"X{currentRow}"].Value = embarque.FechaDespacho; |
||||||
|
worksheet.Cells[$"Y{currentRow}"].Value = embarque.NombrePaqueteria; |
||||||
|
worksheet.Cells[$"Z{currentRow}"].Value = embarque.NoGuiaEmbarqueDestino; |
||||||
|
worksheet.Cells[$"AA{currentRow}"].Value = embarque.FechaEntregaDestinoFinal; |
||||||
|
worksheet.Cells[$"AB{currentRow}"].Value = embarque.FacturaCorresponsal == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AC{currentRow}"].Value = embarque.CertificadoCalidad == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AD{currentRow}"].Value = embarque.PackingList == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AE{currentRow}"].Value = embarque.HojaTecnica == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AF{currentRow}"].Value = embarque.BL == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AG{currentRow}"].Value = embarque.PedimentoInformativo == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AH{currentRow}"].Value = embarque.PedimentoSimplificado == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AI{currentRow}"].Value = embarque.DODA == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AJ{currentRow}"].Value = embarque.Honorarios == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AK{currentRow}"].Value = embarque.TotalHonorarios; |
||||||
|
worksheet.Cells[$"AL{currentRow}"].Value = embarque.GastosTerceros == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AM{currentRow}"].Value = embarque.TotalGastosTerceros; |
||||||
|
worksheet.Cells[$"AN{currentRow}"].Value = embarque.ComprobantesGastosTerceros == 0 ? "NO" : "SI"; |
||||||
|
currentRow++; |
||||||
|
} |
||||||
|
#endregion |
||||||
|
//Se crea el rango de celdas que abarcara la tabla. |
||||||
|
ExcelRange range = worksheet.Cells[7, 1,embarques.Count() + 7, 40]; |
||||||
|
ExcelTable tab = worksheet.Tables.Add(range, "Table1"); |
||||||
|
tab.TableStyle = TableStyles.Light1; |
||||||
|
worksheet.Cells["A1:A6"].Merge = true; |
||||||
|
//Se agrega el logo de GEMCO al documento. |
||||||
|
ExcelPicture excelImage = worksheet.Drawings.AddPicture("Logo", new FileInfo(filePath)); |
||||||
|
excelImage.SetPosition(0,0,1,0); |
||||||
|
//Aqui comienza el encabezado del documento. |
||||||
|
worksheet.Cells["B1:D6"].Merge = true; |
||||||
|
worksheet.Cells["E1:J1"].Merge = true; |
||||||
|
worksheet.Cells["E2:J2"].Merge = true; |
||||||
|
worksheet.Cells["E3:J3"].Merge = true; |
||||||
|
worksheet.Cells["E4:J4"].Merge = true; |
||||||
|
worksheet.Cells["E5:J5"].Merge = true; |
||||||
|
worksheet.Cells["E6:J6"].Merge = true; |
||||||
|
worksheet.Cells["E1:J6"].Style.Font.Size = 16; |
||||||
|
worksheet.Cells["E1:J6"].Style.Font.Color.SetColor(Color.FromArgb(74,74,173)); |
||||||
|
worksheet.Cells["E2"].Value = "REPORTE DE EMBARQUES"; |
||||||
|
worksheet.Cells["E3"].Value = $"Reporte Generado al: {today.Day}/{today.Month}/{today.Year}"; |
||||||
|
worksheet.Cells["E4"].Value = $"Fecha y Hora de Creación: {today.Day}/{today.Month}/{today.Year} {today.Hour}:{today.Minute}:{today.Second}"; |
||||||
|
worksheet.Cells["A1:BK6"].Style.Fill.PatternType = ExcelFillStyle.Solid; |
||||||
|
worksheet.Cells["A1:BK6"].Style.Fill.BackgroundColor.SetColor(ColorTranslator.FromHtml("#FFFFFF")); |
||||||
|
worksheet.Cells["A7:BK7"].Style.Font.Bold = true; |
||||||
|
worksheet.Cells["A7:BK7"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; |
||||||
|
worksheet.Cells["A7:BK7"].Style.VerticalAlignment = ExcelVerticalAlignment.Center; |
||||||
|
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns(); |
||||||
|
excelPackage.Workbook.Calculate(); |
||||||
|
var stream = new MemoryStream(); |
||||||
|
excelPackage.SaveAs(stream); |
||||||
|
stream.Position = 0; |
||||||
|
return stream; |
||||||
|
} |
||||||
|
}catch(Exception ex){ |
||||||
|
throw new Exception(ex.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public async Task<MemoryStream> GetExcelEmbarquesDespachados(IEnumerable<DTOEmbarquesDespachados> embarques, string filePath) |
||||||
|
{ |
||||||
|
try{ |
||||||
|
ExcelPackage.LicenseContext = LicenseContext.NonCommercial; |
||||||
|
using (ExcelPackage excelPackage = new ExcelPackage()){ |
||||||
|
var today = DateTime.Now; |
||||||
|
var worksheet = excelPackage.Workbook.Worksheets.Add($"EmbarquesPorImportar_{today.Day}-{today.Month}-{today.Year}"); |
||||||
|
//Se crean los encabezados |
||||||
|
#region Encabezados |
||||||
|
worksheet.Cells["A7"].Value = "ADUANA"; |
||||||
|
worksheet.Cells["B7"].Value = "TIPO DE EMBARQUE"; |
||||||
|
worksheet.Cells["C7"].Value = "DESTINO"; |
||||||
|
worksheet.Cells["D7"].Value = "DIAS EN ADUANA"; |
||||||
|
worksheet.Cells["E7"].Value = "NOMBRE"; |
||||||
|
worksheet.Cells["F7"].Value = "TRAFICO"; |
||||||
|
worksheet.Cells["G7"].Value = "REFERENCIA"; |
||||||
|
worksheet.Cells["H7"].Value = "NO DE PEDIMENTO"; |
||||||
|
worksheet.Cells["I7"].Value = "CLAVE DE PEDIMENTO"; |
||||||
|
worksheet.Cells["J7"].Value = "TIPO"; |
||||||
|
worksheet.Cells["K7"].Value = "ORDEN DE COMPRA"; |
||||||
|
worksheet.Cells["L7"].Value = "FACTURA"; |
||||||
|
worksheet.Cells["M7"].Value = "PROVEEDOR"; |
||||||
|
worksheet.Cells["N7"].Value = "DESCRIPCION MERCANCIA"; |
||||||
|
worksheet.Cells["O7"].Value = "LÍNEA TRANSPORTISTA INTERNACIONAL"; |
||||||
|
worksheet.Cells["P7"].Value = "LINEA NAVIERA"; |
||||||
|
worksheet.Cells["Q7"].Value = "MAWB"; |
||||||
|
worksheet.Cells["R7"].Value = "HAWB"; |
||||||
|
worksheet.Cells["S7"].Value = "FECHA DE NOTIFICACION"; |
||||||
|
worksheet.Cells["T7"].Value = "BULTOS"; |
||||||
|
worksheet.Cells["U7"].Value = "CANTIDAD CONTENEDORES"; |
||||||
|
worksheet.Cells["V7"].Value = "NO. CONTENEDORES"; |
||||||
|
worksheet.Cells["W7"].Value = "PESO BRUTO"; |
||||||
|
worksheet.Cells["X7"].Value = "PESO NETO"; |
||||||
|
worksheet.Cells["Y7"].Value = "INCOTERM"; |
||||||
|
worksheet.Cells["Z7"].Value = "FECHA ETA"; |
||||||
|
worksheet.Cells["AA7"].Value = "FECHA DE ENTRADA"; |
||||||
|
worksheet.Cells["AB7"].Value = "FECHA DE REVALIDACION GUIA"; |
||||||
|
worksheet.Cells["AC7"].Value = "MONTO USD"; |
||||||
|
worksheet.Cells["AD7"].Value = "ORIGEN"; |
||||||
|
worksheet.Cells["AE7"].Value = "FRACCION ARANCELARIA"; |
||||||
|
worksheet.Cells["AF7"].Value = "DESCRIPCION"; |
||||||
|
worksheet.Cells["AG7"].Value = "PPREFERENCIA ARANCELARIA"; |
||||||
|
worksheet.Cells["AH7"].Value = "ESTATUS"; |
||||||
|
worksheet.Cells["AI7"].Value = "OBSERVACIONES"; |
||||||
|
worksheet.Cells["AJ7"].Value = "FECHA DE INICIO DE GASTOS DE ALMACENAJE"; |
||||||
|
worksheet.Cells["AK7"].Value = "COSTO DIARIO ALMACENAJE"; |
||||||
|
worksheet.Cells["AL7"].Value = "COSTO DIARIO CONEXIÓN"; |
||||||
|
worksheet.Cells["AM7"].Value = "TOTAL A PAGAR ALMACENAJE"; |
||||||
|
worksheet.Cells["AN7"].Value = "TOTAL A PAGAR CONEXIÓN"; |
||||||
|
worksheet.Cells["AO7"].Value = "FECHA DE PAGO PEDIMENTO"; |
||||||
|
worksheet.Cells["AP7"].Value = "FECHA DE INSTRUCCIONES"; |
||||||
|
worksheet.Cells["AQ7"].Value = "HORA DE INSTRUCCIONES"; |
||||||
|
worksheet.Cells["AR7"].Value = "FECHA DE DESPACHO"; |
||||||
|
worksheet.Cells["AS7"].Value = "DIAS C/PDTO PAGADO"; |
||||||
|
worksheet.Cells["AT7"].Value = "FECHA SALIDA DE CONTENEDORES"; |
||||||
|
worksheet.Cells["AU7"].Value = "NOMBRE DE PAQUETERIA O TRANSPORTISTA"; |
||||||
|
worksheet.Cells["AV7"].Value = "NO. DE GUIA DE EMBARQUE A DESTINO"; |
||||||
|
worksheet.Cells["AW7"].Value = "FECHA DE ENTREGA EN DESTINO FINAL"; |
||||||
|
worksheet.Cells["AX7"].Value = "HORA DE ENTREGA EN DESTINO FINAL"; |
||||||
|
worksheet.Cells["AY7"].Value = "FACTURA CORRESPONSAL"; |
||||||
|
worksheet.Cells["AZ7"].Value = "CERTIFICADO DE CALIDAD"; |
||||||
|
worksheet.Cells["BA7"].Value = "PACKING LIST"; |
||||||
|
worksheet.Cells["BB7"].Value = "HOJA TECNICA"; |
||||||
|
worksheet.Cells["BC7"].Value = "BL"; |
||||||
|
worksheet.Cells["BD7"].Value = "PEDIMENTO INFORMATIVO"; |
||||||
|
worksheet.Cells["BE7"].Value = "PEDIMENTO SIMPLIFICADO"; |
||||||
|
worksheet.Cells["BF7"].Value = "DODA"; |
||||||
|
worksheet.Cells["BG7"].Value = "HONORARIOS AA"; |
||||||
|
worksheet.Cells["BH7"].Value = "TOTAL HONORARIOS AA"; |
||||||
|
worksheet.Cells["BI7"].Value = "GASTOS TERCEROS"; |
||||||
|
worksheet.Cells["BJ7"].Value = "TOTAL GASTOS TERCEROS"; |
||||||
|
worksheet.Cells["BK7"].Value = "COMPROBANTES GASTOS TERCEROS"; |
||||||
|
#endregion |
||||||
|
#region Llenado de datos |
||||||
|
int currentRow = 8; |
||||||
|
foreach(var embarque in embarques){ |
||||||
|
worksheet.Cells[$"A{currentRow}"].Value = embarque.Aduana; |
||||||
|
worksheet.Cells[$"B{currentRow}"].Value = embarque.TipoEmbarque; |
||||||
|
worksheet.Cells[$"C{currentRow}"].Value = embarque.Destino; |
||||||
|
worksheet.Cells[$"D{currentRow}"].Value = embarque.DiasEnAduana; |
||||||
|
worksheet.Cells[$"E{currentRow}"].Value = embarque.Nombre; |
||||||
|
worksheet.Cells[$"F{currentRow}"].Value = embarque.Trafico; |
||||||
|
worksheet.Cells[$"G{currentRow}"].Value = embarque.Referencia; |
||||||
|
worksheet.Cells[$"H{currentRow}"].Value = embarque.NoPedimento; |
||||||
|
worksheet.Cells[$"I{currentRow}"].Value = embarque.ClavePedimento; |
||||||
|
worksheet.Cells[$"J{currentRow}"].Value = embarque.Tipo; |
||||||
|
worksheet.Cells[$"K{currentRow}"].Value = embarque.OrdenCompra; |
||||||
|
worksheet.Cells[$"L{currentRow}"].Value = embarque.Factura; |
||||||
|
worksheet.Cells[$"M{currentRow}"].Value = embarque.Proveedor; |
||||||
|
worksheet.Cells[$"N{currentRow}"].Value = embarque.DescripcionMercancia; |
||||||
|
worksheet.Cells[$"O{currentRow}"].Value = embarque.LineaTransportistaInternacional; |
||||||
|
worksheet.Cells[$"P{currentRow}"].Value = embarque.LineaNaviera; |
||||||
|
worksheet.Cells[$"Q{currentRow}"].Value = embarque.MAWB; |
||||||
|
worksheet.Cells[$"R{currentRow}"].Value = embarque.HAWB; |
||||||
|
worksheet.Cells[$"S{currentRow}"].Value = embarque.FechaNotificacion; |
||||||
|
worksheet.Cells[$"T{currentRow}"].Value = embarque.Bultos; |
||||||
|
worksheet.Cells[$"U{currentRow}"].Value = embarque.CantidadContenedores; |
||||||
|
worksheet.Cells[$"V{currentRow}"].Value = embarque.NumerosContenedores; |
||||||
|
worksheet.Cells[$"W{currentRow}"].Value = embarque.PesoBruto; |
||||||
|
worksheet.Cells[$"X{currentRow}"].Value = embarque.PesoNeto; |
||||||
|
worksheet.Cells[$"Y{currentRow}"].Value = embarque.Incoterm; |
||||||
|
worksheet.Cells[$"Z{currentRow}"].Value = embarque.FechaETA; |
||||||
|
worksheet.Cells[$"AA{currentRow}"].Value = embarque.FechaEntrada; |
||||||
|
worksheet.Cells[$"AB{currentRow}"].Value = embarque.FechaRevalidacionGuia; |
||||||
|
worksheet.Cells[$"AC{currentRow}"].Value = embarque.MontoUSD; |
||||||
|
worksheet.Cells[$"AD{currentRow}"].Value = embarque.Origen; |
||||||
|
worksheet.Cells[$"AE{currentRow}"].Value = embarque.FraccionArancelaria; |
||||||
|
worksheet.Cells[$"AF{currentRow}"].Value = embarque.Descripcion; |
||||||
|
worksheet.Cells[$"AG{currentRow}"].Value = embarque.PreferenciaArancelaria; |
||||||
|
worksheet.Cells[$"AH{currentRow}"].Value = embarque.Estatus; |
||||||
|
worksheet.Cells[$"AI{currentRow}"].Value = embarque.Observaciones; |
||||||
|
worksheet.Cells[$"AJ{currentRow}"].Value = embarque.FechaInicioGastosAlmacenaje; |
||||||
|
worksheet.Cells[$"AK{currentRow}"].Value = embarque.CostoDiarioAlmacenaje; |
||||||
|
worksheet.Cells[$"AL{currentRow}"].Value = embarque.CostoDiarioConexion; |
||||||
|
worksheet.Cells[$"AM{currentRow}"].Value = embarque.TotalPagar; |
||||||
|
worksheet.Cells[$"AN{currentRow}"].Value = embarque.TotalPagarConexion; |
||||||
|
worksheet.Cells[$"AO{currentRow}"].Value = embarque.FechaPagoPedimento; |
||||||
|
worksheet.Cells[$"AP{currentRow}"].Value = embarque.FechaInstrucciones; |
||||||
|
worksheet.Cells[$"AQ{currentRow}"].Value = embarque.HoraInstrucciones; |
||||||
|
worksheet.Cells[$"AR{currentRow}"].Value = embarque.FechaDespacho; |
||||||
|
worksheet.Cells[$"AS{currentRow}"].Value = embarque.DiasCPPagado; |
||||||
|
worksheet.Cells[$"AT{currentRow}"].Value = embarque.FechaSalidaContenedores; |
||||||
|
worksheet.Cells[$"AU{currentRow}"].Value = embarque.NombrePaqueteria; |
||||||
|
worksheet.Cells[$"AV{currentRow}"].Value = embarque.NoGuiaEmbarqueDestino; |
||||||
|
worksheet.Cells[$"AW{currentRow}"].Value = embarque.FechaEntregaDestinoFinal; |
||||||
|
worksheet.Cells[$"AX{currentRow}"].Value = embarque.HoraEntregaDestinoFinal; |
||||||
|
worksheet.Cells[$"AY{currentRow}"].Value = embarque.FacturaCorresponsal == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AZ{currentRow}"].Value = embarque.CertificadoCalidad == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BA{currentRow}"].Value = embarque.PackingList == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BB{currentRow}"].Value = embarque.HojaTecnica == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BC{currentRow}"].Value = embarque.BL == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BD{currentRow}"].Value = embarque.PedimentoInformativo == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BE{currentRow}"].Value = embarque.PedimentoSimplificado == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BF{currentRow}"].Value = embarque.DODA == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BG{currentRow}"].Value = embarque.Honorarios == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BH{currentRow}"].Value = embarque.TotalHonorarios; |
||||||
|
worksheet.Cells[$"BI{currentRow}"].Value = embarque.GastosTerceros == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BJ{currentRow}"].Value = embarque.TotalGastosTerceros; |
||||||
|
worksheet.Cells[$"BK{currentRow}"].Value = embarque.ComprobantesGastosTerceros == 0 ? "NO" : "SI"; |
||||||
|
currentRow++; |
||||||
|
} |
||||||
|
#endregion |
||||||
|
//Se crea el rango de celdas que abarcara la tabla. |
||||||
|
ExcelRange range = worksheet.Cells[7, 1,embarques.Count() + 7, 63]; |
||||||
|
ExcelTable tab = worksheet.Tables.Add(range, "Table1"); |
||||||
|
tab.TableStyle = TableStyles.Light1; |
||||||
|
worksheet.Cells["A1:A6"].Merge = true; |
||||||
|
//Se agrega el logo de GEMCO al documento. |
||||||
|
ExcelPicture excelImage = worksheet.Drawings.AddPicture("Logo", new FileInfo(filePath)); |
||||||
|
excelImage.SetPosition(0,0,1,0); |
||||||
|
//Aqui comienza el encabezado del documento. |
||||||
|
worksheet.Cells["B1:D6"].Merge = true; |
||||||
|
worksheet.Cells["E1:J1"].Merge = true; |
||||||
|
worksheet.Cells["E2:J2"].Merge = true; |
||||||
|
worksheet.Cells["E3:J3"].Merge = true; |
||||||
|
worksheet.Cells["E4:J4"].Merge = true; |
||||||
|
worksheet.Cells["E5:J5"].Merge = true; |
||||||
|
worksheet.Cells["E6:J6"].Merge = true; |
||||||
|
worksheet.Cells["E1:J6"].Style.Font.Size = 16; |
||||||
|
worksheet.Cells["E1:J6"].Style.Font.Color.SetColor(Color.FromArgb(74,74,173)); |
||||||
|
worksheet.Cells["E2"].Value = "REPORTE DE EMBARQUES POR DESPACHADOS"; |
||||||
|
worksheet.Cells["E3"].Value = $"Reporte Generado al: {today.Day}/{today.Month}/{today.Year}"; |
||||||
|
worksheet.Cells["E4"].Value = $"Fecha y Hora de Creación: {today.Day}/{today.Month}/{today.Year} {today.Hour}:{today.Minute}:{today.Second}"; |
||||||
|
worksheet.Cells["A1:BK6"].Style.Fill.PatternType = ExcelFillStyle.Solid; |
||||||
|
worksheet.Cells["A1:BK6"].Style.Fill.BackgroundColor.SetColor(ColorTranslator.FromHtml("#FFFFFF")); |
||||||
|
worksheet.Cells["A7:BK7"].Style.Font.Bold = true; |
||||||
|
worksheet.Cells["A7:BK7"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; |
||||||
|
worksheet.Cells["A7:BK7"].Style.VerticalAlignment = ExcelVerticalAlignment.Center; |
||||||
|
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns(); |
||||||
|
excelPackage.Workbook.Calculate(); |
||||||
|
var stream = new MemoryStream(); |
||||||
|
excelPackage.SaveAs(stream); |
||||||
|
stream.Position = 0; |
||||||
|
return stream; |
||||||
|
} |
||||||
|
}catch(Exception ex){ |
||||||
|
throw new Exception(ex.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public async Task<MemoryStream> GetExcelEmbarquesPorImportar(IEnumerable<DTOEmbarquesPorImportar> embarques, string filePath) |
||||||
|
{ |
||||||
|
try{ |
||||||
|
ExcelPackage.LicenseContext = LicenseContext.NonCommercial; |
||||||
|
using (ExcelPackage excelPackage = new ExcelPackage()){ |
||||||
|
var today = DateTime.Now; |
||||||
|
var worksheet = excelPackage.Workbook.Worksheets.Add($"EmbarquesPorImportar_{today.Day}-{today.Month}-{today.Year}"); |
||||||
|
//Se crean los encabezados |
||||||
|
#region Encabezados |
||||||
|
worksheet.Cells["A7"].Value = "ADUANA"; |
||||||
|
worksheet.Cells["B7"].Value = "TIPO DE EMBARQUE"; |
||||||
|
worksheet.Cells["C7"].Value = "DESTINO"; |
||||||
|
worksheet.Cells["D7"].Value = "DIAS EN ADUANA"; |
||||||
|
worksheet.Cells["E7"].Value = "NOMBRE"; |
||||||
|
worksheet.Cells["F7"].Value = "TRAFICO"; |
||||||
|
worksheet.Cells["G7"].Value = "REFERENCIA"; |
||||||
|
worksheet.Cells["H7"].Value = "NO DE PEDIMENTO"; |
||||||
|
worksheet.Cells["I7"].Value = "CLAVE DE PEDIMENTO"; |
||||||
|
worksheet.Cells["J7"].Value = "TIPO"; |
||||||
|
worksheet.Cells["K7"].Value = "ORDEN DE COMPRA"; |
||||||
|
worksheet.Cells["L7"].Value = "FACTURA"; |
||||||
|
worksheet.Cells["M7"].Value = "PROVEEDOR"; |
||||||
|
worksheet.Cells["N7"].Value = "DESCRIPCION MERCANCIA"; |
||||||
|
worksheet.Cells["O7"].Value = "LÍNEA TRANSPORTISTA INTERNACIONAL"; |
||||||
|
worksheet.Cells["P7"].Value = "LINEA NAVIERA"; |
||||||
|
worksheet.Cells["Q7"].Value = "MAWB"; |
||||||
|
worksheet.Cells["R7"].Value = "HAWB"; |
||||||
|
worksheet.Cells["S7"].Value = "FECHA DE NOTIFICACION"; |
||||||
|
worksheet.Cells["T7"].Value = "BULTOS"; |
||||||
|
worksheet.Cells["U7"].Value = "CANTIDAD CONTENEDORES"; |
||||||
|
worksheet.Cells["V7"].Value = "NO. CONTENEDORES"; |
||||||
|
worksheet.Cells["W7"].Value = "PESO BRUTO"; |
||||||
|
worksheet.Cells["X7"].Value = "PESO NETO"; |
||||||
|
worksheet.Cells["Y7"].Value = "INCOTERM"; |
||||||
|
worksheet.Cells["Z7"].Value = "FECHA ETA"; |
||||||
|
worksheet.Cells["AA7"].Value = "FECHA DE ENTRADA"; |
||||||
|
worksheet.Cells["AB7"].Value = "FECHA DE REVALIDACION GUIA"; |
||||||
|
worksheet.Cells["AC7"].Value = "MONTO USD"; |
||||||
|
worksheet.Cells["AD7"].Value = "ORIGEN"; |
||||||
|
worksheet.Cells["AE7"].Value = "FRACCION ARANCELARIA"; |
||||||
|
worksheet.Cells["AF7"].Value = "DESCRIPCION"; |
||||||
|
worksheet.Cells["AG7"].Value = "PPREFERENCIA ARANCELARIA"; |
||||||
|
worksheet.Cells["AH7"].Value = "ESTATUS"; |
||||||
|
worksheet.Cells["AI7"].Value = "OBSERVACIONES"; |
||||||
|
worksheet.Cells["AJ7"].Value = "FECHA DE INICIO DE GASTOS DE ALMACENAJE"; |
||||||
|
worksheet.Cells["AK7"].Value = "COSTO DIARIO ALMACENAJE"; |
||||||
|
worksheet.Cells["AL7"].Value = "COSTO DIARIO CONEXIÓN"; |
||||||
|
worksheet.Cells["AM7"].Value = "TOTAL A PAGAR ALMACENAJE"; |
||||||
|
worksheet.Cells["AN7"].Value = "TOTAL A PAGAR CONEXIÓN"; |
||||||
|
worksheet.Cells["AO7"].Value = "FECHA DE PAGO PEDIMENTO"; |
||||||
|
worksheet.Cells["AP7"].Value = "FECHA DE INSTRUCCIONES"; |
||||||
|
worksheet.Cells["AQ7"].Value = "HORA DE INSTRUCCIONES"; |
||||||
|
worksheet.Cells["AR7"].Value = "FECHA DE DESPACHO"; |
||||||
|
worksheet.Cells["AS7"].Value = "DIAS C/PDTO PAGADO"; |
||||||
|
worksheet.Cells["AT7"].Value = "FECHA SALIDA DE CONTENEDORES"; |
||||||
|
worksheet.Cells["AU7"].Value = "NOMBRE DE PAQUETERIA O TRANSPORTISTA"; |
||||||
|
worksheet.Cells["AV7"].Value = "NO. DE GUIA DE EMBARQUE A DESTINO"; |
||||||
|
worksheet.Cells["AW7"].Value = "FECHA DE ENTREGA EN DESTINO FINAL"; |
||||||
|
worksheet.Cells["AX7"].Value = "HORA DE ENTREGA EN DESTINO FINAL"; |
||||||
|
worksheet.Cells["AY7"].Value = "FACTURA CORRESPONSAL"; |
||||||
|
worksheet.Cells["AZ7"].Value = "CERTIFICADO DE CALIDAD"; |
||||||
|
worksheet.Cells["BA7"].Value = "PACKING LIST"; |
||||||
|
worksheet.Cells["BB7"].Value = "HOJA TECNICA"; |
||||||
|
worksheet.Cells["BC7"].Value = "BL"; |
||||||
|
worksheet.Cells["BD7"].Value = "PEDIMENTO INFORMATIVO"; |
||||||
|
worksheet.Cells["BE7"].Value = "PEDIMENTO SIMPLIFICADO"; |
||||||
|
worksheet.Cells["BF7"].Value = "DODA"; |
||||||
|
#endregion |
||||||
|
#region Llenado de datos |
||||||
|
int currentRow = 8; |
||||||
|
foreach(var embarque in embarques){ |
||||||
|
worksheet.Cells[$"A{currentRow}"].Value = embarque.Aduana; |
||||||
|
worksheet.Cells[$"B{currentRow}"].Value = embarque.TipoEmbarque; |
||||||
|
worksheet.Cells[$"C{currentRow}"].Value = embarque.Destino; |
||||||
|
worksheet.Cells[$"D{currentRow}"].Value = embarque.DiasEnAduana; |
||||||
|
worksheet.Cells[$"E{currentRow}"].Value = embarque.Nombre; |
||||||
|
worksheet.Cells[$"F{currentRow}"].Value = embarque.Trafico; |
||||||
|
worksheet.Cells[$"G{currentRow}"].Value = embarque.Referencia; |
||||||
|
worksheet.Cells[$"H{currentRow}"].Value = embarque.NoPedimento; |
||||||
|
worksheet.Cells[$"I{currentRow}"].Value = embarque.ClavePedimento; |
||||||
|
worksheet.Cells[$"J{currentRow}"].Value = embarque.Tipo; |
||||||
|
worksheet.Cells[$"K{currentRow}"].Value = embarque.OrdenCompra; |
||||||
|
worksheet.Cells[$"L{currentRow}"].Value = embarque.Factura; |
||||||
|
worksheet.Cells[$"M{currentRow}"].Value = embarque.Proveedor; |
||||||
|
worksheet.Cells[$"N{currentRow}"].Value = embarque.DescripcionMercancia; |
||||||
|
worksheet.Cells[$"O{currentRow}"].Value = embarque.LineaTransportistaInternacional; |
||||||
|
worksheet.Cells[$"P{currentRow}"].Value = embarque.LineaNaviera; |
||||||
|
worksheet.Cells[$"Q{currentRow}"].Value = embarque.MAWB; |
||||||
|
worksheet.Cells[$"R{currentRow}"].Value = embarque.HAWB; |
||||||
|
worksheet.Cells[$"S{currentRow}"].Value = embarque.FechaNotificacion; |
||||||
|
worksheet.Cells[$"T{currentRow}"].Value = embarque.Bultos; |
||||||
|
worksheet.Cells[$"U{currentRow}"].Value = embarque.CantidadContenedores; |
||||||
|
worksheet.Cells[$"V{currentRow}"].Value = embarque.NumerosContenedores; |
||||||
|
worksheet.Cells[$"W{currentRow}"].Value = embarque.PesoBruto; |
||||||
|
worksheet.Cells[$"X{currentRow}"].Value = embarque.PesoNeto; |
||||||
|
worksheet.Cells[$"Y{currentRow}"].Value = embarque.Incoterm; |
||||||
|
worksheet.Cells[$"Z{currentRow}"].Value = embarque.FechaETA; |
||||||
|
worksheet.Cells[$"AA{currentRow}"].Value = embarque.FechaEntrada; |
||||||
|
worksheet.Cells[$"AB{currentRow}"].Value = embarque.FechaRevalidacionGuia; |
||||||
|
worksheet.Cells[$"AC{currentRow}"].Value = embarque.MontoUSD; |
||||||
|
worksheet.Cells[$"AD{currentRow}"].Value = embarque.Origen; |
||||||
|
worksheet.Cells[$"AE{currentRow}"].Value = embarque.FraccionArancelaria; |
||||||
|
worksheet.Cells[$"AF{currentRow}"].Value = embarque.Descripcion; |
||||||
|
worksheet.Cells[$"AG{currentRow}"].Value = embarque.PreferenciaArancelaria; |
||||||
|
worksheet.Cells[$"AH{currentRow}"].Value = embarque.Estatus; |
||||||
|
worksheet.Cells[$"AI{currentRow}"].Value = embarque.Observaciones; |
||||||
|
worksheet.Cells[$"AJ{currentRow}"].Value = embarque.FechaInicioGastosAlmacenaje; |
||||||
|
worksheet.Cells[$"AK{currentRow}"].Value = embarque.CostoDiarioAlmacenaje; |
||||||
|
worksheet.Cells[$"AL{currentRow}"].Value = embarque.CostoDiarioConexion; |
||||||
|
worksheet.Cells[$"AM{currentRow}"].Value = embarque.TotalPagar; |
||||||
|
worksheet.Cells[$"AN{currentRow}"].Value = embarque.TotalPagarConexion; |
||||||
|
worksheet.Cells[$"AO{currentRow}"].Value = embarque.FechaPagoPedimento; |
||||||
|
worksheet.Cells[$"AP{currentRow}"].Value = embarque.FechaInstrucciones; |
||||||
|
worksheet.Cells[$"AQ{currentRow}"].Value = embarque.HoraInstrucciones; |
||||||
|
worksheet.Cells[$"AR{currentRow}"].Value = embarque.FechaDespacho; |
||||||
|
worksheet.Cells[$"AS{currentRow}"].Value = embarque.DiasCPPagado; |
||||||
|
worksheet.Cells[$"AT{currentRow}"].Value = embarque.FechaSalidaContenedores; |
||||||
|
worksheet.Cells[$"AU{currentRow}"].Value = embarque.NombrePaqueteria; |
||||||
|
worksheet.Cells[$"AV{currentRow}"].Value = embarque.NoGuiaEmbarqueDestino; |
||||||
|
worksheet.Cells[$"AW{currentRow}"].Value = embarque.FechaEntregaDestinoFinal; |
||||||
|
worksheet.Cells[$"AX{currentRow}"].Value = embarque.HoraEntregaDestinoFinal; |
||||||
|
worksheet.Cells[$"AY{currentRow}"].Value = embarque.FacturaCorresponsal == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"AZ{currentRow}"].Value = embarque.CertificadoCalidad == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BA{currentRow}"].Value = embarque.PackingList == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BB{currentRow}"].Value = embarque.HojaTecnica == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BC{currentRow}"].Value = embarque.BL == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BD{currentRow}"].Value = embarque.PedimentoInformativo == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BE{currentRow}"].Value = embarque.PedimentoSimplificado == 0 ? "NO" : "SI"; |
||||||
|
worksheet.Cells[$"BF{currentRow}"].Value = embarque.DODA == 0 ? "NO" : "SI"; |
||||||
|
currentRow++; |
||||||
|
} |
||||||
|
#endregion |
||||||
|
//Se crea la tabla en el rango de celdas donde se mostrara la inforamcion. |
||||||
|
ExcelRange range = worksheet.Cells[7, 1,embarques.Count() + 7, 58]; |
||||||
|
ExcelTable tab = worksheet.Tables.Add(range, "Table1"); |
||||||
|
tab.TableStyle = TableStyles.Light1; |
||||||
|
worksheet.Cells["A1:A6"].Merge = true; |
||||||
|
//Se agrega el logo de GEMCO al documento. |
||||||
|
ExcelPicture excelImage = worksheet.Drawings.AddPicture("Logo", new FileInfo(filePath)); |
||||||
|
excelImage.SetPosition(0,0,1,0); |
||||||
|
//Aqui comienza el encabezado del documento. |
||||||
|
worksheet.Cells["B1:D6"].Merge = true; |
||||||
|
worksheet.Cells["E1:J1"].Merge = true; |
||||||
|
worksheet.Cells["E2:J2"].Merge = true; |
||||||
|
worksheet.Cells["E3:J3"].Merge = true; |
||||||
|
worksheet.Cells["E4:J4"].Merge = true; |
||||||
|
worksheet.Cells["E5:J5"].Merge = true; |
||||||
|
worksheet.Cells["E6:J6"].Merge = true; |
||||||
|
worksheet.Cells["E1:J6"].Style.Font.Size = 16; |
||||||
|
worksheet.Cells["E1:J6"].Style.Font.Color.SetColor(Color.FromArgb(74,74,173)); |
||||||
|
worksheet.Cells["E2"].Value = "REPORTE DE EMBARQUES POR IMPORTAR"; |
||||||
|
worksheet.Cells["E3"].Value = $"Reporte Generado al: {today.Day}/{today.Month}/{today.Year}"; |
||||||
|
worksheet.Cells["E4"].Value = $"Fecha y Hora de Creación: {today.Day}/{today.Month}/{today.Year} {today.Hour}:{today.Minute}:{today.Second}"; |
||||||
|
worksheet.Cells["A1:BG6"].Style.Fill.PatternType = ExcelFillStyle.Solid; |
||||||
|
worksheet.Cells["A1:BG6"].Style.Fill.BackgroundColor.SetColor(ColorTranslator.FromHtml("#FFFFFF")); |
||||||
|
worksheet.Cells["A7:BG7"].Style.Font.Bold = true; |
||||||
|
worksheet.Cells["A7:BG7"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; |
||||||
|
worksheet.Cells["A7:BG7"].Style.VerticalAlignment = ExcelVerticalAlignment.Center; |
||||||
|
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns(); |
||||||
|
excelPackage.Workbook.Calculate(); |
||||||
|
var stream = new MemoryStream(); |
||||||
|
excelPackage.SaveAs(stream); |
||||||
|
stream.Position = 0; |
||||||
|
return stream; |
||||||
|
} |
||||||
|
}catch(Exception ex){ |
||||||
|
throw new Exception(ex.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
using CORRESPONSALBackend.Contracts.Reportes.GC50; |
||||||
|
using CORRESPONSALBackend.DTO.Reportes.GC50; |
||||||
|
using OfficeOpenXml; |
||||||
|
using OfficeOpenXml.Table; |
||||||
|
|
||||||
|
namespace CORRESPONSALBackend.Services.Reportes.GC50{ |
||||||
|
public class ReporteGC50Service : IReporteGC50Service |
||||||
|
{ |
||||||
|
public async Task<MemoryStream> GetExcel(IEnumerable<DTOReporteGC50> traficos) |
||||||
|
{ |
||||||
|
try{ |
||||||
|
ExcelPackage.LicenseContext = LicenseContext.NonCommercial; |
||||||
|
using (ExcelPackage excelPackage = new ExcelPackage()){ |
||||||
|
var worksheet = excelPackage.Workbook.Worksheets.Add("sheet1"); |
||||||
|
worksheet.Cells["A1"].LoadFromCollection(traficos, true); |
||||||
|
//Se crea la tabla en el rango de celdas donde se mostrara la inforamcion. |
||||||
|
ExcelRange range = worksheet.Cells[1, 1,traficos.Count() + 1, 23]; |
||||||
|
ExcelTable tab = worksheet.Tables.Add(range, "Table1"); |
||||||
|
tab.TableStyle = TableStyles.Light1; |
||||||
|
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns(); |
||||||
|
excelPackage.Workbook.Calculate(); |
||||||
|
var stream = new MemoryStream(); |
||||||
|
excelPackage.SaveAs(stream); |
||||||
|
return stream; |
||||||
|
} |
||||||
|
}catch(Exception ex){ |
||||||
|
throw new Exception(ex.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
using CORRESPONSALBackend.Contracts.Corresponsalias; |
||||||
|
using CORRESPONSALBackend.Contracts.Reportes.Newell.Semanal; |
||||||
|
using CORRESPONSALBackend.Contracts.Utils; |
||||||
|
using CORRESPONSALBackend.DTO.Reportes; |
||||||
|
using CORRESPONSALBackend.Models.Utils; |
||||||
|
using OfficeOpenXml; |
||||||
|
|
||||||
|
namespace CORRESPONSALBackend.Services.Reportes.Newell.Semanal{ |
||||||
|
public class ReporteSemanalService : IReporteSemanalService |
||||||
|
{ |
||||||
|
private readonly IFileManagerRepository _Repo; |
||||||
|
private readonly IFilePaths4ProcessRepository _RepoRelativePath; |
||||||
|
private readonly ICorresponsaliasTraficosRepository _traficosRepository; |
||||||
|
private readonly IConfiguration _config; |
||||||
|
private readonly string RootPathCorresponsales; |
||||||
|
public ReporteSemanalService(IFilePaths4ProcessRepository RepoRelativePath, IConfiguration config, IFileManagerRepository Repo, ICorresponsaliasTraficosRepository traficosRepository){ |
||||||
|
_Repo = Repo; |
||||||
|
_RepoRelativePath = RepoRelativePath; |
||||||
|
_traficosRepository = traficosRepository; |
||||||
|
_config = config; |
||||||
|
RootPathCorresponsales = _config.GetValue<string>("AllFiles"); |
||||||
|
} |
||||||
|
public async Task<MemoryStream> GetReporteSemanal(int idRptSemanalFile) |
||||||
|
{ |
||||||
|
//Obtener la ruta del archivo |
||||||
|
//Se obtiene la ruta del archivo |
||||||
|
FileManager recFound = await _Repo.getFileById(idRptSemanalFile); |
||||||
|
FilePaths4Process RelativePath = await _RepoRelativePath.getPaths4ProcessById(recFound.Proceso); |
||||||
|
string filePath = RootPathCorresponsales + RelativePath.Path + recFound.NombreArchivo; |
||||||
|
var file = new FileInfo(filePath); |
||||||
|
//Leer el archivo con epplus |
||||||
|
ExcelPackage.LicenseContext = LicenseContext.NonCommercial; |
||||||
|
using(ExcelPackage package = new ExcelPackage(file)){ |
||||||
|
var worksheet = package.Workbook.Worksheets.FirstOrDefault(); |
||||||
|
//mapear los renglones a un array |
||||||
|
var start = worksheet.Dimension.Start; |
||||||
|
var end = worksheet.Dimension.End; |
||||||
|
int initialRow = start.Row+1; |
||||||
|
for (int currentRow = initialRow; currentRow <= end.Row; currentRow++)// Recorrer renglon por renglon |
||||||
|
{ |
||||||
|
if(!string.IsNullOrWhiteSpace(worksheet.Cells[$"C{currentRow}"].Value?.ToString()) && !string.IsNullOrEmpty(worksheet.Cells[$"C{currentRow}"].Value?.ToString())){ |
||||||
|
var pedimento = worksheet.Cells[$"C{currentRow}"].Value.ToString(); |
||||||
|
var dto = await _traficosRepository.GetByPedimento(int.Parse(pedimento)); |
||||||
|
worksheet.Cells[$"S{currentRow}"].Value = dto.GC; |
||||||
|
worksheet.Cells[$"T{currentRow}"].Value = dto.Contenedor; |
||||||
|
worksheet.Cells[$"U{currentRow}"].Value = dto.CuentaDeGastos; |
||||||
|
worksheet.Cells[$"V{currentRow}"].Value = dto.Razon; |
||||||
|
worksheet.Cells[$"W{currentRow}"].Value = dto.Maniobras; |
||||||
|
}else{ |
||||||
|
continue; |
||||||
|
} |
||||||
|
} |
||||||
|
//Devolver el MS del archivo. |
||||||
|
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns(); |
||||||
|
var stream = new MemoryStream(); |
||||||
|
package.SaveAs(stream); |
||||||
|
stream.Position = 0; |
||||||
|
if(System.IO.File.Exists(filePath)) System.IO.File.Delete(filePath); |
||||||
|
return stream; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue