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

📄 employeemanage.java

📁 sso呵呵
💻 JAVA
字号:
package com.mdcl.mocha.jlcmcc.employeemanage;

import java.util.List;
import java.util.Set;

import com.mdcl.mocha.bpm.business.sdk.commons.exception.BPMBusinessException;
import com.mdcl.mocha.bpm.sdk.ServiceManager;
import com.mdcl.mocha.bpm.sdk.ThreadLocalManager;
import com.mdcl.mocha.bpm.sdk.cfm.CfmConstants;
import com.mdcl.mocha.bpm.sdk.cfm.ClassificationException;
import com.mdcl.mocha.bpm.sdk.cfm.IClassificationManager;
import com.mdcl.mocha.bpm.sdk.cfm.entity.IDepot;
import com.mdcl.mocha.bpm.sdk.license.ExpiryException;
import com.mdcl.mocha.bpm.sdk.license.LicenseException;
import com.mdcl.mocha.bpm.sdk.license.NotFoundModuleException;
import com.mdcl.mocha.bpm.sdk.osm.IAccountsMgmtService;
import com.mdcl.mocha.bpm.sdk.osm.IEmpMgmtService;
import com.mdcl.mocha.bpm.sdk.osm.OsmException;
import com.mdcl.mocha.bpm.sdk.osm.entity.AccountsBean;
import com.mdcl.mocha.bpm.sdk.osm.entity.EmpBean;
import com.mdcl.mocha.bpm.sdk.osm.util.IOsmUtil;
import com.mdcl.mocha.jlcmcc.userinf.GetUserInf;

/**
 * <strong>Title : EmployeeManage<br></strong>
 * <strong>Description : </strong>吉林移动BPM人员管理impl<br>
 * <strong>Create on : 2007-9-21<br></strong>
 * <p>
 * <strong>Copyright (C) Mocha Software Co.,Ltd.<br></strong>
 * <p>
 * @author liulf@mochasoft.com.cn<br>
 * @version <strong>Mocha BPM v6.2</strong><br>
 * <br>
 * <strong>修改历史:</strong><br>
 * 修改人		修改日期		修改描述<br>
 * -------------------------------------------<br>
 * <br>
 * <br>
 */
public class EmployeeManage {

	private String DepID=null;

	/**
	 *
	 * 添加一个新用户
	 *
	 * @param empinf
	 *            <i>用户信息Bean</i>
	 * @return 成功:true 失败:false
	 * @throws LicenseException
	 * @throws ExpiryException
	 * @throws NotFoundModuleException
	 * @throws ClassificationException
	 * @throws OsmException
	 * @throws BPMBusinessException
	 */
	public boolean addEmp(BPMEmpInfBean empinf) throws NotFoundModuleException, ExpiryException, LicenseException, ClassificationException, OsmException, BPMBusinessException{
		//System.out.println("------------### add user start ###------------");
		IEmpMgmtService IEServer=(IEmpMgmtService)ServiceManager.getInstance().getService(IEmpMgmtService.class);

		//得到管理员权限
		this.getPopedom("mochaadmin");

		//获得人员组织库ID .getAllDepots();//
		IClassificationManager ICManager=(IClassificationManager)ServiceManager.getInstance().getService(IClassificationManager.class);

		List IDeplist=ICManager.getControllableDepotsByDepotType(CfmConstants.T_OSM_DEPOT_TYPE);

		IDepot t_IDep=(IDepot)IDeplist.get(0);
		//System.out.println("------------### t_IDep.getDepotId() = "+t_IDep.getDepotId()+" ###------------");

		//添加人员信息
		//System.out.println("------------### user inf = "+empinf.getEmpname()+empinf.getEmpno()+" ###------------");
		String EmpID=IEServer.addEmp(t_IDep.getDepotId(), empinf.getEmpBean());
		//System.out.println("------------### add name successful ###------------");

		//添加帐号信息
		empinf.setEmpID(EmpID);
		//System.out.println("------------### EmpID = "+EmpID+" ###------------");
		IAccountsMgmtService IAService=(IAccountsMgmtService)ServiceManager.getInstance().getService(IAccountsMgmtService.class);
		IAService.addAccounts(t_IDep.getDepotId(), empinf.getAccountsBean());
		//System.out.println("------------### add user successful ###------------");
		//System.out.println("------------### add user end ###------------");

		return true;
	}

	/**
	 *
	 * 修改用户基本信息
	 *
	 * @param empinf
	 *            <i>用户信息Bean</i>
	 * @return 成功:true 失败:false
	 * @throws LicenseException
	 * @throws ExpiryException
	 * @throws NotFoundModuleException
	 * @throws ClassificationException
	 * @throws OsmException
	 * @throws BPMBusinessException
	 */
	public boolean perfectEmp(BPMEmpInfBean empinf) throws NotFoundModuleException, ExpiryException, LicenseException, ClassificationException, OsmException, BPMBusinessException{
		boolean flag;

		System.out.println("-----------### getAddress = "+empinf.getAddress()+" ###-----------");
		System.out.println("-----------### getBirthday = "+empinf.getBirthday()+" ###-----------");
		System.out.println("-----------### getDefaultmobile = "+empinf.getDefaultmobile()+" ###-----------");
		System.out.println("-----------### getEmail = "+empinf.getEmail()+" ###-----------");
		System.out.println("-----------### getEmpno = "+empinf.getEmpno()+" ###-----------");
		System.out.println("-----------### getEmpname = "+empinf.getEmpname()+" ###-----------");
		System.out.println("-----------### getEmptype = "+empinf.getEmptype()+" ###-----------");
		System.out.println("-----------### getSex = "+empinf.getSex()+" ###-----------");

		IEmpMgmtService IEServer=(IEmpMgmtService)ServiceManager.getInstance().getService(IEmpMgmtService.class);

		//得到管理员权限
		this.getPopedom("mochaadmin");

		//获得人员组织库ID
		IClassificationManager ICManager=(IClassificationManager)ServiceManager.getInstance().getService(IClassificationManager.class);
		List IDeplist=ICManager.getControllableDepotsByDepotType(CfmConstants.T_OSM_DEPOT_TYPE);
		IDepot t_IDep=(IDepot)IDeplist.get(0);
		//System.out.println("------------### t_IDep.getDepotId() = "+t_IDep.getDepotId()+" ###------------");

		//获得人员信息
		GetUserInf guf=(GetUserInf)ServiceManager.getInstance().getService(GetUserInf.class);
		AccountsBean accBean=guf.getUserNameByDengLuZhangHu(empinf.getUserid());
		EmpBean empBean=accBean.getEmpinfo();

		//修改人员信息
		if(empinf.getAddress()!=null)empBean.setAddress(empinf.getAddress());
		if(empinf.getBirthday()!=null)empBean.setBirthday(empinf.getBirthday());
		if(empinf.getDefaultmobile()!=null)empBean.setDefaultmobile(empinf.getDefaultmobile());
		if(empinf.getEmail()!=null)empBean.setEmail(empinf.getEmail());
		if(empinf.getEmpno()!=null)empBean.setEmpno(empinf.getEmpno());
		if(empinf.getEmpname()!=null)empBean.setEmpname(empinf.getEmpname());
		if(empinf.getEmptype()!=null)empBean.setEmptype(empinf.getEmptype());
		if(empinf.getSex()!=null)empBean.setSex(empinf.getSex());
		flag=IEServer.modifyEmp(t_IDep.getDepotId(), empBean);

		return flag;
	}

	/**
	 *
	 * 修改登录密码
	 *
	 * @param empinf
	 *            <i>新密码</i>
	 * @return 成功:true 失败:false
	 * @throws LicenseException
	 * @throws ExpiryException
	 * @throws NotFoundModuleException
	 * @throws OsmException
	 * @throws ClassificationException
	 * @throws BPMBusinessException
	 */
	public boolean changePWD(BPMEmpInfBean empinf) throws NotFoundModuleException, ExpiryException, LicenseException, OsmException, ClassificationException, BPMBusinessException{
		boolean flag;

		IAccountsMgmtService IAService=(IAccountsMgmtService)ServiceManager.getInstance().getService(IAccountsMgmtService.class);

		//得到管理员权限
		this.getPopedom("mochaadmin");

		IClassificationManager ICManager=(IClassificationManager)ServiceManager.getInstance().getService(IClassificationManager.class);
		List IDeplist=ICManager.getControllableDepotsByDepotType(CfmConstants.T_OSM_DEPOT_TYPE);
		IDepot t_IDep=(IDepot)IDeplist.get(0);
		//System.out.println("------------### t_IDep.getDepotId() = "+t_IDep.getDepotId()+" ###------------");

		GetUserInf guf=(GetUserInf)ServiceManager.getInstance().getService(GetUserInf.class);
		AccountsBean accBean=guf.getUserNameByDengLuZhangHu(empinf.getUserid());
		accBean.setPassword(empinf.getNewPWD());
		flag=IAService.modifyAccounts(t_IDep.getDepotId(),accBean);

		return flag;
	}

	/**
	 *
	 * 删除用户
	 *
	 * @param empinf
	 *            <i>用户信息Bean</i>
	 * @return 成功:true 失败:false
	 * @throws LicenseException
	 * @throws ExpiryException
	 * @throws NotFoundModuleException
	 * @throws ClassificationException
	 * @throws OsmException
	 * @throws BPMBusinessException
	 */
	public boolean delAllInf(BPMEmpInfBean empinf) throws NotFoundModuleException, ExpiryException, LicenseException, ClassificationException, OsmException, BPMBusinessException{
		boolean flag;

		//获得人员信息
		GetUserInf guf=(GetUserInf)ServiceManager.getInstance().getService(GetUserInf.class);
		AccountsBean accBean=guf.getUserNameByDengLuZhangHu(empinf.getUserid());
		EmpBean empBean=accBean.getEmpinfo();

		//获得人员ID
		IEmpMgmtService IEServer=(IEmpMgmtService)ServiceManager.getInstance().getService(IEmpMgmtService.class);
		String ID=empBean.getId();

		//得到管理员权限
		this.getPopedom("mochaadmin");

		//删除帐户
		flag=delUser(empinf);

		//删除人员
		String ID_str[]=new String[1];
		ID_str[0]=ID;
		flag=IEServer.removeEmp(DepID, ID_str);

		return flag;
	}

	/**
	 *
	 * 删除用户基本信息
	 *
	 * @param empinf
	 *            <i>用户信息Bean</i>
	 * @return 成功:true 失败:false
	 * @throws LicenseException
	 * @throws ExpiryException
	 * @throws NotFoundModuleException
	 * @throws ClassificationException
	 * @throws OsmException
	 */
	private boolean delEmp(BPMEmpInfBean empinf) throws NotFoundModuleException, ExpiryException, LicenseException, ClassificationException, OsmException{
		boolean flag;

		//获得人员组织库ID
		IClassificationManager ICManager=(IClassificationManager)ServiceManager.getInstance().getService(IClassificationManager.class);
		List IDeplist=ICManager.getControllableDepotsByDepotType(CfmConstants.T_OSM_DEPOT_TYPE);
		IDepot t_IDep=(IDepot)IDeplist.get(0);
		String DepID=t_IDep.getDepotId();
		//System.out.println("------------### t_IDep.getDepotId() = "+DepID+" ###------------");

		//获得人员ID
		IEmpMgmtService IEServer=(IEmpMgmtService)ServiceManager.getInstance().getService(IEmpMgmtService.class);
		String ID=IEServer.getIdByEmpNo(empinf.getEmpno());

		//删除人员
		String ID_str[]=new String[1];
		ID_str[0]=ID;
		flag=IEServer.removeEmp(DepID, ID_str);
		return flag;
	}

	/**
	 *
	 * 删除帐户
	 *
	 * @param empinf
	 *            <i>用户信息Bean</i>
	 * @return 成功:true 失败:false
	 * @throws LicenseException
	 * @throws ExpiryException
	 * @throws NotFoundModuleException
	 * @throws ClassificationException
	 * @throws OsmException
	 */
	private boolean delUser(BPMEmpInfBean empinf) throws NotFoundModuleException, ExpiryException, LicenseException, ClassificationException, OsmException{
		boolean flag;

		//获得人员组织库ID
		IClassificationManager ICManager=(IClassificationManager)ServiceManager.getInstance().getService(IClassificationManager.class);
		List IDeplist=ICManager.getControllableDepotsByDepotType(CfmConstants.T_OSM_DEPOT_TYPE);
		IDepot t_IDep=(IDepot)IDeplist.get(0);
		DepID=t_IDep.getDepotId();
		//System.out.println("------------### t_IDep.getDepotId() = "+t_IDep.getDepotId()+" ###------------");

		//获得帐户ID
		IAccountsMgmtService IAService=(IAccountsMgmtService)ServiceManager.getInstance().getService(IAccountsMgmtService.class);
		String ID=IAService.getAccountsIdByUserID(empinf.getUserid());

		//删除帐户
		String ID_str[]=new String[1];
		ID_str[0]=ID;
		flag=IAService.removeAccounts(DepID, ID_str);

		return flag;
	}

	/**
	 *
	 * 用户登录
	 *
	 * @param user
	 *            <i>登录名</i>
	 * @throws NotFoundModuleException
	 * @throws ExpiryException
	 * @throws LicenseException
	 * @throws BPMBusinessException
	 */
	private void getPopedom(String user) throws NotFoundModuleException, ExpiryException, LicenseException, BPMBusinessException{
		//获得user的主键
		GetUserInf UI=(GetUserInf)ServiceManager.getInstance().getService(GetUserInf.class);
		AccountsBean admin=UI.getUserNameByDengLuZhangHu(user);
		String m_accountId =admin.getId();

		//登录系统
		IAccountsMgmtService t_service = (IAccountsMgmtService) ServiceManager.getInstance().getService(IAccountsMgmtService.class);
		IOsmUtil t_util = (IOsmUtil) ServiceManager.getInstance().getService(IOsmUtil.class);
		try {
			AccountsBean t_bean = t_service.getAccountsById(m_accountId);
			t_bean = t_util.getAllPrincipalByAccountId(t_bean);
			Set set = t_bean.getPrincipal();
			for (int i = 0; i < 30; i++) {
				set.add(String.valueOf(i));
			}
			t_bean.setPrincipal(set);

			ThreadLocalManager.getInstance().setCurrentUser(t_bean);

		} catch (Exception e) {
			 // TODO: handle exception
			 e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

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