📄 humanfileaction.java
字号:
//更改
public ActionForward doUpdate(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
HumanFileForm humanFileForm = (HumanFileForm) form;
HumanFile humanFile=humanFileForm.getHumanFile();
//设置附加属性
this.setAppendMes(humanFile);
//获取图片
FormFile headPic=humanFileForm.getHeadPic();
String headpicname=request.getParameter("headPic");
System.out.println("图片名:"+headPic.getFileName());
if(headPic.getFileName().indexOf(".")!=-1){
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;
}
//设置图片
humanFile.setHumanPicture(fileName);
//上传图片
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();
}
}
//取更改时间
String times=request.getParameter("times");
try {
SimpleDateFormat format =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=format.parse(times);
Timestamp timestamp=new Timestamp(date.getTime());
humanFile.setChangeTime(timestamp); //设置更改时间
humanFile.setLastlyChangeTime(timestamp); //最后更改时间
if(humanFile.getFileChangAmount()==null){
humanFile.setFileChangAmount(Short.parseShort(1+"")); //设置更改次数
}else{
humanFile.setFileChangAmount(Short.parseShort(humanFile.getFileChangAmount()+1+"")); //设置更改次数
}
} catch (ParseException e) {
e.printStackTrace();
}
//设置信息状态
humanFile.setHumanFileStatus(Short.parseShort("1"));
humanFile.setCheckStatus(Short.parseShort("0"));
//设置薪酬总额
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=toUpdateFind'</script>");
return null;
}
//到删除页面
public ActionForward toDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HumanFileForm humanFileForm = (HumanFileForm) form;
HumanFile humanFile=new HumanFile();
humanFile.setCheckStatus(Short.parseShort("1"));
humanFile.setHumanFileStatus(Short.parseShort("1"));
PageResult pageResult=humanFileForm.getPageResult();
this.humanFileBiz.setPageResult(humanFile, pageResult);
return mapping.findForward("todel");
}
//删除
public ActionForward doDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
HumanFileForm humanFileForm = (HumanFileForm) form;
Short hid=Short.parseShort(request.getParameter("hid"));
HumanFile humanFile=this.humanFileBiz.findById(hid);
Date date=new Date();
humanFile.setDeleteTime(new Timestamp(date.getTime()));
humanFile.setHumanFileStatus(Short.parseShort("0"));
this.humanFileBiz.update(humanFile);
PrintWriter out=response.getWriter();
out.print("<script>alert('删除成功');location.href='humanFile.do?ophf=toDel'</script>");
return null;
}
//到恢复删除页面
public ActionForward toBackDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HumanFileForm humanFileForm = (HumanFileForm) form;
HumanFile humanFile=new HumanFile();
humanFile.setHumanFileStatus(Short.parseShort("0"));
PageResult pageResult=humanFileForm.getPageResult();
this.humanFileBiz.setPageResult(humanFile, pageResult);
return mapping.findForward("tobackdel");
}
//恢复
public ActionForward doBackDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
HumanFileForm humanFileForm = (HumanFileForm) form;
Short hid=Short.parseShort(request.getParameter("hid"));
HumanFile humanFile=this.humanFileBiz.findById(hid);
humanFile.setRecoveryTime(new Timestamp(new Date().getTime()));
humanFile.setHumanFileStatus(Short.parseShort("1"));
this.humanFileBiz.update(humanFile);
PrintWriter out=response.getWriter();
out.print("<script>alert('恢复成功');location.href='humanFile.do?ophf=toBackDel'</script>");
return null;
}
//到永久删除页面
public ActionForward toFDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HumanFileForm humanFileForm = (HumanFileForm) form;
HumanFile humanFile=new HumanFile();
humanFile.setHumanFileStatus(Short.parseShort("0"));
PageResult pageResult=humanFileForm.getPageResult();
this.humanFileBiz.setPageResult(humanFile, pageResult);
return mapping.findForward("tofdel");
}
//永久删除
public ActionForward doFDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
HumanFileForm humanFileForm = (HumanFileForm) form;
Short hid=Short.parseShort(request.getParameter("hid"));
this.humanFileBiz.del(hid);
PrintWriter out=response.getWriter();
out.print("<script>alert('信息已永久成功');location.href='humanFile.do?ophf=toFDel'</script>");
return null;
}
//查看信息
public ActionForward toShow(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
HumanFileForm humanFileForm = (HumanFileForm) form;
Short hid=Short.parseShort(request.getParameter("hid"));
HumanFile humanFile=this.humanFileBiz.findById(hid);
humanFileForm.setHumanFile(humanFile);
return mapping.findForward("toshow");
}
//员工其他信息的处理
//将要操作用户的附加信息还原
private void setAppendMes(HumanFile humanFile){
// "salary_sum" : 基本薪酬总额
if(this.humanFile.getSalarySum()!=null){
humanFile.setSalarySum(this.humanFile.getSalarySum());
}
// "demand_salaray_sum" : 应发薪酬总额
if(this.humanFile.getDemandSalaraySum()!=null){
humanFile.setDemandSalaraySum(this.humanFile.getDemandSalaraySum());
}
// "paid_salary_sum" : 实发薪酬总额
if(this.humanFile.getPaidSalarySum()!=null){
humanFile.setPaidSalarySum(this.humanFile.getPaidSalarySum());
}
// "major_change_amount" : 调动次数
if(this.humanFile.getMajorChangeAmount()!=null){
humanFile.setMajorChangeAmount(this.humanFile.getMajorChangeAmount());
}
// "bonus_amount" : 激励累计次数
if(this.humanFile.getBonusAmount()!=null){
humanFile.setBonusAmount(this.humanFile.getBonusAmount());
}
// "training_amount" : 培训累计次数
if(this.humanFile.getTrainingAmount()!=null){
humanFile.setTrainingAmount(this.humanFile.getTrainingAmount());
}
// "file_chang_amount" : 档案变更累计次数
if(this.humanFile.getFileChangAmount()!=null){
humanFile.setFileChangAmount(this.humanFile.getFileChangAmount());
}
// "attachment_name" : 附件名称
if(this.humanFile.getAttachmentName()!=null){
humanFile.setAttachmentName(this.humanFile.getAttachmentName());
}
// "change_time" : 档案变更时间
if(this.humanFile.getChangeTime()!=null){
humanFile.setChangeTime(this.humanFile.getChangeTime());
}
// "lastly_change_time" : 档案最近更改时间
if(this.humanFile.getLastlyChangeTime()!=null){
humanFile.setLastlyChangeTime(this.humanFile.getLastlyChangeTime());
}
// "delete_time" : 档案删除时间
if(this.humanFile.getDeleteTime()!=null){
humanFile.setDeleteTime(this.humanFile.getDeleteTime());
}
// "recovery_time" : 档案恢复时间
if(this.humanFile.getRecoveryTime()!=null){
humanFile.setRecoveryTime(this.humanFile.getRecoveryTime());
}
// "human_file_status" : 档案状态
if(this.humanFile.getHumanFileStatus()!=null){
humanFile.setHumanFileStatus(this.humanFile.getHumanFileStatus());
}
}
public void setStandardsBiz(IStandardsBiz standardsBiz) {
this.standardsBiz = standardsBiz;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -