SaveBeisenApplyIdService.java 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package com.kingdee.eas.custom.recuritment.service;
  2. import com.kingdee.bos.BOSException;
  3. import com.kingdee.bos.Context;
  4. import com.kingdee.bos.bsf.service.app.IHRMsfService;
  5. import com.kingdee.bos.dao.IObjectPK;
  6. import com.kingdee.eas.common.EASBizException;
  7. import com.kingdee.eas.custom.recuritment.ApplicantBeisenCollection;
  8. import com.kingdee.eas.custom.recuritment.ApplicantBeisenFactory;
  9. import com.kingdee.eas.custom.recuritment.ApplicantBeisenInfo;
  10. import com.kingdee.eas.custom.recuritment.IApplicantBeisen;
  11. import com.kingdee.util.StringUtils;
  12. import org.apache.log4j.Logger;
  13. import java.util.HashMap;
  14. import java.util.Map;
  15. /**
  16. * 同步北森简历:写入北森申请ID和应聘ID
  17. *
  18. * @author qingwu
  19. * @date 2025/6/25
  20. * @apiNote
  21. */
  22. public class SaveBeisenApplyIdService implements IHRMsfService {
  23. private static Logger logger =
  24. Logger.getLogger(SaveBeisenApplyIdService.class);
  25. @Override
  26. public Object process(Context ctx, Map<String, Object> map) throws EASBizException, BOSException {
  27. //申请id
  28. String applyId = (String) map.get("applyId");
  29. //应聘id
  30. String candidateId = (String) map.get("candidateId");
  31. if (StringUtils.isEmpty(applyId)) {
  32. return packageResult(500, "", "申请id不能为空!");
  33. }
  34. if (StringUtils.isEmpty(candidateId)) {
  35. return packageResult(500, "", "应聘id不能为空!");
  36. }
  37. try {
  38. IApplicantBeisen iApplicantBeisen = ApplicantBeisenFactory.getLocalInstance(ctx);
  39. String where = "where applyId='" + applyId + "' or candidateId = '" + candidateId + "'";
  40. ApplicantBeisenCollection applicantBeisenCollection = iApplicantBeisen.getApplicantBeisenCollection(where);
  41. if (applicantBeisenCollection.size() > 0) {
  42. ApplicantBeisenInfo applicantBeisenInfo = applicantBeisenCollection.get(0);
  43. String applyId2 = applicantBeisenInfo.getApplyId();
  44. String candidateId2 = applicantBeisenInfo.getCandidateId();
  45. String msg = "";
  46. if (applyId2.equals(applyId)) {
  47. msg = "申请id[" + applyId + "]、";
  48. }
  49. if (candidateId2.equals(candidateId)) {
  50. msg += "应聘id[" + candidateId + "]、";
  51. }
  52. msg.substring(0, msg.length() - 1);// 删除最后一个字符
  53. msg += "重复!";
  54. return packageResult(500, "", msg);
  55. }
  56. ApplicantBeisenInfo applicantBeisenInfo = new ApplicantBeisenInfo();
  57. applicantBeisenInfo.setApplyId(applyId);
  58. applicantBeisenInfo.setCandidateId(candidateId);
  59. //String billNumber = NumberCodeRule.readCodeRuleNumber(ctx, applicantBeisenInfo, NumberCodeRule.getMainOrgByCu(ctx));
  60. //applicantBeisenInfo.setNumber(billNumber);
  61. ////需求管理
  62. //RecuritmentDemandInfo recuritmentDemandInfo = getRecuritmentByApplyId(ctx, applyId);
  63. //if (recuritmentDemandInfo != null) {
  64. // applicantBeisenInfo.setRecuritment(recuritmentDemandInfo);
  65. //}
  66. IObjectPK addnew = iApplicantBeisen.addnew(applicantBeisenInfo);
  67. if (addnew != null) {
  68. return packageResult(200, addnew.toString(), "成功");
  69. }
  70. } catch (Exception e) {
  71. e.printStackTrace();
  72. throw new RuntimeException(e);
  73. }
  74. return packageResult(500, "", "保存失败!");
  75. }
  76. ///**
  77. // * 通过申请ID获取需求管理
  78. // *
  79. // * @param applyId
  80. // */
  81. //public RecuritmentDemandInfo getRecuritmentByApplyId(Context ctx, String applyId) throws JSONException, IOException, URISyntaxException, BOSException, org.json.JSONException {
  82. // JSONObject pamas = new JSONObject();
  83. // JSONArray applyIds = new JSONArray();
  84. // applyIds.add(applyId);
  85. // pamas.put("applyIds", applyIds);
  86. // String jobId = "";
  87. // //根据申请ID获取申请信息
  88. // JSONObject applyJson = ItalentHelper.getApplyListByApplyId(pamas);
  89. // logger.error("applyJson--" + applyJson);
  90. // if (null != applyJson && applyJson.size() > 0 && "200".equals(applyJson.get("code") + "")) {
  91. // JSONArray data = applyJson.getJSONArray("data");
  92. // for (int i = 0; i < data.size(); i++) {
  93. // JSONObject applyData = data.getJSONObject(0);
  94. // //职位ID
  95. // jobId = applyData.getString("jobId");
  96. // }
  97. // } else {
  98. // logger.error("根据申请ID获取申请信息失败,原因:" + applyJson.get("message"));
  99. // }
  100. // logger.error("jobId--" + jobId);
  101. // //根据ID获取获取数据单条
  102. // JSONObject entity = ItalentHelper.getEntity(jobId);
  103. // logger.error("entity--" + entity);
  104. // JSONObject entityData = entity.getJSONObject("data");
  105. // //根据招聘需求ID获取招聘需求
  106. // JSONObject columns = entityData.getJSONObject("columns");
  107. // JSONObject recruit = columns.getJSONObject("RecruitRequirementIds");
  108. // String recruitRequirementId = recruit.getString("value");
  109. // JSONArray recruitRequirementIds = new JSONArray();
  110. // recruitRequirementIds.add(recruitRequirementId);
  111. // //根据招聘需求ID获取招聘需求
  112. // JSONObject requirements = ItalentHelper.getRequirements(recruitRequirementIds);
  113. // logger.error("requirements--" + requirements);
  114. // //一个职位可能关联多个招聘需求,建议校验需求状态,获取需求状态=进行中的招聘需求;
  115. // JSONArray data = requirements.getJSONArray("data");
  116. // //需求Id
  117. // String requirementId = "";
  118. // for (int i = 0; i < data.size(); i++) {
  119. // JSONObject requirementData = data.getJSONObject(i);
  120. // //需求状态 10=草稿,20=审批中,30=审批未通过,40=进行中,50=已关闭,60=已完成,70=已暂停,80=审批已终止
  121. // String requirementStatus = requirementData.getString("requirementStatus");
  122. // if ("40".equals(requirementStatus)) {
  123. // requirementId = requirementData.getString("requirementId");
  124. // }
  125. // }
  126. // //招聘需求
  127. // IRecuritmentDemand iRecuritmentDemand = RecuritmentDemandFactory.getLocalInstance(ctx);
  128. // //RecuritmentDemandCollection recuritmentDemandCollection = iRecuritmentDemand.getRecuritmentDemandCollection("where requirementId='" + requirementId + "");
  129. // //if (recuritmentDemandCollection.size() > 0) {
  130. // // return recuritmentDemandCollection.get(0);
  131. // //}
  132. // return null;
  133. //}
  134. /**
  135. * 封装结果
  136. *
  137. * @param code
  138. * @param number
  139. * @param msg
  140. * @return
  141. */
  142. public Map packageResult(int code, String number, String msg) {
  143. Map result = new HashMap();
  144. result.put("code", code);
  145. if (number != "") {
  146. result.put("number", number);
  147. }
  148. result.put("message", msg);
  149. return result;
  150. }
  151. }