SyncResumeToPreServiceEx.java 11 KB

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