设计思想:员工的入职申请审批完成,在执行后创建用户,执行的代码类为:EntrymngManageServiceImpl.java
在执行动作后添加方法去创建用户;
创建用户方法:
//(获取入职人员的主键和用户组主键——组织;运行方法创建用户:
EntryCreateUser.entryCreateUser(entrypkpsndoc, pk_userGroup));
详细代码:
EntryCreateUser EntryCreateUser=new EntryCreateUser();
String entrypkpsndoc = null;
String pk_userGroup = null;
for (int i = 0; i < retVOs.length; i++){
entrypkpsndoc =(String)retVOs[i].getParentVO().getAttributeValue("pk_psndoc");
pk_userGroup =(String)retVOs[i].getParentVO().getAttributeValue("pk_org");
}
if (entrypkpsndoc!=null && pk_userGroup!=null) {
try {
EntryCreateUser.entryCreateUser(entrypkpsndoc, pk_userGroup);
} catch (Exception e) {
Logger.error(e.getMessage(), e);
}
}
创建用户类:(主要是获取PsndocVO,通过queryPsndocByPks查询——nc.vo.bd.psn.PsndocVO[] vos = getPsndocQueryService().queryPsndocVOsByCondition(“pk_psndoc =’”+pkpsndoc+”’”);)
package nc.ui.hi.psndoc.action;
import java.util.ArrayList;
import nc.bs.framework.common.NCLocator;
import nc.itf.bd.psn.psndoc.IPsndocQueryService;
import nc.itf.hi.IPsndocService;
import nc.itf.uap.IUAPQueryBS;
import nc.vo.bd.psn.PsndocExtend;
import nc.vo.bd.psn.PsndocVO;
import nc.vo.pub.BusinessException;
public class EntryCreateUser {
private IUAPQueryBS uapQuery;
private IPsndocQueryService psndocQryService = null;
public void entryCreateUser(String pkpsndoc, String pk_userGroup)
throws BusinessException
{
PsndocVO[] vos = queryPsndocByPks(pkpsndoc);
PsndocExtend[] vosWithMes = new PsndocExtend[vos.length];
vosWithMes = (PsndocExtend[])createUser(vos, pk_userGroup);
}
private PsndocExtend[] createUser(PsndocVO[] vos, String pk_userGroup) throws BusinessException {
// TODO 自动生成的方法存根
return ((IPsndocService)NCLocator.getInstance().lookup(IPsndocService.class)).createUser((PsndocVO[]) vos, pk_userGroup);
}
private PsndocVO[] queryPsndocByPks(String pkpsndoc) throws BusinessException {
nc.vo.bd.psn.PsndocVO[] vos = getPsndocQueryService().queryPsndocVOsByCondition("pk_psndoc ='"+pkpsndoc+"'");
ArrayList<nc.vo.bd.psn.PsndocVO> al = new ArrayList();
for (int i = 0; (vos != null) && (i < vos.length); i++) {
if ((vos[i].getPsnjobs() != null) && (vos[i].getPsnjobs().length != 0)) {
al.add(vos[i]);
}
}
vos = (nc.vo.bd.psn.PsndocVO[])al.toArray(new nc.vo.bd.psn.PsndocVO[0]);
if (vos == null) {
throw new BusinessException("NULL.");
}
return vos;
}
private IPsndocQueryService getPsndocQueryService() {
// TODO 自动生成的方法存根
if (this.psndocQryService == null) {
this.psndocQryService = ((IPsndocQueryService)NCLocator.getInstance().lookup(IPsndocQueryService.class));
}
return this.psndocQryService;
}
public IUAPQueryBS getUapQuery()
{
if (this.uapQuery == null) {
this.uapQuery = ((IUAPQueryBS)NCLocator.getInstance().lookup(IUAPQueryBS.class));
}
return this.uapQuery;
}
}
原文链接:https://blog.csdn.net/hwq293/article/details/79540746