diff --git a/src/main/java/mx/gob/jumapacelaya/api/SecurityService.java b/src/main/java/mx/gob/jumapacelaya/api/SecurityService.java deleted file mode 100644 index 3d52e83..0000000 --- a/src/main/java/mx/gob/jumapacelaya/api/SecurityService.java +++ /dev/null @@ -1 +0,0 @@ -package mx.gob.jumapacelaya.api; diff --git a/src/main/java/mx/gob/jumapacelaya/ui/ActDiariaView.java b/src/main/java/mx/gob/jumapacelaya/ui/ActDiariaView.java index fbadb46..1447d2d 100644 --- a/src/main/java/mx/gob/jumapacelaya/ui/ActDiariaView.java +++ b/src/main/java/mx/gob/jumapacelaya/ui/ActDiariaView.java @@ -42,10 +42,9 @@ import mx.gob.jumapacelaya.models.Ticket; import mx.gob.jumapacelaya.services.LdapService; import mx.gob.jumapacelaya.services.UserService; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,6 +54,7 @@ import org.vaadin.lineawesome.LineAwesomeIcon; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; @@ -431,15 +431,94 @@ public class ActDiariaView extends VerticalLayout { Workbook workbook = new XSSFWorkbook(); Sheet sheet = workbook.createSheet("Tickets cerrados"); + CellStyle titleStyle = workbook.createCellStyle(); + Font titleFont = workbook.createFont(); + titleFont.setBold(true); + titleFont.setFontHeightInPoints((short) 20); + titleStyle.setFont(titleFont); + titleStyle.setAlignment(HorizontalAlignment.CENTER); + + CellStyle subTitleStyle = workbook.createCellStyle(); + Font subTitleFont = workbook.createFont(); + subTitleFont.setFontHeightInPoints((short) 18); + subTitleStyle.setFont(subTitleFont); + subTitleStyle.setAlignment(HorizontalAlignment.CENTER); + + int ultimaCol = 10; + + Row row1 = sheet.createRow(1); + Cell cell1 = row1.createCell(0); + cell1.setCellValue("JUNTA MUNICIPAL DE AGUA POTABLE Y ALCANTARILLADO DE CELAYA."); + cell1.setCellStyle(titleStyle); + sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, ultimaCol)); + + Row row2 = sheet.createRow(2); + Cell cell2 = row2.createCell(0); + cell2.setCellValue("División Del Norte #132, Col. El Vergel, Celaya, Gto. C.P: 38078"); + cell2.setCellStyle(subTitleStyle); + sheet.addMergedRegion(new CellRangeAddress(2, 2, 0, ultimaCol)); + + + try ( + InputStream jmpaLogo = ActDiariaView.class.getClassLoader() + .getResourceAsStream("META-INF/resources/images/LOGO_24'27.png"); + InputStream adminLogo = ActDiariaView.class.getClassLoader() + .getResourceAsStream("META-INF/resources/images/LOGO_admon2.png") + ) { + if (jmpaLogo != null || adminLogo != null) { + byte[] bytes = IOUtils.toByteArray(jmpaLogo); + byte[] bytes1 = IOUtils.toByteArray(adminLogo); + int pictureIdx = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG); + int pictureIdx1 = workbook.addPicture(bytes1, Workbook.PICTURE_TYPE_PNG); + + Drawing drawing = sheet.createDrawingPatriarch(); + CreationHelper helper = workbook.getCreationHelper(); + CreationHelper helper1 = workbook.getCreationHelper(); + + ClientAnchor anchor = helper.createClientAnchor(); + ClientAnchor anchor1 = helper1.createClientAnchor(); + + // Posición en la esquina superior izquierda + anchor.setCol1(1); + anchor.setRow1(1); + + anchor1.setCol1(10); + anchor1.setRow1(1); + + Picture pict = drawing.createPicture(anchor, pictureIdx); + pict.resize(0.30, 0.60); // Ajusta según el tamaño de tu imagen original + + Picture pict1 = drawing.createPicture(anchor1, pictureIdx1); + pict1.resize(0.30, 0.37); + } else { + log.error("No se encontró el archivo de imagen en la ruta especificada"); + } + } catch (Exception e) { + log.error("Error al procesar el logo", e); + } + + + CellStyle headerStyle = workbook.createCellStyle(); + Font headerFont = workbook.createFont(); + headerFont.setBold(true); + headerFont.setColor(IndexedColors.WHITE.getIndex()); + headerStyle.setFont(headerFont); + headerStyle.setFillForegroundColor(IndexedColors.MAROON.getIndex()); + headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle.setAlignment(HorizontalAlignment.CENTER); + headerStyle.setBorderBottom(BorderStyle.THIN); + String[] headers = {"ID","Tipo","Tiempo estimado","Fecha creación","Fecha cierre", "Fecha actualización","Situación","Estado","Duración","Autor","Asunto"}; - Row headerRow = sheet.createRow(0); + + int rowNum = 6; + Row headerRow = sheet.createRow(rowNum++); for (int i = 0; i < headers.length; i++) { Cell cell = headerRow.createCell(i); cell.setCellValue(headers[i]); + cell.setCellStyle(headerStyle); } - int rowNum = 1; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss"); for (Ticket ticket : ticketsCerrados) { diff --git a/src/main/resources/META-INF/resources/images/LOGO_admon2.png b/src/main/resources/META-INF/resources/images/LOGO_admon2.png new file mode 100644 index 0000000..da7a4af Binary files /dev/null and b/src/main/resources/META-INF/resources/images/LOGO_admon2.png differ