Commit 032f2942 by Denys Tito Urbano

[FIXED] Parametro fecha_hora_registro del endpoint ejecutar

parent 8fe58636
......@@ -74,23 +74,16 @@ public class ExcelApi {
@POST
@Path("/ejecutar")
public Response ejecutar(String json) throws Exception {
String[] jsonString = {"p_drive_origen", "p_drive_fila", "p_sede", "p_fecha_hora_registro", "p_medio_atencion",
"p_contacto_nombres", "p_contacto_apellidos", "p_numero_documento", "p_contacto_correo",
"p_contacto_telefono", "p_distrito", "p_grado", "p_colegio_procedencia","p_medio_difusion_nombre",
"p_atencion_usuario", "p_atencion_fecha", "p_atencion_estado", "p_atencion_medio_atencion", "p_atencion_hora", "p_atencion_observacion"};
String[] jsonString = {"p_drive_origen", "p_drive_fila", "p_sede", "p_fecha_hora_registro", "p_medio_atencion", "p_contacto_nombres", "p_contacto_apellidos", "p_numero_documento", "p_contacto_correo", "p_contacto_telefono", "p_distrito", "p_grado", "p_colegio_procedencia","p_medio_difusion_nombre", "p_atencion_usuario", "p_atencion_fecha", "p_atencion_estado", "p_atencion_medio_atencion", "p_atencion_hora", "p_atencion_observacion"};
JSONObject entrada = new JSONObject(json);
JSONObject formato = Commons.formatoJSON(jsonString);
if(Commons.validarFormato(jsonString,json)){
if (Commons.validarFormato(jsonString,json)) {
ExcelServices excelServices = new ExcelServices();
MSJ_RESPUESTA = excelServices.ejecutar(entrada);
return Response.status(200).entity(MSJ_RESPUESTA.toString()).build();
}else{
} else {
return Response.status(500).entity(
MSJ_RESPUESTA.put("status", false)
.put("mensaje", "Error en el formato de entrada")
......@@ -138,15 +131,29 @@ public class ExcelApi {
@POST
@Path("/ejecutar_reporte_sedes")
public Response ejecutar_reporte_sedes(String json) throws Exception {
JSONObject salida = new JSONObject();
JSONObject entrada = new JSONObject(json);
ExcelServices excelServices = new ExcelServices();
MSJ_RESPUESTA = excelServices.execute_reporte_sedes(entrada);
try {
JSONObject entrada = new JSONObject(json);
return Response.status(200).entity(MSJ_RESPUESTA.toString()).build();
salida = new ExcelServices().execute_reporte_sedes(entrada);
return Response.status(200).entity(salida.toString()).build();
} catch (JSONException ex) {
salida.put("status", false);
salida.put("message", ex.getMessage());
throw new WebApplicationException(Response.status(400).entity(salida.toString()).build());
} catch (BadRequestException ex) {
salida = new JSONObject(ex.getMessage());
throw new WebApplicationException(Response.status(500).entity(salida.toString()).build());
} catch (Exception ex) {
salida.put("status", false);
salida.put("message", ex.getMessage());
throw new WebApplicationException(Response.status(500).entity(salida.toString()).build());
}
}
@POST
@Path("/ejecutar_reporte_correos")
public Response ejecutar_reporte_correos(String json) throws Exception {
......
......@@ -16,7 +16,7 @@ public interface ExcelDAO{
JSONObject execute_VU (JSONObject json) throws Exception;
JSONObject execute_reporte_sedes (JSONObject json) throws Exception;
JSONObject execute_reporte_sedes (JSONObject entrada) throws Exception;
JSONObject execute_reporte_correos (JSONObject json) throws Exception;
......
......@@ -111,12 +111,9 @@ public class PostgreSqlExcel implements ExcelDAO {
Connection conexion = null;
try {
Date date = new Date();
java.sql.Timestamp sqlTime = new java.sql.Timestamp(date.getTime());
String p_drive_origen = json.getString("p_drive_origen");
int p_drive_fila = json.getInt("p_drive_fila");
String p_fecha_hora_registro = json.getString("p_fecha_hora_registro");
String p_sede = json.getString("p_sede");
String p_medio_atencion = json.getString("p_medio_atencion");
String p_contacto_nombres = json.getString("p_contacto_nombres");
......@@ -134,14 +131,15 @@ public class PostgreSqlExcel implements ExcelDAO {
String p_atencion_hora = json.getString("p_atencion_hora");
String p_atencion_observacion = json.getString("p_atencion_observacion");
String p_medio_difusion_nombre = json.getString("p_medio_difusion_nombre");
String p_elija_fecha = json.getString("p_elija_fecha");
conexion = PostgreSqlFactoryDAO.obtenerConexion("siiaa");
String sql = "select matricula.func_informe_registrar(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String sql = "select matricula.func_informe_registrar(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement ps = conexion.prepareStatement(sql);
ps.setString(1, p_drive_origen);
ps.setInt(2, p_drive_fila);
ps.setString(3, sqlTime.toString());
ps.setString(3, p_fecha_hora_registro);
ps.setString(4, p_sede);
ps.setString(5, p_medio_atencion);
ps.setString(6, p_contacto_nombres);
......@@ -159,6 +157,7 @@ public class PostgreSqlExcel implements ExcelDAO {
ps.setString(18, p_atencion_medio_atencion);
ps.setString(19, p_atencion_hora);
ps.setString(20, p_atencion_observacion);
ps.setString(21, p_elija_fecha);
ResultSet rs = ps.executeQuery();
......@@ -303,32 +302,10 @@ public class PostgreSqlExcel implements ExcelDAO {
}
@Override
public JSONObject execute_reporte_sedes(JSONObject json) throws Exception {
JSONObject respuesta = new JSONObject();
Connection conexion = null;
conexion = PostgreSqlFactoryDAO.obtenerConexion("siiaa");
try {
String sql = "select * from matricula.func_reporte_general_matricula()";
ResultSet rs = conexion.prepareStatement(sql).executeQuery();
if (rs.next()) {
int columnCount = rs.getMetaData().getColumnCount();
for (int i = 1; i <= columnCount; i++) {
respuesta.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
}
}
} catch (Exception e) {
respuesta.put("error", e.getMessage());
} finally {
if (conexion != null) {
conexion.close();
}
}
return respuesta;
public JSONObject execute_reporte_sedes(JSONObject entrada) throws Exception {
String sql = "SELECT * FROM matricula.func_reporte_general_matricula ( ? );";
JSONObject salida = PostgreSqlFactoryDAO.queryPSSingle("siiaa", sql, entrada.getJSONArray("params"));
return new JSONObject(salida.getString("json"));
}
@Override
......
......@@ -36,9 +36,15 @@ public class ExcelServices {
public JSONObject execute_VU(JSONObject json) throws Exception {
return dao.execute_VU(json);
}
public JSONObject execute_reporte_sedes(JSONObject entrada) throws Exception {
JSONArray params = new JSONArray();
params.put(0, entrada.getString("tipo_operacion"));
entrada.put("params", params);
public JSONObject execute_reporte_sedes(JSONObject json) throws Exception {
return dao.execute_reporte_sedes(json);
return dao.execute_reporte_sedes(entrada);
}
public JSONObject execute_reporte_correos(JSONObject json) throws Exception {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment