⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 humanfileaction.java

📁 人力资源管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.accphr.web.action;


import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.actions.DispatchAction;
import org.apache.struts.upload.FormFile;

import com.accphr.biz.IHumanFileBiz;
import com.accphr.biz.IPublicCharBiz;
import com.accphr.biz.IStandardsBiz;
import com.accphr.entity.HumanFile;
import com.accphr.entity.Standards;
import com.accphr.page.PageResult;
import com.accphr.web.form.HumanFileForm;
import com.sun.xml.internal.bind.api.impl.NameConverter.Standard;

/** 
 * 人力资源档案管理
 * Creation date: 03-05-2009
 * 
 * XDoclet definition:
 * @struts.action path="/humanFile" name="humanFileForm" input="/WEB-INF/page/renli/humanfile_regist.jsp" parameter="ophf" scope="request" validate="true"
 * @struts.action-forward name="tocheck" path="/WEB-INF/page/renli/humanfile_check.jsp"
 * @struts.action-forward name="toregist" path="/WEB-INF/page/renli/humanfile_regist.jsp"
 * @struts.action-forward name="toupdate" path="/WEB-INF/page/renli/humanfile_update.jsp"
 * @struts.action-forward name="tolist" path="/WEB-INF/page/renli/humanfile_find.jsp"
 */
public class HumanFileAction extends DispatchAction {

	private IHumanFileBiz humanFileBiz ;
	private IStandardsBiz standardsBiz;
	private HumanFile humanFile;	//存储当前要操作对象的附加信息(薪酬,调动.....)
	public HumanFile getHumanFile() {
		return humanFile;
	}

	public void setHumanFile(HumanFile humanFile) {
		this.humanFile = humanFile;
	}

	public void setHumanFileBiz(IHumanFileBiz humanFileBiz) {
		this.humanFileBiz = humanFileBiz;
	}

	//到显示页面
	public ActionForward toList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		HumanFileForm humanFileForm = (HumanFileForm) form;
		HumanFile humanFile=humanFileForm.getHumanFile();
		PageResult pageResult=humanFileForm.getPageResult();
		this.humanFileBiz.setPageResult(humanFile, pageResult);
		return mapping.findForward("tolist");
	}
	
	//到添加页面
	public ActionForward toAdd(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		HumanFileForm humanFileForm = (HumanFileForm) form;

		return mapping.findForward("toregist");
	}
	
	//到复核页面
	public ActionForward toCheck(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		HumanFileForm humanFileForm = (HumanFileForm) form;

		Short hid=Short.parseShort(request.getParameter("hid"));
		HumanFile humanFile=this.humanFileBiz.findById(hid);
		//存储
		this.humanFile=humanFile;
		humanFileForm.setHumanFile(humanFile);
		return mapping.findForward("tocheck");
	}
	//到复核查询页面
	public ActionForward toCheckFind(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		HumanFileForm humanFileForm = (HumanFileForm) form;
		PageResult pageResult=humanFileForm.getPageResult();
		HumanFile humanFile=new HumanFile();
		humanFile.setHumanFileStatus(Short.parseShort("1"));
		humanFile.setCheckStatus(Short.parseShort("0"));
		this.humanFileBiz.setPageResult(humanFile, pageResult);
		return mapping.findForward("tocheckfind");
	}
	

	
	
	//到更改页面
	public ActionForward toUpdate(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		HumanFileForm humanFileForm = (HumanFileForm) form;
		Short hid=Short.parseShort(request.getParameter("hid"));
		HumanFile humanFile=this.humanFileBiz.findById(hid);
		//存储
		this.humanFile=humanFile;
		humanFileForm.setHumanFile(humanFile);
		return mapping.findForward("toupdate");
	}
	//到更改页面查询
	public ActionForward toUpdateFind(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		HumanFileForm humanFileForm = (HumanFileForm) form;
		PageResult pageResult=humanFileForm.getPageResult();
		HumanFile humanFile=new HumanFile();
		humanFile.setHumanFileStatus(Short.parseShort("1"));
		this.humanFileBiz.setPageResult(humanFile, pageResult);
		
		return mapping.findForward("toupdatefind");
	}
	
	//添加信息
	public ActionForward doAdd(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		HumanFileForm humanFileForm = (HumanFileForm) form;
		
		HumanFile humanFile=humanFileForm.getHumanFile();
		
		//获取图片
		FormFile headPic=humanFileForm.getHeadPic();
		String fileName=new Date().getTime()+headPic.getFileName().substring(headPic.getFileName().indexOf("."));
		//检验图片
		if(!headPic.getContentType().startsWith("image")){
			PrintWriter out=response.getWriter();
			out.print("<script>alert('图片格式不正确');location.href='humanFile.do?ophf=toAdd'</script>");
			return null;
			}
		if(headPic.getFileData().length>(2*1024*1024)){
			PrintWriter out=response.getWriter();
			out.print("<script>alert('图片太大');location.href='humanFile.do?ophf=toAdd'</script>");
			return null;
		}
		//取登记时间
		String times=request.getParameter("times");
		try {
			SimpleDateFormat format =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Date date=format.parse(times);
			//设置登记时间
			humanFile.setRegistTime(new Timestamp(date.getTime()));
		} catch (ParseException e) {
			e.printStackTrace();
		}
		//设置复核状态
		humanFile.setCheckStatus(Short.parseShort("0"));
		//设置更改状态
		humanFile.setCheckStatus(Short.parseShort("0"));
		//设置信息状态
		humanFile.setHumanFileStatus(Short.parseShort("1"));
		//设置图片
		humanFile.setHumanPicture(fileName);
		//设置薪酬总额
		if(humanFile.getSalaryStandardId()!=null){
			Standards standards=this.standardsBiz.findBySid(String.valueOf(humanFile.getSalaryStandardId()));
			humanFile.setSalarySum(standards.getSalarySum());
		}

		//添加信息
		this.humanFileBiz.add(humanFile);
		
		//上传图片		
		String up=request.getRealPath("/up")+"\\"+fileName;
			try {
				FileOutputStream out=new FileOutputStream(up);
				byte data[]=headPic.getFileData();
				out.write(data);
				out.close();
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		PrintWriter out=response.getWriter();
		out.print("<script>alert('添加成功');location.href='humanFile.do?ophf=toAdd'</script>");
		
		return null;
	}


	//复核
	public ActionForward doCheck(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		HumanFileForm humanFileForm = (HumanFileForm) form;
		HumanFile humanFile=humanFileForm.getHumanFile();
		//设置附加属性
		this.setAppendMes(humanFile);
		//取登记时间
		String times=request.getParameter("times");
		try {
			SimpleDateFormat format =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Date date=format.parse(times);
			//设置登记时间
			humanFile.setCheckTime(new Timestamp(date.getTime()));
		} catch (ParseException e) {
			e.printStackTrace();
		}
		//设置复核状态
		humanFile.setCheckStatus(Short.parseShort("1"));
		//设置信息状态
		humanFile.setHumanFileStatus(Short.parseShort("1"));
		//设置薪酬总额
		if(humanFile.getSalaryStandardId()!=null){
			Standards standards=this.standardsBiz.findBySid(String.valueOf(humanFile.getSalaryStandardId()));
			humanFile.setSalarySum(standards.getSalarySum());
		}
		//更新数据库
		this.humanFileBiz.update(humanFile);
		
		PrintWriter out=response.getWriter();
		out.print("<script>alert('复核成功');location.href='humanFile.do?ophf=toCheckFind'</script>");
		return null;
	}
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -