|
@@ -0,0 +1,1178 @@
|
|
|
+package nc.impl.hi.psndoc;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import nc.bs.dao.BaseDAO;
|
|
|
+import nc.bs.dao.DAOException;
|
|
|
+import nc.bs.framework.common.InvocationInfoProxy;
|
|
|
+import nc.bs.framework.common.NCLocator;
|
|
|
+import nc.bs.framework.core.util.ObjectCreator;
|
|
|
+import nc.hr.frame.persistence.SimpleDocServiceTemplate;
|
|
|
+import nc.hr.utils.InSQLCreator;
|
|
|
+import nc.hr.utils.PubEnv;
|
|
|
+import nc.hr.utils.ResHelper;
|
|
|
+import nc.itf.bd.psn.psndoc.IPsndocService;
|
|
|
+import nc.itf.hi.IPersonRecordService;
|
|
|
+import nc.itf.hr.frame.IPersistenceRetrieve;
|
|
|
+import nc.itf.om.IAOSQueryService;
|
|
|
+import nc.md.persist.framework.MDPersistenceService;
|
|
|
+import nc.pub.tools.HiSQLHelper;
|
|
|
+import nc.pub.tools.VOUtils;
|
|
|
+import nc.vo.bd.psn.PsndocExtend;
|
|
|
+import nc.vo.bd.psn.PsndocVO;
|
|
|
+import nc.vo.bd.psn.PsnjobVO;
|
|
|
+import nc.vo.hi.psndoc.CertVO;
|
|
|
+import nc.vo.hi.psndoc.PartTimeVO;
|
|
|
+import nc.vo.hi.psndoc.PsnChgVO;
|
|
|
+import nc.vo.hi.psndoc.PsnJobVO;
|
|
|
+import nc.vo.hi.psndoc.PsnOrgVO;
|
|
|
+import nc.vo.hi.psndoc.PsndocAggVO;
|
|
|
+import nc.vo.hi.pub.HICommonValue;
|
|
|
+import nc.vo.hi.pub.HiEventValueObject;
|
|
|
+import nc.vo.hi.pub.IHiEventType;
|
|
|
+import nc.vo.hr.infoset.DefineMap;
|
|
|
+import nc.vo.hrcm.make.ConttypeStateVO;
|
|
|
+import nc.vo.om.pub.SuperVOHelper;
|
|
|
+import nc.vo.org.JobVO;
|
|
|
+import nc.vo.org.OrgVO;
|
|
|
+import nc.vo.org.PostVO;
|
|
|
+import nc.vo.pub.BusinessException;
|
|
|
+import nc.vo.pub.VOStatus;
|
|
|
+import nc.vo.pub.lang.UFBoolean;
|
|
|
+import nc.vo.pub.lang.UFLiteralDate;
|
|
|
+
|
|
|
+import org.apache.commons.lang.ArrayUtils;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 分组织启用HR,双向同步,HR实现类
|
|
|
+ *
|
|
|
+ * @author fengwei
|
|
|
+ */
|
|
|
+public class PsndocUAPToHRServiceImpl implements IPsndocService
|
|
|
+{
|
|
|
+
|
|
|
+ /**
|
|
|
+ * UAP开发模块号
|
|
|
+ */
|
|
|
+ public static final String uapMoudle = "baseapp";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * UAP实现类
|
|
|
+ */
|
|
|
+ public static final String uapImplClass = "nc.impl.bd.psn.psndoc.PsndocServiceImpl";
|
|
|
+
|
|
|
+ private SimpleDocServiceTemplate serviceTemplate;
|
|
|
+
|
|
|
+ private BaseDAO baseDAO;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PsndocVO insertPsndoc(PsndocVO vo, boolean isCheckRepeat) throws BusinessException
|
|
|
+ {
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ if (!PubEnv.isModuleStarted(null, PubEnv.MODULE_HRHI))
|
|
|
+ {
|
|
|
+ return service.insertPsndoc(vo, isCheckRepeat);
|
|
|
+ }
|
|
|
+ nc.vo.hi.psndoc.PsndocVO doc = nc.vo.om.aos.SuperVOHelper.createSuperVOFromSuperVO(vo, nc.vo.hi.psndoc.PsndocVO.class);
|
|
|
+ PsndocAggVO agg = NCLocator.getInstance().lookup(nc.itf.hi.IPsndocService.class).checkPsnUnique(doc, false);
|
|
|
+ if (agg != null && !agg.getParentVO().getIsuapmanage().booleanValue() && agg.getParentVO().getPsnOrgVO() != null
|
|
|
+ && agg.getParentVO().getPsnOrgVO().getEndflag() != null && !agg.getParentVO().getPsnOrgVO().getEndflag().booleanValue())
|
|
|
+ {
|
|
|
+ throw new BusinessException(ResHelper.getString("6007psn", "06007psn0479")/* "当前人员是HR系统管理的在职人员,不能再非HR管理的行政组织入职。" */);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 首先调用UAP实现方法
|
|
|
+ PsndocVO uapPsnVO = service.insertPsndoc(vo, isCheckRepeat);
|
|
|
+
|
|
|
+ // 根据uap人员信息同步hr人员信息
|
|
|
+ if (uapPsnVO.getDataoriginflag() != null && (uapPsnVO.getDataoriginflag() == 1 || uapPsnVO.getDataoriginflag() == 2))
|
|
|
+ {
|
|
|
+ // 如果是上级下发或下级上传的不处理
|
|
|
+ return uapPsnVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ // HR同步UAP新增人员
|
|
|
+ doInsertHRPsndoc(uapPsnVO, true, 1);
|
|
|
+
|
|
|
+ return MDPersistenceService.lookupPersistenceQueryService().queryBillOfVOByPK(PsndocVO.class, uapPsnVO.getPk_psndoc(), false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * HR同步UAP新增人员</p>
|
|
|
+ * <ol>
|
|
|
+ * <li>同步基本信息自定义项</li>
|
|
|
+ * <li>同步证件子集</li>
|
|
|
+ * <li>同步生成新的组织关系</li>
|
|
|
+ * <li>将UAP的工作信息同步到HR的工作信息表</li>
|
|
|
+ * <li>同步流动情况
|
|
|
+ * </ol>
|
|
|
+ *
|
|
|
+ * @param uapPsnVO
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+ private void doInsertHRPsndoc(PsndocVO uapPsnVO, boolean isSyncCert, int orgrelaid) throws BusinessException
|
|
|
+ {
|
|
|
+ PsnjobVO[] uapJobVO = uapPsnVO.getPsnjobs();
|
|
|
+ // 如果没有工作记录,直接返回
|
|
|
+ if (uapJobVO == null || uapJobVO.length == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1.同步基本信息自定义项
|
|
|
+ syncDefineAtrrs(uapPsnVO);
|
|
|
+
|
|
|
+ if (isSyncCert)
|
|
|
+ {
|
|
|
+ // 2.同步证件子集
|
|
|
+ syncCertVO(uapPsnVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.同步生成新的组织关系
|
|
|
+ // String pk_psnorg = SyncCreateOrg(uapJobVO, orgrelaid);
|
|
|
+ PsnOrgVO orgVO = SyncCreateOrg(uapJobVO, orgrelaid);
|
|
|
+
|
|
|
+ // 4.将UAP的工作信息同步到HR的工作信息表
|
|
|
+ List<PsnJobVO> jobList = syncHRPsnjobs(orgVO, uapJobVO);
|
|
|
+
|
|
|
+ PsnJobVO mainJobVO = null;
|
|
|
+ // 5.同步流动情况
|
|
|
+ for (PsnJobVO psnJobVO : jobList)
|
|
|
+ {
|
|
|
+ if (psnJobVO.getIsmainjob() == null || !psnJobVO.getIsmainjob().booleanValue())
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ mainJobVO = psnJobVO;
|
|
|
+ NCLocator.getInstance().lookup(IPersonRecordService.class).addPsnChgWhenIntoDoc(psnJobVO);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 6.同步生成一条合同状态记录
|
|
|
+ if (PubEnv.isModuleStarted(PubEnv.getPk_group(), PubEnv.MODULE_HRCM))
|
|
|
+ {
|
|
|
+
|
|
|
+ ConttypeStateVO stateVO = new ConttypeStateVO();
|
|
|
+ stateVO.setAssgid(mainJobVO.getAssgid());
|
|
|
+ stateVO.setContstate(1/* HRCMCommonValue.contstate_nomake */);
|
|
|
+ stateVO.setConttype("hi_psndoc_ctrt");
|
|
|
+ stateVO.setPk_psndoc(uapPsnVO.getPk_psndoc());
|
|
|
+ stateVO.setPk_psnorg(orgVO.getPk_psnorg());
|
|
|
+ getServiceTemplate().insert(stateVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PsndocVO updatePsndoc(PsndocVO vo, boolean isCheckRepeat) throws BusinessException
|
|
|
+ {
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ if (!PubEnv.isModuleStarted(null, PubEnv.MODULE_HRHI))
|
|
|
+ {
|
|
|
+ return service.updatePsndoc(vo, isCheckRepeat);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用此方法,可能是uap返聘业务,所以要跟普通的修改保存区分
|
|
|
+ nc.vo.hi.psndoc.PsndocVO doc = nc.vo.om.aos.SuperVOHelper.createSuperVOFromSuperVO(vo, nc.vo.hi.psndoc.PsndocVO.class);
|
|
|
+ //
|
|
|
+ PsndocAggVO agg = NCLocator.getInstance().lookup(nc.itf.hi.IPsndocService.class).checkPsnUnique(doc, false);
|
|
|
+
|
|
|
+ //对人员状态不作修改 否则会导致UAP停用不了人员 add by jiazhtb 2016.01.27
|
|
|
+ //vo.setEnablestate(IPubEnumConst.ENABLESTATE_ENABLE);
|
|
|
+ // 首先调用UAP实现方法
|
|
|
+ PsndocVO uapPsnVO = service.updatePsndoc(vo, isCheckRepeat);
|
|
|
+
|
|
|
+ if (uapPsnVO.getDataoriginflag() != null && (uapPsnVO.getDataoriginflag() == 1 || uapPsnVO.getDataoriginflag() == 2))
|
|
|
+ {
|
|
|
+ // 如果是上级下发或下级上传的不处理
|
|
|
+ return uapPsnVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ //由于人员离职,可以不停用人员,判断是否再聘,不能通过Enablestate来判断 add by jiazhtb 2015.01.27
|
|
|
+ if (agg != null && !agg.getParentVO().getIsuapmanage().booleanValue()
|
|
|
+ && agg.getParentVO().getPsnOrgVO().getEndflag().booleanValue())
|
|
|
+ {
|
|
|
+ // uap返聘业务
|
|
|
+ doInsertHRPsndocWhenRehire(uapPsnVO, false, agg.getParentVO().getPsnOrgVO().getOrgrelaid() + 1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // HR同步UAP修改人员
|
|
|
+ doUpdateHRPsndoc(uapPsnVO);
|
|
|
+ }
|
|
|
+ return MDPersistenceService.lookupPersistenceQueryService().queryBillOfVOByPK(PsndocVO.class, uapPsnVO.getPk_psndoc(), false);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * HR同步UAP修改人员
|
|
|
+ * <ol>
|
|
|
+ * <li>更新HR工作记录</li>
|
|
|
+ * <li>同步基本信息自定义项</li>
|
|
|
+ * <li>更新证件子集</li>
|
|
|
+ * <li>更新组织关系</li>
|
|
|
+ * <li>更新流动情况</li>
|
|
|
+ * <li>所有任职记录的异动时间为入职</li>
|
|
|
+ * <li>将信息同步到HR</li>
|
|
|
+ * </ol>
|
|
|
+ *
|
|
|
+ * @param uapPsnVO
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+ private void doUpdateHRPsndoc(PsndocVO uapPsnVO) throws BusinessException
|
|
|
+ {
|
|
|
+ // UAP所有工作记录
|
|
|
+ PsnjobVO[] uapJobVOs = uapPsnVO.getPsnjobs();
|
|
|
+
|
|
|
+ // 当前有效的组织关系
|
|
|
+ String strcondition = PsnOrgVO.PK_PSNDOC + " = '" + uapPsnVO.getPk_psndoc() + "' and " + PsnOrgVO.LASTFLAG + " = 'Y' ";
|
|
|
+ PsnOrgVO[] orgVOs = getServiceTemplate().queryByCondition(PsnOrgVO.class, strcondition);
|
|
|
+
|
|
|
+ //UAP传递的工作记录中,有无效数据,必须剔除
|
|
|
+ uapJobVOs = deleteInvalidJobVO(uapJobVOs,orgVOs[0]);
|
|
|
+
|
|
|
+
|
|
|
+ // 根据人员主键查出HR人员信息
|
|
|
+ PsndocAggVO psnAggVO = getServiceTemplate().queryByPk(PsndocAggVO.class, uapPsnVO.getPk_psndoc());
|
|
|
+
|
|
|
+ // 更新HR工作记录
|
|
|
+ updateHRJobVO(uapJobVOs, orgVOs, psnAggVO);
|
|
|
+
|
|
|
+ // 同步基本信息自定义项
|
|
|
+ syncDefineAtrrs(uapPsnVO);
|
|
|
+
|
|
|
+ // 更新证件子集
|
|
|
+ CertVO[] cert = (CertVO[]) psnAggVO.getTableVO(CertVO.getDefaultTableName());
|
|
|
+ if (cert != null && cert.length > 0)
|
|
|
+ {
|
|
|
+ cert[0].setIdtype(psnAggVO.getParentVO().getIdtype());
|
|
|
+ cert[0].setId(psnAggVO.getParentVO().getId());
|
|
|
+ cert[0].setStatus(VOStatus.UPDATED);
|
|
|
+
|
|
|
+ getServiceTemplate().update(cert[0], false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新psnorg,可能psnorg中没有设置hrorg
|
|
|
+ PsnJobVO mainJob = psnAggVO.getParentVO().getPsnJobVO();
|
|
|
+
|
|
|
+ orgVOs[0].setPk_group(mainJob.getPk_hrgroup());
|
|
|
+ orgVOs[0].setPk_org(mainJob.getPk_org());
|
|
|
+ orgVOs[0].setPk_hrorg(mainJob.getPk_hrorg());
|
|
|
+ orgVOs[0].setBegindate(mainJob.getBegindate());
|
|
|
+ // orgVOs[0].setEndflag(UFBoolean.FALSE);
|
|
|
+ orgVOs[0].setStatus(VOStatus.UPDATED);
|
|
|
+ getServiceTemplate().update(orgVOs[0], false);
|
|
|
+ psnAggVO.getParentVO().setPsnOrgVO(orgVOs[0]);
|
|
|
+
|
|
|
+ // 用最新工作记录更新流动情况
|
|
|
+ PsnChgVO[] psnchg = (PsnChgVO[]) psnAggVO.getTableVO(PsnChgVO.getDefaultTableName());
|
|
|
+ if (psnchg != null && psnchg.length > 0)
|
|
|
+ {
|
|
|
+ String pk_newcorp = HiSQLHelper.getPkCorpByPkOrg(mainJob.getPk_org());
|
|
|
+
|
|
|
+ // 公司发生变化
|
|
|
+ psnchg[0].setPk_corp(pk_newcorp);
|
|
|
+ psnchg[0].setBegindate(mainJob.getBegindate());
|
|
|
+ psnchg[0].setStatus(VOStatus.UPDATED);
|
|
|
+
|
|
|
+ getServiceTemplate().update(psnchg[0], false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 所有任职记录的异动时间为入职
|
|
|
+ // SuperVO[] jobs = psnAggVO.getTableVO(PsnJobVO.getDefaultTableName());
|
|
|
+ // for (int i = 0; jobs != null && i < jobs.length; i++) {
|
|
|
+ // jobs[i].setAttributeValue(PsnJobVO.TRNSEVENT, 1);// 入职
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 将信息同步到HR
|
|
|
+ // NCLocator.getInstance().lookup(nc.itf.hi.IPsndocService.class)
|
|
|
+ // .savePsndoc(psnAggVO, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void deletePsndoc(PsndocVO vo) throws BusinessException
|
|
|
+ {
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ if (!PubEnv.isModuleStarted(null, PubEnv.MODULE_HRHI))
|
|
|
+ {
|
|
|
+ service.deletePsndoc(vo);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ String pk_psndoc = vo.getPk_psndoc();
|
|
|
+ // 首先调用UAP实现方法
|
|
|
+ service.deletePsndoc(vo);
|
|
|
+
|
|
|
+ // HR同步删除人员
|
|
|
+ doDeleteHRPsndoc(pk_psndoc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void doDeleteHRPsndoc(String pk_psndoc) throws BusinessException
|
|
|
+ {
|
|
|
+ String condition = PsnJobVO.PK_PSNDOC + "= '" + pk_psndoc + "'";
|
|
|
+ // 根据人员信息主键,查出HR所有工作记录和组织关系、证件信息
|
|
|
+ PsnJobVO[] jobVOs = getServiceTemplate().queryByCondition(PsnJobVO.class, condition);
|
|
|
+
|
|
|
+ PsnJobVO mainjob = null;
|
|
|
+ if (jobVOs == null || jobVOs.length == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (PsnJobVO job : jobVOs)
|
|
|
+ {
|
|
|
+ if (job.getIsmainjob() != null && job.getIsmainjob().booleanValue())
|
|
|
+ {
|
|
|
+ mainjob = job;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除前事件
|
|
|
+ HiEventValueObject.fireEvent(mainjob, null, mainjob.getPk_hrorg(), HICommonValue.MD_ID_PSNDOC, IHiEventType.DELETE_EMPLOYEE_BEFORE);
|
|
|
+
|
|
|
+ PsnOrgVO[] orgVOs = getServiceTemplate().queryByCondition(PsnOrgVO.class, condition);
|
|
|
+ CertVO[] certVOs = getServiceTemplate().queryByCondition(CertVO.class, condition);
|
|
|
+ PsnChgVO[] psnchgVOs = getServiceTemplate().queryByCondition(PsnChgVO.class, condition);
|
|
|
+
|
|
|
+ // 删除所有组织关系
|
|
|
+ MDPersistenceService.lookupPersistenceService().deleteBillFromDB(orgVOs);
|
|
|
+ // 删除所有任职记录
|
|
|
+ MDPersistenceService.lookupPersistenceService().deleteBillFromDB(jobVOs);
|
|
|
+ // 删除所有证件信息
|
|
|
+ MDPersistenceService.lookupPersistenceService().deleteBillFromDB(certVOs);
|
|
|
+ // 删除流动情况信息
|
|
|
+ MDPersistenceService.lookupPersistenceService().deleteBillFromDB(psnchgVOs);
|
|
|
+
|
|
|
+ // 删除后事件
|
|
|
+ HiEventValueObject.fireEvent(mainjob, null, mainjob.getPk_hrorg(), HICommonValue.MD_ID_PSNDOC, IHiEventType.DELETE_EMPLOYEE_AFTER);
|
|
|
+ HiEventValueObject.fireDataPermChangeEvent(HICommonValue.MD_ID_PSNJOB);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PsndocVO disEnablePsndoc(PsndocVO vo) throws BusinessException
|
|
|
+ {
|
|
|
+ // 首先调用UAP实现方法
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ PsndocVO returnVO = service.disEnablePsndoc(vo);
|
|
|
+ return returnVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PsndocVO enablePsndoc(PsndocVO vo) throws BusinessException
|
|
|
+ {
|
|
|
+ // 首先调用UAP实现方法
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ PsndocVO returnVO = service.enablePsndoc(vo);
|
|
|
+ return returnVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ // public PsndocVO transferPsndoc(PsndocVO vo, boolean keepSrcJob) throws BusinessException
|
|
|
+ public PsndocVO transferPsndoc(PsndocVO vo) throws BusinessException
|
|
|
+ {
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ if (!PubEnv.isModuleStarted(null, PubEnv.MODULE_HRHI))
|
|
|
+ {
|
|
|
+ // return service.transferPsndoc(vo, keepSrcJob);
|
|
|
+ return service.transferPsndoc(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 首先调用UAP实现方法
|
|
|
+ // PsndocVO uapPsnVO = service.transferPsndoc(vo, keepSrcJob);
|
|
|
+ PsndocVO uapPsnVO = service.transferPsndoc(vo);
|
|
|
+
|
|
|
+ if (uapPsnVO.getDataoriginflag() != null && (uapPsnVO.getDataoriginflag() == 1 || uapPsnVO.getDataoriginflag() == 2))
|
|
|
+ {
|
|
|
+ // 如果是上级下发或下级上传的不处理
|
|
|
+ return uapPsnVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ // HR同步UAP调动人员
|
|
|
+ // 逻辑与更新相同
|
|
|
+ doUpdateHRPsndoc(uapPsnVO);
|
|
|
+
|
|
|
+ return uapPsnVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PsndocVO deletePsnJob(PsndocVO vo, String pk_org) throws BusinessException
|
|
|
+ {
|
|
|
+ // 首先调用UAP实现方法
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ PsndocVO returnVO = service.deletePsnJob(vo, pk_org);
|
|
|
+ return returnVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新HR工作记录,主职和兼职都不保留历史记录。
|
|
|
+ * <ol>
|
|
|
+ * <li>删除原HR所有任职记录(包括主职和兼职)</li>
|
|
|
+ * <li>同步工作信息到HR任职记录</li>
|
|
|
+ * <li>处理工作记录中的一些信息,将主职和兼职分别放入到psnAggVO中</li>
|
|
|
+ * </ol>
|
|
|
+ *
|
|
|
+ * @param uapJobVOs
|
|
|
+ * @param orgVOs
|
|
|
+ * @param psnAggVO
|
|
|
+ * @return
|
|
|
+ * @throws DAOException
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+ private PsndocAggVO updateHRJobVO(PsnjobVO[] uapJobVOs, PsnOrgVO[] orgVOs, PsndocAggVO psnAggVO) throws DAOException, BusinessException
|
|
|
+ {
|
|
|
+ // 删除UAP同步生成组织关系的所有HR任职记录(包括主职和兼职)
|
|
|
+ List<PsnJobVO> delMainJobVOList = new ArrayList<PsnJobVO>();
|
|
|
+ PsnJobVO[] oldMainJobVOs = (PsnJobVO[]) psnAggVO.getTableVO(PsnJobVO.getDefaultTableName());// 主职
|
|
|
+
|
|
|
+ if (!ArrayUtils.isEmpty(oldMainJobVOs))
|
|
|
+ {
|
|
|
+ for (int i = 0; i < oldMainJobVOs.length; i++)
|
|
|
+ {
|
|
|
+ if (oldMainJobVOs[i].getPk_psnorg().equals(orgVOs[0].getPk_psnorg()))
|
|
|
+ {
|
|
|
+ delMainJobVOList.add(oldMainJobVOs[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!delMainJobVOList.isEmpty())
|
|
|
+ {
|
|
|
+ getBaseDAO().deleteVOArray(delMainJobVOList.toArray(new PsnJobVO[0]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PartTimeVO> delPartJobVOList = new ArrayList<PartTimeVO>();
|
|
|
+ PartTimeVO[] oldParttimeVOs = (PartTimeVO[]) psnAggVO.getTableVO(PartTimeVO.getDefaultTableName());// 兼职
|
|
|
+ if (!ArrayUtils.isEmpty(oldParttimeVOs))
|
|
|
+ {
|
|
|
+ for (int i = 0; i < oldParttimeVOs.length; i++)
|
|
|
+ {
|
|
|
+ if (oldParttimeVOs[i].getPk_psnorg().equals(orgVOs[0].getPk_psnorg()))
|
|
|
+ {
|
|
|
+ delPartJobVOList.add(oldParttimeVOs[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!delPartJobVOList.isEmpty())
|
|
|
+ {
|
|
|
+ getBaseDAO().deleteVOArray(delPartJobVOList.toArray(new PsnJobVO[0]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 同步工作信息到HR任职记录
|
|
|
+ // List<PsnJobVO> jobList = syncHRPsnjobs(orgVOs[0].getPk_psnorg(), uapJobVOs);
|
|
|
+ List<PsnJobVO> jobList = syncHRPsnjobs(orgVOs[0], uapJobVOs);
|
|
|
+
|
|
|
+ // 处理工作记录中的一些信息,将主职和兼职分别放入到psnAggVO中
|
|
|
+ List<PsnJobVO> mainJobList = new ArrayList<PsnJobVO>();
|
|
|
+ List<PsnJobVO> parttimeList = new ArrayList<PsnJobVO>();
|
|
|
+ PsnJobVO mainJob = new PsnJobVO();
|
|
|
+ for (PsnJobVO psnJobVO : jobList)
|
|
|
+ {
|
|
|
+ if (psnJobVO.getIsmainjob().booleanValue())
|
|
|
+ {// 主职
|
|
|
+ mainJob = psnJobVO;
|
|
|
+ mainJobList.add(psnJobVO);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {// 兼职
|
|
|
+ parttimeList.add(psnJobVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ psnAggVO.setTableVO(PsnJobVO.getDefaultTableName(), mainJobList.toArray(new PsnJobVO[0]));
|
|
|
+ PartTimeVO[] partTimeVOs = SuperVOHelper.createSuperVOsFromSuperVOs(parttimeList.toArray(new PsnJobVO[0]), PartTimeVO.class);
|
|
|
+ psnAggVO.setTableVO(PartTimeVO.getDefaultTableName(), partTimeVOs);
|
|
|
+
|
|
|
+ psnAggVO.getParentVO().setPsnJobVO(mainJob);
|
|
|
+
|
|
|
+ return psnAggVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据任职记录生成新的HR工作记录,并插入数据库
|
|
|
+ *
|
|
|
+ * @param pk_psnorg 新生成的组织关系主键
|
|
|
+ * @param uapJobVOs UAP任职记录
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+ // private List<PsnJobVO> syncHRPsnjobs(String pk_psnorg, PsnjobVO[] uapJobVOs) throws BusinessException
|
|
|
+ private List<PsnJobVO> syncHRPsnjobs(PsnOrgVO orgVO, PsnjobVO[] uapJobVOs) throws BusinessException
|
|
|
+ {
|
|
|
+ String pk_psnorg = orgVO.getPk_psnorg();
|
|
|
+
|
|
|
+ // 同步工作信息自定义项
|
|
|
+ PsnJobVO[] psnJobVOs = syncJobDefine(uapJobVOs);
|
|
|
+ // 生成HR任职记录
|
|
|
+ List<PsnJobVO> jobList = new ArrayList<PsnJobVO>();
|
|
|
+ int assgid = 2;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * add by yanglt 2015-05-26 处理UAP传递给HR的人员工作记录数据,进行数据处理:
|
|
|
+ * 如果只有1条数据,判断是否有结束日期,有则再生成一条新的离职记录数据(开始日期为结束日期加1,异动事件为离职,原有的数据异动事件为入职),
|
|
|
+ * 如果有多条数据,选取开始日期最早的一条的异动事件定义为入职,其余数据的异动事件均为调配,找出开始日期最大的数据(针对这条数据进行同上处理)
|
|
|
+ *
|
|
|
+ * */
|
|
|
+ List<Object> list = handleHRPsnjobs(psnJobVOs);
|
|
|
+ List<UFLiteralDate> listdates = (List<UFLiteralDate>) list.get(0);
|
|
|
+ PsnJobVO Maxpsnjobvo = (PsnJobVO) list.get(1);
|
|
|
+ PsnJobVO Minpsnjobvo = (PsnJobVO) list.get(2);
|
|
|
+ // 处理需要生成的离职数据
|
|
|
+ if (Maxpsnjobvo.getEnddate() != null)
|
|
|
+ {
|
|
|
+ PsnJobVO newpsnjobvo = (PsnJobVO) Maxpsnjobvo.clone();
|
|
|
+ PsnJobVO psnjobquitvo = getQuitData(newpsnjobvo, assgid, pk_psnorg);
|
|
|
+ jobList.add(psnjobquitvo);
|
|
|
+
|
|
|
+ orgVO.setEndflag(UFBoolean.TRUE);
|
|
|
+ orgVO.setEnddate(Maxpsnjobvo.getEnddate());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (PsnJobVO psnJobVO : psnJobVOs)
|
|
|
+ {
|
|
|
+ if (psnJobVO.getBegindate() == null)
|
|
|
+ {
|
|
|
+ throw new BusinessException(ResHelper.getString("6007psn", "06007psn0300")/*
|
|
|
+ * @res
|
|
|
+ * "人员任职记录的到职日期为空"
|
|
|
+ */);
|
|
|
+ }
|
|
|
+ if (psnJobVO.getIsmainjob().booleanValue())
|
|
|
+ {
|
|
|
+ psnJobVO.setAssgid(Integer.valueOf(1));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ psnJobVO.setAssgid(assgid);
|
|
|
+ assgid++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (psnJobVO.getPk_job() != null)
|
|
|
+ {
|
|
|
+ psnJobVO.setSeries(getPKJobType(psnJobVO.getPk_job()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (psnJobVO.getPk_post() != null)
|
|
|
+ {
|
|
|
+ psnJobVO.setPk_postseries(getPKPostSeries(psnJobVO.getPk_post()));
|
|
|
+ }
|
|
|
+
|
|
|
+ psnJobVO.setPk_hrgroup(psnJobVO.getPk_group());
|
|
|
+ // pk_hrorg永远是最新的
|
|
|
+ psnJobVO.setPk_hrorg(getPkHrorg(psnJobVO.getPk_org()));
|
|
|
+ psnJobVO.setPk_psnorg(pk_psnorg);
|
|
|
+ psnJobVO.setPsntype(0);
|
|
|
+ List<PsnJobVO> mainjobs = new ArrayList<PsnJobVO>();
|
|
|
+ for (int i = 0; i < psnJobVOs.length; i++)
|
|
|
+ {
|
|
|
+ PsnJobVO job = psnJobVOs[i];
|
|
|
+ if (job.getIsmainjob().booleanValue())
|
|
|
+ {
|
|
|
+ mainjobs.add(job);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (psnJobVO.getIsmainjob().booleanValue())
|
|
|
+ {// 这里只处理主职,兼职不处理
|
|
|
+ if (mainjobs.size() == 1)
|
|
|
+ {// 只有一条数据时
|
|
|
+ psnJobVO.setLastflag(Maxpsnjobvo.getEnddate() == null ? UFBoolean.TRUE : UFBoolean.FALSE);
|
|
|
+ psnJobVO.setEndflag(Maxpsnjobvo.getEnddate() == null ? UFBoolean.FALSE : UFBoolean.TRUE);
|
|
|
+ psnJobVO.setRecordnum(Maxpsnjobvo.getEnddate() == null ? Integer.valueOf(listdates.size() - 1) : Integer
|
|
|
+ .valueOf(listdates.size()));
|
|
|
+ psnJobVO.setPoststat(Maxpsnjobvo.getEnddate() == null ? UFBoolean.TRUE : UFBoolean.FALSE);
|
|
|
+ psnJobVO.setTrnsevent(1);// 入职
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {// 多条数据
|
|
|
+ if (psnJobVO.getBegindate().equals(Minpsnjobvo.getBegindate()))
|
|
|
+ {// 最早的一条数据
|
|
|
+ psnJobVO.setLastflag(UFBoolean.FALSE);
|
|
|
+ psnJobVO.setEndflag(Minpsnjobvo.getEnddate() == null ? UFBoolean.FALSE : UFBoolean.TRUE);
|
|
|
+ psnJobVO.setRecordnum(Maxpsnjobvo.getEnddate() == null ? Integer.valueOf(listdates.size() - 1) : Integer
|
|
|
+ .valueOf(listdates.size()));
|
|
|
+ psnJobVO.setTrnsevent(1);// 入职
|
|
|
+ psnJobVO.setPoststat(UFBoolean.FALSE);
|
|
|
+ }
|
|
|
+ else if (psnJobVO.getBegindate().equals(Maxpsnjobvo.getBegindate()))
|
|
|
+ {// 最大的一条数据
|
|
|
+ psnJobVO.setLastflag(Maxpsnjobvo.getEnddate() == null ? UFBoolean.TRUE : UFBoolean.FALSE);
|
|
|
+ psnJobVO.setEndflag(Maxpsnjobvo.getEnddate() == null ? UFBoolean.FALSE : UFBoolean.TRUE);
|
|
|
+ psnJobVO.setRecordnum(Maxpsnjobvo.getEnddate() == null ? Integer.valueOf(0) : Integer.valueOf(1));
|
|
|
+ psnJobVO.setTrnsevent(3);// 调配
|
|
|
+ psnJobVO.setPoststat(Maxpsnjobvo.getEnddate() == null ? UFBoolean.TRUE : UFBoolean.FALSE);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {// 中间的数据
|
|
|
+ psnJobVO.setLastflag(UFBoolean.FALSE);
|
|
|
+ psnJobVO.setEndflag(Maxpsnjobvo.getEnddate() == null ? UFBoolean.FALSE : UFBoolean.TRUE);
|
|
|
+ for (int i = 0; i < listdates.size(); i++)
|
|
|
+ {
|
|
|
+ if (psnJobVO.getBegindate().equals(listdates.get(i)))
|
|
|
+ {
|
|
|
+ psnJobVO.setRecordnum(Integer.valueOf(listdates.size() - i - 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ psnJobVO.setTrnsevent(3);// 调配
|
|
|
+ psnJobVO.setPoststat(UFBoolean.FALSE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //兼职处理
|
|
|
+ if(psnJobVO.getEnddate()==null){
|
|
|
+ //如果兼职没有结束日期,则生成一条兼职的离职记录
|
|
|
+ psnJobVO.setLastflag(UFBoolean.TRUE);
|
|
|
+ psnJobVO.setEndflag(UFBoolean.FALSE);
|
|
|
+ psnJobVO.setTrnsevent(1);// 离职
|
|
|
+ psnJobVO.setPoststat(UFBoolean.TRUE);
|
|
|
+ }else{
|
|
|
+ psnJobVO.setLastflag(UFBoolean.FALSE);
|
|
|
+ psnJobVO.setEndflag(UFBoolean.TRUE);
|
|
|
+ psnJobVO.setTrnsevent(4);// 离职
|
|
|
+ psnJobVO.setPoststat(UFBoolean.FALSE);
|
|
|
+ }
|
|
|
+ psnJobVO.setRecordnum(Integer.valueOf(0));
|
|
|
+ }
|
|
|
+
|
|
|
+ int showorder = psnJobVO.getShoworder() == null ? 9999999 : psnJobVO.getShoworder();
|
|
|
+ psnJobVO.setShoworder(showorder);
|
|
|
+ if (StringUtils.isNotBlank(psnJobVO.getClerkcode()))
|
|
|
+ {
|
|
|
+ psnJobVO.setClerkcode(psnJobVO.getClerkcode().trim());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ jobList.add(psnJobVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果UAP人员有任职结束日期,则在此就将其组织关系也结束了
|
|
|
+ getServiceTemplate().update(orgVO, false);
|
|
|
+
|
|
|
+ getBaseDAO().insertVOArrayWithPK(jobList.toArray(new PsnJobVO[jobList.size()]));
|
|
|
+
|
|
|
+ return jobList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * add by yanglt 2015-05-26 处理UAP传递给HR的人员工作记录数据,进行数据处理:
|
|
|
+ * 如果只有1条数据,判断是否有结束日期,有则再生成一条新的离职记录数据(开始日期为结束日期加1,异动事件为离职,原有的数据异动事件为入职),
|
|
|
+ * 如果有多条数据,选取开始日期最早的一条的异动事件定义为入职,其余数据的异动事件均为调配,找出开始日期最大的数据(针对这条数据进行同上处理)
|
|
|
+ *
|
|
|
+ * */
|
|
|
+ public List<Object> handleHRPsnjobs(PsnJobVO[] psnJobVOs) throws BusinessException
|
|
|
+ {
|
|
|
+ List<Object> list = new ArrayList<Object>();
|
|
|
+ List<UFLiteralDate> listdates = new ArrayList<UFLiteralDate>();
|
|
|
+ PsnJobVO Maxpsnjobvo = new PsnJobVO();
|
|
|
+ PsnJobVO Minpsnjobvo = new PsnJobVO();
|
|
|
+
|
|
|
+ for (int i = 0; i < psnJobVOs.length; i++)
|
|
|
+ {
|
|
|
+ if (psnJobVOs[i].getIsmainjob().booleanValue())
|
|
|
+ listdates.add(psnJobVOs[i].getBegindate());
|
|
|
+ }
|
|
|
+ Collections.sort(listdates);
|
|
|
+
|
|
|
+ for (int j = 0; j < psnJobVOs.length; j++)
|
|
|
+ {
|
|
|
+ if (psnJobVOs[j].getIsmainjob().booleanValue())
|
|
|
+ {
|
|
|
+ if (psnJobVOs[j].getBegindate().equals(listdates.get(0)))
|
|
|
+ {
|
|
|
+ Minpsnjobvo = psnJobVOs[j];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (psnJobVOs[j].getBegindate().equals(listdates.get(listdates.size() - 1)))
|
|
|
+ {
|
|
|
+ Maxpsnjobvo = psnJobVOs[j];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(listdates);
|
|
|
+ list.add(Maxpsnjobvo);
|
|
|
+ list.add(Minpsnjobvo);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成离职的数据
|
|
|
+ public PsnJobVO getQuitData(PsnJobVO Maxpsnjobvo, int assgid, String pk_psnorg) throws BusinessException
|
|
|
+ {
|
|
|
+ if (Maxpsnjobvo.getEnddate() != null)
|
|
|
+ {
|
|
|
+ if (Maxpsnjobvo.getBegindate() == null)
|
|
|
+ {
|
|
|
+ throw new BusinessException(ResHelper.getString("6007psn", "06007psn0300")/*
|
|
|
+ * @res
|
|
|
+ * "人员任职记录的到职日期为空"
|
|
|
+ */);
|
|
|
+ }
|
|
|
+ if (Maxpsnjobvo.getIsmainjob().booleanValue())
|
|
|
+ {
|
|
|
+ Maxpsnjobvo.setAssgid(Integer.valueOf(1));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Maxpsnjobvo.setAssgid(assgid);
|
|
|
+ assgid++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Maxpsnjobvo.getPk_job() != null)
|
|
|
+ {
|
|
|
+ Maxpsnjobvo.setSeries(getPKJobType(Maxpsnjobvo.getPk_job()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Maxpsnjobvo.getPk_post() != null)
|
|
|
+ {
|
|
|
+ Maxpsnjobvo.setPk_postseries(getPKPostSeries(Maxpsnjobvo.getPk_post()));
|
|
|
+ }
|
|
|
+
|
|
|
+ Maxpsnjobvo.setBegindate(Maxpsnjobvo.getEnddate().getDateAfter(1));
|
|
|
+ Maxpsnjobvo.setEnddate(null);
|
|
|
+ Maxpsnjobvo.setPk_hrgroup(Maxpsnjobvo.getPk_group());
|
|
|
+ // pk_hrorg永远是最新的
|
|
|
+ Maxpsnjobvo.setPk_hrorg(getPkHrorg(Maxpsnjobvo.getPk_org()));
|
|
|
+ Maxpsnjobvo.setPk_psnorg(pk_psnorg);
|
|
|
+ Maxpsnjobvo.setPsntype(0);
|
|
|
+ Maxpsnjobvo.setLastflag(UFBoolean.TRUE);
|
|
|
+ Maxpsnjobvo.setEndflag(UFBoolean.TRUE);
|
|
|
+ Maxpsnjobvo.setRecordnum(Integer.valueOf(0));
|
|
|
+ Maxpsnjobvo.setTrnsevent(4);// 离职
|
|
|
+ Maxpsnjobvo.setPoststat(UFBoolean.FALSE);
|
|
|
+ Maxpsnjobvo.setPk_psnjob(null);
|
|
|
+ int showorder = Maxpsnjobvo.getShoworder() == null ? 9999999 : Maxpsnjobvo.getShoworder();
|
|
|
+ Maxpsnjobvo.setShoworder(showorder);
|
|
|
+ if (StringUtils.isNotBlank(Maxpsnjobvo.getClerkcode()))
|
|
|
+ {
|
|
|
+ Maxpsnjobvo.setClerkcode(Maxpsnjobvo.getClerkcode().trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return Maxpsnjobvo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据任职记录生成最新的组织关系
|
|
|
+ *
|
|
|
+ * @param uapJobVOs
|
|
|
+ * @param orgrelaid
|
|
|
+ * @return
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+ private PsnOrgVO SyncCreateOrg(PsnjobVO[] uapJobVOs, int orgrelaid) throws BusinessException
|
|
|
+ {
|
|
|
+ PsnOrgVO orgVO = null;
|
|
|
+ InSQLCreator isc = new InSQLCreator();
|
|
|
+ ArrayList<String> pk_psndoc_List = new ArrayList<String>();
|
|
|
+
|
|
|
+ for (PsnjobVO psnjobVO : uapJobVOs)
|
|
|
+ {
|
|
|
+ if (psnjobVO.getIsmainjob().booleanValue())
|
|
|
+ {
|
|
|
+ orgVO = SuperVOHelper.createSuperVOFromSuperVO(psnjobVO, PsnOrgVO.class);
|
|
|
+ orgVO.setOrgrelaid(orgrelaid);
|
|
|
+ orgVO.setPsntype(0);
|
|
|
+ orgVO.setBegindate(psnjobVO.getIndutydate());
|
|
|
+ orgVO.setIndocflag(UFBoolean.TRUE);
|
|
|
+ orgVO.setLastflag(UFBoolean.TRUE);
|
|
|
+ orgVO.setEndflag(UFBoolean.FALSE);
|
|
|
+ if (orgVO.getPk_hrorg() == null)
|
|
|
+ {
|
|
|
+ orgVO.setPk_hrorg(getPkHrorg(orgVO.getPk_org()));
|
|
|
+ }
|
|
|
+ pk_psndoc_List.add(psnjobVO.getPk_psndoc());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (pk_psndoc_List.size() > 0)
|
|
|
+ {
|
|
|
+ String strInSql = isc.getInSQL(pk_psndoc_List.toArray(new String[0]));
|
|
|
+ // 修改时先把该人员的私有组织关系的lastflag设置成‘N’,后面保存组织关系的时候会通过VO中的值重新设置
|
|
|
+ String strSQL =
|
|
|
+ "update " + PsnOrgVO.getDefaultTableName() + " set " + PsnOrgVO.LASTFLAG + "='" + UFBoolean.FALSE + "' where "
|
|
|
+ + PsnOrgVO.PK_PSNDOC + " in (" + strInSql + ") ";
|
|
|
+
|
|
|
+ getBaseDAO().executeUpdate(strSQL);
|
|
|
+ }
|
|
|
+ orgVO = getServiceTemplate().insert(orgVO);
|
|
|
+ // return orgVO.getPk_psnorg();
|
|
|
+ return orgVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getPkHrorg(String pkOrg) throws BusinessException
|
|
|
+ {
|
|
|
+ OrgVO org = NCLocator.getInstance().lookup(IAOSQueryService.class).queryHROrgByOrgPK(pkOrg);
|
|
|
+ if (org == null)
|
|
|
+ {
|
|
|
+ String orgName = VOUtils.getDocName(OrgVO.class, pkOrg);
|
|
|
+ throw new BusinessException(ResHelper.getString("6007psn", "06007psn0301"/*
|
|
|
+ * @res
|
|
|
+ * "业务单元[{0}]不在其所属集团的行政组织体系下,无法作为人员的任职业务单元."
|
|
|
+ */, orgName));
|
|
|
+ }
|
|
|
+ return org.getPk_org();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getPKJobType(String pk_job) throws BusinessException
|
|
|
+ {
|
|
|
+ String pk_jobtype = "";
|
|
|
+ JobVO jobVO = getServiceTemplate().queryByPk(JobVO.class, pk_job);
|
|
|
+ pk_jobtype = jobVO.getPk_jobtype();
|
|
|
+
|
|
|
+ return pk_jobtype;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getPKPostSeries(String pk_post) throws BusinessException
|
|
|
+ {
|
|
|
+ String pk_postseries = "";
|
|
|
+ PostVO postVO = getServiceTemplate().queryByPk(PostVO.class, pk_post);
|
|
|
+ pk_postseries = postVO.getPk_postseries();
|
|
|
+
|
|
|
+ return pk_postseries;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步证件子集
|
|
|
+ *
|
|
|
+ * @param uapPsnVO
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+ private void syncCertVO(PsndocVO uapPsnVO) throws BusinessException
|
|
|
+ {
|
|
|
+ nc.vo.hi.psndoc.PsndocVO psnVO = getServiceTemplate().queryByPk(nc.vo.hi.psndoc.PsndocVO.class, uapPsnVO.getPk_psndoc(), true);
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(psnVO.getCode()))
|
|
|
+ {
|
|
|
+ psnVO.setCode(psnVO.getCode().trim());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(psnVO.getName()))
|
|
|
+ {
|
|
|
+ psnVO.setName(psnVO.getName().trim());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(psnVO.getName2()))
|
|
|
+ {
|
|
|
+ psnVO.setName2(psnVO.getName2().trim());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(psnVO.getName3()))
|
|
|
+ {
|
|
|
+ psnVO.setName3(psnVO.getName3().trim());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(psnVO.getName4()))
|
|
|
+ {
|
|
|
+ psnVO.setName4(psnVO.getName4().trim());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(psnVO.getName5()))
|
|
|
+ {
|
|
|
+ psnVO.setName5(psnVO.getName5().trim());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(psnVO.getName6()))
|
|
|
+ {
|
|
|
+ psnVO.setName6(psnVO.getName6().trim());
|
|
|
+ }
|
|
|
+ getServiceTemplate().update(psnVO, false);
|
|
|
+
|
|
|
+ CertVO cert = new CertVO();
|
|
|
+ cert.setPk_psndoc(psnVO.getPk_psndoc());
|
|
|
+ cert.setIdtype(psnVO.getIdtype());
|
|
|
+ cert.setId(psnVO.getId());
|
|
|
+ cert.setIseffect(UFBoolean.TRUE);
|
|
|
+ cert.setIsstart(UFBoolean.TRUE);
|
|
|
+ cert.setStatus(VOStatus.NEW);
|
|
|
+ cert.setPk_group(psnVO.getPk_group());
|
|
|
+ cert.setPk_org(psnVO.getPk_org());
|
|
|
+ getServiceTemplate().insert(cert);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步基本信息自定义项
|
|
|
+ *
|
|
|
+ * @param uapPsnVO
|
|
|
+ * @throws DAOException
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+ private void syncDefineAtrrs(PsndocVO uapPsnVO) throws DAOException, BusinessException
|
|
|
+ {
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ Collection<DefineMap> c = getBaseDAO().retrieveByClause(DefineMap.class, DefineMap.UAP_TABLENAME + " = 'bd_psndoc'");
|
|
|
+ if (c != null && !c.isEmpty())
|
|
|
+ {
|
|
|
+ String[] srcExtraAttrs = new String[c.size()];
|
|
|
+ String[] desExtraAttrs = new String[c.size()];
|
|
|
+ DefineMap[] defineMaps = c.toArray(new DefineMap[0]);
|
|
|
+ for (int i = 0; i < defineMaps.length; i++)
|
|
|
+ {
|
|
|
+ srcExtraAttrs[i] = defineMaps[i].getPropindex();
|
|
|
+ desExtraAttrs[i] = defineMaps[i].getHr_fieldname();
|
|
|
+ }
|
|
|
+ nc.vo.hi.psndoc.PsndocVO docVO = new nc.vo.hi.psndoc.PsndocVO();
|
|
|
+ SuperVOHelper.copySuperVOAttributes(new PsndocVO[]{uapPsnVO}, new nc.vo.hi.psndoc.PsndocVO[]{docVO}, srcExtraAttrs,
|
|
|
+ desExtraAttrs, false);
|
|
|
+ getServiceTemplate().update(docVO, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步工作信息自定义项
|
|
|
+ *
|
|
|
+ * @param uapJobVOs
|
|
|
+ * @return
|
|
|
+ * @throws DAOException
|
|
|
+ */
|
|
|
+ private PsnJobVO[] syncJobDefine(PsnjobVO[] uapJobVOs) throws DAOException
|
|
|
+ {
|
|
|
+ // 将UAP工作记录转换成HR工作记录(包括主职和兼职)
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ Collection<DefineMap> c = getBaseDAO().retrieveByClause(DefineMap.class, DefineMap.UAP_TABLENAME + " = 'bd_psnjob'");
|
|
|
+ String[] srcExtraAttrs = new String[c.size() + 3];
|
|
|
+ String[] desExtraAttrs = new String[c.size() + 3];
|
|
|
+ srcExtraAttrs[0] = "psncode";
|
|
|
+ srcExtraAttrs[1] = "indutydate";
|
|
|
+ srcExtraAttrs[2] = "enddutydate";
|
|
|
+ desExtraAttrs[0] = "clerkcode";
|
|
|
+ desExtraAttrs[1] = "begindate";
|
|
|
+ desExtraAttrs[2] = "enddate";
|
|
|
+ if (c != null && !c.isEmpty())
|
|
|
+ {
|
|
|
+ DefineMap[] defineMaps = c.toArray(new DefineMap[0]);
|
|
|
+ for (int i = 0; i < defineMaps.length; i++)
|
|
|
+ {
|
|
|
+ srcExtraAttrs[i + 3] = defineMaps[i].getPropindex();
|
|
|
+ desExtraAttrs[i + 3] = defineMaps[i].getHr_fieldname();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PsnJobVO[] psnJobVOs = SuperVOHelper.createSuperVOsFromSuperVOs(uapJobVOs, PsnJobVO.class, srcExtraAttrs, desExtraAttrs, false);
|
|
|
+ return psnJobVOs;
|
|
|
+ }
|
|
|
+
|
|
|
+ private SimpleDocServiceTemplate getServiceTemplate()
|
|
|
+ {
|
|
|
+ if (serviceTemplate == null)
|
|
|
+ {
|
|
|
+ serviceTemplate = new SimpleDocServiceTemplate("SyncUAPDataToHRImpl");
|
|
|
+ }
|
|
|
+ return serviceTemplate;
|
|
|
+ }
|
|
|
+
|
|
|
+ public BaseDAO getBaseDAO()
|
|
|
+ {
|
|
|
+ if (baseDAO == null)
|
|
|
+ {
|
|
|
+ baseDAO = new BaseDAO();
|
|
|
+ }
|
|
|
+ return baseDAO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isHREnabled(String pk_org) throws BusinessException
|
|
|
+ {
|
|
|
+ // 由服务类名判断是否UAP节点进入,如果是HR节点则不进行校验 zhangqiano 2015-9-2
|
|
|
+ String busiAction = InvocationInfoProxy.getInstance().getServiceName();
|
|
|
+
|
|
|
+ // UAP接口需要判断组织是否启用HR职能,如果启用则不允许生成用户
|
|
|
+ if (null != busiAction && busiAction.equalsIgnoreCase("nc.itf.bd.psn.psndoc.IPsndocService"))
|
|
|
+ {
|
|
|
+ if (PubEnv.isModuleStarted(null, PubEnv.MODULE_HRHI))
|
|
|
+ {
|
|
|
+ int count =
|
|
|
+ NCLocator.getInstance().lookup(IPersistenceRetrieve.class)
|
|
|
+ .getCountByCondition("org_admin_enable", " pk_adminorg ='" + pk_org + "' ");
|
|
|
+ return count > 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void transferUser(PsndocVO vo, boolean innerGroup) throws BusinessException
|
|
|
+ {
|
|
|
+ // 首先调用UAP实现方法
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ service.transferUser(vo, innerGroup);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, UFBoolean> isHREnabled(String[] pk_orgs) throws BusinessException
|
|
|
+ {
|
|
|
+ if (!PubEnv.isModuleStarted(null, PubEnv.MODULE_HRHI))
|
|
|
+ {
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ return service.isHREnabled(pk_orgs);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, UFBoolean> map = new HashMap<String, UFBoolean>();
|
|
|
+ for (String pk_org : pk_orgs)
|
|
|
+ {
|
|
|
+ map.put(pk_org, UFBoolean.valueOf(isHREnabled(pk_org)));
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PsndocExtend[] createUser(PsndocExtend[] vo, String pk_userGroup, String passwordStrategy) throws BusinessException
|
|
|
+ {
|
|
|
+ // 首先调用UAP实现方法
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ PsndocExtend[] vos = service.createUser(vo, pk_userGroup, passwordStrategy);
|
|
|
+ return vos;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void transferUserCrossGroup(PsndocVO vo, boolean ParamValue) throws BusinessException
|
|
|
+ {
|
|
|
+ IPsndocService service = (IPsndocService) ObjectCreator.newInstance(uapMoudle, uapImplClass);
|
|
|
+ service.transferUserCrossGroup(vo, ParamValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * UAP 人员返聘
|
|
|
+ * @param uapPsnVO
|
|
|
+ * @param isSyncCert
|
|
|
+ * @param orgrelaid
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+ private void doInsertHRPsndocWhenRehire(PsndocVO uapPsnVO, boolean isSyncCert, int orgrelaid) throws BusinessException
|
|
|
+ {
|
|
|
+ PsnjobVO[] uapJobVO = uapPsnVO.getPsnjobs();
|
|
|
+
|
|
|
+ //除去第一条工作记录 jiazhtb
|
|
|
+ uapJobVO=deleteFirstJobVO(uapJobVO);
|
|
|
+
|
|
|
+ // 如果没有工作记录,直接返回
|
|
|
+ if (uapJobVO == null || uapJobVO.length == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1.同步基本信息自定义项
|
|
|
+ syncDefineAtrrs(uapPsnVO);
|
|
|
+
|
|
|
+ if (isSyncCert)
|
|
|
+ {
|
|
|
+ // 2.同步证件子集
|
|
|
+ syncCertVO(uapPsnVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.同步生成新的组织关系
|
|
|
+ // String pk_psnorg = SyncCreateOrg(uapJobVO, orgrelaid);
|
|
|
+ PsnOrgVO orgVO = SyncCreateOrg(uapJobVO, orgrelaid);
|
|
|
+
|
|
|
+ // 4.将UAP的工作信息同步到HR的工作信息表
|
|
|
+ List<PsnJobVO> jobList = syncHRPsnjobs(orgVO, uapJobVO);
|
|
|
+
|
|
|
+ PsnJobVO mainJobVO = null;
|
|
|
+ // 5.同步流动情况
|
|
|
+ for (PsnJobVO psnJobVO : jobList)
|
|
|
+ {
|
|
|
+ if (psnJobVO.getIsmainjob() == null || !psnJobVO.getIsmainjob().booleanValue())
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ mainJobVO = psnJobVO;
|
|
|
+ NCLocator.getInstance().lookup(IPersonRecordService.class).addPsnChgWhenIntoDoc(psnJobVO);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 6.同步生成一条合同状态记录
|
|
|
+ if (PubEnv.isModuleStarted(PubEnv.getPk_group(), PubEnv.MODULE_HRCM))
|
|
|
+ {
|
|
|
+
|
|
|
+ ConttypeStateVO stateVO = new ConttypeStateVO();
|
|
|
+ stateVO.setAssgid(mainJobVO.getAssgid());
|
|
|
+ stateVO.setContstate(1/* HRCMCommonValue.contstate_nomake */);
|
|
|
+ stateVO.setConttype("hi_psndoc_ctrt");
|
|
|
+ stateVO.setPk_psndoc(uapPsnVO.getPk_psndoc());
|
|
|
+ stateVO.setPk_psnorg(orgVO.getPk_psnorg());
|
|
|
+ getServiceTemplate().insert(stateVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * UAP人员返聘,会将HR上次组织关系下的离职记录带过来
|
|
|
+ * 该方法将离职记录从数据除去
|
|
|
+ * @author jiazhtb
|
|
|
+ *
|
|
|
+ * @param uapJobVOs uap传过来的工作记录
|
|
|
+ * @return 除去第一条工作记录后的数组
|
|
|
+ */
|
|
|
+ private PsnjobVO [] deleteFirstJobVO(PsnjobVO[] uapJobVOs) throws BusinessException{
|
|
|
+
|
|
|
+ String pk_psndoc=uapJobVOs[0].getPk_psndoc() ;
|
|
|
+ //对生成的HR工作记录进行 处理,确定是更新还是插入 jiazhtb 2016.01.19
|
|
|
+ List<PsnjobVO> insertJobs = new ArrayList<PsnjobVO>();
|
|
|
+
|
|
|
+ String condition=" pk_psndoc= '"+pk_psndoc+"' ";
|
|
|
+ PsnJobVO [] hrJobVOs;
|
|
|
+ try {
|
|
|
+ hrJobVOs= getServiceTemplate().queryByCondition(PsnJobVO.class, condition);
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ }
|
|
|
+ //根据主键和HR的工作记录,去掉HR已经存在的工作记录
|
|
|
+ if(hrJobVOs!=null&&hrJobVOs.length>0){
|
|
|
+ List<String> pk_hrPsnjobs=new ArrayList<String>();
|
|
|
+ for(int i=0;i<hrJobVOs.length;i++){
|
|
|
+ pk_hrPsnjobs.add(((PsnJobVO)hrJobVOs[i]).getPk_psnjob());
|
|
|
+ }
|
|
|
+ for(int i=0;i<uapJobVOs.length;i++){
|
|
|
+
|
|
|
+ PsnjobVO psnjobVO=uapJobVOs[i];
|
|
|
+ String pk_psnjob=psnjobVO.getPk_psnjob();
|
|
|
+ if(!pk_hrPsnjobs.contains(pk_psnjob)){
|
|
|
+
|
|
|
+ insertJobs.add(psnjobVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return insertJobs.toArray(new PsnjobVO[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return uapJobVOs;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * UAP更新人员时,传递过来的工作记录有问题需要将无效记录剔除掉
|
|
|
+ * 剔除的对象:非HR最新组织关系下的工作记录
|
|
|
+ * @author jiazhtb
|
|
|
+ * @param uapJobVOs UAP的工作记录
|
|
|
+ * @param orgVO HR最新的组织关系
|
|
|
+ */
|
|
|
+ private PsnjobVO [] deleteInvalidJobVO(PsnjobVO[] uapJobVOs,PsnOrgVO psnOrgVO) throws BusinessException{
|
|
|
+
|
|
|
+ String pk_psndoc=uapJobVOs[0].getPk_psndoc() ;
|
|
|
+ String condition=" pk_psndoc= '"+pk_psndoc+"' and pk_psnorg != '"+psnOrgVO.getPk_psnorg()+"' ";
|
|
|
+
|
|
|
+ //对生成的HR工作记录进行 处理,确定是更新还是插入 jiazhtb 2016.01.19
|
|
|
+ List<PsnjobVO> insertJobs = new ArrayList<PsnjobVO>();
|
|
|
+
|
|
|
+ PsnJobVO [] hrJobVOs;
|
|
|
+ try {
|
|
|
+ hrJobVOs= getServiceTemplate().queryByCondition(PsnJobVO.class, condition);
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ }
|
|
|
+ //根据主键和HR的工作记录,去掉HR已经存在的工作记录
|
|
|
+ if(hrJobVOs!=null&&hrJobVOs.length>0){
|
|
|
+ List<String> pk_hrPsnjobs=new ArrayList<String>();
|
|
|
+ for(int i=0;i<hrJobVOs.length;i++){
|
|
|
+ pk_hrPsnjobs.add(((PsnJobVO)hrJobVOs[i]).getPk_psnjob());
|
|
|
+ }
|
|
|
+ for(int i=0;i<uapJobVOs.length;i++){
|
|
|
+
|
|
|
+ PsnjobVO psnjobVO=uapJobVOs[i];
|
|
|
+ String pk_psnjob=psnjobVO.getPk_psnjob();
|
|
|
+ if(!pk_hrPsnjobs.contains(pk_psnjob)){
|
|
|
+
|
|
|
+ insertJobs.add(psnjobVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return insertJobs.toArray(new PsnjobVO[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return uapJobVOs;
|
|
|
+ }
|
|
|
+}
|