📄 jobaction.java
字号:
package org.HumResManSys.action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.HumResManSys.actionForm.Change_jobForm;
import org.HumResManSys.factory.ServiceFactory;
import org.HumResManSys.vo.Change_job;
import org.HumResManSys.vo.Employee;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
public class JobAction extends DispatchAction {
private ServiceFactory serviceFactory;
Log log=LogFactory.getLog(JobAction.class);
//提交职位变更申请表
public ActionForward addJobChangeIntent(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
try {
//获取表单内容
Change_jobForm changeForm=(Change_jobForm)form;
String old_dept=changeForm.getOld_dept().trim();
String old_job=changeForm.getOld_job().trim();
String new_dept=changeForm.getNew_dept().trim();
String new_job=changeForm.getNew_job().trim();
String reason=changeForm.getReason().trim();
//获取员工名字
HttpSession session=request.getSession();
Employee oneEmpInfo=null;
oneEmpInfo=(Employee)session.getAttribute("oneEmpInfo");
String emp_name=oneEmpInfo.getEmp_name();
//测试
// String emp_name="wcl1";
//创建Change_job对象
Change_job changes=new Change_job();
changes.setEmp_name(emp_name);
changes.setNew_dept(new_dept);
changes.setNew_job(new_job);
changes.setOld_dept(old_dept);
changes.setOld_job(old_job);
changes.setReason(reason);
changes.setTab_state("等待");
//插入数据库
boolean OKOrNot=serviceFactory.getJobService().addJobChangeIntent(changes);
//跳转
if(OKOrNot){
request.setAttribute("dest", "EmployeeAction.do?method=displaySelfInfos");
return mapping.findForward("jump");
//return mapping.findForward("ZWSuccess");
}else{
request.setAttribute("error", "提交职位变更申请表失败!");
request.setAttribute("back2", "EmployeeAction.do?method=displaySelfInfos");
return mapping.findForward("ue");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
request.setAttribute("error", "提交职位变更申请表失败!");
request.setAttribute("back2", "EmployeeAction.do?method=displaySelfInfos");
return mapping.findForward("ue");
}
}
//显示所有职位变更申请表
public ActionForward displayAllJobChangeIntent(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
try {
List<Change_job> jobIntents=serviceFactory.getJobService().displayAllJobChangeIntents();
request.setAttribute("jobIntents", jobIntents);
return mapping.findForward("ZWadmin");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
request.setAttribute("error", "显示职位变更申请表失败!");
request.setAttribute("back2", "JobAction.do?method=displayAllJobChangeIntent");
return mapping.findForward("error");
}
}
//显示一个员工的职位变更申请表
public ActionForward getJobChangesHistory(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
try {
//获取员工名字
HttpSession session=request.getSession();
Employee oneEmpInfo=null;
oneEmpInfo=(Employee)session.getAttribute("oneEmpInfo");
String emp_name=oneEmpInfo.getEmp_name();
/*
String id=(String)request.getParameter("id");
Change_job job=serviceFactory.getJobService().displaySelfChangeIntent(id);*/
List<Change_job> jobIntents=this.getServiceFactory().getJobService().queryChange_jobsByEmp_name(emp_name);
/* List<Change_job> jobIntents=new ArrayList();
jobIntents.add(job);*/
for(Change_job c:jobIntents){
System.out.println("名字:"+c.getEmp_name()+" "+c.getTab_state());
}
request.setAttribute("jobIntents", jobIntents);
return mapping.findForward("ZWChangeHistory");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
request.setAttribute("error", "显示职位变更申请表历史失败!");
request.setAttribute("back2", "EmployeeAction.do?method=displaySelfInfos");
return mapping.findForward("error");
}
}
//显示一个员工的职位变更申请表 管理员端
public ActionForward displaySelfJobChangeIntent(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
try {
/* //获取员工名字
HttpSession session=request.getSession();
Employee oneEmpInfo=null;
oneEmpInfo=(Employee)session.getAttribute("oneEmpInfo");
String emp_name=oneEmpInfo.getEmp_name();*/
String id=(String)request.getParameter("id");
Change_job job=serviceFactory.getJobService().displaySelfChangeIntent(id);
if(job==null){
request.setAttribute("error", "显示职位变更申请表失败!");
request.setAttribute("back2", "EmployeeAction.do?method=displaySelfInfos");
return mapping.findForward("error");
}else{
List<Change_job> jobIntents=new ArrayList();
jobIntents.add(job);
/* for(Change_job c:jobIntents){
System.out.println("名字:"+c.getEmp_name()+" "+c.getTab_state());
}*/
request.setAttribute("jobIntents", jobIntents);
return mapping.findForward("ZWadminDetail");
}
//List<Change_job> jobIntents=this.getServiceFactory().getJobService().queryChange_jobsByEmp_name(emp_name);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
request.setAttribute("error", "显示职位变更申请表失败!");
request.setAttribute("back2", "EmployeeAction.do?method=displaySelfInfos");
return mapping.findForward("error");
}
}
//批准或者拒绝员工的职位变更申请表
public ActionForward detemin(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
String act=request.getParameter("act");
try {
String name= new String(request.getParameter("name").getBytes("ISO-8859-1"), "GB2312").trim();
//Change_job j=this.getServiceFactory().getJobService().queryOneChange_jobByCondition("emp_name", name);
if(act.equalsIgnoreCase("yes")){
if(this.getServiceFactory().getJobService().updateChange_job(name, "批准")){
request.setAttribute("dest", "JobAction.do?method=displayAllJobChangeIntent");
return mapping.findForward("jump");
}else{
request.setAttribute("error", "审核失败!");
request.setAttribute("back2", "JobAction.do?method=displayAllJobChangeIntent");
return mapping.findForward("error");
}
}else if(act.equalsIgnoreCase("no")){
if(this.getServiceFactory().getJobService().updateChange_job(name, "拒绝")){
request.setAttribute("dest", "JobAction.do?method=displayAllJobChangeIntent");
return mapping.findForward("jump");
}else{
request.setAttribute("error", "审核失败!");
request.setAttribute("back2", "JobAction.do?method=displayAllJobChangeIntent");
return mapping.findForward("error");
}
}else{
request.setAttribute("error", "审核失败!");
request.setAttribute("back2", "JobAction.do?method=displayAllJobChangeIntent");
return mapping.findForward("error");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
request.setAttribute("error", "审核失败!");
request.setAttribute("back2", "JobAction.do?method=displayAllJobChangeIntent");
return mapping.findForward("error");
}
}
public void setServiceFactory(ServiceFactory serviceFactory) {
this.serviceFactory = serviceFactory;
}
public ServiceFactory getServiceFactory() {
return serviceFactory;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -