|
|
|
@ -1,182 +1,319 @@
|
|
|
|
package com.controller.schoadmin;
|
|
|
|
package com.controller.schoadmin;
|
|
|
|
|
|
|
|
// 声明该类所在的包为 com.controller.schoadmin,用于组织和管理与学校管理员相关的控制器类
|
|
|
|
|
|
|
|
|
|
|
|
import com.dao.DeptAdminDao;
|
|
|
|
import com.dao.DeptAdminDao;
|
|
|
|
|
|
|
|
// 导入自定义的 DeptAdminDao 类,该类可能封装了与数据库交互的方法,如执行 SQL 查询、获取记录总数等操作
|
|
|
|
|
|
|
|
|
|
|
|
import com.dao.StuDao;
|
|
|
|
import com.dao.StuDao;
|
|
|
|
|
|
|
|
// 导入自定义的 StuDao 类,用于执行与学生相关的数据查询操作,如查询学生打卡信息等
|
|
|
|
|
|
|
|
|
|
|
|
import com.entity.PageBean;
|
|
|
|
import com.entity.PageBean;
|
|
|
|
|
|
|
|
// 导入自定义的 PageBean 类,用于封装分页相关的信息,如当前页码、每页记录数、总记录数、数据列表等
|
|
|
|
|
|
|
|
|
|
|
|
import com.entity.StuPunch;
|
|
|
|
import com.entity.StuPunch;
|
|
|
|
|
|
|
|
// 导入自定义的 StuPunch 类,这是一个实体类,用于封装学生打卡的相关信息,如学生编号、姓名、班级、打卡状态等
|
|
|
|
|
|
|
|
|
|
|
|
import com.utils.JDBCUtils;
|
|
|
|
import com.utils.JDBCUtils;
|
|
|
|
|
|
|
|
// 导入自定义的 JDBCUtils 类,通常包含与 JDBC(Java Database Connectivity)操作相关的工具方法,如获取数据库连接、关闭连接、处理结果集等
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
|
|
|
|
// 导入 Servlet 异常类,用于处理 Servlet 执行过程中可能出现的异常情况
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.annotation.WebServlet;
|
|
|
|
import javax.servlet.annotation.WebServlet;
|
|
|
|
|
|
|
|
// 导入 WebServlet 注解,用于将一个普通的 Java 类标记为 Servlet,并指定其访问路径
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServlet;
|
|
|
|
import javax.servlet.http.HttpServlet;
|
|
|
|
|
|
|
|
// 导入 HttpServlet 类,所有的 HTTP Servlet 都需要继承该类,并重写相应的方法来处理 HTTP 请求
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
// 导入 HttpServletRequest 接口,用于封装客户端发送的 HTTP 请求信息,如请求参数、请求头、请求方法等
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
// 导入 HttpServletResponse 接口,用于封装服务器返回给客户端的 HTTP 响应信息,如响应状态码、响应头、响应内容等
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
|
|
|
|
// 导入 HttpSession 接口,用于管理用户会话,存储用户在一次会话期间的相关信息,如用户登录状态、用户信息等
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
// 导入 IOException 类,用于处理输入输出操作中可能出现的异常情况,如文件读取、网络传输等异常
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
|
|
|
|
// 导入 ResultSet 接口,用于表示数据库查询结果集,通过该接口可以遍历和获取查询结果中的每一行数据
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
// 导入 ArrayList 类,用于存储和操作动态数组,这里用于存储查询到的学生打卡信息
|
|
|
|
|
|
|
|
|
|
|
|
@WebServlet("/SchoQueryStuPunchByPageServlet")
|
|
|
|
@WebServlet("/SchoQueryStuPunchByPageServlet")
|
|
|
|
|
|
|
|
// 使用 WebServlet 注解将当前类标记为一个 Servlet,并指定其访问路径为 /SchoQueryStuPunchByPageServlet,客户端可以通过该路径访问该 Servlet
|
|
|
|
|
|
|
|
|
|
|
|
public class SchoQueryStuPunchByPageServlet extends HttpServlet {
|
|
|
|
public class SchoQueryStuPunchByPageServlet extends HttpServlet {
|
|
|
|
|
|
|
|
// 定义一个公共类 SchoQueryStuPunchByPageServlet,继承自 HttpServlet 类,用于处理 HTTP 请求
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
|
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
|
|
|
|
|
|
// 重写 HttpServlet 类的 doGet 方法,用于处理客户端发送的 GET 请求
|
|
|
|
|
|
|
|
// req 是 HttpServletRequest 对象,封装了客户端的请求信息;resp 是 HttpServletResponse 对象,用于向客户端发送响应信息
|
|
|
|
|
|
|
|
|
|
|
|
req.setCharacterEncoding("utf-8");
|
|
|
|
req.setCharacterEncoding("utf-8");
|
|
|
|
|
|
|
|
// 设置请求的字符编码为 UTF-8,确保能正确处理包含中文等特殊字符的请求参数
|
|
|
|
|
|
|
|
|
|
|
|
resp.setCharacterEncoding("utf-8");
|
|
|
|
resp.setCharacterEncoding("utf-8");
|
|
|
|
|
|
|
|
// 设置响应的字符编码为 UTF-8,确保能正确输出包含中文等特殊字符的响应内容
|
|
|
|
|
|
|
|
|
|
|
|
resp.setContentType("text/html;charset=utf-8");
|
|
|
|
resp.setContentType("text/html;charset=utf-8");
|
|
|
|
|
|
|
|
// 设置响应的内容类型为 text/html,并指定字符编码为 UTF-8,告诉客户端响应的内容是 HTML 格式,且使用 UTF-8 编码
|
|
|
|
|
|
|
|
|
|
|
|
//获取请求参数
|
|
|
|
//获取请求参数
|
|
|
|
String sname = req.getParameter("sname");
|
|
|
|
String sname = req.getParameter("sname");
|
|
|
|
|
|
|
|
// 从请求中获取名为 "sname" 的参数值,该参数可能表示学生姓名,存储在字符串变量 sname 中
|
|
|
|
|
|
|
|
|
|
|
|
String sclass = req.getParameter("sclass");
|
|
|
|
String sclass = req.getParameter("sclass");
|
|
|
|
|
|
|
|
// 从请求中获取名为 "sclass" 的参数值,该参数可能表示学生班级,存储在字符串变量 sclass 中
|
|
|
|
|
|
|
|
|
|
|
|
String sdept = req.getParameter("sdept");
|
|
|
|
String sdept = req.getParameter("sdept");
|
|
|
|
|
|
|
|
// 从请求中获取名为 "sdept" 的参数值,该参数可能表示学生所在部门,存储在字符串变量 sdept 中
|
|
|
|
|
|
|
|
|
|
|
|
String spunchdate = req.getParameter("spunchdate");
|
|
|
|
String spunchdate = req.getParameter("spunchdate");
|
|
|
|
|
|
|
|
// 从请求中获取名为 "spunchdate" 的参数值,该参数可能表示学生打卡日期,存储在字符串变量 spunchdate 中
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(sname);
|
|
|
|
System.out.println(sname);
|
|
|
|
|
|
|
|
// 将 sname 的值输出到控制台,用于调试目的,查看获取的学生姓名参数值
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(sclass);
|
|
|
|
System.out.println(sclass);
|
|
|
|
|
|
|
|
// 将 sclass 的值输出到控制台,用于调试目的,查看获取的学生班级参数值
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(sdept);
|
|
|
|
System.out.println(sdept);
|
|
|
|
System.out.println(spunchdate);
|
|
|
|
// 将 sdept 的值输出到控制台,用于调试目的,查看获取的学生所在部门参数值
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(spunchdate);
|
|
|
|
|
|
|
|
// 将 spunchdate 的值输出到控制台,用于调试目的,查看获取的学生打卡日期参数值
|
|
|
|
|
|
|
|
|
|
|
|
//如果传入的参数为null,则置为空字符串
|
|
|
|
//如果传入的参数为null,则置为空字符串
|
|
|
|
if (sname == null){
|
|
|
|
if (sname == null){
|
|
|
|
sname = "";
|
|
|
|
sname = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 如果 sname 参数为 null,将其设置为空字符串,避免后续操作出现空指针异常
|
|
|
|
|
|
|
|
|
|
|
|
if (sclass == null){
|
|
|
|
if (sclass == null){
|
|
|
|
sclass = "";
|
|
|
|
sclass = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 如果 sclass 参数为 null,将其设置为空字符串,避免后续操作出现空指针异常
|
|
|
|
|
|
|
|
|
|
|
|
if (sdept == null){
|
|
|
|
if (sdept == null){
|
|
|
|
sdept = "";
|
|
|
|
sdept = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 如果 sdept 参数为 null,将其设置为空字符串,避免后续操作出现空指针异常
|
|
|
|
|
|
|
|
|
|
|
|
if (spunchdate == null){
|
|
|
|
if (spunchdate == null){
|
|
|
|
spunchdate = "";
|
|
|
|
spunchdate = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 如果 spunchdate 参数为 null,将其设置为空字符串,避免后续操作出现空指针异常
|
|
|
|
|
|
|
|
|
|
|
|
//变为like查询所需的字符串参数
|
|
|
|
//变为like查询所需的字符串参数
|
|
|
|
String sname1 = "%" + sname + "%";
|
|
|
|
String sname1 = "%" + sname + "%";
|
|
|
|
|
|
|
|
// 在 sname 前后添加 % 符号,用于模糊查询,匹配包含 sname 字符串的学生姓名
|
|
|
|
|
|
|
|
|
|
|
|
String sclass1 = "%" + sclass + "%";
|
|
|
|
String sclass1 = "%" + sclass + "%";
|
|
|
|
|
|
|
|
// 在 sclass 前后添加 % 符号,用于模糊查询,匹配包含 sclass 字符串的学生班级
|
|
|
|
|
|
|
|
|
|
|
|
String sdept1 = "%" + sdept + "%";
|
|
|
|
String sdept1 = "%" + sdept + "%";
|
|
|
|
|
|
|
|
// 在 sdept 前后添加 % 符号,用于模糊查询,匹配包含 sdept 字符串的学生所在部门
|
|
|
|
|
|
|
|
|
|
|
|
String spunchdate1 = "%" + spunchdate + "%";
|
|
|
|
String spunchdate1 = "%" + spunchdate + "%";
|
|
|
|
|
|
|
|
// 在 spunchdate 前后添加 % 符号,用于模糊查询,匹配包含 spunchdate 字符串的学生打卡日期
|
|
|
|
|
|
|
|
|
|
|
|
//设置请求的属性参数,后面需要用
|
|
|
|
//设置请求的属性参数,后面需要用
|
|
|
|
req.setAttribute("sname",sname);
|
|
|
|
req.setAttribute("sname",sname);
|
|
|
|
|
|
|
|
// 将 sname 参数设置为请求的属性,方便后续页面或其他处理使用
|
|
|
|
|
|
|
|
|
|
|
|
req.setAttribute("sclass", sclass);
|
|
|
|
req.setAttribute("sclass", sclass);
|
|
|
|
|
|
|
|
// 将 sclass 参数设置为请求的属性,方便后续页面或其他处理使用
|
|
|
|
|
|
|
|
|
|
|
|
req.setAttribute("sdept", sdept);
|
|
|
|
req.setAttribute("sdept", sdept);
|
|
|
|
|
|
|
|
// 将 sdept 参数设置为请求的属性,方便后续页面或其他处理使用
|
|
|
|
|
|
|
|
|
|
|
|
req.setAttribute("spunchdate",spunchdate);
|
|
|
|
req.setAttribute("spunchdate",spunchdate);
|
|
|
|
|
|
|
|
// 将 spunchdate 参数设置为请求的属性,方便后续页面或其他处理使用
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(sname1);
|
|
|
|
System.out.println(sname1);
|
|
|
|
|
|
|
|
// 将 sname1 的值输出到控制台,用于调试目的,查看模糊查询的学生姓名参数
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(sclass1);
|
|
|
|
System.out.println(sclass1);
|
|
|
|
|
|
|
|
// 将 sclass1 的值输出到控制台,用于调试目的,查看模糊查询的学生班级参数
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(sdept1);
|
|
|
|
System.out.println(sdept1);
|
|
|
|
|
|
|
|
// 将 sdept1 的值输出到控制台,用于调试目的,查看模糊查询的学生所在部门参数
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(spunchdate1);
|
|
|
|
System.out.println(spunchdate1);
|
|
|
|
|
|
|
|
// 将 spunchdate1 的值输出到控制台,用于调试目的,查看模糊查询的学生打卡日期参数
|
|
|
|
|
|
|
|
|
|
|
|
//获取登录时的session会话对象
|
|
|
|
//获取登录时的session会话对象
|
|
|
|
HttpSession session = req.getSession();
|
|
|
|
HttpSession session = req.getSession();
|
|
|
|
|
|
|
|
// 获取当前请求对应的 HttpSession 对象,如果会话不存在则会创建一个新的会话
|
|
|
|
|
|
|
|
|
|
|
|
// String userName = (String) session.getAttribute("userName");
|
|
|
|
// String userName = (String) session.getAttribute("userName");
|
|
|
|
|
|
|
|
// 注释掉的代码,原本是从会话中获取名为 "userName" 的属性值,并将其转换为字符串类型存储在 userName 变量中
|
|
|
|
|
|
|
|
|
|
|
|
// String sno = (String) session.getAttribute("sno");
|
|
|
|
// String sno = (String) session.getAttribute("sno");
|
|
|
|
|
|
|
|
// 注释掉的代码,原本是从会话中获取名为 "sno" 的属性值,并将其转换为字符串类型存储在 sno 变量中
|
|
|
|
|
|
|
|
|
|
|
|
String belong = (String) session.getAttribute("belong");
|
|
|
|
String belong = (String) session.getAttribute("belong");
|
|
|
|
|
|
|
|
// 从会话中获取名为 "belong" 的属性值,并将其转换为字符串类型存储在 belong 变量中,该属性可能表示用户所属的部门或角色等信息
|
|
|
|
|
|
|
|
|
|
|
|
String sql = null;
|
|
|
|
String sql = null;
|
|
|
|
|
|
|
|
// 声明一个字符串变量 sql,用于存储 SQL 查询语句,初始值为 null
|
|
|
|
|
|
|
|
|
|
|
|
// System.out.println(userName);
|
|
|
|
// System.out.println(userName);
|
|
|
|
|
|
|
|
// 注释掉的代码,原本是将 userName 的值输出到控制台,用于调试目的
|
|
|
|
|
|
|
|
|
|
|
|
// System.out.println(sno);
|
|
|
|
// System.out.println(sno);
|
|
|
|
|
|
|
|
// 注释掉的代码,原本是将 sno 的值输出到控制台,用于调试目的
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(belong);
|
|
|
|
System.out.println(belong);
|
|
|
|
|
|
|
|
// 将 belong 的值输出到控制台,用于调试目的
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("hdghghjg");
|
|
|
|
System.out.println("hdghghjg");
|
|
|
|
|
|
|
|
// 输出一个调试信息,用于确认代码执行到此处
|
|
|
|
|
|
|
|
|
|
|
|
String currentPage = req.getParameter("currentPage");//从请求对象中获取当前页码
|
|
|
|
String currentPage = req.getParameter("currentPage");//从请求对象中获取当前页码
|
|
|
|
|
|
|
|
// 从请求中获取名为 "currentPage" 的参数值,该参数表示当前页码
|
|
|
|
|
|
|
|
|
|
|
|
String rows = req.getParameter("rows");//从请求获取对象中每页显示的行数
|
|
|
|
String rows = req.getParameter("rows");//从请求获取对象中每页显示的行数
|
|
|
|
|
|
|
|
// 从请求中获取名为 "rows" 的参数值,该参数表示每页显示的记录数
|
|
|
|
|
|
|
|
|
|
|
|
//如果未设请求参数,此处自动设置参数为第一页
|
|
|
|
//如果未设请求参数,此处自动设置参数为第一页
|
|
|
|
if (currentPage == null || "".equals(currentPage)){
|
|
|
|
if (currentPage == null || "".equals(currentPage)){
|
|
|
|
currentPage = "1";
|
|
|
|
currentPage = "1";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 如果当前页码参数为空或未设置,将当前页码设置为 1
|
|
|
|
|
|
|
|
|
|
|
|
//如果没有设置rows的请求参数,此处自动设置
|
|
|
|
//如果没有设置rows的请求参数,此处自动设置
|
|
|
|
if (rows == null || "".equals(rows)){
|
|
|
|
if (rows == null || "".equals(rows)){
|
|
|
|
rows = "7";
|
|
|
|
rows = "7";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 如果每页显示的记录数参数为空或未设置,将每页显示的记录数设置为 7
|
|
|
|
|
|
|
|
|
|
|
|
//获取条件查询的参数
|
|
|
|
//获取条件查询的参数
|
|
|
|
int currentPage1 = Integer.parseInt(currentPage);
|
|
|
|
int currentPage1 = Integer.parseInt(currentPage);
|
|
|
|
|
|
|
|
// 将当前页码字符串转换为整数类型
|
|
|
|
|
|
|
|
|
|
|
|
int rows1 = Integer.parseInt(rows);
|
|
|
|
int rows1 = Integer.parseInt(rows);
|
|
|
|
|
|
|
|
// 将每页显示的记录数字符串转换为整数类型
|
|
|
|
|
|
|
|
|
|
|
|
//如果当前页数小于1,则设置当前页数为1
|
|
|
|
//如果当前页数小于1,则设置当前页数为1
|
|
|
|
if (currentPage1 <= 0){
|
|
|
|
if (currentPage1 <= 0){
|
|
|
|
currentPage1 = 1;
|
|
|
|
currentPage1 = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 如果当前页码小于等于 0,将当前页码设置为 1
|
|
|
|
|
|
|
|
|
|
|
|
//设置StuPunch类的对象类型
|
|
|
|
//设置StuPunch类的对象类型
|
|
|
|
PageBean<StuPunch> pageBean = new PageBean<StuPunch>();
|
|
|
|
PageBean<StuPunch> pageBean = new PageBean<StuPunch>();
|
|
|
|
|
|
|
|
// 创建一个 PageBean 类的对象 pageBean,泛型指定为 StuPunch 类型,用于存储学生打卡信息的分页数据
|
|
|
|
|
|
|
|
|
|
|
|
//设置当前页码
|
|
|
|
//设置当前页码
|
|
|
|
pageBean.setCurrentPage(currentPage1);
|
|
|
|
pageBean.setCurrentPage(currentPage1);
|
|
|
|
|
|
|
|
// 将当前页码设置到 pageBean 对象中
|
|
|
|
|
|
|
|
|
|
|
|
//设置每页的记录数
|
|
|
|
//设置每页的记录数
|
|
|
|
pageBean.setRows(rows1);
|
|
|
|
pageBean.setRows(rows1);
|
|
|
|
|
|
|
|
// 将每页显示的记录数设置到 pageBean 对象中
|
|
|
|
|
|
|
|
|
|
|
|
sql = " select count(*) as num from student s, stupunchin sp where s.sno = sp.sno and s.sname like ? and s.sclass like ? and s.sdept like ? and sp.spunchdate like ?";
|
|
|
|
sql = " select count(*) as num from student s, stupunchin sp where s.sno = sp.sno and s.sname like ? and s.sclass like ? and s.sdept like ? and sp.spunchdate like ?";
|
|
|
|
|
|
|
|
// 定义一个 SQL 查询语句,用于查询满足条件(学生姓名、班级、部门、打卡日期模糊匹配)的学生打卡记录总数,通过关联 student 表和 stupunchin 表
|
|
|
|
|
|
|
|
|
|
|
|
Object[] objects = {sname1, sclass1, sdept1, spunchdate1};
|
|
|
|
Object[] objects = {sname1, sclass1, sdept1, spunchdate1};
|
|
|
|
|
|
|
|
// 创建一个 Object 类型的数组 objects,将模糊查询所需的参数放入数组中
|
|
|
|
|
|
|
|
|
|
|
|
//计算总记录数,并设置
|
|
|
|
//计算总记录数,并设置
|
|
|
|
int totalCount = DeptAdminDao.findTotalCount(sql, objects);
|
|
|
|
int totalCount = DeptAdminDao.findTotalCount(sql, objects);
|
|
|
|
|
|
|
|
// 调用 DeptAdminDao 类的 findTotalCount 方法,传入 SQL 查询语句和查询参数数组,执行查询并返回满足条件的记录总数
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(totalCount);
|
|
|
|
System.out.println(totalCount);
|
|
|
|
|
|
|
|
// 将总记录数输出到控制台,用于调试目的
|
|
|
|
|
|
|
|
|
|
|
|
pageBean.setTotalCount(totalCount);
|
|
|
|
pageBean.setTotalCount(totalCount);
|
|
|
|
|
|
|
|
// 将总记录数设置到 pageBean 对象中
|
|
|
|
|
|
|
|
|
|
|
|
if (totalCount > 0){
|
|
|
|
if (totalCount > 0){
|
|
|
|
|
|
|
|
// 如果总记录数大于 0,说明存在满足条件的记录
|
|
|
|
|
|
|
|
|
|
|
|
//计算总页码,并设置
|
|
|
|
//计算总页码,并设置
|
|
|
|
int totalPage = (totalCount % rows1) == 0 ? totalCount/rows1 : (totalCount/rows1 + 1);
|
|
|
|
int totalPage = (totalCount % rows1) == 0 ? totalCount/rows1 : (totalCount/rows1 + 1);
|
|
|
|
|
|
|
|
// 根据总记录数和每页显示的记录数计算总页码,如果总记录数能被每页记录数整除,则总页码为总记录数除以每页记录数;否则,总页码为总记录数除以每页记录数加 1
|
|
|
|
|
|
|
|
|
|
|
|
pageBean.setTotalPage(totalPage);
|
|
|
|
pageBean.setTotalPage(totalPage);
|
|
|
|
|
|
|
|
// 将总页码设置到 pageBean 对象中
|
|
|
|
|
|
|
|
|
|
|
|
//如果当前页数大于总页数
|
|
|
|
//如果当前页数大于总页数
|
|
|
|
if (currentPage1 > pageBean.getTotalPage()){
|
|
|
|
if (currentPage1 > pageBean.getTotalPage()){
|
|
|
|
currentPage1 = pageBean.getTotalPage();
|
|
|
|
currentPage1 = pageBean.getTotalPage();
|
|
|
|
|
|
|
|
// 如果当前页码大于总页码,将当前页码设置为总页码
|
|
|
|
|
|
|
|
|
|
|
|
//重新设置当前页码
|
|
|
|
//重新设置当前页码
|
|
|
|
pageBean.setCurrentPage(currentPage1);
|
|
|
|
pageBean.setCurrentPage(currentPage1);
|
|
|
|
|
|
|
|
// 将更新后的当前页码重新设置到 pageBean 对象中
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//计算开始的记录和list对象集合,并设置
|
|
|
|
//计算开始的记录和list对象集合,并设置
|
|
|
|
int start = (currentPage1 - 1) * rows1;
|
|
|
|
int start = (currentPage1 - 1) * rows1;
|
|
|
|
|
|
|
|
// 根据当前页码和每页显示的记录数计算当前页的起始记录索引
|
|
|
|
|
|
|
|
|
|
|
|
sql = "select s.sname,s.sclass,s.sdept,sp.* from student s, stupunchin sp where s.sno = sp.sno and s.sname like ? and s.sclass like ? and s.sdept like ? and sp.spunchdate like ? limit ?, ?";
|
|
|
|
sql = "select s.sname,s.sclass,s.sdept,sp.* from student s, stupunchin sp where s.sno = sp.sno and s.sname like ? and s.sclass like ? and s.sdept like ? and sp.spunchdate like ? limit ?, ?";
|
|
|
|
|
|
|
|
// 定义一个 SQL 查询语句,用于查询当前页的学生打卡信息,使用 limit 关键字进行分页查询,通过关联 student 表和 stupunchin 表
|
|
|
|
|
|
|
|
|
|
|
|
Object[] objects1 = {sname1, sclass1, sdept1, spunchdate1, start, rows1};
|
|
|
|
Object[] objects1 = {sname1, sclass1, sdept1, spunchdate1, start, rows1};
|
|
|
|
|
|
|
|
// 创建一个 Object 类型的数组 objects1,将模糊查询所需的参数和分页参数放入数组中
|
|
|
|
|
|
|
|
|
|
|
|
ResultSet resultSet = StuDao.QureyInfoByPage(sql, objects1);
|
|
|
|
ResultSet resultSet = StuDao.QureyInfoByPage(sql, objects1);
|
|
|
|
|
|
|
|
// 调用 StuDao 类的 QureyInfoByPage 方法,传入 SQL 查询语句和查询参数数组,执行查询并返回结果集
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList stuPunchArrayList = new ArrayList();
|
|
|
|
ArrayList stuPunchArrayList = new ArrayList();
|
|
|
|
|
|
|
|
// 创建一个 ArrayList 对象,用于存储查询到的学生打卡信息
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
while (resultSet.next()){
|
|
|
|
while (resultSet.next()){
|
|
|
|
|
|
|
|
// 遍历结果集,每次循环处理结果集中的一行数据
|
|
|
|
|
|
|
|
|
|
|
|
StuPunch stuPunch = new StuPunch();
|
|
|
|
StuPunch stuPunch = new StuPunch();
|
|
|
|
|
|
|
|
// 创建一个 StuPunch 类的对象,用于存储当前行的学生打卡信息
|
|
|
|
|
|
|
|
|
|
|
|
stuPunch.setSno(resultSet.getString("sno"));
|
|
|
|
stuPunch.setSno(resultSet.getString("sno"));
|
|
|
|
|
|
|
|
// 从结果集中获取名为 "sno" 的列的值,并将其设置到 stuPunch 对象的 sno 属性中
|
|
|
|
|
|
|
|
|
|
|
|
stuPunch.setSname(resultSet.getString("sname"));
|
|
|
|
stuPunch.setSname(resultSet.getString("sname"));
|
|
|
|
|
|
|
|
// 从结果集中获取名为 "sname" 的列的值,并将其设置到 stuPunch 对象的 sname 属性中
|
|
|
|
|
|
|
|
|
|
|
|
stuPunch.setSclass(resultSet.getString("sclass"));
|
|
|
|
stuPunch.setSclass(resultSet.getString("sclass"));
|
|
|
|
|
|
|
|
// 从结果集中获取名为 "sclass" 的列的值,并将其设置到 stuPunch 对象的 sclass 属性中
|
|
|
|
|
|
|
|
|
|
|
|
stuPunch.setSdept(resultSet.getString("sdept"));
|
|
|
|
stuPunch.setSdept(resultSet.getString("sdept"));
|
|
|
|
|
|
|
|
// 从结果集中获取名为 "sdept" 的列的值,并将其设置到 stuPunch 对象的 sdept 属性中
|
|
|
|
|
|
|
|
|
|
|
|
stuPunch.setSispunch(resultSet.getString("sispunch"));
|
|
|
|
stuPunch.setSispunch(resultSet.getString("sispunch"));
|
|
|
|
|
|
|
|
// 从结果集中获取名为 "sispunch" 的列的值,并将其设置到 stuPunch 对象的 sispunch 属性中
|
|
|
|
|
|
|
|
|
|
|
|
stuPunch.setSpunchdate(resultSet.getDate("spunchdate"));
|
|
|
|
stuPunch.setSpunchdate(resultSet.getDate("spunchdate"));
|
|
|
|
|
|
|
|
// 从结果集中获取名为 "spunchdate" 的列的值,并将其设置到 stuPunch 对象的 spunchdate 属性中
|
|
|
|
|
|
|
|
|
|
|
|
stuPunch.setSpunchtime(resultSet.getString("spunchtime"));
|
|
|
|
stuPunch.setSpunchtime(resultSet.getString("spunchtime"));
|
|
|
|
|
|
|
|
// 从结果集中获取名为 "spunchtime" 的列的值,并将其设置到 stuPunch 对象的 spunchtime 属性中
|
|
|
|
|
|
|
|
|
|
|
|
stuPunch.setSishot(resultSet.getString("sishot"));
|
|
|
|
stuPunch.setSishot(resultSet.getString("sishot"));
|
|
|
|
|
|
|
|
// 从结果集中获取名为 "sishot" 的列的值,并将其设置到 stuPunch 对象的 sishot 属性中
|
|
|
|
|
|
|
|
|
|
|
|
stuPunch.setSiscough(resultSet.getString("siscough"));
|
|
|
|
stuPunch.setSiscough(resultSet.getString("siscough"));
|
|
|
|
stuPunch.setSisseem(resultSet.getString("sisseem"));
|
|
|
|
// 从结果集中获取名为 "siscough" 的列的值,并将其设置到 stuPunch 对象的 siscough 属性中
|
|
|
|
stuPunch.setSisdiagnose(resultSet.getString("sisdiagnose"));
|
|
|
|
|
|
|
|
stuPunch.setSstatus(resultSet.getString("sstatus"));
|
|
|
|
|
|
|
|
stuPunchArrayList.add(stuPunch);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
|
|
|
|
JDBCUtils.close(resultSet);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pageBean.setArrayList(stuPunchArrayList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(stuPunchArrayList);
|
|
|
|
stuPunch.setSisseem(resultSet.getString("sisseem"));
|
|
|
|
System.out.println(pageBean);
|
|
|
|
// 从结果集中获取名为 "sisseem" 的列的值,并将其设置到 stuPunch 对象的 sisseem 属性中
|
|
|
|
|
|
|
|
|
|
|
|
req.setAttribute("pageBean", pageBean);
|
|
|
|
stuPunch.setSisdiagnose(resultSet.getString("sisdiagnose"));
|
|
|
|
|
|
|
|
// 从结果集中获取名为 "sisdiagnose" 的列的值,并将其设置到 stuPunch 对象的 sisdiagnose 属性中
|
|
|
|
|
|
|
|
|
|
|
|
req.getRequestDispatcher("/view/schoadmin/stupunchlist.jsp").forward(req, resp);
|
|
|
|
stuPunch.setSstatus(resultSet.getString("sstatus"));
|
|
|
|
}else {
|
|
|
|
// 从结果集中获取名为 "sstatus" 的列的值,并将其设置到 stuPunch 对象的 sstatus 属性中
|
|
|
|
req.getRequestDispatcher("/view/alluse/nodata.jsp").forward(req, resp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
stuPunchArrayList.add(stuPunch);
|
|
|
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
|
|
// 将存储了当前行学生打卡信息的 stuPunch 对象添加到 stuPunchArrayList 中
|
|
|
|
doGet(req, resp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e)
|