|
|
@ -0,0 +1,693 @@ |
|
|
|
|
|
package mx.gob.jumapacelaya.ui; |
|
|
|
|
|
|
|
|
|
|
|
import com.vaadin.flow.component.Text; |
|
|
|
|
|
import com.vaadin.flow.component.UI; |
|
|
|
|
|
import com.vaadin.flow.component.button.Button; |
|
|
|
|
|
import com.vaadin.flow.component.button.ButtonVariant; |
|
|
|
|
|
import com.vaadin.flow.component.checkbox.CheckboxGroup; |
|
|
|
|
|
import com.vaadin.flow.component.combobox.ComboBox; |
|
|
|
|
|
import com.vaadin.flow.component.datepicker.DatePicker; |
|
|
|
|
|
import com.vaadin.flow.component.dependency.CssImport; |
|
|
|
|
|
import com.vaadin.flow.component.dialog.Dialog; |
|
|
|
|
|
import com.vaadin.flow.component.formlayout.FormLayout; |
|
|
|
|
|
import com.vaadin.flow.component.grid.Grid; |
|
|
|
|
|
import com.vaadin.flow.component.grid.GridVariant; |
|
|
|
|
|
import com.vaadin.flow.component.html.Image; |
|
|
|
|
|
import com.vaadin.flow.component.html.Span; |
|
|
|
|
|
import com.vaadin.flow.component.icon.Icon; |
|
|
|
|
|
import com.vaadin.flow.component.icon.VaadinIcon; |
|
|
|
|
|
import com.vaadin.flow.component.notification.Notification; |
|
|
|
|
|
import com.vaadin.flow.component.notification.NotificationVariant; |
|
|
|
|
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; |
|
|
|
|
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout; |
|
|
|
|
|
import com.vaadin.flow.component.radiobutton.RadioButtonGroup; |
|
|
|
|
|
import com.vaadin.flow.component.textfield.TextArea; |
|
|
|
|
|
import com.vaadin.flow.component.textfield.TextField; |
|
|
|
|
|
import com.vaadin.flow.data.renderer.ComponentRenderer; |
|
|
|
|
|
import com.vaadin.flow.function.ValueProvider; |
|
|
|
|
|
import com.vaadin.flow.router.BeforeEnterEvent; |
|
|
|
|
|
import com.vaadin.flow.router.BeforeEnterObserver; |
|
|
|
|
|
import com.vaadin.flow.router.PageTitle; |
|
|
|
|
|
import com.vaadin.flow.router.Route; |
|
|
|
|
|
import de.f0rce.signaturepad.SignaturePad; |
|
|
|
|
|
import jakarta.annotation.security.PermitAll; |
|
|
|
|
|
import mx.gob.jumapacelaya.models.*; |
|
|
|
|
|
import mx.gob.jumapacelaya.services.DatabaseService; |
|
|
|
|
|
import mx.gob.jumapacelaya.services.EmailService; |
|
|
|
|
|
import mx.gob.jumapacelaya.services.SecurityService; |
|
|
|
|
|
import mx.gob.jumapacelaya.services.UserService; |
|
|
|
|
|
import org.vaadin.lineawesome.LineAwesomeIcon; |
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
@PermitAll |
|
|
|
|
|
@PageTitle("Correctivo") |
|
|
|
|
|
@Route(value = "correctivo", layout = MainLayout.class) |
|
|
|
|
|
@CssImport("./themes/sistema-mantenimiento/styles.css") |
|
|
|
|
|
public class MantCorrectivoView extends VerticalLayout { |
|
|
|
|
|
|
|
|
|
|
|
private VerticalLayout mainLayout; |
|
|
|
|
|
private final SecurityService securityService; |
|
|
|
|
|
private final VerticalLayout controlsLayout; |
|
|
|
|
|
private final DatabaseService databaseService; |
|
|
|
|
|
private final VerticalLayout actualizacionesLayout; |
|
|
|
|
|
//private final VerticalLayout etiquetaLayout; |
|
|
|
|
|
private final HorizontalLayout firmasLayout; |
|
|
|
|
|
private final DatePicker fecha; |
|
|
|
|
|
private final ComboBox<TiposMantenimiento> tipoMantt; |
|
|
|
|
|
private final ComboBox<DepartamentosModel> area; |
|
|
|
|
|
private final ComboBox<Usuario> usuario; |
|
|
|
|
|
private final TextField txtNombreEquipo; |
|
|
|
|
|
private final UserService userService; |
|
|
|
|
|
private final EmailService emailService; |
|
|
|
|
|
private RadioButtonGroup<String> formaGroup; |
|
|
|
|
|
private CheckboxGroup<String> actualizaciones; |
|
|
|
|
|
private final HorizontalLayout botonesLayout; |
|
|
|
|
|
private TextArea txtCuales; |
|
|
|
|
|
private RadioButtonGroup<String> masActualizacionesGroup; |
|
|
|
|
|
private SignaturePad userSignPad; |
|
|
|
|
|
private SignaturePad smtSignPad; |
|
|
|
|
|
private SignaturePad gciatiSignPad; |
|
|
|
|
|
private PlanAnual planAnualActual; |
|
|
|
|
|
private LocalDate fechaProgramada; |
|
|
|
|
|
private LocalDate fechaSeleccionada; |
|
|
|
|
|
private TextArea jsutificacion; |
|
|
|
|
|
Span userSignSpan = new Span("Nombre Usuario"); |
|
|
|
|
|
private TextArea txtReparacion; |
|
|
|
|
|
private HorizontalLayout headerLayout; |
|
|
|
|
|
|
|
|
|
|
|
public MantCorrectivoView(UserService userService, SecurityService securityService, EmailService emailService, DatabaseService databaseService) { |
|
|
|
|
|
this.databaseService = databaseService; |
|
|
|
|
|
this.controlsLayout = new VerticalLayout(); |
|
|
|
|
|
this.actualizacionesLayout = new VerticalLayout(); |
|
|
|
|
|
//this.etiquetaLayout = new VerticalLayout(); |
|
|
|
|
|
this.firmasLayout = new HorizontalLayout(); |
|
|
|
|
|
this.botonesLayout = new HorizontalLayout(); |
|
|
|
|
|
this.securityService = securityService; |
|
|
|
|
|
this.userService = userService; |
|
|
|
|
|
this.emailService = emailService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
headerLayout = new HorizontalLayout(); |
|
|
|
|
|
headerLayout.setWidthFull(); |
|
|
|
|
|
headerLayout.setMargin(false); |
|
|
|
|
|
headerLayout.getStyle() |
|
|
|
|
|
.set("box-shadow", "0 4px 8px rgba(0,0,0,0.2)") |
|
|
|
|
|
.set("border-radius", "10px") |
|
|
|
|
|
.set("background-color", "white") |
|
|
|
|
|
.set("padding", "1rem") |
|
|
|
|
|
.set("margin", "1rem auto"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mainLayout = new VerticalLayout(); |
|
|
|
|
|
mainLayout.setHeightFull(); |
|
|
|
|
|
mainLayout.setMargin(false); |
|
|
|
|
|
mainLayout.getStyle() |
|
|
|
|
|
.set("box-shadow", "0 4px 8px rgba(0,0,0,0.2)") |
|
|
|
|
|
.set("border-radius", "12px") |
|
|
|
|
|
.set("background-color", "white") |
|
|
|
|
|
.set("padding", "1rem") |
|
|
|
|
|
.set("margin", "1rem auto"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextField nomenclatura = new TextField("Nomenclatura"); |
|
|
|
|
|
nomenclatura.setReadOnly(true); |
|
|
|
|
|
nomenclatura.addClassName("mantenimiento-text-field"); |
|
|
|
|
|
|
|
|
|
|
|
Button btnListado = new Button("Mantenimientos realizados", VaadinIcon.CLIPBOARD_CHECK.create()); |
|
|
|
|
|
btnListado.addClickListener(e -> verListadoMantenimientos()); |
|
|
|
|
|
|
|
|
|
|
|
fecha = new DatePicker("Fecha:"); |
|
|
|
|
|
fecha.setRequired(true); |
|
|
|
|
|
fecha.setLocale(new Locale("es", "MX")); |
|
|
|
|
|
DatePicker.DatePickerI18n i18n = new DatePicker.DatePickerI18n() |
|
|
|
|
|
.setWeekdays(List.of("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado")) |
|
|
|
|
|
.setWeekdaysShort(List.of("Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb")) |
|
|
|
|
|
.setMonthNames(List.of("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")) |
|
|
|
|
|
.setFirstDayOfWeek(1) |
|
|
|
|
|
.setToday("Hoy") |
|
|
|
|
|
.setCancel("Cancelar") |
|
|
|
|
|
.setDateFormat("dd/MM/yyyy"); |
|
|
|
|
|
fecha.setI18n(i18n); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tipoMantt = new ComboBox<>("Tipo de Mantenimiento"); |
|
|
|
|
|
List<TiposMantenimiento> tiposMantenimiento = databaseService.getTiposDeMantenimientos(); |
|
|
|
|
|
tipoMantt.setItems(tiposMantenimiento); |
|
|
|
|
|
tipoMantt.addClassName("mantenimiento-combo"); |
|
|
|
|
|
// Listener para manejar el cambio en el tipo de mantenimiento |
|
|
|
|
|
tipoMantt.addValueChangeListener(e -> { |
|
|
|
|
|
TiposMantenimiento tipoSeleccionado = e.getValue(); |
|
|
|
|
|
if (tipoSeleccionado != null) { |
|
|
|
|
|
String nomenclaturaValue = databaseService.getNomenclatura(tipoSeleccionado.getTipomantId()); |
|
|
|
|
|
nomenclatura.setValue(nomenclaturaValue); |
|
|
|
|
|
fecha.setValue(LocalDate.now()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
HorizontalLayout fechaLayout = new HorizontalLayout(); |
|
|
|
|
|
fechaLayout.add(fecha); |
|
|
|
|
|
fechaLayout.addAndExpand(new HorizontalLayout()); |
|
|
|
|
|
fechaLayout.add(tipoMantt, nomenclatura); |
|
|
|
|
|
fechaLayout.setWidthFull(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HorizontalLayout departamentoUsuarioLayout = new HorizontalLayout(); |
|
|
|
|
|
area = new ComboBox<>("Área o Departamento:"); |
|
|
|
|
|
area.setRequired(true); |
|
|
|
|
|
List<DepartamentosModel> areas = databaseService.getDepartamentos(); |
|
|
|
|
|
area.setItems(areas); |
|
|
|
|
|
|
|
|
|
|
|
usuario = new ComboBox<>("Usuario:"); |
|
|
|
|
|
List<Usuario> usuarios = databaseService.getUsuarios(); |
|
|
|
|
|
usuario.setItems(usuarios); |
|
|
|
|
|
usuario.setItemLabelGenerator(Usuario::getNombre); |
|
|
|
|
|
usuario.setRequired(true); |
|
|
|
|
|
usuario.addValueChangeListener(e -> { |
|
|
|
|
|
Usuario usuarioSeleccionado = e.getValue(); |
|
|
|
|
|
if (usuarioSeleccionado != null) { |
|
|
|
|
|
String empleadoId = usuarioSeleccionado.getEmpleadoId(); |
|
|
|
|
|
String nombreUsuario = usuarioSeleccionado.getNombre(); |
|
|
|
|
|
//userSignSpan.setText(nombreUsuario); |
|
|
|
|
|
} else { |
|
|
|
|
|
//userSignSpan.setText("S.M.T Nombre"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
txtNombreEquipo = new TextField("Nombre del Equipo:"); |
|
|
|
|
|
departamentoUsuarioLayout.add(area, usuario, txtNombreEquipo); |
|
|
|
|
|
departamentoUsuarioLayout.setWidthFull(); |
|
|
|
|
|
|
|
|
|
|
|
createHardwareSection(databaseService); |
|
|
|
|
|
addActualizacionesSection(); |
|
|
|
|
|
signLayout(); |
|
|
|
|
|
buttons(); |
|
|
|
|
|
|
|
|
|
|
|
headerLayout.add(btnListado); |
|
|
|
|
|
mainLayout.add(fechaLayout, departamentoUsuarioLayout, controlsLayout, actualizacionesLayout, firmasLayout, botonesLayout); |
|
|
|
|
|
add(headerLayout, mainLayout); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Metodo para inicializar el formulario de hardware |
|
|
|
|
|
private void createHardwareSection(DatabaseService databaseService) { |
|
|
|
|
|
HorizontalLayout etiquetaLayout = new HorizontalLayout(); |
|
|
|
|
|
Span etiqueta = new Span("Limpieza de Equipo Realizada"); |
|
|
|
|
|
|
|
|
|
|
|
Button btnAgregarTipo = new Button(new Icon(VaadinIcon.PLUS)); |
|
|
|
|
|
btnAgregarTipo.addThemeVariants(ButtonVariant.LUMO_ICON); |
|
|
|
|
|
btnAgregarTipo.setAriaLabel("Agregar Equipo"); |
|
|
|
|
|
btnAgregarTipo.addClickListener(e -> { |
|
|
|
|
|
addNuevoTipo(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
etiquetaLayout.add(etiqueta, btnAgregarTipo); |
|
|
|
|
|
controlsLayout.add(etiquetaLayout); |
|
|
|
|
|
controlsLayout.setSpacing(false); |
|
|
|
|
|
|
|
|
|
|
|
addNuevoTipo(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Método para crear el combo box y campos de texto para eñ hardware en tiempo de ejecución |
|
|
|
|
|
private List<HorizontalLayout> hardwareLayouts = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
private void addNuevoTipo() { |
|
|
|
|
|
ComboBox<TiposHardware> tipoHardware = new ComboBox<>(); |
|
|
|
|
|
tipoHardware.setPlaceholder("Tipos de Hardware"); |
|
|
|
|
|
tipoHardware.setItemLabelGenerator(TiposHardware::getNombreHardware); |
|
|
|
|
|
tipoHardware.setItems(databaseService.getTiposHardware()); |
|
|
|
|
|
tipoHardware.setSizeFull(); |
|
|
|
|
|
|
|
|
|
|
|
TextField noSerie = new TextField(); |
|
|
|
|
|
noSerie.setEnabled(false); |
|
|
|
|
|
noSerie.setRequired(true); |
|
|
|
|
|
noSerie.setPlaceholder("No. de Serie"); |
|
|
|
|
|
noSerie.setSizeFull(); |
|
|
|
|
|
noSerie.addValueChangeListener(e -> { |
|
|
|
|
|
String upperCaseValue = e.getValue().toUpperCase(); |
|
|
|
|
|
noSerie.setValue(upperCaseValue); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
TextField modelo = new TextField(); |
|
|
|
|
|
modelo.setEnabled(false); |
|
|
|
|
|
modelo.setRequired(true); |
|
|
|
|
|
modelo.setPlaceholder("Modelo"); |
|
|
|
|
|
modelo.setSizeFull(); |
|
|
|
|
|
modelo.addValueChangeListener(event -> { |
|
|
|
|
|
String upperCaseValue = event.getValue().toUpperCase(); |
|
|
|
|
|
modelo.setValue(upperCaseValue); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
TextField placa = new TextField(); |
|
|
|
|
|
placa.setEnabled(false); |
|
|
|
|
|
placa.setRequired(true); |
|
|
|
|
|
placa.setPlaceholder("Placa"); |
|
|
|
|
|
placa.setSizeFull(); |
|
|
|
|
|
// Validacion para que este campo solo acepte numeros |
|
|
|
|
|
placa.getElement().executeJs( |
|
|
|
|
|
"this.addEventListener('input', function(e) { " + |
|
|
|
|
|
" e.target.value = e.target.value.replace(/[^0-9]/g, '');" + // Solo permite dígitos |
|
|
|
|
|
"});" |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
tipoHardware.addValueChangeListener(event -> { |
|
|
|
|
|
TiposHardware tipoSeleccionado = event.getValue(); |
|
|
|
|
|
|
|
|
|
|
|
if (tipoSeleccionado != null) { |
|
|
|
|
|
String nombreTipo = tipoSeleccionado.getNombreHardware(); |
|
|
|
|
|
if ("TECLADO".equals(nombreTipo)) { |
|
|
|
|
|
noSerie.setEnabled(false); |
|
|
|
|
|
modelo.setEnabled(false); |
|
|
|
|
|
placa.setEnabled(false); |
|
|
|
|
|
} else if ("MOUSE".equals(nombreTipo)) { |
|
|
|
|
|
noSerie.setEnabled(false); |
|
|
|
|
|
modelo.setEnabled(false); |
|
|
|
|
|
placa.setEnabled(false); |
|
|
|
|
|
} else { |
|
|
|
|
|
noSerie.setEnabled(true); |
|
|
|
|
|
modelo.setEnabled(true); |
|
|
|
|
|
placa.setEnabled(true); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
noSerie.setEnabled(false); |
|
|
|
|
|
modelo.setEnabled(false); |
|
|
|
|
|
placa.setEnabled(false); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Button btnEliminar = new Button(new Icon(VaadinIcon.TRASH)); |
|
|
|
|
|
btnEliminar.addThemeVariants(ButtonVariant.LUMO_ICON, ButtonVariant.LUMO_ERROR); |
|
|
|
|
|
btnEliminar.setAriaLabel("Eliminar Tipo"); |
|
|
|
|
|
|
|
|
|
|
|
//Crear nuevo layout horizontal con estos campos |
|
|
|
|
|
HorizontalLayout hardwareDetailsLayout = new HorizontalLayout(); |
|
|
|
|
|
hardwareDetailsLayout.add(tipoHardware, noSerie, modelo, placa, btnEliminar); |
|
|
|
|
|
hardwareDetailsLayout.setWidthFull(); |
|
|
|
|
|
|
|
|
|
|
|
hardwareLayouts.add(hardwareDetailsLayout); |
|
|
|
|
|
controlsLayout.add(hardwareDetailsLayout); |
|
|
|
|
|
|
|
|
|
|
|
//Listener para eliminar el tipo |
|
|
|
|
|
btnEliminar.addClickListener(event -> { |
|
|
|
|
|
controlsLayout.remove(hardwareDetailsLayout); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
controlsLayout.add(hardwareDetailsLayout); |
|
|
|
|
|
controlsLayout.setSizeFull(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void addActualizacionesSection() { |
|
|
|
|
|
VerticalLayout etiquetaLayout = new VerticalLayout(); |
|
|
|
|
|
Span Titulo = new Span("Actualizaciones de Seguridad Informatica:"); |
|
|
|
|
|
etiquetaLayout.add(Titulo); |
|
|
|
|
|
|
|
|
|
|
|
actualizaciones = new CheckboxGroup<>(); |
|
|
|
|
|
actualizaciones.setLabel("Actualizaciones Necesarias"); |
|
|
|
|
|
actualizaciones.setItems("S.O", "Antivirus", "Firewall"); |
|
|
|
|
|
|
|
|
|
|
|
formaGroup = new RadioButtonGroup<>(); |
|
|
|
|
|
formaGroup.setLabel("Actividad Realizada de Forma:"); |
|
|
|
|
|
formaGroup.setRequired(true); |
|
|
|
|
|
formaGroup.setItems("Remota", "Manual"); |
|
|
|
|
|
|
|
|
|
|
|
txtCuales = new TextArea(); |
|
|
|
|
|
txtCuales.setLabel("¿Cuáles?"); |
|
|
|
|
|
txtCuales.setEnabled(false); |
|
|
|
|
|
txtCuales.setWidthFull(); |
|
|
|
|
|
|
|
|
|
|
|
masActualizacionesGroup = new RadioButtonGroup<>(); |
|
|
|
|
|
masActualizacionesGroup.setRequired(true); |
|
|
|
|
|
masActualizacionesGroup.setLabel("¿Requiere más actualizaciones?"); |
|
|
|
|
|
masActualizacionesGroup.setItems("Si", "No"); |
|
|
|
|
|
masActualizacionesGroup.addValueChangeListener(e -> { |
|
|
|
|
|
if ("Si".equals(e.getValue())) { |
|
|
|
|
|
txtCuales.setEnabled(true); |
|
|
|
|
|
txtCuales.setRequired(true); |
|
|
|
|
|
txtCuales.clear(); |
|
|
|
|
|
} else { |
|
|
|
|
|
txtCuales.setEnabled(false); |
|
|
|
|
|
txtCuales.setRequired(false); |
|
|
|
|
|
txtCuales.clear(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
txtReparacion = new TextArea("Reparación Realizada:"); |
|
|
|
|
|
txtReparacion.setWidthFull(); |
|
|
|
|
|
txtReparacion.setHeight("100px"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HorizontalLayout formasLayout = new HorizontalLayout(); |
|
|
|
|
|
formasLayout.add(formaGroup, masActualizacionesGroup, txtCuales); |
|
|
|
|
|
formasLayout.setSizeFull(); |
|
|
|
|
|
|
|
|
|
|
|
actualizacionesLayout.add(Titulo, actualizaciones, formasLayout, txtReparacion); |
|
|
|
|
|
actualizacionesLayout.setSpacing(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void signLayout() { |
|
|
|
|
|
VerticalLayout userSignLayout = new VerticalLayout(); |
|
|
|
|
|
userSignPad = new SignaturePad(); |
|
|
|
|
|
userSignPad.setBackgroundColor("#FFFFFF"); |
|
|
|
|
|
userSignPad.setHeight("200px"); |
|
|
|
|
|
userSignPad.setPenColor("#000000"); |
|
|
|
|
|
userSignPad.getElement().getStyle().set("border", "1px solid black"); |
|
|
|
|
|
Span tituloUser = new Span("Usuario Interno"); |
|
|
|
|
|
userSignLayout.setSizeFull(); |
|
|
|
|
|
userSignLayout.setSpacing(true); |
|
|
|
|
|
userSignLayout.setSpacing(false); |
|
|
|
|
|
userSignLayout.setAlignItems(Alignment.CENTER); |
|
|
|
|
|
userSignLayout.add(userSignPad, userSignSpan, tituloUser); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VerticalLayout smtSignLayout = new VerticalLayout(); |
|
|
|
|
|
smtSignPad = new SignaturePad(); |
|
|
|
|
|
smtSignPad.setHeight("200px"); |
|
|
|
|
|
smtSignPad.setBackgroundColor("#FFFFFF"); |
|
|
|
|
|
smtSignPad.setPenColor("#000000"); |
|
|
|
|
|
smtSignPad.getElement().getStyle().set("border", "1px solid black"); |
|
|
|
|
|
String u = securityService.getAuthenticatedUser(); |
|
|
|
|
|
Span smtSignSpan = new Span(u); |
|
|
|
|
|
Span tituloSMT = new Span("Responsable de Soporte"); |
|
|
|
|
|
smtSignLayout.setSizeFull(); |
|
|
|
|
|
smtSignLayout.setSpacing(true); |
|
|
|
|
|
smtSignLayout.setSpacing(false); |
|
|
|
|
|
smtSignLayout.setAlignItems(Alignment.CENTER); |
|
|
|
|
|
smtSignLayout.add(smtSignPad, smtSignSpan, tituloSMT); |
|
|
|
|
|
|
|
|
|
|
|
VerticalLayout gcialSignLayout = new VerticalLayout(); |
|
|
|
|
|
Image firmaGcia = new Image("images/FirmaGerenteTI.png", "Firma Gerente de Sistemas"); |
|
|
|
|
|
firmaGcia.setHeight("200px"); |
|
|
|
|
|
firmaGcia.setWidthFull(); |
|
|
|
|
|
Span gciatiSignSpan = new Span("Ing. Javier Patiño Martinez"); |
|
|
|
|
|
Span tituloGerente = new Span("Gerente de T.I"); |
|
|
|
|
|
gcialSignLayout.setSizeFull(); |
|
|
|
|
|
gcialSignLayout.setSpacing(false); |
|
|
|
|
|
gcialSignLayout.setAlignItems(Alignment.CENTER); |
|
|
|
|
|
gcialSignLayout.add(firmaGcia, gciatiSignSpan, tituloGerente); |
|
|
|
|
|
|
|
|
|
|
|
firmasLayout.add(userSignLayout, smtSignLayout, gcialSignLayout); |
|
|
|
|
|
firmasLayout.setWidthFull(); |
|
|
|
|
|
firmasLayout.setSpacing(false); |
|
|
|
|
|
firmasLayout.setJustifyContentMode(JustifyContentMode.CENTER); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Metodo para verificar si la firma corresponde a una cadena de firma vacia |
|
|
|
|
|
private boolean esFirmaVacia(String firmaBase64) { |
|
|
|
|
|
|
|
|
|
|
|
String firmaVacia = "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"; |
|
|
|
|
|
return firmaBase64.equals(firmaVacia); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void buttons() { |
|
|
|
|
|
VerticalLayout buttonsLayout = new VerticalLayout(); |
|
|
|
|
|
Button btnGuardar = new Button("Guardar", LineAwesomeIcon.SAVE.create()); |
|
|
|
|
|
btnGuardar.addThemeVariants(ButtonVariant.LUMO_PRIMARY); |
|
|
|
|
|
btnGuardar.addThemeVariants(ButtonVariant.LUMO_LARGE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btnGuardar.addClickListener(event -> { |
|
|
|
|
|
fechaSeleccionada = fecha.getValue(); |
|
|
|
|
|
guardarMantenimiento(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
buttonsLayout.setSizeFull(); |
|
|
|
|
|
buttonsLayout.add(btnGuardar); |
|
|
|
|
|
buttonsLayout.setAlignItems(Alignment.CENTER); |
|
|
|
|
|
botonesLayout.add(buttonsLayout); |
|
|
|
|
|
botonesLayout.setSizeFull(); |
|
|
|
|
|
//botonesLayout.setAlignItems(Alignment.CENTER); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// METODO PARA ENVIAR CORREOS ELECTRONICOS |
|
|
|
|
|
private void enviarCorreo() { |
|
|
|
|
|
Usuario usuarioSeleccionado = usuario.getValue(); |
|
|
|
|
|
if (usuarioSeleccionado != null && usuarioSeleccionado.getEmail() != null) { |
|
|
|
|
|
String destinatario = usuarioSeleccionado.getEmail(); |
|
|
|
|
|
String asunto = "MANTENIMIENTO DE EQUIPO DE COMPUTO REALIZADO"; |
|
|
|
|
|
|
|
|
|
|
|
String cuerpo = "<html>" + |
|
|
|
|
|
"<body>" + |
|
|
|
|
|
"<img src='cid:image_id'/>" + |
|
|
|
|
|
"</body>" + |
|
|
|
|
|
"</html>"; |
|
|
|
|
|
|
|
|
|
|
|
String imagePath = "META-INF/resources/images/imgCorreo/correoMantt.png"; |
|
|
|
|
|
|
|
|
|
|
|
emailService.enviarCorreo(destinatario, asunto, cuerpo, imagePath); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
Notification.show("Por favor selecciona un usuario", 4000, Notification.Position.MIDDLE); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void guardarMantenimiento() { |
|
|
|
|
|
|
|
|
|
|
|
TiposMantenimiento tiposMantenimiento = tipoMantt.getValue(); |
|
|
|
|
|
String tipoMantId = tiposMantenimiento != null ? tiposMantenimiento.getTipomantId() : null; |
|
|
|
|
|
String justificacionValue = jsutificacion != null ? jsutificacion.getValue() : null; |
|
|
|
|
|
String reparacionValue = txtReparacion != null ? txtReparacion.getValue() : null; |
|
|
|
|
|
|
|
|
|
|
|
DepartamentosModel departamentoSeleccionado = area.getValue(); |
|
|
|
|
|
String departamentoId = departamentoSeleccionado != null ? departamentoSeleccionado.getDepartamentoId().toString() : null; |
|
|
|
|
|
|
|
|
|
|
|
Usuario usuarioSeleccionado = usuario.getValue(); |
|
|
|
|
|
String empleadoId = usuarioSeleccionado != null ? usuarioSeleccionado.getEmpleadoId().toString() : null; |
|
|
|
|
|
String equipoId = txtNombreEquipo.getValue(); |
|
|
|
|
|
|
|
|
|
|
|
String formaSeleccionada = formaGroup.getValue(); |
|
|
|
|
|
String formaMantt = null; |
|
|
|
|
|
if ("Remota".equals(formaSeleccionada)) { |
|
|
|
|
|
formaMantt = "R"; |
|
|
|
|
|
} else if ("Manual".equals(formaSeleccionada)) { |
|
|
|
|
|
formaMantt = "M"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Validación de campos obligatorios |
|
|
|
|
|
if (fechaSeleccionada == null || tipoMantId == null || departamentoId == null || empleadoId == null || |
|
|
|
|
|
equipoId == null || equipoId.trim().isEmpty() || formaMantt == null) { |
|
|
|
|
|
Notification.show("Por favor, completa todos los campos requeridos", 4000, Notification.Position.MIDDLE); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
byte[] userSignatureBytes = userSignPad.getImageBase64(); |
|
|
|
|
|
byte[] smtSignatureBytes = smtSignPad.getImageBase64(); |
|
|
|
|
|
//byte[] gciaSignatureBytes = gciatiSignPad.getImageBase64(); |
|
|
|
|
|
|
|
|
|
|
|
String userSignatureBase64 = Base64.getEncoder().encodeToString(userSignatureBytes); |
|
|
|
|
|
String smtSignatureBase64 = Base64.getEncoder().encodeToString(smtSignatureBytes); |
|
|
|
|
|
//String gciaSignatureBase64 = Base64.getEncoder().encodeToString(gciaSignatureBytes); |
|
|
|
|
|
|
|
|
|
|
|
if (esFirmaVacia(userSignatureBase64)) userSignatureBase64 = null; |
|
|
|
|
|
if (esFirmaVacia(smtSignatureBase64)) smtSignatureBase64 = null; |
|
|
|
|
|
//if (esFirmaVacia(gciaSignatureBase64)) gciaSignatureBase64 = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validación de campos de hardware |
|
|
|
|
|
List<Map<String, String>> detallesHardware = new ArrayList<>(); |
|
|
|
|
|
for (HorizontalLayout layout : hardwareLayouts) { |
|
|
|
|
|
ComboBox<TiposHardware> tipoHardware = (ComboBox<TiposHardware>) layout.getComponentAt(0); |
|
|
|
|
|
TextField noSerie = (TextField) layout.getComponentAt(1); |
|
|
|
|
|
TextField modelo = (TextField) layout.getComponentAt(2); |
|
|
|
|
|
TextField placa = (TextField) layout.getComponentAt(3); |
|
|
|
|
|
|
|
|
|
|
|
TiposHardware tipoSeleccionado = tipoHardware.getValue(); |
|
|
|
|
|
if (tipoSeleccionado == null) { |
|
|
|
|
|
Notification.show("Por favor, selecciona un tipo de hardware", 4000, Notification.Position.MIDDLE) |
|
|
|
|
|
.addThemeVariants(NotificationVariant.LUMO_WARNING); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
boolean esOpcional = Arrays.asList("TECLADO", "MOUSE").contains(tipoSeleccionado.getNombreHardware()); |
|
|
|
|
|
|
|
|
|
|
|
String numSerie = noSerie.getValue(); |
|
|
|
|
|
String modeloVal = modelo.getValue(); |
|
|
|
|
|
String placaVal = placa.getValue(); |
|
|
|
|
|
|
|
|
|
|
|
if (!esOpcional && (modeloVal == null || modeloVal.isEmpty() || numSerie == null || numSerie.isEmpty() || placaVal == null || placaVal.isEmpty())) { |
|
|
|
|
|
Notification.show("Por favor, completa todos los campos de hardware.", 4000, Notification.Position.MIDDLE) |
|
|
|
|
|
.addThemeVariants(NotificationVariant.LUMO_WARNING); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> hw = new HashMap<>(); |
|
|
|
|
|
hw.put("tipoHardwareId", tipoSeleccionado.getTipoHardwareId()); |
|
|
|
|
|
hw.put("numSerie", numSerie); |
|
|
|
|
|
hw.put("modelo", modeloVal); |
|
|
|
|
|
hw.put("placa", placaVal); |
|
|
|
|
|
detallesHardware.add(hw); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set<String> actualizacionesSeleccionadas = actualizaciones.getSelectedItems(); |
|
|
|
|
|
String otrasActualizaciones = null; |
|
|
|
|
|
if ("Si".equals(masActualizacionesGroup.getValue())) { |
|
|
|
|
|
otrasActualizaciones = txtCuales.getValue(); |
|
|
|
|
|
if (otrasActualizaciones == null || otrasActualizaciones.trim().isEmpty()) { |
|
|
|
|
|
Notification.show("Especifica las otras actualizaciones", 4000, Notification.Position.MIDDLE) |
|
|
|
|
|
.addThemeVariants(NotificationVariant.LUMO_WARNING); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Una vez que validamos todos los campos del formulario, procedemos a insertar en BD |
|
|
|
|
|
try { |
|
|
|
|
|
int isInserted = databaseService.insertarMantenimiento(fechaSeleccionada, tipoMantId, departamentoId, empleadoId, formaMantt, equipoId, userSignatureBase64, smtSignatureBase64, null, justificacionValue, reparacionValue); |
|
|
|
|
|
|
|
|
|
|
|
if (isInserted <= 0) { |
|
|
|
|
|
Notification.show("Error al guardar el mantenimiento", 4000, Notification.Position.MIDDLE) |
|
|
|
|
|
.addThemeVariants(NotificationVariant.LUMO_ERROR); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int mantenimientoId = databaseService.getUltimoMantenimientoId(); |
|
|
|
|
|
|
|
|
|
|
|
for (Map<String, String> hw : detallesHardware) { |
|
|
|
|
|
boolean ok = databaseService.insertarHardware( |
|
|
|
|
|
hw.get("tipoHardwareId"), |
|
|
|
|
|
hw.get("numSerie"), |
|
|
|
|
|
hw.get("modelo"), |
|
|
|
|
|
hw.get("placa"), |
|
|
|
|
|
mantenimientoId |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (!ok) { |
|
|
|
|
|
Notification.show("Error al insertar detalles del hardware: ", 4000, Notification.Position.MIDDLE) |
|
|
|
|
|
.addThemeVariants(NotificationVariant.LUMO_ERROR); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (String act : actualizacionesSeleccionadas) { |
|
|
|
|
|
boolean ok = databaseService.insertActualizacionSeg(act, null, mantenimientoId); |
|
|
|
|
|
if (!ok) { |
|
|
|
|
|
Notification.show("Error al insertar actualización de seguridad", 4000, Notification.Position.MIDDLE) |
|
|
|
|
|
.addThemeVariants(NotificationVariant.LUMO_ERROR); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (otrasActualizaciones != null) { |
|
|
|
|
|
boolean ok = databaseService.insertActualizacionSeg("Otras", otrasActualizaciones, mantenimientoId); |
|
|
|
|
|
if (!ok) { |
|
|
|
|
|
Notification.show("Error al insertar otras actualizaciones", 4000, Notification.Position.MIDDLE) |
|
|
|
|
|
.addThemeVariants(NotificationVariant.LUMO_ERROR); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// === EXITO === |
|
|
|
|
|
Notification.show("¡Mantenimiento guardado exitosamente!", 4000, Notification.Position.MIDDLE) |
|
|
|
|
|
.addThemeVariants(NotificationVariant.LUMO_SUCCESS); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
enviarCorreo(); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
Notification.show("Error al enviar el correo", 4000, Notification.Position.MIDDLE) |
|
|
|
|
|
.addThemeVariants(NotificationVariant.LUMO_ERROR); |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Limpiar campos |
|
|
|
|
|
fecha.clear(); |
|
|
|
|
|
tipoMantt.clear(); |
|
|
|
|
|
area.clear(); |
|
|
|
|
|
usuario.clear(); |
|
|
|
|
|
txtNombreEquipo.clear(); |
|
|
|
|
|
formaGroup.clear(); |
|
|
|
|
|
actualizaciones.clear(); |
|
|
|
|
|
masActualizacionesGroup.clear(); |
|
|
|
|
|
txtCuales.clear(); |
|
|
|
|
|
userSignPad.clear(); |
|
|
|
|
|
smtSignPad.clear(); |
|
|
|
|
|
//gciatiSignPad.clear(); |
|
|
|
|
|
txtReparacion.clear(); |
|
|
|
|
|
|
|
|
|
|
|
for (HorizontalLayout layout : hardwareLayouts) { |
|
|
|
|
|
((ComboBox<?>) layout.getComponentAt(0)).clear(); |
|
|
|
|
|
((TextField) layout.getComponentAt(1)).clear(); |
|
|
|
|
|
((TextField) layout.getComponentAt(2)).clear(); |
|
|
|
|
|
((TextField) layout.getComponentAt(3)).clear(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UI.getCurrent().navigate("/"); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
Notification.show("Ocurrio un error inesperado: " + ex.getMessage(), 5000, Notification.Position.MIDDLE) |
|
|
|
|
|
.addThemeVariants(NotificationVariant.LUMO_ERROR); |
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Muestra un dialogo con el listado de los mantenimientos correctivos realizados |
|
|
|
|
|
private void verListadoMantenimientos() { |
|
|
|
|
|
Dialog dialog = new Dialog(); |
|
|
|
|
|
dialog.setSizeFull(); |
|
|
|
|
|
dialog.setCloseOnEsc(true); |
|
|
|
|
|
dialog.setCloseOnOutsideClick(true); |
|
|
|
|
|
dialog.setHeaderTitle("Listado de Mantenimientos Correctivos"); |
|
|
|
|
|
|
|
|
|
|
|
Grid<MantCorrectivosModel> grid = new Grid<>(MantCorrectivosModel.class, false); |
|
|
|
|
|
grid.addColumn(MantCorrectivosModel::getMantenimientoId) |
|
|
|
|
|
.setHeader("No.").setAutoWidth(true); |
|
|
|
|
|
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); |
|
|
|
|
|
grid.addColumn(item -> item.getFecha() != null ? item.getFecha().format(formatter) : "N/A") |
|
|
|
|
|
.setHeader("Fecha:").setAutoWidth(true); |
|
|
|
|
|
|
|
|
|
|
|
grid.addColumn(MantCorrectivosModel::getTipo) |
|
|
|
|
|
.setHeader("Tipo:").setAutoWidth(true); |
|
|
|
|
|
|
|
|
|
|
|
grid.addColumn(MantCorrectivosModel::getArea) |
|
|
|
|
|
.setHeader("Área:").setAutoWidth(true); |
|
|
|
|
|
|
|
|
|
|
|
grid.addColumn(MantCorrectivosModel::getNombre) |
|
|
|
|
|
.setHeader("Usuario:").setAutoWidth(true); |
|
|
|
|
|
|
|
|
|
|
|
grid.addColumn(MantCorrectivosModel::getForma) |
|
|
|
|
|
.setHeader("Forma:").setAutoWidth(true); |
|
|
|
|
|
|
|
|
|
|
|
grid.addColumn(MantCorrectivosModel::getNomequipo) |
|
|
|
|
|
.setHeader("Equipo:").setAutoWidth(true); |
|
|
|
|
|
|
|
|
|
|
|
grid.setItems(databaseService.getMantenimientosCorrectivos(2)); |
|
|
|
|
|
grid.setItemDetailsRenderer(ReparacionDetails.createReparacionesDetails()); |
|
|
|
|
|
grid.addThemeVariants(GridVariant.LUMO_ROW_STRIPES); |
|
|
|
|
|
|
|
|
|
|
|
Button closeButton = new Button("Cerrar", e -> dialog.close()); |
|
|
|
|
|
closeButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY); |
|
|
|
|
|
|
|
|
|
|
|
dialog.add(grid, closeButton); |
|
|
|
|
|
dialog.open(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class ReparacionDetails extends FormLayout { |
|
|
|
|
|
private final TextArea txtReparacion = new TextArea("Reparación realizada:"); |
|
|
|
|
|
|
|
|
|
|
|
public ReparacionDetails() { |
|
|
|
|
|
txtReparacion.setReadOnly(true); |
|
|
|
|
|
add(txtReparacion); |
|
|
|
|
|
setResponsiveSteps(new ResponsiveStep("0", 1)); |
|
|
|
|
|
setColspan(txtReparacion, 1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setModel(MantCorrectivosModel model) { |
|
|
|
|
|
txtReparacion.setValue(model.getReparacion() != null ? model.getReparacion() : ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static ComponentRenderer<ReparacionDetails, MantCorrectivosModel> createReparacionesDetails() { |
|
|
|
|
|
return new ComponentRenderer<>(ReparacionDetails::new, ReparacionDetails::setModel); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |