Browse Source

Ya se guardan los datos del formulario cuando es pago especial, solo faltaria la que tambien se guarde

main
mramirezg 8 months ago
parent
commit
2b5d11f6b6
4 changed files with 169 additions and 46 deletions
  1. +28
    -0
      src/main/java/mx/gob/jumapacelaya/Services/GuardarSolicitudService.java
  2. +38
    -39
      src/main/java/mx/gob/jumapacelaya/views/SolicitudDescView.java
  3. +56
    -5
      src/main/java/mx/gob/jumapacelaya/views/tiposSolicitud/DescEspView.java
  4. +47
    -2
      src/main/java/mx/gob/jumapacelaya/views/tiposSolicitud/RecargosView.java

+ 28
- 0
src/main/java/mx/gob/jumapacelaya/Services/GuardarSolicitudService.java View File

@ -0,0 +1,28 @@
package mx.gob.jumapacelaya.Services;
import mx.gob.jumapacelaya.models.Usuario;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
@Service
public class GuardarSolicitudService {
private final JdbcTemplate jdbcTemplate;
public GuardarSolicitudService(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
public void guardarSolicitud(int predioId, String tipoSolicitud, String solicitante, String parentesco,
String tipoIdentificacion, String numIdentificacion, String usuarioId) {
String query = "INSERT INTO soldigitales (PREDIOID, TIPO, FECHORA, FECHA, SOLICITANTE, PARENTESCO, TIPOIDEN, NUMIDEN, USUARIOID) " +
"VALUES (?, ?, SYSDATE, ?, ?, ?, SUBSTR(?, 0, 4), ?, ?)";
jdbcTemplate.update(query, predioId, tipoSolicitud, LocalDate.now(), solicitante, parentesco, tipoIdentificacion, numIdentificacion, usuarioId);
}
}

+ 38
- 39
src/main/java/mx/gob/jumapacelaya/views/SolicitudDescView.java View File

@ -16,6 +16,7 @@ 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 mx.gob.jumapacelaya.Services.GuardarSolicitudService;
import mx.gob.jumapacelaya.Services.PredioService;
import mx.gob.jumapacelaya.models.Predio;
import mx.gob.jumapacelaya.views.tiposSolicitud.InfraccionesView;
@ -33,12 +34,15 @@ import java.util.List;
public class SolicitudDescView extends VerticalLayout implements BeforeEnterObserver {
private H3 label;
private String usuarioId;
private final PredioService predioService;
private final GuardarSolicitudService guardarSolicitudService;
@Autowired
public SolicitudDescView(PredioService predioService) {
public SolicitudDescView(PredioService predioService, GuardarSolicitudService guardarSolicitudService) {
this.setSizeFull();
this.predioService = predioService;
this.guardarSolicitudService = guardarSolicitudService;
cabezera();
titulo();
@ -139,48 +143,43 @@ public class SolicitudDescView extends VerticalLayout implements BeforeEnterObse
Predio resultado = predios.get(0);
UI.getCurrent().getSession().setAttribute("predio", resultado);
UI.getCurrent().getSession().setAttribute("tipoSolicitud", tipoSolicitud);
UI.getCurrent().getSession().setAttribute("nombreSolicitante", nombreSolicitante);
UI.getCurrent().getSession().setAttribute("txtParentesco", txtParentesco.getValue());
UI.getCurrent().getSession().setAttribute("cmbTipoIdentificacion", cmbTipoIdentificacion.getValue());
UI.getCurrent().getSession().setAttribute("numIdentificacion", numIdentificacion.getValue());
UI.getCurrent().getSession().setAttribute("usuarioId", usuarioId);
System.out.println(resultado.getPredioid());
System.out.println(resultado.getNomcliente());
System.out.println(resultado.getDireccorta());
System.out.println(resultado.getTelefono());
System.out.println(resultado.getUso());
System.out.println(resultado.getActividad());
System.out.println(resultado.getContrato());
} else {
Notification.show("No se encontro informacion del predio", 3000, Notification.Position.MIDDLE);
}
} else {
Notification.show("Ingresa un numero de predio", 3000, Notification.Position.MIDDLE);
}
if (tipoSolicitud != null && nombreSolicitante != null) {
String url = "";
// Luego de guardar la solicitud, redirigir a la página correspondiente
String url = "";
switch (tipoSolicitud) {
case "Recargos":
url = "recargos?solicitante=" + nombreSolicitante;
break;
switch (tipoSolicitud) {
case "Recargos":
url = "recargos?solicitante=" + nombreSolicitante;
break;
case "Infracciones":
url = "infracciones?solicitante=" + nombreSolicitante;
url = "infracciones?solicitante=" + nombreSolicitante;
break;
case "Ajuste de Facturas":
url = "ajustefacturas?solicitante=" + nombreSolicitante;
break;
case "Descuento Especial Pago Anual":
url = "descesp?solicitante=" + nombreSolicitante;
break;
default:
Notification.show("Selecciona un tipo de solicitud", 3000, Notification.Position.MIDDLE);
}
if (!url.isEmpty()) {
UI.getCurrent().navigate(url);
case "Ajuste de Facturas":
url = "ajustefacturas?solicitante=" + nombreSolicitante;
break;
case "Descuento Especial Pago Anual":
url = "descesp?solicitante=" + nombreSolicitante;
break;
default:
Notification.show("Selecciona un tipo de solicitud", 3000, Notification.Position.MIDDLE);
return; // No continuar si no se seleccionó un tipo válido
}
if (!url.isEmpty()) {
UI.getCurrent().navigate(url);
}
} else {
Notification.show("No se encontró información del predio", 3000, Notification.Position.MIDDLE);
}
} else {
Notification.show("Selecciona una opcion", 3000, Notification.Position.MIDDLE);
Notification.show("Ingresa un número de predio", 3000, Notification.Position.MIDDLE);
}
});
@ -196,13 +195,13 @@ public class SolicitudDescView extends VerticalLayout implements BeforeEnterObse
@Override
public void beforeEnter(BeforeEnterEvent event) {
String usuario = event.getLocation().getQueryParameters().getParameters().get("usuarioid") != null
usuarioId = event.getLocation().getQueryParameters().getParameters().get("usuarioid") != null
? event.getLocation().getQueryParameters().getParameters().get("usuarioid").stream().findFirst().orElse(null)
: null;
if (usuario != null) {
label.setText("Solicitud de Descuento en adeudo [" + usuario + "]");
if (usuarioId != null) {
label.setText("Solicitud de Descuento en adeudo [" + usuarioId + "]");
} else {
label.setText("Usuario Desconocido");
UI.getCurrent().navigate("/");


+ 56
- 5
src/main/java/mx/gob/jumapacelaya/views/tiposSolicitud/DescEspView.java View File

@ -1,6 +1,7 @@
package mx.gob.jumapacelaya.views.tiposSolicitud;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.*;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
@ -10,6 +11,7 @@ import com.vaadin.flow.router.BeforeEnterObserver;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import de.f0rce.signaturepad.SignaturePad;
import mx.gob.jumapacelaya.Services.GuardarSolicitudService;
import mx.gob.jumapacelaya.Services.PredioService;
import mx.gob.jumapacelaya.models.Predio;
import mx.gob.jumapacelaya.views.MainLayout;
@ -22,23 +24,72 @@ import java.time.format.DateTimeFormatter;
public class DescEspView extends VerticalLayout implements BeforeEnterObserver {
private final PredioService predioService;
private final GuardarSolicitudService guardarSolicitudService;
private Predio predio;
Span nombreCliente = new Span();
public DescEspView(PredioService predioService) {
public DescEspView(PredioService predioService, GuardarSolicitudService guardarSolicitudService) {
this.guardarSolicitudService = guardarSolicitudService;
this.predioService = predioService;
this.predio = (Predio) UI.getCurrent().getSession().getAttribute("predio");
if (predio == null) {
Notification.show("No se encontró el predio en la sesion. Por favor ingresa un numero de predio primero.", 3000, Notification.Position.MIDDLE);
// Recuperar los datos de la sesión
this.predio = (Predio) UI.getCurrent().getSession().getAttribute("predio");
String tipoSolicitud = (String) UI.getCurrent().getSession().getAttribute("tipoSolicitud");
String nombreSolicitante = (String) UI.getCurrent().getSession().getAttribute("nombreSolicitante");
String parentesco = (String) UI.getCurrent().getSession().getAttribute("txtParentesco");
String tipoIdentificacion = (String) UI.getCurrent().getSession().getAttribute("cmbTipoIdentificacion");
String numIdentificacion = (String) UI.getCurrent().getSession().getAttribute("numIdentificacion");
String usuarioId = (String) UI.getCurrent().getSession().getAttribute("usuarioId");
// Verificar que los datos estén disponibles
if (predio == null || tipoSolicitud == null || nombreSolicitante == null) {
Notification.show("Faltan datos importantes. Por favor ingresa la solicitud nuevamente.", 3000, Notification.Position.MIDDLE);
UI.getCurrent().navigate("solidesc");
} else {
cabezera();
titulo();
body();
sign();
}
// Guardar la solicitud cuando el usuario firme
Button btnGuardarSolicitud = new Button("Guardar Solicitud");
btnGuardarSolicitud.addClickListener(event -> {
String abreviatura = "";
switch (tipoSolicitud) {
case "Recargos":
abreviatura = "REC";
break;
case "Infracciones":
abreviatura = "INF";
break;
case "Ajuste de Facturas":
abreviatura = "AJU";
break;
case "Descuento Especial Pago Anual":
abreviatura = "DCA";
break;
default:
abreviatura = "R";
}
guardarSolicitudService.guardarSolicitud(
predio.getPredioid(),
abreviatura, // Abreviatura para Descuento Especial Pago Anual
nombreSolicitante,
parentesco,
tipoIdentificacion,
numIdentificacion,
usuarioId
);
Notification.show("Solicitud guardada con éxito.", 3000, Notification.Position.MIDDLE);
});
this.add(btnGuardarSolicitud);
}
private void cabezera() {


+ 47
- 2
src/main/java/mx/gob/jumapacelaya/views/tiposSolicitud/RecargosView.java View File

@ -1,8 +1,11 @@
package mx.gob.jumapacelaya.views.tiposSolicitud;
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.html.*;
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.router.BeforeEnterEvent;
@ -10,6 +13,7 @@ import com.vaadin.flow.router.BeforeEnterObserver;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import de.f0rce.signaturepad.SignaturePad;
import mx.gob.jumapacelaya.Services.GuardarSolicitudService;
import mx.gob.jumapacelaya.Services.PredioService;
import mx.gob.jumapacelaya.models.Predio;
import mx.gob.jumapacelaya.views.MainLayout;
@ -23,17 +27,19 @@ import java.time.format.DateTimeFormatter;
public class RecargosView extends VerticalLayout implements BeforeEnterObserver {
private final PredioService predioService;
private final GuardarSolicitudService guardarSolicitudService;
private Predio predio;
Span nombreCliente = new Span();
@Autowired
public RecargosView(PredioService predioService) {
public RecargosView(PredioService predioService, GuardarSolicitudService guardarSolicitudService) {
this.predioService = predioService;
this.guardarSolicitudService = guardarSolicitudService;
this.predio = (Predio) UI.getCurrent().getSession().getAttribute("predio");
if (predio == null) {
Notification.show("No se encontró el predio en la sesion. Por favor ingresa un numero de predio primero.", 3000, Notification.Position.MIDDLE);
Notification.show("No se encontró el predio en la sesion. Por favor ingresa un numero de predio primero. Redirigiendo a la vista anterior, espere...", 5000, Notification.Position.MIDDLE);
UI.getCurrent().navigate("solidesc");
} else {
@ -41,6 +47,7 @@ public class RecargosView extends VerticalLayout implements BeforeEnterObserver
titulo();
body();
sign();
boton();
}
}
@ -126,6 +133,44 @@ public class RecargosView extends VerticalLayout implements BeforeEnterObserver
this.add(signLayout);
}
private void boton() {
VerticalLayout botonLayout = new VerticalLayout();
Button boton = new Button("Guardar");
boton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
boton.setSizeFull();
boton.addClickListener(event -> {
String usuarioId = (String) UI.getCurrent().getSession().getAttribute("usuario");
if (usuarioId == null || usuarioId.trim().isEmpty()) {
Notification.show("Usuario no encontrado en la sesión.", 3000, Notification.Position.MIDDLE);
return;
}
String solicitante = nombreCliente.getText().replace("Nombre del Solicitante: ", "").trim();
if (predio != null && !solicitante.isEmpty()) {
try {
guardarSolicitudService.guardarSolicitud(
predio.getPredioid(), "Recargos", solicitante, "", "", "", usuarioId);
Notification.show("Solicitud guardada exitosamente", 3000, Notification.Position.MIDDLE);
UI.getCurrent().navigate("solidesc");
} catch (Exception e) {
e.printStackTrace();
Notification.show("Error al guardar la solicitud: " + e.getMessage(), 5000, Notification.Position.MIDDLE);
}
} else {
Notification.show("Faltan datos obligatorios.", 3000, Notification.Position.MIDDLE);
}
});
botonLayout.add(boton);
this.add(botonLayout);
}
@Override
public void beforeEnter(BeforeEnterEvent event) {
String solicitante = event.getLocation().getQueryParameters().getParameters().get("solicitante") != null


Loading…
Cancel
Save