📄 modiperson.java
字号:
package com.t60.oa.service.org;
import java.util.*;
import com.t60.oa.po.DepEmp;
import com.t60.oa.po.PurView;
import com.t60.oa.web.org.ModiPersonActionForm;
import hong.javanet.dao.HibernateUtil;
import org.apache.commons.beanutils.BeanUtils;
import org.hibernate.Session;
import com.t60.oa.po.Department;
import com.t60.oa.po.Employee;
import java.text.SimpleDateFormat;
public class ModiPerson {
private ModiPersonActionForm modiform;
private List reusult;
private String message;
private static SimpleDateFormat sdf =
new SimpleDateFormat("yyyy-MM-dd");
public void ModiPerson() throws Exception
{
System.out.println("离开部门时间:"+modiform.getDepleaveTime());
System.out.println(modiform.getDepleaveTime().trim().toString().length());
System.out.println("离开公司时间:"+modiform.getLeaveTime());
System.out.println(modiform.getLeaveTime().trim().toString().length());
System.out.println("部门名字"+modiform.getDepName());
System.out.println(modiform.getDepName().trim().toString().length());
//离开部门又没有到其它部门,视为离开公司
if( modiform.getDepleaveTime().trim().toString().length()!=0 &&
modiform.getDepName().trim().toString().length()==0)
{
Session session = HibernateUtil.currentSession();
DepEmp depemp = (DepEmp)
HibernateUtil.currentSession()
.load(DepEmp.class, Integer.valueOf(modiform.getDeId()));
// Employee emp = (Employee)session.load(Employee.class, new Integer(Integer.parseInt(modiform.getEmpid())));
modiform.setState("4");
modiform.setLeaveTime(modiform.getDepleaveTime());
BeanUtils.copyProperties(depemp, modiform);
BeanUtils.copyProperties(depemp.getEmp(), modiform);
System.out.println(depemp.getEmp().getId().intValue());
PurView purview = (PurView) HibernateUtil.currentSession().load(PurView.class,
depemp.getEmp().getId());
System.out.println(modiform.getUserType());
purview.setUserType(Byte.valueOf(modiform.getUserType()));
// BeanUtils.copyProperties(purview, modiform);
// depemp.getEmp().setState(Byte.valueOf("4"));
session.update(depemp);
HibernateUtil.currentSession().update(depemp.getEmp());
HibernateUtil.currentSession().update(purview);
}
//离开改公司
if(modiform.getLeaveTime().trim().toString().length()!=0)
{
Session session = HibernateUtil.currentSession();
DepEmp depemp = (DepEmp)
HibernateUtil.currentSession()
.load(DepEmp.class, Integer.valueOf(modiform.getDeId()));
// Employee emp = (Employee)session.load(Employee.class, new Integer(Integer.parseInt(modiform.getEmpid())));
modiform.setState("4");
modiform.setDepleaveTime(modiform.getLeaveTime());
BeanUtils.copyProperties(depemp, modiform);
BeanUtils.copyProperties(depemp.getEmp(), modiform);
System.out.println(depemp.getEmp().getId().intValue());
PurView purview = (PurView) HibernateUtil.currentSession().load(PurView.class,
depemp.getEmp().getId());
System.out.println(modiform.getUserType());
purview.setUserType(Byte.valueOf(modiform.getUserType()));
// BeanUtils.copyProperties(purview, modiform);
// depemp.getEmp().setState(Byte.valueOf("4"));
//depemp.getEmp().setLeaveTime(depemp.getDepleaveTime());
session.update(depemp);
HibernateUtil.currentSession().update(depemp.getEmp());
HibernateUtil.currentSession().update(purview);
}
//不掉转,修改原有部门的信息
if( modiform.getDepleaveTime().trim().toString().length()==0 &&
modiform.getLeaveTime().trim().toString().length()==0 &&
modiform.getDepName().trim().toString().length()==0)
{
Session session = HibernateUtil.currentSession();
DepEmp depemp = (DepEmp)
HibernateUtil.currentSession()
.load(DepEmp.class, Integer.valueOf(modiform.getDeId()));
// Employee emp = (Employee)session.load(Employee.class, new Integer(Integer.parseInt(modiform.getEmpid())));
//把状态改为离退休人员,同时把离职时间也填上
if(modiform.getState().equals("4") || modiform.getState().equals("6"))
{ Date d = new Date();//System.currentTimeMillis();
System.out.println(d);
modiform.setLeaveTime(sdf.format(d));
modiform.setDepleaveTime(modiform.getLeaveTime());
}
BeanUtils.copyProperties(depemp, modiform);
BeanUtils.copyProperties(depemp.getEmp(), modiform);
System.out.println(depemp.getEmp().getId().intValue());
PurView purview = (PurView) HibernateUtil.currentSession().load(PurView.class,
depemp.getEmp().getId());
System.out.println(modiform.getUserType());
purview.setUserType(Byte.valueOf(modiform.getUserType()));
// BeanUtils.copyProperties(purview, modiform);
session.update(depemp);
HibernateUtil.currentSession().update(depemp.getEmp());
HibernateUtil.currentSession().update(purview);
}
//离开原有部门到另外一个部门
if( modiform.getDepleaveTime().trim().toString().length()!=0
&& modiform.getLeaveTime().trim().toString().length()==0
&& modiform.getDepName().trim().toString().length()!=0)
{
Session session = HibernateUtil.currentSession();
DepEmp depemp = (DepEmp)
HibernateUtil.currentSession()
.load(DepEmp.class, Integer.valueOf(modiform.getDeId()));
// Employee emp = (Employee)session.load(Employee.class, new Integer(Integer.parseInt(modiform.getEmpid())));
// Department dep = (Department) HibernateUtil.currentSession().load(
// Department.class, modiform.getDepId());
// depemp.setDep(dep);
//掉转部门后,新的部门不显示离开部门时间
// modiform.setDepleaveTime("");
BeanUtils.copyProperties(depemp, modiform);
BeanUtils.copyProperties(depemp.getEmp(), modiform);
System.out.println(depemp.getEmp().getId().intValue());
PurView purview = (PurView) HibernateUtil.currentSession().load(PurView.class,
depemp.getEmp().getId());
System.out.println(modiform.getUserType());
purview.setUserType(Byte.valueOf(modiform.getUserType()));
// BeanUtils.copyProperties(purview, modiform);
depemp.getEmp().setState(Byte.valueOf("11"));//还在该公司,离开该部门,在该部门状态为"11"
session.update(depemp);
HibernateUtil.currentSession().update(depemp.getEmp());
HibernateUtil.currentSession().update(purview);
//
Employee emp = new Employee();//员工
depemp = new DepEmp();//部门员工
Department dep = new Department();//部门
PurView pur = new PurView();//权限
BeanUtils.copyProperties(emp,modiform);//表单数据复制给持久类
BeanUtils.copyProperties(depemp,modiform);
BeanUtils.copyProperties(pur,modiform);
String id=modiform.getDepId();
depemp.setDepleaveTime("");
dep = (Department)session.load(Department.class,id);
// dep = (Department)session.load(Department.class,"0001");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -