Commit 009265f5 by Felipe Escala Torres

Reporte asistencias

parent 5ee3fc83
......@@ -45,8 +45,8 @@ public class MySqlDAOFactory extends DAOFactory {
try {
conexion = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/academianew",
"root",
"Saco1357$");
"hostPrueba",
"123456");
// "jdbc:mysql://172.16.0.18:3306/academianew",
// "backup",
// "mysql2016");
......@@ -65,9 +65,9 @@ public class MySqlDAOFactory extends DAOFactory {
/*"jdbc:mysql://172.16.0.18:3306/encuesta_docente",
"eduardo",
"mysql");*/
"jdbc:mysql://172.16.2.38:3306/prueba",
"jdbc:mysql://localhost:3306/academianew",
"root",
"Mysql2016");
"mysql2018");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
......
......@@ -457,6 +457,7 @@ public class MysqlAsistenciaDAO implements AsistenciaDAO {
@Override
public JSONObject listarEstudiantesPorCiclo(JSONObject datos) throws Exception {
JSONObject jreturn;
JSONArray reporte = new JSONArray();
JSONArray lista = new JSONArray();
JSONObject data = new JSONObject();
Connection con = null;
......@@ -467,7 +468,110 @@ public class MysqlAsistenciaDAO implements AsistenciaDAO {
ResponseHelper response = new ResponseHelper();
try {
con = MySqlDAOFactory.obtenerConexion(GeneralVariables.nameDB);
sql = "";
sql = " SELECT "
+ " e.codestudiante, "
+ " CONCAT_WS(' ',e.paterno,e.materno,e.nombres) "
+ "FROM "
+ " matricula AS m "
+ "INNER JOIN estudiante AS e ON e.codestudiante = m.cod_estud_matri "
+ " AND m.estado_matri = 1 "
+ "WHERE "
+ " m.codAula = ? "
+ " ORDER BY e.paterno ASC ";
pst = con.prepareStatement(sql);
pst.setInt(1, datos.getInt("codigoCiclo"));
rSet = pst.executeQuery();
while (rSet.next()) {
JSONObject obj = new JSONObject();
obj.put("codigoEstudiante", rSet.getInt(1));
obj.put("nombreEstudiante", rSet.getString(2));
lista.put(obj);
}
// System.out.println("ESTUDIANTES" + lista);
sql = " SELECT "
+ " CASE a.estado_asistencia "
+ " WHEN 1 THEN 'A' "
+ " WHEN 2 THEN 'T' "
+ " WHEN 0 THEN 'F' "
+ " ELSE '-' "
+ " END "
+ "FROM "
+ " ( "
+ " SELECT "
+ " tb.dow AS dow, "
+ " tb.dt AS dt "
+ " FROM "
+ " ( "
+ " SELECT "
+ " DAYOFMONTH( "
+ " DATE_ADD( "
+ " CONCAT_WS('-', YEAR(NOW()), ?, '01'), "
+ " INTERVAL ta. ROW DAY "
+ " ) "
+ " ) AS dom, "
+ " DAYOFWEEK( "
+ " DATE_ADD( "
+ " CONCAT_WS('-', YEAR(NOW()), ?, '01'), "
+ " INTERVAL ta. ROW DAY "
+ " ) "
+ " ) - 1 AS dow, "
+ " DATE_ADD( "
+ " CONCAT_WS('-', YEAR(NOW()), ?, '01'), "
+ " INTERVAL ta. ROW DAY "
+ " ) AS dt "
+ " FROM "
+ " ( "
+ " SELECT "
+ " @ROW := @ROW + 1 AS ROW "
+ " FROM "
+ " INFORMATION_SCHEMA. COLUMNS, "
+ " (SELECT @ROW := - 1) t "
+ " ) Ta "
+ " WHERE "
+ " Ta. ROW < DAYOFMONTH( "
+ " LAST_DAY( "
+ " CONCAT_WS('-', YEAR(NOW()), ?, '01') "
+ " ) "
+ " ) "
+ " ) AS tb "
+ " INNER JOIN ( "
+ " SELECT "
+ " b.dia_bloque AS db "
+ " FROM "
+ " bloques AS b "
+ " INNER JOIN horarios AS h ON h.codigo_horario = b.codigo_horario "
+ " INNER JOIN aula AS a ON a.codigo_horario = h.codigo_horario "
+ " WHERE "
+ " a.codAula = ? "
+ " ) AS tc ON tc.db = tb.dow "
+ " ) AS b "
+ "LEFT JOIN asistencias AS a ON a.fecha_asistencia = b.dt "
+ "AND a.codigo_estudiante = ? AND a.codigo_aula = ? "
+ "ORDER BY "
+ " b.dt ASC; ";
pst = con.prepareStatement(sql);
for (int i = 0; i < lista.length(); i++) {
JSONObject asistenciaEstudiante = new JSONObject();
int c = 1;
JSONArray asistencias = new JSONArray();
JSONObject estudiante = lista.getJSONObject(i);
pst.setString(c++, datos.getString("mesReporte"));
pst.setString(c++, datos.getString("mesReporte"));
pst.setString(c++, datos.getString("mesReporte"));
pst.setString(c++, datos.getString("mesReporte"));
pst.setInt(c++, datos.getInt("codigoCiclo"));
pst.setInt(c++, estudiante.getInt("codigoEstudiante"));
pst.setInt(c++, datos.getInt("codigoCiclo"));
rSet = pst.executeQuery();
while (rSet.next()) {
asistencias.put(rSet.getString(1));
}
asistenciaEstudiante.put("asistencias", asistencias);
asistenciaEstudiante.put("estudiante", estudiante.getString("nombreEstudiante"));
reporte.put(asistenciaEstudiante);
}
// System.out.println("Reporte " + reporte);
response.setResults(reporte);
} catch (Exception e) {
e.printStackTrace();
response.setStatus(false);
......@@ -506,52 +610,76 @@ public class MysqlAsistenciaDAO implements AsistenciaDAO {
ResponseHelper response = new ResponseHelper();
try {
con = MySqlDAOFactory.obtenerConexion(GeneralVariables.nameDB);
sql = " SELECT "
+ " DAYOFMONTH(DATE_ADD(CONCAT_WS('-', YEAR(NOW()), ?, '01'),INTERVAL ta. ROW DAY)), "
+ " DAYOFWEEK (DATE_ADD(CONCAT_WS('-', YEAR(NOW()), ?, '01'),INTERVAL ta. ROW DAY)) -1, "
+ " DATE_ADD(CONCAT_WS('-', YEAR(NOW()), ?, '01'),INTERVAL ta. ROW DAY) "
+ " FROM "
+ " ( "
+ " SELECT @ROW := @ROW + 1 AS ROW "
+ " FROM INFORMATION_SCHEMA. COLUMNS, "
+ " (SELECT @ROW := - 1) t "
+ " ) Ta "
+ " WHERE Ta. ROW < DAYOFMONTH( "
+ " LAST_DAY(CONCAT_WS('-', YEAR(NOW()), ?, '01'))) "
+ " AND DAYOFWEEK(DATE_ADD(CONCAT_WS('-', YEAR(NOW()), ?, '01'), INTERVAL row DAY)) - 1 IN "
sql = " SELECT "
+ " CASE tb.dow "
+ " WHEN 1 THEN 'L' "
+ " WHEN 2 THEN 'M' "
+ " WHEN 3 THEN 'X' "
+ " WHEN 4 THEN 'J' "
+ " WHEN 5 THEN 'V' "
+ " WHEN 6 THEN 'S' "
+ " WHEN 7 THEN 'D' "
+ " END AS dow, "
+ " DATE_FORMAT(tb.dt, '%d') AS dt "
+ "FROM "
+ " ( "
+ " SELECT "
+ " b.dia_bloque "
+ " SELECT "
+ " DAYOFMONTH( "
+ " DATE_ADD( "
+ " CONCAT_WS('-', YEAR(NOW()), ?, '01'), "
+ " INTERVAL ta. ROW DAY "
+ " ) "
+ " ) AS dom, "
+ " DAYOFWEEK( "
+ " DATE_ADD( "
+ " CONCAT_WS('-', YEAR(NOW()), ?, '01'), "
+ " INTERVAL ta. ROW DAY "
+ " ) "
+ " ) - 1 AS dow, "
+ " DATE_ADD( "
+ " CONCAT_WS('-', YEAR(NOW()), ?, '01'), "
+ " INTERVAL ta. ROW DAY "
+ " ) AS dt "
+ " FROM "
+ " bloques AS b "
+ " INNER JOIN horarios AS h ON h.codigo_horario = b.codigo_horario "
+ " INNER JOIN aula AS a ON a.codigo_horario = h.codigo_horario "
+ " WHERE a.codAula = ? "
+ " ); "
+ "";
+ " ( "
+ " SELECT "
+ " @ROW := @ROW + 1 AS ROW "
+ " FROM "
+ " INFORMATION_SCHEMA. COLUMNS, "
+ " (SELECT @ROW := - 1) t "
+ " ) Ta "
+ " WHERE "
+ " Ta. ROW < DAYOFMONTH( "
+ " LAST_DAY( "
+ " CONCAT_WS('-', YEAR(NOW()), ?, '01') "
+ " ) "
+ " ) "
+ " ) AS tb "
+ "INNER JOIN ( "
+ " SELECT "
+ " b.dia_bloque AS db "
+ " FROM "
+ " bloques AS b "
+ " INNER JOIN horarios AS h ON h.codigo_horario = b.codigo_horario "
+ " INNER JOIN aula AS a ON a.codigo_horario = h.codigo_horario "
+ " WHERE "
+ " a.codAula = ? "
+ ") AS tc ON tc.db = tb.dow; ";
pst = con.prepareStatement(sql);
int c = 1;
pst.setString(c++, datos.getString("mesReporte"));
pst.setString(c++, datos.getString("mesReporte"));
pst.setString(c++, datos.getString("mesReporte"));
pst.setString(c++, datos.getString("mesReporte"));
pst.setString(c++, datos.getString("mesReporte"));
pst.setInt(c++, datos.getInt("codigoCiclo"));
rSet = pst.executeQuery();
while (rSet.next()) {
JSONObject obj = new JSONObject();
obj.put("dayMonth", rSet.getInt(1));
obj.put("dayWeek", rSet.getInt(2));
obj.put("date", rSet.getString(3));
obj.put("dayWeek", rSet.getString(1));
obj.put("dayMonth", rSet.getString(2));
lista.put(obj);
}
if (lista.length() >= 1) {
response.setStatus(true);
response.setResults(lista);
} else {
response.setStatus(false);
response.setMessage("No hay contenido");
}
response.setResults(lista);
} catch (Exception e) {
e.printStackTrace();
response.setStatus(false);
......
......@@ -67,4 +67,24 @@ public class AsistenciaService {
}
return obj;
}
public JSONObject listarEstudiantesPorCiclo(JSONObject datos) {
JSONObject obj = null;
try {
obj = dao.listarEstudiantesPorCiclo(datos);
} catch (Exception e) {
e.printStackTrace();
}
return obj;
}
public JSONObject listarClasesPorCiclo(JSONObject datos) {
JSONObject obj = null;
try {
obj = dao.listarClasesPorCiclo(datos);
} catch (Exception e) {
e.printStackTrace();
}
return obj;
}
}
......@@ -42,6 +42,12 @@ public class ServletAsistencia extends HttpServlet {
case "listarCicloPorEstudiante":
listarCicloPorEstudiante(request, response);
break;
case "listarEstudiantesPorCiclo":
listarEstudiantesPorCiclo(request, response);
break;
case "listarClasesPorCiclo":
listarClasesPorCiclo(request, response);
break;
default:
}
}
......@@ -105,4 +111,24 @@ public class ServletAsistencia extends HttpServlet {
out.println(rs);
}
private void listarEstudiantesPorCiclo(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("application/json");
PrintWriter out = response.getWriter();
AsistenciaService srv = new AsistenciaService();
String jsonString = request.getParameter("json");
JSONObject json = new JSONObject(jsonString);
JSONObject rs = srv.listarEstudiantesPorCiclo(json);
out.println(rs);
}
private void listarClasesPorCiclo(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("application/json");
PrintWriter out = response.getWriter();
AsistenciaService srv = new AsistenciaService();
String jsonString = request.getParameter("json");
JSONObject json = new JSONObject(jsonString);
JSONObject rs = srv.listarClasesPorCiclo(json);
out.println(rs);
}
}
<%@page import="org.json.JSONObject"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.Calendar"%>
<%@page import="pe.siso.academia.Beans.Aula"%>
<%@page import="javax.swing.JPanel"%>
<%@page import="java.util.ArrayList"%>
<%@page import="org.json.JSONArray"%>
<%@page import="java.io.PrintWriter"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="pe.siso.academia.Services.AsistenciaService"%>
<%@page import="org.json.JSONObject"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<%
PrintWriter pw = response.getWriter();
String json = request.getParameter("json");
JSONObject parameters = new JSONObject(json);
int codigoCiclo = parameters.getInt("idCiclo");
String nombreCiclo = parameters.getString("nombreCiclo");
String mesAsistencia = parameters.getString("mesAsistencia");
JSONObject result1 = new JSONObject();
JSONObject result2 = new JSONObject();
JSONArray array1 = new JSONArray();
JSONArray array2 = new JSONArray();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename=" + "AsistenciaCiclo" + nombreCiclo + "-" + mesAsistencia + ".xls");
response.setHeader("Content-Disposition", "inline; filename=" + "AsistenciaCiclo" + parameters.getString("nombreCiclo") + "-" + parameters.getString("mesAsistencia") + ".xls");
AsistenciaService service = new AsistenciaService();
JSONObject param = new JSONObject()
.put("mesReporte", parameters.getString("mesAsistencia"))
.put("codigoCiclo", parameters.getInt("idCiclo"));
result1 = service.listarClasesPorCiclo(param);
result2 = service.listarEstudiantesPorCiclo(param);
array1 = result1.getJSONArray("results");
array2 = result2.getJSONArray("results");
%>
<table>
</table>
</head>
<body>
<h3 align="center">REPORTE DE ASISTENCIAS</h3>
<table border="1">
<thead>
<tr>
<th style="text-align: center"></th>
<th style="text-align: center">ESTUDIANTE</th>
<%
for (int i = 0; i < array1.length(); i++) {
JSONObject dia = array1.getJSONObject(i);
%>
<th style="text-align: center; width: 20px;"><%=dia.getString("dayWeek")%><br><%=dia.getString("dayMonth")%></th>
<%
}
%>
</tr>
</thead>
<tbody>
<%
for (int i = 0; i < array2.length(); i++) {
JSONObject asistenciaEstudiante = array2.getJSONObject(i);
JSONArray asistencia = asistenciaEstudiante.getJSONArray("asistencias");
%>
<tr>
<td style="text-align: center"><%=i + 1%></td>
<td><%=asistenciaEstudiante.getString("estudiante")%></td>
<%
for (int j = 0; j < asistencia.length(); j++) {
%>
<td style="text-align: center"><%=asistencia.getString(j)%></td>
<%}%>
</tr>
<% }%>
</tbody>
</table>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</body>
</html>
\ No newline at end of file
......@@ -22,53 +22,50 @@
jobj.put("length", "-1");
JSONObject jReturn = new JSONObject();
JSONArray arrayReturn = new JSONArray();
String exportToExcel = request.getParameter("exportToExcel");
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
HttpSession session_actual = request.getSession(true);
Usuario usuario = (Usuario) session_actual.getAttribute("usuario");
jobj.put("codigoSede", usuario.getCodigoSede());
// if (exportToExcel != null && exportToExcel.toString().equalsIgnoreCase("YES")) {timestamp.getTime()
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename=ReporteAsistencias" + timestamp.getTime() + ".xls");
AsistenciaService service = new AsistenciaService();
jReturn = service.listarAsistencia(jobj);
arrayReturn = jReturn.getJSONArray("data");
// }
%>
<style>
label,h5,h2,td,.btn,li,option,select,p,b,input,span {
font-family: 'Poppins', sans-serif;
font-style: normal
}
th{
font-weight: 100;
font-family: 'Poppins', sans-serif;
}
td{
margin : 0px;
padding: 10px;
}
</style>
<!-- <style>
label,h5,h2,td,.btn,li,option,select,p,b,input,span {
font-family: 'Poppins', sans-serif;
font-style: normal
}
th{
font-weight: 100;
font-family: 'Poppins', sans-serif;
}
td{
margin : 0px;
padding: 10px;
}
</style>-->
</head>
<body>
<h3 align="center">REPORTE DE ASISTENCIAS</h3>
<table style="font-size: 11px" border="2" align="center">
<table border="1" align="center">
<thead>
<tr bgcolor="#2D72AD" style="color: white">
<th class="text-center"></th>
<th class="text-center">ESTUDIANTE</th>
<th class="text-center">DNI</th>
<th class="text-center">CICLO</th>
<th class="text-center">FECHA</th>
<th class="text-center">HORA ASISTENCIA</th>
<th class="text-center">HORA CLASE</th>
<th class="text-center">OBSERVACION</th>
<th class="text-center">ESTADO</th>
<tr>
<th style="text-align: center"></th>
<th style="text-align: center">ESTUDIANTE</th>
<th style="text-align: center">DNI</th>
<th style="text-align: center">CICLO</th>
<th style="text-align: center">FECHA</th>
<th style="text-align: center">HORA ASISTENCIA</th>
<th style="text-align: center">HORA CLASE</th>
<th style="text-align: center">OBSERVACION</th>
<th style="text-align: center">ESTADO</th>
</tr>
</thead>
......@@ -78,35 +75,35 @@
for (int i = 0; i < sizeArray; i++) {
JSONObject obj = arrayReturn.getJSONObject(i);
%>
<tr bgcolor="#FEFEFE">
<th style="padding : 10px;" align="center"><%=obj.getInt("numeral")%></th>
<th style="padding : 10px;" align="left"><%=obj.getString("nombreEstudiante")%></th>
<th style="padding : 10px;" align="center"><%=obj.getInt("dniEstudiante")%></th>
<th style="padding : 10px;" align="left"><%=obj.getString("nombreCiclo")%></th>
<th style="padding : 10px;" align="center"><%=obj.getString("fechaAsistencia")%></th>
<th style="padding : 10px;" align="center"><%=obj.getString("horaAsistencia")%></th>
<th style="padding : 10px;" align="center"><%=obj.getString("horaInicio") + " - " + obj.getString("horaSalida")%></th>
<th style="padding : 10px;" align="left"><%=obj.getString("observacionAsistencia")%></th>
<%
switch (obj.getInt("estadoAsistencia")) {
case 0:
%>
<th style="padding : 10px; background-color: #BB091C; color: white" align="center"><%="FALTA"%></th>
<%
break;
case 1:
%>
<th style="padding : 10px; background-color: #8CC152; color: white" align="center"><%="ASITENCIA"%></th>
<%
<tr>
<td align="center"><%=obj.getInt("numeral")%></td>
<td align="left"><%=obj.getString("nombreEstudiante")%></td>
<td align="center"><%=obj.getInt("dniEstudiante")%></td>
<td align="left"><%=obj.getString("nombreCiclo")%></td>
<td align="center"><%=obj.getString("fechaAsistencia")%></td>
<td align="center"><%=obj.getString("horaAsistencia")%></td>
<td align="center"><%=obj.getString("horaInicio") + " - " + obj.getString("horaSalida")%></td>
<td align="left"><%=obj.getString("observacionAsistencia")%></td>
<%
switch (obj.getInt("estadoAsistencia")) {
case 0:
%>
<td style="background-color: #BB091C; color: white" align="center"><%="FALTA"%></td>
<%
break;
case 1:
%>
<td style="background-color: #8CC152; color: white" align="center"><%="ASITENCIA"%></td>
<%
break;
case 2:
%>
<td style="background-color:#F5BB42; color: white" align="center"><%="TARDANZA"%></td>
<%
break;
case 2:
%>
<th style="padding : 10px; background-color:#F5BB42; color: white" align="center"><%="TARDANZA"%></th>
<%
break;
default:
}
%>
default:
}
%>
</tr>
<% }%>
</tbody>
......
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