[ADD] SE AGREGO NUEVO ENDPOINT PARA AVANCES DE ENCUESTAS

parent 2200f7ef
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</component> </component>
<component name="JavacSettings"> <component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE"> <option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="formulario-api" options="-endorseddirs D:\formulario-api\target/endorsed" /> <module name="formulario-api" options="-endorseddirs $PROJECT_DIR$/target/endorsed" />
</option> </option>
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</inspection_tool> </inspection_tool>
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true"> <inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages> <Languages>
<language minSize="48" name="Java" /> <language minSize="50" name="Java" />
</Languages> </Languages>
</inspection_tool> </inspection_tool>
<inspection_tool class="SpellCheckingInspection" enabled="false" level="WARNING" enabled_by_default="false" editorAttributes="WARNING_ATTRIBUTES"> <inspection_tool class="SpellCheckingInspection" enabled="false" level="WARNING" enabled_by_default="false" editorAttributes="WARNING_ATTRIBUTES">
...@@ -19,5 +19,6 @@ ...@@ -19,5 +19,6 @@
<option name="processLiterals" value="true" /> <option name="processLiterals" value="true" />
<option name="processComments" value="true" /> <option name="processComments" value="true" />
</inspection_tool> </inspection_tool>
<inspection_tool class="VulnerableCodeUsages" enabled="false" level="WARNING" enabled_by_default="false" />
</profile> </profile>
</component> </component>
\ No newline at end of file
...@@ -154,4 +154,15 @@ public class ExcelApi { ...@@ -154,4 +154,15 @@ public class ExcelApi {
} }
@POST
@Path("/ejecutar_avance_encuestas")
public Response ejecutar_avance_encuestas(String json) throws Exception {
JSONObject entrada = new JSONObject(json);
ExcelServices excelServices = new ExcelServices();
MSJ_RESPUESTA = excelServices.execute_avance_encuesta(entrada);
return Response.status(200).entity(MSJ_RESPUESTA.toString()).build();
}
} }
...@@ -20,4 +20,6 @@ public interface ExcelDAO{ ...@@ -20,4 +20,6 @@ public interface ExcelDAO{
JSONObject execute_reporte_correos (JSONObject json) throws Exception; JSONObject execute_reporte_correos (JSONObject json) throws Exception;
JSONObject execute_avance_encuesta (JSONObject json) throws Exception;
} }
...@@ -360,4 +360,53 @@ public class PostgreSqlExcel implements ExcelDAO{ ...@@ -360,4 +360,53 @@ public class PostgreSqlExcel implements ExcelDAO{
return respuesta; return respuesta;
} }
@Override
public JSONObject execute_avance_encuesta(JSONObject json) throws Exception{
JSONObject respuesta=new JSONObject();
Connection conexion=null;
try {
int p_opt=json.getInt("p_opt");
conexion=PostgreSqlFactoryDAO.obtenerConexion("siiaa");
String sql="select academico.func_encuesta_total(?)";
PreparedStatement ps=conexion.prepareStatement(sql);
Statement st=conexion.createStatement();
ps.setInt(1,p_opt);
ResultSet rs=ps.executeQuery();
if(rs.next()){
int columnCount=rs.getMetaData().getColumnCount();
for (int i=1; i <= columnCount; i++) {
respuesta.put(rs.getMetaData().getColumnName(i),new JSONObject(rs.getObject(i).toString()));
}
}
JSONArray data=respuesta.getJSONObject("func_encuesta_total").getJSONArray("data");
JSONArray respuesta2=new JSONArray();
data.forEach(item -> {
JSONObject obj=(JSONObject)item;
String sql2=obj.getString("script");
try {
st.executeQuery(sql2);
} catch (SQLException ignored) {
}
});
respuesta.put("salida",respuesta2);
} catch (Exception e) {
respuesta.put("error",e.getMessage());
} finally {
if(conexion != null){
conexion.close();
}
}
return respuesta;
}
} }
...@@ -38,4 +38,8 @@ public class ExcelServices{ ...@@ -38,4 +38,8 @@ public class ExcelServices{
public JSONObject execute_reporte_correos(JSONObject json) throws Exception{ public JSONObject execute_reporte_correos(JSONObject json) throws Exception{
return dao.execute_reporte_correos(json); return dao.execute_reporte_correos(json);
} }
public JSONObject execute_avance_encuesta(JSONObject json) throws Exception{
return dao.execute_avance_encuesta(json);
}
} }
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