Browse Source

Se agrego la columna del tipo de ticket que es y tambien se agrego una columna con la fecha en que se cerro el ticket

master
parent
commit
df3a6a68f9
6 changed files with 118 additions and 18 deletions
  1. +20
    -3
      src/main/java/mx/gob/jumapacelaya/api/RedmineClient.java
  2. +60
    -8
      src/main/java/mx/gob/jumapacelaya/models/Ticket.java
  3. +13
    -1
      src/main/java/mx/gob/jumapacelaya/ui/ActDiariaView.java
  4. +15
    -2
      src/main/java/mx/gob/jumapacelaya/ui/MantenimientoView.java
  5. +1
    -1
      src/main/java/mx/gob/jumapacelaya/ui/PlanAnualView.java
  6. +9
    -3
      src/main/resources/application.properties

+ 20
- 3
src/main/java/mx/gob/jumapacelaya/api/RedmineClient.java View File

@ -140,17 +140,31 @@ public class RedmineClient {
// Verifica y obtiene la fecha de creación // Verifica y obtiene la fecha de creación
String dateString = issue.has("created_on") && !issue.get("created_on").isJsonNull() ? issue.get("created_on").getAsString() : ""; String dateString = issue.has("created_on") && !issue.get("created_on").isJsonNull() ? issue.get("created_on").getAsString() : "";
LocalDate date = null;
LocalDate dateCreate = null;
if (!dateString.isEmpty()) { if (!dateString.isEmpty()) {
try { try {
DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME; DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
date = LocalDate.parse(dateString, formatter);
dateCreate = LocalDate.parse(dateString, formatter);
} catch (DateTimeParseException e) { } catch (DateTimeParseException e) {
System.err.println("Error al parsear la fecha: " + dateString); System.err.println("Error al parsear la fecha: " + dateString);
e.printStackTrace(); e.printStackTrace();
} }
} }
// Verifica y obtiene la fecha de cierre
String closeDateString = issue.has("closed_on") && !issue.get("closed_on").isJsonNull() ? issue.get("closed_on").getAsString() : "";
LocalDate dateClose = null;
if (!closeDateString.isEmpty()) {
try {
DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
dateClose = LocalDate.parse(closeDateString, formatter);
} catch (DateTimeParseException e) {
System.err.println("Error al parsear la fecha de cierre: " + closeDateString);
e.printStackTrace();
}
}
//Verifica y obtiene el ID del tipo de ticket //Verifica y obtiene el ID del tipo de ticket
Integer trackerId = null; Integer trackerId = null;
if (issue.has("tracker") && !issue.get("tracker").isJsonNull()) { if (issue.has("tracker") && !issue.get("tracker").isJsonNull()) {
@ -162,7 +176,10 @@ public class RedmineClient {
// Agrega el ticket a la lista // Agrega el ticket a la lista
tickets.add(new Ticket(id, subject, description, status, date != null ? date.toString() : "", trackerId));
tickets.add(new Ticket(id, subject, description, status,
dateCreate != null ? dateCreate.toString() : "",
dateClose != null ? dateClose.toString() : "",
trackerId, "Tipo Desconocido"));
} }
} else { } else {
System.out.println("La respuesta JSON no contiene la clave 'issues'"); System.out.println("La respuesta JSON no contiene la clave 'issues'");


+ 60
- 8
src/main/java/mx/gob/jumapacelaya/models/Ticket.java View File

@ -4,23 +4,39 @@ import java.sql.Date;
import java.time.LocalDate; import java.time.LocalDate;
public class Ticket { public class Ticket {
private int id;
private String subject;
private String description;
private String status;
private LocalDate dateCreate;
private final int id;
private final String subject;
private final String description;
private final String status;
private final LocalDate dateCreate;
private LocalDate dateClose;
private User author; private User author;
private Integer trackerId; private Integer trackerId;
private String type;
public Ticket(int id, String subject, String description, String status, String dateCreate, Integer trackerId) {
public Ticket(int id, String subject, String description, String status, String dateCreate, String dateClose, Integer trackerId, String type) {
this.id = id; this.id = id;
this.subject = subject; this.subject = subject;
this.description = description; this.description = description;
this.status = status; this.status = status;
this.dateCreate = LocalDate.parse(dateCreate);
// Manejo de la fecha de creación
if (dateCreate != null && !dateCreate.isEmpty()) {
this.dateCreate = LocalDate.parse(dateCreate); // Solo se parsea si no está vacío
} else {
this.dateCreate = null; // Si está vacío, asignar null
}
// Manejo de la fecha de cierre
if (dateClose != null && !dateClose.isEmpty()) {
this.dateClose = LocalDate.parse(dateClose); // Solo se parsea si no está vacío
} else {
this.dateClose = null; // Si está vacío, asignar null
}
this.author = author; this.author = author;
this.trackerId = trackerId; this.trackerId = trackerId;
this.type = type;
} }
public int getId() { public int getId() {
@ -56,9 +72,22 @@ public class Ticket {
} }
public void setTrackerId(Integer tipoId) { public void setTrackerId(Integer tipoId) {
this.trackerId = trackerId;
this.trackerId = tipoId;
}
public LocalDate getDateClose() {
return dateClose;
}
public void setDateClose(LocalDate dateClose) {
this.dateClose = dateClose;
} }
public void setType(String type) {
this.type = type;
}
public static class User { public static class User {
private String username; private String username;
@ -95,4 +124,27 @@ public class Ticket {
return "N/A"; return "N/A";
} }
} }
public String getType() {
if (trackerId == null) {
return "Desconocido";
}
return switch (trackerId) {
case 4 -> "Acceso/Permiso/Bajas";
case 5 -> "Soporte de Software";
case 6 -> "Capacitacion de Software";
case 7 -> "Configuracion de Software";
case 8 -> "Desarrollo de Software";
case 9 -> "Digitalizacion GIS";
case 10 -> "Documento";
case 11 -> "Reporte";
case 13 -> "DML";
case 14 -> "DCL";
case 15 -> "DDL";
case 16 -> "Mantenimiento Correctivo";
case 17 -> "Actividad";
default -> "N/A";
};
}
} }

+ 13
- 1
src/main/java/mx/gob/jumapacelaya/ui/ActDiariaView.java View File

@ -21,6 +21,7 @@ import mx.gob.jumapacelaya.services.UserService;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*; import java.util.*;
@ -44,6 +45,10 @@ public class ActDiariaView extends VerticalLayout {
grid.addColumn(Ticket::getId).setHeader("No.") grid.addColumn(Ticket::getId).setHeader("No.")
.setAutoWidth(true).setFlexGrow(0).setSortable(true); .setAutoWidth(true).setFlexGrow(0).setSortable(true);
grid.addColumn(Ticket::getType)
.setHeader("Tipo")
.setAutoWidth(true);
grid.addColumn(Ticket::getSubject).setHeader("Asunto") grid.addColumn(Ticket::getSubject).setHeader("Asunto")
.setAutoWidth(true); .setAutoWidth(true);
@ -57,12 +62,19 @@ public class ActDiariaView extends VerticalLayout {
} else { } else {
return ""; return "";
} }
}).setHeader("Fecha creacion");
}).setHeader("Fecha creacion").setAutoWidth(true);
grid.addColumn(ticket -> {
LocalDate fechaCierre = ticket.getDateClose();
return fechaCierre != null ? fechaCierre.toString() : "";
}).setHeader("Fecha cierre").setAutoWidth(true);
grid.addColumn(ticket -> ticket.tiempoEst(ticket.getTrackerId())).setHeader("Tiempo estimado de atencion").setAutoWidth(false); grid.addColumn(ticket -> ticket.tiempoEst(ticket.getTrackerId())).setHeader("Tiempo estimado de atencion").setAutoWidth(false);
grid.addColumn(Ticket::getDescription).setHeader("Descripción").setWidth("25em"); grid.addColumn(Ticket::getDescription).setHeader("Descripción").setWidth("25em");
//grid.addColumn().setHeader("Realizar");
grid.addThemeVariants(GridVariant.LUMO_WRAP_CELL_CONTENT); grid.addThemeVariants(GridVariant.LUMO_WRAP_CELL_CONTENT);
grid.getStyle().set("opacity", "0.8"); grid.getStyle().set("opacity", "0.8");
grid.setAllRowsVisible(true); grid.setAllRowsVisible(true);


+ 15
- 2
src/main/java/mx/gob/jumapacelaya/ui/MantenimientoView.java View File

@ -37,6 +37,7 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
private final VerticalLayout actualizacionesLayout; private final VerticalLayout actualizacionesLayout;
private final VerticalLayout etiquetaLayout; private final VerticalLayout etiquetaLayout;
private DatePicker fecha; private DatePicker fecha;
private ComboBox<String> tipoMantt;
public MantenimientoView() { public MantenimientoView() {
this.databaseService = new DatabaseService(); this.databaseService = new DatabaseService();
@ -61,8 +62,8 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
//ComboBox Tipo de Mantenimiento //ComboBox Tipo de Mantenimiento
ComboBox<String> tipoMantt = new ComboBox<>("Tipo de Mantenimiento");
List<String> tiposDeMantenimiento = databaseService.getTiposDeMantenimientos(); List<String> tiposDeMantenimiento = databaseService.getTiposDeMantenimientos();
this.tipoMantt = new ComboBox<>("Tipo de Mantenimiento");
tipoMantt.setItems(tiposDeMantenimiento); tipoMantt.setItems(tiposDeMantenimiento);
tipoMantt.addClassName("mantenimiento-combo"); tipoMantt.addClassName("mantenimiento-combo");
tipoMantt.addValueChangeListener(event -> { tipoMantt.addValueChangeListener(event -> {
@ -297,7 +298,14 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
@Override @Override
public void beforeEnter(BeforeEnterEvent beforeEnterEvent) { public void beforeEnter(BeforeEnterEvent beforeEnterEvent) {
String fechaParam = beforeEnterEvent.getLocation().getQueryParameters().getParameters().get("fecha") != null ? beforeEnterEvent.getLocation().getQueryParameters().getParameters().get("fecha").stream().findFirst().orElse(null) : null;
String fechaParam = beforeEnterEvent.getLocation().getQueryParameters().getParameters().get("fecha") != null
? beforeEnterEvent.getLocation().getQueryParameters().getParameters().get("fecha").stream().findFirst().orElse(null)
: null;
String tipoParam = beforeEnterEvent.getLocation().getQueryParameters().getParameters().get("tipo") != null
? beforeEnterEvent.getLocation().getQueryParameters().getParameters("tipo").stream().findFirst().orElse(null)
: null;
if (fechaParam != null) { if (fechaParam != null) {
try { try {
LocalDate fechaActual = LocalDate.parse(fechaParam); LocalDate fechaActual = LocalDate.parse(fechaParam);
@ -306,5 +314,10 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
Notification.show("Error al establecer la fecha: " + e.getMessage(), 3000, Notification.Position.MIDDLE); Notification.show("Error al establecer la fecha: " + e.getMessage(), 3000, Notification.Position.MIDDLE);
} }
} }
if ("PREVENTIVO".equalsIgnoreCase(tipoParam)) {
tipoMantt.setValue("PREVENTIVO");
tipoMantt.setReadOnly(true);
}
} }
} }

+ 1
- 1
src/main/java/mx/gob/jumapacelaya/ui/PlanAnualView.java View File

@ -74,7 +74,7 @@ public class PlanAnualView extends VerticalLayout {
btnRealizar.addClickListener(event -> { btnRealizar.addClickListener(event -> {
LocalDate fechaSistem = LocalDate.now(); LocalDate fechaSistem = LocalDate.now();
String fechaStr = fechaSistem.toString(); String fechaStr = fechaSistem.toString();
btnRealizar.getUI().ifPresent(ui -> ui.navigate("mantenimiento?fecha=" + fechaStr));
btnRealizar.getUI().ifPresent(ui -> ui.navigate("mantenimiento?fecha=" + fechaStr + "&tipo=PREVENTIVO"));
}); });
return btnRealizar; return btnRealizar;
}).setHeader("Realizar").setAutoWidth(true); }).setHeader("Realizar").setAutoWidth(true);


+ 9
- 3
src/main/resources/application.properties View File

@ -15,9 +15,15 @@ spring.ldap.base=DC=JUMAPACELAYA,DC=GOB,DC=MX
spring.ldap.username=administrator spring.ldap.username=administrator
spring.ldap.password=Dr3na%134$4guA spring.ldap.password=Dr3na%134$4guA
########PRODUCTIVO#################################
redmine.url=https://proyman.jumapacelaya.gob.mx/
redmine.api_key=ce4dc8b6b531c818017e6831a5732ccc15b8faf6
###################PRODUCTIVO####################
#redmine.url=https://proyman.jumapacelaya.gob.mx/
#redmine.api_key=ce4dc8b6b531c818017e6831a5732ccc15b8faf6
######################PRUEBAS####################
redmine.url=http://localhost:10083/
redmine.api_key=bada7949fd4d879cbd98eb645ae4b88603bf77d0
#Conexion a la base de datos Mantenimientos #Conexion a la base de datos Mantenimientos
#MySQL Configuration #MySQL Configuration


Loading…
Cancel
Save