📄 pd_dispatchqueryservlet.java
字号:
/**
* @(#)Prmis , Created on 2008-10-19
*
* Copyright (c) galaxy Teamwork
*
* MODIFY MEMO:
*
*/
package com.galaxy.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.galaxy.dao.ChangeRecordDAO;
import com.galaxy.dao.DeptInfoDAO;
import com.galaxy.dao.UserInfoDAO;
import com.galaxy.util.PageHelp;
import com.galaxy.vo.DeptInfoVO;
public class PD_DispatchQueryServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public PD_DispatchQueryServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gb2312");
response.setCharacterEncoding("gb2312");
String opflag="";
opflag=request.getParameter("opflag");
if("login".equals(opflag))
{
loadItem(request,response);
}
else if("detaillist".equals(opflag)){
listItem(request,response);
}
else if("retirelist".equals(opflag)){
retirelistItem(request,response);
}
else if("detailQuery".equals(opflag))
{
detailQueryItem(request,response);
}
else if("retireload".equals(opflag)){
retireloadItem(request,response);
}
else if("query".equals(opflag)){
queryItem(request,response);
}
else if("retireQuery".equals(opflag))
{
retireQueryItem(request,response);
}
else if("retireCK".equals(opflag)){
retireCK(request,response);
}
}
/***************************************************************************************/
/**
* PD_DispatchQueryServlet的私有方法
* 操作符opflag为"retireload"时直接调出所有的退休人员记录
*
* @throws IOException if an error occurred
* @throws ServletException if an error occurred
*/
private void retireloadItem(HttpServletRequest request, HttpServletResponse response) {
ChangeRecordDAO changedao=new ChangeRecordDAO();
String sql=" and pcr_class='离退' or pcr_class='开除' or pcr_class='辞职'";
/***/
PageHelp pagehelp = new PageHelp();
int pageSize = 5; // 设置每页的显示条数
pagehelp = changedao.getUserList(sql, pageSize,1);
request.setAttribute("pagehelp", pagehelp);
/**操作符为""时调出所有部门到下拉菜单*/
List deptlist=new ArrayList();
DeptInfoDAO deptdao=new DeptInfoDAO();
String depSql=" and di_state='可用'";
deptlist=deptdao.queryByCondition(depSql);
request.setAttribute("deptlist", deptlist);
/**页面跳转到人事调动管理主页面*/
try {
request.getRequestDispatcher("retireCenter3.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* PD_DispatchQueryServlet的私有方法
* 操作符opflag为"list"所调用的方法
* @throws IOException if an error occurred
* @throws ServletException if an error occurred
*/
private void listItem(HttpServletRequest request, HttpServletResponse response) {
/**操作符为"list"时调出所有部门到下拉菜单*/
List deptlist=new ArrayList();
DeptInfoDAO deptdao=new DeptInfoDAO();
String depSql=" and di_state='可用'";
deptlist=deptdao.queryByCondition(depSql);
request.setAttribute("deptlist", deptlist);
/**调用PageHelp类实现分页功能*/
ChangeRecordDAO changedao=new ChangeRecordDAO();
PageHelp pagehelp = new PageHelp();
int pageSize = 5;
String condition=request.getParameter("condition");
int currentPage=Integer.parseInt(request.getParameter("currentPage"));
pagehelp =changedao.getUserList(condition,pageSize,currentPage);
request.setAttribute("currentPage", request.getParameter("currentPage"));
request.setAttribute("pagehelp", pagehelp);
String flag=request.getParameter("flag");
if("retire3".equals(flag)){
/**跳转到离退人员管理页面*/
try {
request.getRequestDispatcher("retireCenter3.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}else if("resourceQuery".equals(flag)){
/**跳转到人事调动的综合详细查询页面*/
try {
request.getRequestDispatcher("ResourceChangedQuery.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* PD_DispatchQueryServlet的私有方法
* 操作符opflag为"retirelist"所调用的方法
* @throws IOException if an error occurred
* @throws ServletException if an error occurred
*/
private void retirelistItem(HttpServletRequest request, HttpServletResponse response) {
ChangeRecordDAO changedao=new ChangeRecordDAO();
PageHelp pagehelp = new PageHelp();
int pageSize = 5;
String condition=request.getParameter("condition");
int currentPage=Integer.parseInt(request.getParameter("currentPage"));
pagehelp =changedao.getList(condition,pageSize,currentPage);
request.setAttribute("currentPage", request.getParameter("currentPage"));
request.setAttribute("pagehelp", pagehelp);
/**跳转到退休参考查询页面*/
try {
request.getRequestDispatcher("retireCenter2.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* PD_DispatchQueryServlet的私有方法
* 操作符opflag为"query"所调用的方法
* @throws IOException if an error occurred
* @throws ServletException if an error occurred
*/
private void queryItem(HttpServletRequest request, HttpServletResponse response) {
ChangeRecordDAO changedao=new ChangeRecordDAO();
String ui_realname="%";
String cond="";
Long di_id=0l;
if(request.getParameter("dept")!=null&&!"0".equals(request.getParameter("dept"))){
di_id=Long.valueOf((request.getParameter("dept")));
cond+=" and pcr_exdept='"+di_id+"'";
}
if(request.getParameter("username")!=null&&!"".equals(request.getParameter("username"))){
ui_realname=request.getParameter("username");
cond+=" and ui_realname like '%"+ui_realname+"%'";
}
/**为用户提供真实姓名和所在部门的查询,查询结果按时间排序*/
PageHelp pagehelp=new PageHelp();
int pageSize=5;
pagehelp =changedao.getUserList(cond,pageSize,1);
request.setAttribute("pagehelp", pagehelp);
/**操作符为"query"时调出所有部门到下拉菜单*/
List deptlist=new ArrayList();
DeptInfoDAO deptdao=new DeptInfoDAO();
String depSql="";
deptlist=deptdao.queryByCondition(depSql);
request.setAttribute("deptlist", deptlist);
/**跳转到离退人员管理页面*/
try {
request.getRequestDispatcher("retireCenter3.jsp").forward(request,response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* PD_DispatchQueryServlet的私有方法
* 操作符opflag为"retireQuery"时所调用的方法
* 退休参考表页面响应查询的方法
* @throws IOException if an error occurred
* @throws ServletException if an error occurred
*/
private void retireQueryItem(HttpServletRequest request, HttpServletResponse response) {
ChangeRecordDAO changedao=new ChangeRecordDAO();
int ui_age=0;
if(!"".equals(request.getParameter("ui_age"))&&request.getParameter("ui_age")!=null)
ui_age=Integer.parseInt(request.getParameter("ui_age"));
/**只查询出在职用户*/
String cond=" and ui_age >= "+ui_age+" and ui_retirestate is null ";
/**为用户提供真实姓名和所在部门的查询,查询结果按时间排序*/
PageHelp pagehelp=new PageHelp();
int pageSize=5;
pagehelp =changedao.getList(cond,pageSize,1);
request.setAttribute("pagehelp", pagehelp);
/**跳转到退休参考查询页面*/
try {
request.getRequestDispatcher("retireCenter2.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* PD_DispatchQueryServlet的私有方法
* 操作符opflag为"detaiQuery"时所调用的方法
* 人事调动综合查询页面响应查询方法
* @throws IOException if an error occurred
* @throws ServletException if an error occurred
*/
private void detailQueryItem(HttpServletRequest request, HttpServletResponse response) {
/**操作符为"list"时调出所有部门到下拉菜单*/
List deptlist=new ArrayList();
DeptInfoDAO deptdao=new DeptInfoDAO();
String depSql="";
deptlist=deptdao.queryByDepid(depSql);
request.setAttribute("deptlist", deptlist);
ChangeRecordDAO changedao=new ChangeRecordDAO();
String cdstr="";
/**建立数组用以装从页面获取的查询字段和查询条件*/
String[] ckey=request.getParameterValues("keyparam");
String[] cvalue=request.getParameterValues("keyvalue");
String startdate=request.getParameter("startdate");
String enddate=request.getParameter("enddate");
Long dept=0l;
/**为用户提供真实姓名和所在部门、现任职位的查询以及按时间段查询,查询结果按时间排序*/
for(int i=0;i<ckey.length;i++){
if(!"".equals(cvalue[i])){
cdstr+= " and "+ckey[i]+" like '%"+ cvalue[i]+"%' ";
}
}
if(request.getParameter("dept")!=null&&!"0".equals(request.getParameter("dept"))){
dept=Long.valueOf((request.getParameter("dept")));
cdstr+=" and di_id="+dept+"";
}
if(null!=startdate&&!startdate.equals("")){
cdstr+=" and pcr_time >= to_date('"+startdate+"','yyyy-mm-dd')";
}
if(null!=enddate&&!enddate.equals("")){
cdstr+=" and pcr_time <=to_date('"+enddate+"','yyyy-mm-dd')";
}
/**使用pagehelp,调用人事调动记录表的方法*/
int pageSize = 5;
PageHelp pagehelp=new PageHelp();
pagehelp =changedao.UserList(cdstr,pageSize,1);
request.setAttribute("pagehelp", pagehelp);
/**跳转到人事调动综合查询页面*/
try {
request.getRequestDispatcher("ResourceChangedQuery.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* PD_DispatchQueryServlet的私有方法
* 操作符opflag为"load"时所调用的方法
* 直接调出所有的人事调动记录
* @throws IOException if an error occurred
* @throws ServletException if an error occurred
*/
private void loadItem(HttpServletRequest request, HttpServletResponse response) {
/**操作符为"query"时调出所有部门到下拉菜单*/
List deptlist=new ArrayList();
DeptInfoDAO deptdao=new DeptInfoDAO();
String depSql="";
deptlist=deptdao.queryByDepid(depSql);
request.setAttribute("deptlist", deptlist);
ChangeRecordDAO changedao=new ChangeRecordDAO();
/**使用pagehelp,调用人事调动记录表的方法*/
PageHelp pagehelp = new PageHelp();
int pageSize = 5;
pagehelp = changedao.UserList("", pageSize,1);
request.setAttribute("pagehelp", pagehelp);
/**页面跳转到人事综合查询页面*/
try {
request.getRequestDispatcher("ResourceChangedQuery.jsp").
forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* PD_DispatchQueryServlet的私有方法
* 操作符opflag为"retireCK"(意思是:退休参考)时所调用的方法
* 直接调出所有的在职员工信息记录
* @throws IOException if an error occurred
* @throws ServletException if an error occurred
*/
private void retireCK(HttpServletRequest request, HttpServletResponse response) {
ChangeRecordDAO changedao=new ChangeRecordDAO();
String cond=" and ui_retirestate is null";
PageHelp pagehelp = new PageHelp();
int pageSize = 5;
pagehelp = changedao.getList(cond, pageSize,1);
request.setAttribute("pagehelp", pagehelp);
/**页面跳转到生成退休参考表页面*/
try {
request.getRequestDispatcher("retireCenter2.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -