SyncResumeToPreServiceEx.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. package com.kingdee.shr.recuritment.service.offer;
  2. import com.kingdee.bos.BOSException;
  3. import com.kingdee.bos.Context;
  4. import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
  5. import com.kingdee.bos.metadata.data.SortType;
  6. import com.kingdee.bos.metadata.entity.*;
  7. import com.kingdee.bos.metadata.query.util.CompareType;
  8. import com.kingdee.eas.base.attachment.AttachmentInfo;
  9. import com.kingdee.eas.common.EASBizException;
  10. import com.kingdee.eas.custom.beisen.utils.HRAttachmentUploadUtil;
  11. import com.kingdee.eas.custom.recuritment.utils.AttachmentUtils;
  12. import com.kingdee.shr.attachment.ISHRAttachmentExt;
  13. import com.kingdee.shr.attachment.SHRAttachmentExtCollection;
  14. import com.kingdee.shr.attachment.SHRAttachmentExtFactory;
  15. import com.kingdee.shr.attachment.SHRAttachmentExtInfo;
  16. import com.kingdee.shr.base.syssetting.exception.SHRWebException;
  17. import com.kingdee.shr.preentry.*;
  18. import com.kingdee.shr.recuritment.*;
  19. import com.kingdee.shr.recuritment.app.util.ParamUtil;
  20. import com.kingdee.shr.recuritment.app.util.db.RecDBUtils;
  21. import com.kingdee.shr.recuritment.service.recRegister.RecRegisterService;
  22. import org.apache.commons.lang3.StringUtils;
  23. import org.apache.log4j.Logger;
  24. /**
  25. * @Description 同步简历到预入职
  26. * @Date 2025/9/18 10:28
  27. * @Created by 59279
  28. */
  29. public class SyncResumeToPreServiceEx extends SyncResumeToPreService {
  30. private Logger logger = Logger.getLogger(SyncResumeToPreServiceEx.class);
  31. /**
  32. * 根据简历信息添加新的预入职记录。
  33. * <p>
  34. * 该方法首先根据简历基础信息查询最新的招聘登记记录,如果不存在则创建一个新的招聘登记记录。
  35. * 然后基于招聘登记记录或简历信息生成预入职信息,并更新相关状态。
  36. * 同时将对应的招聘登记记录及简历标记为无效。
  37. *
  38. * @param ctx 上下文对象,用于获取业务服务实例
  39. * @param offer 包含简历和预入职相关信息的 Offer 信息对象
  40. * @param isSSC 是否为共享服务中心操作标识
  41. * @return 返回创建的预入职信息对象
  42. * @throws EASBizException 业务异常
  43. * @throws BOSException BOS框架异常
  44. * @throws SHRWebException SHR Web服务异常
  45. */
  46. public PreEntryInfo addNewPreEntryByResume(Context ctx, OfferInfo offer, boolean isSSC) throws EASBizException, BOSException, SHRWebException {
  47. // 构建查询条件:根据简历基础记录ID查找招聘登记记录
  48. EntityViewInfo view = new EntityViewInfo();
  49. FilterInfo filter = new FilterInfo();
  50. filter.getFilterItems().add(new FilterItemInfo("resumeBaseRec", offer.getResumeBaseRec().getId().toString(), CompareType.EQUALS));
  51. view.setFilter(filter);
  52. // 设置查询字段选择器,包含所有字段、人才信息和简历基础信息
  53. SelectorItemCollection selector = new SelectorItemCollection();
  54. selector.add("*");
  55. selector.add("talent.*");
  56. selector.add("resumeBaseRec.*");
  57. view.setSelector(selector);
  58. // 设置排序规则:按创建时间降序排列
  59. SorterItemCollection sorterColl = new SorterItemCollection();
  60. SorterItemInfo sorterItemInfo = new SorterItemInfo("createTime");
  61. sorterItemInfo.setSortType(SortType.DESCEND);
  62. sorterColl.add(sorterItemInfo);
  63. view.setSorter(sorterColl);
  64. // 查询招聘登记记录集合
  65. RecRegisterCollection coll = RecRegisterFactory.getLocalInstance(ctx).getRecRegisterCollection(view);
  66. // 如果未查到记录,则尝试通过简历创建新的招聘登记记录并重新查询
  67. if (RecDBUtils.isEmpty(coll)) {
  68. ResumeBaseRecInfo resumeBaseRecInfo = ResumeBaseRecFactory.getLocalInstance(ctx).getResumeBaseRecInfo("select * where id='" + offer.getResumeBaseRec().getId().toString() + "'");
  69. ResumeConvertUtilEx.addRecRegisterByResume(ctx, resumeBaseRecInfo);
  70. coll = RecRegisterFactory.getLocalInstance(ctx).getRecRegisterCollection("select *,talent.*,resumeBaseRec.* where resumeBaseRec = '" + offer.getResumeBaseRec().getId().toString() + "' order by createTime desc");
  71. }
  72. PreEntryInfo preEntryInfo = null;
  73. // 处理查询到的招聘登记记录
  74. if (coll != null && coll.size() > 0) {
  75. RecRegisterInfo recRegisterInfo = coll.get(0);
  76. // 判断是否有关联的人才信息
  77. if (recRegisterInfo.getTalent() != null) {
  78. // 若 Offer 中已有预入职信息且已设置报到状态,则直接使用
  79. if (offer.getPreEntry() != null && offer.getPreEntry().getCheckInState() != null) {
  80. preEntryInfo = offer.getPreEntry();
  81. } else {
  82. // 否则基于招聘登记信息创建新的预入职信息
  83. preEntryInfo = this.addNewPreEntryByRecRegister(ctx, recRegisterInfo, offer.getPreEntryDate(), isSSC);
  84. offer.setPreEntry(preEntryInfo);
  85. OfferFactory.getLocalInstance(ctx).update(new ObjectUuidPK(offer.getId()), offer);
  86. }
  87. } else {
  88. // 没有关联人才信息时,基于简历创建预入职信息
  89. preEntryInfo = this.addNewPreEntryByResume(ctx, offer, isSSC, preEntryInfo);
  90. }
  91. // 将当前招聘登记记录及其关联的简历标记为无效
  92. boolean result = RecRegisterService.getInstance().invalidRegister(ctx, recRegisterInfo);
  93. if (result) {
  94. recRegisterInfo.setRecRegisterState(RecRegisterStateEnum.INVALID);
  95. RecRegisterFactory.getLocalInstance(ctx).update(new ObjectUuidPK(recRegisterInfo.getId()), recRegisterInfo);
  96. ResumeBaseRecInfo resumeInfo = recRegisterInfo.getResumeBaseRec();
  97. resumeInfo.setRecRegisterState(RecRegisterStateEnum.INVALID);
  98. ResumeBaseRecFactory.getLocalInstance(ctx).update(new ObjectUuidPK(resumeInfo.getId()), resumeInfo);
  99. // 根据配置决定是否更新文件状态
  100. Integer registerEditWay = ParamUtil.getInstance().getRecRegisterEditWay(ctx);
  101. if (registerEditWay == 2) {
  102. this.updateFileStateForSubmit(ctx, recRegisterInfo.getResumeBaseRec().getId().toString());
  103. }
  104. }
  105. } else {
  106. // 无招聘登记记录时,基于简历创建预入职信息
  107. preEntryInfo = this.addNewPreEntryByResume(ctx, offer, isSSC, preEntryInfo);
  108. }
  109. // 标记简历为无效状态
  110. RecRegisterService.getInstance().invalidResume(ctx, offer.getResumeBaseRec().getId().toString());
  111. // 执行预入职后的后续处理逻辑
  112. this.afterPreEntry(ctx, offer);
  113. return preEntryInfo;
  114. }
  115. /**
  116. * 同步简历信息到预入职人员信息
  117. * <p>
  118. * 该方法用于将简历中的各项信息同步到预入职人员对象中,包括基本信息、头像、联系方式、工作经历、学历、
  119. * 项目经验、语言能力、证书等,并最终调用扩展服务完成简历与预入职人员的关联。
  120. * </p>
  121. *
  122. * @param ctx 上下文对象,用于获取服务实例和传递上下文信息
  123. * @param person 预入职人员信息对象,作为信息同步的目标对象
  124. * @param resume 简历基础信息对象,作为信息同步的来源对象
  125. */
  126. public void syncResumeToPEPerson(Context ctx, PreEntryPersonInfo person, ResumeBaseRecInfo resume) {
  127. super.syncResumeToPEPerson(ctx, person, resume);
  128. if (person != null) {
  129. logger.error("***************************同步简历附件到预入职开始***************************");
  130. //预入职id
  131. String id = person.getId().toString();
  132. //简历id
  133. String resumeId = resume.getId().toString();
  134. try {
  135. //删除简历附件
  136. String filter = "where boid = '" + id + "' and (attachment.name like '%标准简历%' or attachment.name like '%面试评价%' or attachment.name like '%原始简历%' or attachment.name like '%背景调查审批表%' )";
  137. AttachmentUtils.deleteAttachment(ctx, filter);
  138. ISHRAttachmentExt ishrAttachmentExt = SHRAttachmentExtFactory.getLocalInstance(ctx);
  139. SHRAttachmentExtCollection shrAttachmentExtCollection =
  140. ishrAttachmentExt.getSHRAttachmentExtCollection("select attachment.* where boID = '" + resumeId + "'");
  141. String uipk = "hr.preentry.resume.base";//预入职人员_基本信息
  142. for (int i = 0; i < shrAttachmentExtCollection.size(); i++) {
  143. SHRAttachmentExtInfo shrAttachmentExtInfo = shrAttachmentExtCollection.get(i);
  144. AttachmentInfo attachmentInfo = shrAttachmentExtInfo.getAttachment();
  145. if (attachmentInfo == null || attachmentInfo.getFile() == null) {
  146. continue;
  147. }
  148. String type = attachmentInfo.getSimpleName();
  149. String fileName = attachmentInfo.getName();
  150. byte[] file = attachmentInfo.getFile();
  151. //上传附件
  152. HRAttachmentUploadUtil.uploadAttachment(ctx, file, type, fileName, id, uipk, "null0");
  153. }
  154. } catch (Exception e) {
  155. logger.error(e.getMessage(), e);
  156. }
  157. logger.error("***************************同步简历附件到预入职结束***************************");
  158. }
  159. }
  160. /**
  161. * 同步人员基本信息
  162. *
  163. * @param person 人员信息对象
  164. * @param resume 简历基本信息对象
  165. * @param ctx 上下文环境
  166. * @return 同步后的人员信息对象
  167. */
  168. public PreEntryPersonInfo syncPersonBaseInfo(PreEntryPersonInfo person, ResumeBaseRecInfo resume, Context ctx) {
  169. super.syncPersonBaseInfo(person, resume, ctx);
  170. //简历id
  171. try {
  172. String resumeId = resume.getId().toString();
  173. IRecApproval iRecApproval = RecApprovalFactory.getLocalInstance(ctx);
  174. RecApprovalCollection recApprovalCollection =
  175. iRecApproval.getRecApprovalCollection("where resumeBaseRec = '" + resumeId + "'");
  176. if (!recApprovalCollection.isEmpty()) {
  177. //获取招聘审批信息
  178. RecApprovalInfo recApprovalInfo = recApprovalCollection.get(0);
  179. //获取背调信息
  180. String personalScreening = recApprovalInfo.getPersonalScreening();
  181. if (StringUtils.isNotBlank(personalScreening)) {
  182. person.put("personalScreening", personalScreening);
  183. }
  184. }
  185. } catch (BOSException e) {
  186. logger.error(e.getMessage(), e);
  187. }
  188. return person;
  189. }
  190. }