RecuritmentFacadeControllerBean.java 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595
  1. package com.kingdee.eas.custom.recuritment.task;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.kingdee.bos.BOSException;
  5. import com.kingdee.bos.Context;
  6. import com.kingdee.bos.dao.IObjectPK;
  7. import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
  8. import com.kingdee.bos.json.JSONTokener;
  9. import com.kingdee.bos.metadata.entity.*;
  10. import com.kingdee.bos.metadata.query.util.CompareType;
  11. import com.kingdee.bos.util.BOSUuid;
  12. import com.kingdee.eas.basedata.hraux.*;
  13. import com.kingdee.eas.basedata.org.HROrgUnitInfo;
  14. import com.kingdee.eas.basedata.person.BloodType;
  15. import com.kingdee.eas.basedata.person.Genders;
  16. import com.kingdee.eas.common.EASBizException;
  17. import com.kingdee.eas.csinterface.agent.service.base.util.DateTimeUtils;
  18. import com.kingdee.eas.custom.beisen.utils.BeisenApiClient;
  19. import com.kingdee.eas.custom.beisen.utils.BeisenParam;
  20. import com.kingdee.eas.custom.beisen.utils.BeisenParamByProperties;
  21. import com.kingdee.eas.custom.recuritment.ApplicantBeisenCollection;
  22. import com.kingdee.eas.custom.recuritment.ApplicantBeisenFactory;
  23. import com.kingdee.eas.custom.recuritment.ApplicantBeisenInfo;
  24. import com.kingdee.eas.custom.recuritment.IApplicantBeisen;
  25. import com.kingdee.eas.custom.recuritment.bizEnum.ExecuteResultEnum;
  26. import com.kingdee.eas.custom.recuritment.entity.BackInfoTableHeader;
  27. import com.kingdee.eas.custom.recuritment.utils.AttachmentUtils;
  28. import com.kingdee.eas.custom.recuritment.utils.InitialValueUtils;
  29. import com.kingdee.eas.hr.base.IRelation;
  30. import com.kingdee.eas.hr.base.RelationCollection;
  31. import com.kingdee.eas.hr.base.RelationFactory;
  32. import com.kingdee.shr.base.syssetting.app.osf.OSFAppUtil;
  33. import com.kingdee.shr.base.syssetting.exception.SHRWebException;
  34. import com.kingdee.shr.recuritment.*;
  35. import com.kingdee.shr.recuritment.service.SelectNextStageService;
  36. import com.kingdee.util.StringUtils;
  37. import org.apache.commons.lang3.ObjectUtils;
  38. import org.apache.log4j.Logger;
  39. import org.apache.logging.log4j.util.TriConsumer;
  40. import java.io.FileInputStream;
  41. import java.io.IOException;
  42. import java.io.InputStreamReader;
  43. import java.nio.file.Files;
  44. import java.nio.file.Paths;
  45. import java.text.ParseException;
  46. import java.time.LocalDate;
  47. import java.time.LocalDateTime;
  48. import java.time.format.DateTimeFormatter;
  49. import java.util.*;
  50. public class RecuritmentFacadeControllerBean extends AbstractRecuritmentFacadeControllerBean {
  51. private static final Logger logger = Logger.getLogger(RecuritmentFacadeControllerBean.class);
  52. // 北京时区/shanghai时区
  53. // private static final ZoneId BEIJING_ZONE = ZoneId.of("Asia/Shanghai");
  54. private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  55. Map<String, String> configMap = new HashMap<>();
  56. private Properties propt = new Properties();//共用参数
  57. //背景调查表头字段
  58. JSONObject json = new JSONObject();
  59. //背景调查表头ID
  60. String applyIdNumber = "";
  61. /**
  62. * @throws IOException
  63. */
  64. public RecuritmentFacadeControllerBean() throws IOException {
  65. String filePath = System.getProperty("EAS_HOME") + "/server/properties/beisen/beisenConfig.properties";
  66. try (InputStreamReader reader = new InputStreamReader(new FileInputStream(filePath), "UTF-8")) {
  67. this.propt.load(reader);
  68. } catch (IOException e) {
  69. e.printStackTrace();
  70. logger.error("未找到" + filePath + "配置文件。");
  71. throw e;
  72. }
  73. Set<Map.Entry<Object, Object>> set = this.propt.entrySet();
  74. for (Map.Entry<Object, Object> entry : set) {
  75. configMap.put((String) entry.getKey(), (String) entry.getValue());
  76. }
  77. try {
  78. // 使用Files.readAllBytes读取文件内容,然后转换为字符串
  79. byte[] bytes = Files.readAllBytes(Paths.get(System.getProperty("EAS_HOME") + "/server/properties/beisen/backInfoTableHeader.json"));
  80. String content = new String(bytes);
  81. // 使用JSONTokener解析JSON内容
  82. JSONTokener tokener = new JSONTokener(content);
  83. com.kingdee.bos.json.JSONArray array = (com.kingdee.bos.json.JSONArray) tokener.nextValue();
  84. for (int i = 0; i < array.length(); i++) {
  85. com.kingdee.bos.json.JSONObject jsonObject = array.getJSONObject(i);
  86. String title = jsonObject.getString("title");
  87. String id = jsonObject.getString("id");
  88. boolean isStorage = jsonObject.getBoolean("isStorage");
  89. json.put(id, new BackInfoTableHeader(title, id, isStorage));
  90. if ("申请ID".equals(title)) {
  91. applyIdNumber = id;
  92. }
  93. }
  94. } catch (Exception e) {
  95. e.printStackTrace();
  96. }
  97. }
  98. /**
  99. * 同步北森简历和附件
  100. *
  101. * @param ctx
  102. * @param billId 单据ID
  103. * @throws BOSException
  104. * @throws EASBizException
  105. */
  106. @Override
  107. protected void _syncBeisenResume(Context ctx, String billId) throws BOSException, EASBizException {
  108. super._syncBeisenResume(ctx, billId);
  109. IResumeBaseRec iResumeBaseRec = ResumeBaseRecFactory.getLocalInstance(ctx);
  110. logger.error("billId" + billId);
  111. //北森应聘者
  112. IApplicantBeisen iApplicantBeisen = ApplicantBeisenFactory.getLocalInstance(ctx);
  113. FilterInfo filterInfo = new FilterInfo();
  114. FilterItemCollection filterItems = filterInfo.getFilterItems();
  115. if (!StringUtils.isEmpty(billId)) {
  116. filterItems.add(new FilterItemInfo("id", billId));
  117. } else {
  118. filterItems.add(new FilterItemInfo("syncStatus", "0"));
  119. }
  120. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, null, null);
  121. ApplicantBeisenCollection applicantBeisenCollection = iApplicantBeisen.getApplicantBeisenCollection(entityViewInfo);
  122. //同步结果
  123. int errorSize = 0;
  124. int successSize = 0;
  125. Map msgMap = new HashMap();
  126. for (int i = 0; i < applicantBeisenCollection.size(); i++) {
  127. ApplicantBeisenInfo applicantBeisenInfo = applicantBeisenCollection.get(i);
  128. //申请id
  129. String applyId = applicantBeisenInfo.getApplyId();
  130. //应聘者id
  131. String candidateId = applicantBeisenInfo.getCandidateId();
  132. try {
  133. ResumeBaseRecCollection collection = iResumeBaseRec.getResumeBaseRecCollection("select * ,resumeState.number where applyId = '" + applyId + "'");
  134. // 1. 获取简历基础信息
  135. //ResumeBaseRecInfo resumeInfo = collection.get(0);
  136. ResumeBaseRecInfo resumeInfo = null;
  137. if (!collection.isEmpty()) {
  138. resumeInfo = collection.get(0);
  139. if (!"0001".equals(resumeInfo.getResumeState().getNumber())) {
  140. // 非待筛选不同步
  141. continue;
  142. }
  143. } else {
  144. resumeInfo = new ResumeBaseRecInfo();
  145. resumeInfo.put("applyId", applyId);
  146. resumeInfo.put("candidateId", candidateId);
  147. }
  148. //通过申请ID获取招聘需求
  149. RecuritmentDemandInfo recuritmentDemandInfo = getRecuritmentByApplyId(ctx, applyId);
  150. //招聘需求
  151. resumeInfo.setRecuritmentDemand(recuritmentDemandInfo);
  152. //招聘职位
  153. resumeInfo.setDepartment(recuritmentDemandInfo.getDepartment());
  154. //招聘部门
  155. resumeInfo.setRecuritPosition(recuritmentDemandInfo.getRecuritPosition());
  156. //北森应聘者-需求管理
  157. applicantBeisenInfo.setRecuritment(recuritmentDemandInfo);
  158. //招聘需求名称
  159. //applicantBeisenInfo.setRecuritmentName(recuritmentDemandInfo.getPositionName());
  160. // 2. 获取 标准简历数据
  161. JSONObject resumeJson = getResumeByApplyId(applyId);
  162. logger.error("resumeJson--" + resumeJson);
  163. Integer code = resumeJson.getInteger("code");
  164. if (200 == code) {
  165. JSONObject data = resumeJson.getJSONObject("data");
  166. // 3. 处理简历各部分数据
  167. Map<String, String> mapData = processResumeSections(ctx, data, resumeInfo);
  168. //北森应聘者--应聘者名称
  169. applicantBeisenInfo.setCandidateName(mapData.get("name"));
  170. //删除附件信息
  171. String where = "where boid = '" + resumeInfo.getId().toString() + "' and (attachment.name like '%标准简历%' or attachment.name like '%面试评价%' or attachment.name like '%原始简历%' )";
  172. AttachmentUtils.deleteAttachment(ctx, where);
  173. // 根据申请Id获取并处理简历文件
  174. processResumeFile(applyId, ctx, resumeInfo, "标准简历");
  175. // 获取并处理面试评价文件
  176. processResumeFile(applyId, ctx, resumeInfo, "面试评价");
  177. // 获取并处理原始简历文件
  178. processResumeFile(applyId, ctx, resumeInfo, "原始简历");
  179. // 获取并处理背调信息文件
  180. processResumeFile(applyId, ctx, resumeInfo, "背景调查审批表");
  181. //生成录用报批
  182. //String errorMsg = saveRecApproval(ctx, mapData);
  183. String serviceName = "generateHireApprovalService";
  184. Map param = new HashMap();
  185. param.put("resumeBaseRecId", mapData.get("resumeBaseRecId").toString());
  186. String errorMsg = (String) OSFAppUtil.callService(ctx, serviceName, param);
  187. //String errorMsg = null;
  188. if (com.kingdee.bos.rabbitmq.util.StringUtils.isEmpty(errorMsg)) {
  189. //修改录用报批数据
  190. updateApproval(ctx, mapData, applyId);
  191. //修复简历数据
  192. updateResumeBaseRe(ctx, iResumeBaseRec, mapData.get("resumeBaseRecId").toString());
  193. //中间表成功信息
  194. applicantBeisenInfo.setSyncResult("同步成功!");
  195. applicantBeisenInfo.setSyncStatus(ExecuteResultEnum.SUCCESS);
  196. successSize++;
  197. //返回给北森信息
  198. pushMessageToBeisen(applyId, "同步成功");
  199. } else {
  200. throw new BOSException(errorMsg.toString());
  201. }
  202. } else {
  203. throw new BOSException(resumeJson.getString("message"));
  204. }
  205. iApplicantBeisen.save(applicantBeisenInfo);
  206. } catch (Exception e) {
  207. e.printStackTrace();
  208. pushMessageToBeisen(applyId, e.getMessage());
  209. applicantBeisenInfo.setSyncStatus(ExecuteResultEnum.ERROR);
  210. applicantBeisenInfo.setSyncResult("简历处理失败: " + e.getMessage());
  211. iApplicantBeisen.save(applicantBeisenInfo);
  212. errorSize++;
  213. logger.error("简历处理失败: " + e.getMessage(), e);
  214. msgMap.put("error", e.getMessage());
  215. }
  216. }
  217. logger.error("成功条数" + successSize);
  218. logger.error("失败条数" + errorSize);
  219. msgMap.put("successSize", successSize);
  220. msgMap.put("errorSize", errorSize);
  221. //return msgMap;
  222. }
  223. /**
  224. * 修复简历数据
  225. *
  226. * @param ctx
  227. * @param iResumeBaseRec
  228. * @param resumeBaseRecId
  229. * @throws BOSException
  230. * @throws EASBizException
  231. */
  232. public void updateResumeBaseRe(Context ctx, IResumeBaseRec iResumeBaseRec, String resumeBaseRecId) throws BOSException, EASBizException {
  233. ResumeBaseRecInfo resumeBaseRecInfo = iResumeBaseRec.getResumeBaseRecInfo(new ObjectUuidPK(resumeBaseRecId));
  234. IWorkingExp iWorkingExp = WorkingExpFactory.getLocalInstance(ctx);
  235. WorkingExpCollection workingExpColl = iWorkingExp.getWorkingExpCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "' order by dateEnd desc");
  236. if (!workingExpColl.isEmpty()) {
  237. WorkingExpInfo workingExpInfo = workingExpColl.get(0);
  238. //职位
  239. resumeBaseRecInfo.setLastJob(workingExpInfo.getPosition());
  240. //公司
  241. resumeBaseRecInfo.setLastCompany(workingExpInfo.getCompany());
  242. //行业
  243. resumeBaseRecInfo.setLastIndustry(workingExpInfo.getIndustry());
  244. }
  245. SelectorItemCollection sic = new SelectorItemCollection();
  246. sic.add("lastJob");
  247. sic.add("lastCompany");
  248. sic.add("lastIndustry");
  249. iResumeBaseRec.updatePartial(resumeBaseRecInfo, sic);
  250. }
  251. /**
  252. * 修改录用报批数据
  253. *
  254. * @param ctx
  255. * @param mapData
  256. */
  257. public void updateApproval(Context ctx, Map<String, String> mapData, String applyId) throws BOSException, EASBizException, IOException {
  258. logger.error("updateApproval--");
  259. //简历ID
  260. String resumeBaseRecId = mapData.get("resumeBaseRecId");
  261. logger.error("简历ID" + resumeBaseRecId);
  262. //获取录用报批 通过结束日期排序 获取最高学历
  263. IRecApproval iRecApproval = RecApprovalFactory.getLocalInstance(ctx);
  264. RecApprovalCollection recApprovalCollection = iRecApproval.getRecApprovalCollection("where resumeBaseRec = '" + resumeBaseRecId + "'");
  265. if (recApprovalCollection.isEmpty()) {
  266. throw new BOSException("未查询到录用报批数据!");
  267. }
  268. SelectorItemCollection sic = new SelectorItemCollection();
  269. sic.add("firsteducation");
  270. sic.add("firstspeciality");
  271. sic.add("firstschool");
  272. sic.add("personalScreening");
  273. RecApprovalInfo recApprovalInfo = recApprovalCollection.get(0);
  274. //查询简历-教育经历数据
  275. IEducationExpREC iEducationExpREC = EducationExpRECFactory.getLocalInstance(ctx);
  276. EducationExpRECCollection educationExpRECCollection = iEducationExpREC.getEducationExpRECCollection("where resumeBase = '" + resumeBaseRecId + "' order by dateEnd desc");
  277. if (!educationExpRECCollection.isEmpty()) {
  278. EducationExpRECInfo educationExpRECInfo = educationExpRECCollection.get(0);
  279. //第一学历
  280. recApprovalInfo.put("firsteducation", educationExpRECInfo.getDegreeF7().getId());
  281. //专业
  282. recApprovalInfo.put("firstspeciality", educationExpRECInfo.getMajor());
  283. //毕业院校
  284. recApprovalInfo.put("firstschool", educationExpRECInfo.getSchool());
  285. iRecApproval.updatePartial(recApprovalInfo, sic);
  286. }
  287. //背调信息
  288. String reportId = configMap.get("reportId");
  289. String param = "?page=1&pageSize=100&reportId=" + reportId;
  290. BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  291. logger.error("updateApproval--param--" + param);
  292. JSONObject jsonObject = beisenApiClient.callGetApi(BeisenParam.GET_GRIDDATA + param, new JSONObject());
  293. //JSONObject jsonObject = beisenApiClient.callGetApi("https://openapi.italent.cn/Ocean/api/v2/Reports/GridData" + param, new JSONObject());
  294. logger.error("updateApproval--jsonObject--" + jsonObject);
  295. if (jsonObject.getInteger("code") == 200) {
  296. JSONObject data = jsonObject.getJSONObject("data");
  297. JSONArray datas = data.getJSONArray("datas");
  298. StringBuffer sb = new StringBuffer();
  299. for (int i = 0; i < datas.size(); i++) {
  300. JSONObject datasJSONObject = datas.getJSONObject(i);
  301. logger.error("updateApproval--datasJSONObject--" + datasJSONObject);
  302. logger.error("updateApproval--json--" + json);
  303. logger.error("updateApproval--applyIdNumber--" + applyIdNumber);
  304. //判断申请ID是否一致
  305. if (datasJSONObject.getString(applyIdNumber).equals(applyId)) {
  306. sb.append(datas.size() > 1 ? ("背调信息" + (i + 1) + "\n") : "");
  307. for (String key : datasJSONObject.keySet()) {
  308. if (json.containsKey(key)) {
  309. //获取表头
  310. BackInfoTableHeader backInfoTableHeader = (BackInfoTableHeader) json.get(key);
  311. String title = backInfoTableHeader.getTitle();
  312. String id = backInfoTableHeader.getId();
  313. boolean isStorage = backInfoTableHeader.isStorage();
  314. //获取值
  315. String value = datasJSONObject.getString(id);
  316. if (isStorage) {
  317. sb.append("\t").append(title).append(":").append(value).append("\n");
  318. }
  319. }
  320. }
  321. }
  322. }
  323. recApprovalInfo.setPersonalScreening(sb.toString());
  324. iRecApproval.updatePartial(recApprovalInfo, sic);
  325. }
  326. }
  327. /**
  328. * 自动生成录用报批
  329. * 第二次调整新增代码
  330. *
  331. * @param ctx
  332. * @param mapData
  333. * @return
  334. * @throws SHRWebException
  335. * @throws BOSException
  336. * @throws EASBizException
  337. */
  338. public String saveRecApproval(Context ctx, Map mapData) throws SHRWebException, BOSException, EASBizException {
  339. IResumeState iResumeState = ResumeStateFactory.getLocalInstance(ctx);
  340. //"0009" 待报批 录用报批状态
  341. ResumeStateInfo resumeStateInfo = iResumeState.getResumeStateInfo("where number = '0009'");
  342. String resumeBaseRecId = mapData.get("resumeBaseRecId").toString();
  343. String resumeStateId = resumeStateInfo.getId().toString();
  344. String errorMsg = SelectNextStageService.getInstance().dealNext(ctx, resumeBaseRecId, resumeStateId, "resumeList");
  345. //String errorMsg = SelectNextStageUtils.getInstance().dealNext(ctx, resumeBaseRecId, resumeStateId, "resumeList");
  346. logger.error("errorMsg--" + errorMsg);
  347. return errorMsg;
  348. }
  349. /**
  350. * 通过申请ID获取需求管理
  351. *
  352. * @param applyId
  353. */
  354. public RecuritmentDemandInfo getRecuritmentByApplyId(Context ctx, String applyId) throws IOException, BOSException {
  355. BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  356. JSONObject pamas = new JSONObject();
  357. JSONArray applyIds = new JSONArray();
  358. applyIds.add(applyId);
  359. pamas.put("applyIds", applyIds);
  360. String jobId = "";
  361. //根据申请ID获取申请信息
  362. JSONObject applyJson = beisenApiClient.callApi(BeisenParam.GET_APPLYLIST_APPLYID, pamas);
  363. logger.error("applyJson--" + applyJson);
  364. if (200 == applyJson.getInteger("code")) {
  365. JSONArray data = applyJson.getJSONArray("data");
  366. JSONObject applyData = data.getJSONObject(0);
  367. //职位ID
  368. jobId = applyData.getString("jobId");
  369. } else {
  370. throw new BOSException("根据申请ID获取申请信息失败,原因:" + applyJson.get("message"));
  371. }
  372. logger.error("jobId--" + jobId);
  373. //根据ID获取获取数据单条
  374. JSONObject entityPamas = new JSONObject();
  375. entityPamas.put("id", jobId);
  376. entityPamas.put("metaObjectName", "Recruitment.Job");
  377. JSONObject entity = beisenApiClient.callApi(BeisenParam.GET_ENTITY, entityPamas);
  378. logger.error("entity--" + entity);
  379. if (200 != entity.getInteger("code")) {
  380. throw new BOSException("根据ID获取获取数据单条失败,原因:" + entity.get("message"));
  381. }
  382. JSONObject entityData = entity.getJSONObject("data");
  383. //根据招聘需求ID获取招聘需求
  384. JSONObject columns = entityData.getJSONObject("columns");
  385. JSONObject recruit = columns.getJSONObject("RecruitRequirementIds");
  386. if (recruit == null) {
  387. throw new BOSException("未查询到需求IDRecruitRequirementIds");
  388. }
  389. String recruitRequirementId = recruit.getString("value");
  390. //未查询到北森的该人员招聘需求
  391. if (com.kingdee.bos.rabbitmq.util.StringUtils.isEmpty(recruitRequirementId)) {
  392. throw new BOSException("通过applyId[" + applyId + "]未查询到招聘需求!");
  393. }
  394. logger.error("requirementId--" + recruitRequirementId);
  395. //根据需求ID获取招聘需求
  396. JSONArray items = new JSONArray();
  397. items.add(recruitRequirementId);
  398. JSONObject requirements = beisenApiClient.callApi(BeisenParam.GET_REQUIREMENTS, items);
  399. logger.error("requirements--" + requirements);
  400. if (200 != requirements.getInteger("code")) {
  401. throw new BOSException("根据需求ID获取招聘需求失败,原因:" + entity.get("message"));
  402. }
  403. JSONArray data = requirements.getJSONArray("data");
  404. JSONObject dataJson = data.getJSONObject(0);
  405. //招聘需求
  406. IRecuritmentDemand iRecuritmentDemand = RecuritmentDemandFactory.getLocalInstance(ctx);
  407. //招聘需求
  408. RecuritmentDemandCollection recuritmentDemandCollection = iRecuritmentDemand.getRecuritmentDemandCollection("where requirementId='" + recruitRequirementId + "'");
  409. //shr未查询到对应的招聘需求
  410. if (recuritmentDemandCollection.isEmpty()) {
  411. //String message = "sHR未查询到对应的招聘需求,北森需求ID:" + recruitRequirementId + ",需求名称:" + dataJson.getString("name");;
  412. // 推送未查询到招聘需求消息至北森
  413. //pushMessageToBeisen(applyId, configMap.get("syncToBsErrorMsg"));
  414. //pushMessageToBeisen(applyId, "显示匹配不上金蝶原始需求单据");
  415. throw new BOSException("sHR未查询到对应的招聘需求,北森需求名称:" + dataJson.getString("name") + ",北森需求ID:" + recruitRequirementId);
  416. }
  417. //成功則修改北森字段为空
  418. //pushMessageToBeisen(applyId, "成功");
  419. return recuritmentDemandCollection.get(0);
  420. }
  421. /**
  422. * 推送消息至北森
  423. *
  424. * @param applyId 申请ID
  425. * @param message 消息
  426. */
  427. public void pushMessageToBeisen(String applyId, String message) throws BOSException {
  428. try {
  429. BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  430. //POST_UPDATEAPPLYLIST 更新申请信息
  431. JSONObject pamas = new JSONObject();
  432. JSONArray applyList = new JSONArray();
  433. JSONObject pama = new JSONObject();
  434. JSONObject fieldValues = new JSONObject();
  435. //测试环境:extjianlitongbujieguo_433899_1252390002
  436. //正式环境:extjianlitongbujieguo_614492_1252390002
  437. fieldValues.put(configMap.get("syncToErrorBS"), message);//是否同步成功
  438. pama.put("fieldValues", fieldValues);
  439. pama.put("applyId", applyId);
  440. applyList.add(pama);
  441. pamas.put("applyList", applyList);
  442. logger.error("pushMessageToBeisen--pamas--" + pamas);
  443. JSONObject result = beisenApiClient.callApi(BeisenParam.POST_UPDATEAPPLYLIST, pamas);
  444. logger.error("pushMessageToBeisen--result--" + result);
  445. } catch (IOException e) {
  446. e.printStackTrace();
  447. throw new BOSException(e);
  448. }
  449. }
  450. /**
  451. * 处理简历文件或面试评价文件
  452. *
  453. * @param applyId 申请ID
  454. * @param ctx 上下文
  455. * @param resumeInfo 简历信息
  456. * @param fileType 文件类型("标准简历"或"面试评价")
  457. */
  458. private void processResumeFile(String applyId, Context ctx, ResumeBaseRecInfo resumeInfo, String fileType) {
  459. logger.error("processResumeFile--");
  460. //是否是背景信息
  461. boolean isOrigin = false;
  462. try {
  463. // 根据文件类型获取对应的文件信息
  464. //JSONObject fileInfo = "标准简历".equals(fileType) ? getStandardResumeFileUrlByApplyId(applyId) : getInterviewEvaluationFile(applyId);
  465. JSONObject fileInfo = null;
  466. String param = "?applyId=" + applyId;
  467. BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  468. if ("标准简历".equals(fileType)) {
  469. //fileInfo = getStandardResumeFileUrlByApplyId(applyId);
  470. fileInfo = beisenApiClient.callGetApi(BeisenParam.GET_STANDERDRESUMEFILURLBYAPPLYID + param, new JSONObject());
  471. } else if ("面试评价".equals(fileType)) {
  472. //fileInfo = getInterviewEvaluationFile(applyId);
  473. fileInfo = beisenApiClient.callGetApi(BeisenParam.GET_INTERVIEWEVALUATIONFILE + param, new JSONObject());
  474. } else if ("原始简历".equals(fileType)) {
  475. fileInfo = beisenApiClient.callGetApi(BeisenParam.GET_ORIGINRESUMEBYAPPLYID + param, new JSONObject());
  476. } else if ("背景调查审批表".equals(fileType)) {
  477. param = "?applyId=" + applyId + "&supportManualCreate=true";
  478. String GET_BACKGROUNDINVESTIGATIONBYAPPLYID = "https://openapi.italent.cn/RecruitV6/api/v1/Investigation/GetBackgroundInvestigationByApplyId";
  479. //背景调查附件单独处理
  480. //fileInfo = beisenApiClient.callGetApi(BeisenParam.GET_BACKGROUNDINVESTIGATIONBYAPPLYID + param, new JSONObject());
  481. fileInfo = beisenApiClient.callGetApi(GET_BACKGROUNDINVESTIGATIONBYAPPLYID + param, new JSONObject());
  482. logger.error("背景调查审批表--" + fileInfo);
  483. //originResume
  484. isOrigin = true;
  485. }
  486. logger.error("fileInfo--" + fileInfo);
  487. if (fileInfo == null) {
  488. throw new BOSException("获取{}文件信息失败: 返回结果为null" + fileType);
  489. }
  490. Integer code = fileInfo.getInteger("code");
  491. if (!Integer.valueOf(200).equals(code)) {
  492. //未获取到简历不执行
  493. logger.error("获取{" + fileType + "}文件失败: 返回code={" + code + "}");
  494. return;
  495. //throw new BOSException("获取{" + fileType + "}文件失败: 返回code={" + code + "}");
  496. }
  497. logger.error("isOrigin--" + isOrigin);
  498. //背景调查附件单独处理
  499. if (isOrigin) {
  500. JSONArray data = fileInfo.getJSONArray("data");
  501. for (int i = 0; i < data.size(); i++) {
  502. JSONObject dataJson = data.getJSONObject(i);
  503. //fileDetails-背调报告文件详情列表
  504. JSONArray fileDetails = dataJson.getJSONArray("fileDetails");
  505. for (int j = 0; j < fileDetails.size(); j++) {
  506. JSONObject file = fileDetails.getJSONObject(j);
  507. String fileName = file.getString("fileName");
  508. String fileExtension = AttachmentUtils.extractFileExtension(fileName);
  509. String customFileName = "北森" + (fileType + (j + 1)) + "." + fileExtension;
  510. //删除之前的附件
  511. String where = "where boid = '" + resumeInfo.getId().toString() + "' and name like '%" + fileName + "%'";
  512. logger.error("where--" + where);
  513. AttachmentUtils.deleteAttachment(ctx, where);
  514. String downloadUrl = file.getString("downloadUrl");
  515. // 获取文件内容并保存
  516. byte[] fileData = AttachmentUtils.getBytesByNetURL("https:" + downloadUrl);
  517. if (fileData == null || fileData.length == 0) {
  518. throw new BOSException("获取{" + fileType + "}文件内容失败: 下载内容为空");
  519. }
  520. AttachmentUtils.insertAttachment(ctx, customFileName, resumeInfo, fileData, fileName);
  521. }
  522. }
  523. } else {
  524. JSONObject data = fileInfo.getJSONObject("data");
  525. if (data == null) {
  526. throw new BOSException("获取{" + fileType + "}文件失败: data字段为空");
  527. }
  528. String downloadUrl = data.getString("downloadUrl");
  529. String dfsPath = data.getString("dfsPath");
  530. if (com.kingdee.bos.rabbitmq.util.StringUtils.isBlank(downloadUrl) || com.kingdee.bos.rabbitmq.util.StringUtils.isBlank(dfsPath)) {
  531. throw new BOSException("获取{" + fileType + "}文件失败: downloadUrl或dfsPath为空");
  532. }
  533. // 处理文件名
  534. String fileName = AttachmentUtils.extractFileNameFromPath(dfsPath);
  535. String fileExtension = AttachmentUtils.extractFileExtension(fileName);
  536. String customFileName = "北森" + fileType + "." + fileExtension;
  537. // 获取文件内容并保存
  538. byte[] fileData = AttachmentUtils.getBytesByNetURL("https:" + downloadUrl);
  539. if (fileData == null || fileData.length == 0) {
  540. throw new BOSException("获取{" + fileType + "}文件内容失败: 下载内容为空");
  541. }
  542. AttachmentUtils.insertAttachment(ctx, customFileName, resumeInfo, fileData, fileName);
  543. logger.error("{" + fileType + "}文件处理成功: {" + customFileName + "}");
  544. }
  545. //}
  546. } catch (Exception e) {
  547. logger.error("处理" + fileType + "文件时发生异常", e);
  548. }
  549. }
  550. /**
  551. * 处理简历各部分数据
  552. */
  553. private Map processResumeSections(Context ctx, JSONObject resumeJson, ResumeBaseRecInfo resumeInfo) throws BOSException, EASBizException, ParseException, IOException {
  554. Map mapData = new HashMap();
  555. JSONArray personProfile = resumeJson.getJSONArray("personProfile");
  556. saveResumeBaseRec(ctx, personProfile, resumeInfo, mapData);
  557. JSONArray education = resumeJson.getJSONArray("education");
  558. saveEducationExpRE(ctx, education, resumeInfo);
  559. JSONArray workExperience = resumeJson.getJSONArray("workExperience");
  560. saveWorkingExp(ctx, workExperience, resumeInfo);
  561. //使用Map定义简历部分与处理方法的对应关系
  562. Map<String, TriConsumer<Context, JSONArray, ResumeBaseRecInfo>> sectionHandlers = new LinkedHashMap<>();
  563. //sectionHandlers.put("personProfile", this::saveResumeBaseRec);
  564. //sectionHandlers.put("workExperience", this::saveWorkingExp);
  565. //sectionHandlers.put("education", this::saveEducationExpRE);
  566. sectionHandlers.put("project", this::saveProjectExp);
  567. sectionHandlers.put("train", this::saveTrainingExp);
  568. sectionHandlers.put("certificate", this::saveCredential);
  569. sectionHandlers.put("lang", this::saveLanguageAbility);
  570. sectionHandlers.put("skill", this::saveProfessionalSkills);
  571. sectionHandlers.put("awards", this::saveResumeRewardPunish);
  572. //
  573. sectionHandlers.put("family", this::saveFamilyInfo);
  574. // 遍历处理所有简历部分
  575. sectionHandlers.forEach((sectionKey, handler) -> {
  576. //判断是否存key
  577. if (resumeJson.containsKey(sectionKey)) {
  578. JSONArray sectionData = resumeJson.getJSONArray(sectionKey);
  579. if (sectionData != null && !sectionData.isEmpty()) {
  580. handler.accept(ctx, sectionData, resumeInfo);
  581. }
  582. }
  583. });
  584. return mapData;
  585. }
  586. ///**
  587. // * 根据申请Id获取标准简历文件
  588. // *
  589. // * @param applyId
  590. // * @return
  591. // */
  592. //public JSONObject getStandardResumeFileUrlByApplyId(String applyId) throws IOException {
  593. // String param = "?applyId=" + applyId;
  594. // BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  595. // JSONObject jsonObject = beisenApiClient.callGetApi(BeisenParam.GET_STANDERDRESUMEFILURLBYAPPLYID + param, new JSONObject());
  596. // return jsonObject;
  597. //}
  598. //
  599. ///**
  600. // * 根据申请Id获取标准简历文件
  601. // *
  602. // * @param applyId
  603. // * @return
  604. // */
  605. //public JSONObject getInterviewEvaluationFile(String applyId) throws IOException {
  606. // String param = "?applyId=" + applyId;
  607. // BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  608. // JSONObject jsonObject = beisenApiClient.callGetApi(BeisenParam.GET_INTERVIEWEVALUATIONFILE + param, new JSONObject());
  609. // return jsonObject;
  610. //}
  611. /**
  612. * 根据申请Id获取标准简历
  613. *
  614. * @param applyId
  615. * @return
  616. */
  617. public JSONObject getResumeByApplyId(String applyId) throws IOException {
  618. String param = "?applyId=" + applyId;
  619. BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  620. JSONObject jsonObject = beisenApiClient.callGetApi(BeisenParam.GET_RESUMEBYAPPLYID + param, new JSONObject());
  621. return jsonObject;
  622. }
  623. /**
  624. * 招聘管理简历基本信息
  625. *
  626. * @param personProfile
  627. */
  628. public void saveResumeBaseRec(Context ctx, JSONArray personProfile, ResumeBaseRecInfo resumeBaseRecInfo, Map mapData) throws BOSException, EASBizException, ParseException, IOException {
  629. logger.error("personProfile--" + personProfile);
  630. BeisenParamByProperties beisenParamByProperties = new BeisenParamByProperties();
  631. Map<String, String> config = beisenParamByProperties.getConfig();
  632. //招聘业务组织
  633. HROrgUnitInfo hrOrgUnitInfo = new HROrgUnitInfo();
  634. hrOrgUnitInfo.setId(BOSUuid.read("00000000-0000-0000-0000-000000000000CCE7AED4"));
  635. resumeBaseRecInfo.setHrOrgUnit(hrOrgUnitInfo);
  636. //来源方式 INTEGRATESYSTEM=集成系统
  637. resumeBaseRecInfo.setSourceMethod(ResumeSourceMethod.INTEGRATESYSTEM);
  638. //招聘状态 WAITING 待筛选
  639. resumeBaseRecInfo.setResumeStatus(ResumeStatusEnum.WAITING);
  640. //招聘状态 0001 待筛选
  641. IResumeState iResumeState = ResumeStateFactory.getLocalInstance(ctx);
  642. ResumeStateInfo resumeStateInfo = iResumeState.getResumeStateInfo("where number = '0001'");
  643. resumeBaseRecInfo.setResumeState(resumeStateInfo);
  644. //入库时间
  645. resumeBaseRecInfo.setWarehouseEntry(new Date());
  646. //国籍
  647. INationality iNationality = NationalityFactory.getLocalInstance(ctx);
  648. //学历
  649. IDiploma iDiploma = DiplomaFactory.getLocalInstance(ctx);
  650. //政治面貌
  651. IPoliticalFace iPoliticalFace = PoliticalFaceFactory.getLocalInstance(ctx);
  652. //民族
  653. IFolk iFolk = FolkFactory.getLocalInstance(ctx);
  654. //婚姻状况
  655. IWed iWed = WedFactory.getLocalInstance(ctx);
  656. //血型
  657. Map<String, String> bloodTypeMap = InitialValueUtils.bloodTypeMap;
  658. String carType = "";//证件类型
  659. String carno = "";//证件号
  660. for (int i = 0; i < personProfile.size(); i++) {
  661. JSONObject data = personProfile.getJSONObject(i);
  662. String name = data.getString("name");
  663. String value = data.getString("value");
  664. String text = data.getString("text");
  665. //姓名
  666. if ("Name".equals(name)) {
  667. resumeBaseRecInfo.setName(text);
  668. }
  669. //参加工作时间
  670. if ("WorkStartTime".equals(name)) {
  671. resumeBaseRecInfo.setWorkDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  672. }
  673. //参加工作年限 workSeniority
  674. if ("YearsOfWork".equals(name) && !com.kingdee.util.StringUtils.isEmpty(text)) {
  675. resumeBaseRecInfo.setWorkSeniority(text);
  676. }
  677. //工作年限 YearsOfWork
  678. if ("YearsOfWork".equals(name) && !com.kingdee.util.StringUtils.isEmpty(text)) {
  679. resumeBaseRecInfo.setWorkSeniority(text);
  680. }
  681. //身份证号码 identityCardNo
  682. if ("CertificateNumber".equals(name)) {
  683. carno = text;
  684. if ("身份证".equals(carType)) {
  685. resumeBaseRecInfo.setIdentityCardNo(carno);
  686. resumeBaseRecInfo.setPassportNo("");
  687. } else {
  688. resumeBaseRecInfo.setPassportNo(carno);
  689. }
  690. }
  691. //证件类型
  692. if ("CertificateType".equals(name)) {
  693. carType = text;
  694. if ("身份证".equals(text)) {
  695. resumeBaseRecInfo.setIdentityCardNo(carno);
  696. resumeBaseRecInfo.setPassportNo("");
  697. } else {
  698. resumeBaseRecInfo.setPassportNo(carno);
  699. }
  700. }
  701. //出生年月 birthday
  702. if ("Birthday".equals(name)) {
  703. resumeBaseRecInfo.setBirthday(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  704. }
  705. //户口所在地 domicilePlace
  706. if ("AccountArea".equals(name)) {
  707. resumeBaseRecInfo.setDomicilePlace(text);
  708. }
  709. //QQ QQ
  710. if ("QQ".equals(name)) {
  711. resumeBaseRecInfo.setQQ(text);
  712. }
  713. //身高 stature
  714. if ("Height".equals(name)) {
  715. resumeBaseRecInfo.setStature(text);
  716. }
  717. //现居住地 nowResidence
  718. if ("LivingArea".equals(name)) {
  719. resumeBaseRecInfo.setNowResidence(text);
  720. }
  721. //手机号 mobilePhone
  722. if ("Mobile".equals(name)) {
  723. resumeBaseRecInfo.setMobilePhone(text);
  724. }
  725. //家庭电话 fixedPhone
  726. if ("Telephone".equals(name)) {
  727. resumeBaseRecInfo.setFixedPhone(text);
  728. }
  729. //邮件 email
  730. if ("Email".equals(name)) {
  731. resumeBaseRecInfo.setEmail(text);
  732. }
  733. //目前年薪 annualPay
  734. if ("Salary".equals(name)) {
  735. resumeBaseRecInfo.setAnnualPay(text);
  736. }
  737. //目前工作状态 currentWorkingStatus
  738. if ("JobHunting".equals(name)) {
  739. resumeBaseRecInfo.setCurrentWorkingStatus(CurrentWorkingStatusEnum.getEnum(Integer.parseInt(value) - 1));
  740. }
  741. //期望年薪 expectantPay
  742. if ("ExpectSalary".equals(name)) {
  743. resumeBaseRecInfo.setExpectantPay(Integer.parseInt(text));
  744. }
  745. //职业目标 careerGoal
  746. if ("CareerGoals".equals(name)) {
  747. resumeBaseRecInfo.setCareerGoal(text);
  748. }
  749. //自我评价 selfEvaluation
  750. if ("Evaluation".equals(name)) {
  751. resumeBaseRecInfo.setSelfEvaluation(text);
  752. }
  753. //国籍 national
  754. if ("Nationality".equals(name)) {
  755. NationalityCollection nationalityCollection = iNationality.getNationalityCollection("where name like '%" + text + "%'");
  756. if (nationalityCollection.size() > 0) {
  757. resumeBaseRecInfo.setNational(nationalityCollection.get(0));
  758. }
  759. }
  760. //籍贯 nativePlace
  761. if ("NativeArea".equals(name)) {
  762. resumeBaseRecInfo.setNativePlace(text);
  763. }
  764. //年龄 age
  765. if ("OceanAge".equals(name)) {
  766. resumeBaseRecInfo.setAge(Integer.parseInt(text));
  767. }
  768. //最高学历 hDegree
  769. if ("EducationLevel".equals(name)) {
  770. DiplomaCollection diplomaCollection = iDiploma.getDiplomaCollection("where beisenVal = '" + value + "'");
  771. if (!diplomaCollection.isEmpty()) {
  772. resumeBaseRecInfo.setHDegree(diplomaCollection.get(0));
  773. }
  774. }
  775. //政治面貌 politicalFace
  776. if ("Polity".equals(name)) {
  777. PoliticalFaceCollection politicalFaceCollection = iPoliticalFace.getPoliticalFaceCollection("where beisenVal = '" + value + "'");
  778. if (!politicalFaceCollection.isEmpty()) {
  779. resumeBaseRecInfo.setPoliticalFace(politicalFaceCollection.get(0));
  780. }
  781. }
  782. //婚姻状况 wed 北森已停用字段
  783. if (config.get("WedState").equals(name)) {
  784. WedCollection wedCollection = iWed.getWedCollection("where beisenVal = '" + value + "'");
  785. if (!wedCollection.isEmpty()) {
  786. resumeBaseRecInfo.setWed(wedCollection.get(0));
  787. }
  788. }
  789. //民族 folk
  790. if ("Nation".equals(name)) {
  791. FolkCollection folkCollection = iFolk.getFolkCollection("where beisenVal = '" + value + "'");
  792. if (!folkCollection.isEmpty()) {
  793. resumeBaseRecInfo.setFolk(folkCollection.get(0));
  794. }
  795. }
  796. //毕业学校 school
  797. if ("LastSchool".equals(name)) {
  798. if (com.kingdee.util.StringUtils.isEmpty(text)) {
  799. throw new BOSException("毕业学校不能为空!");
  800. }
  801. resumeBaseRecInfo.setName(text);
  802. }
  803. //血型 bloodType
  804. if ("BloodType".equals(name)) {
  805. String hDegree = bloodTypeMap.getOrDefault(value, "90");
  806. resumeBaseRecInfo.setBloodType(BloodType.getEnum(hDegree));
  807. }
  808. //紧急联系人 emergencyContact
  809. if ("EmergencyContact".equals(name)) {
  810. resumeBaseRecInfo.setEmergencyContact(text);
  811. }
  812. //紧急联系人电话 emergencyContactPhone
  813. if ("EmergencyPhone".equals(name)) {
  814. resumeBaseRecInfo.setEmergencyContactPhone(text);
  815. }
  816. //期望月薪 expectantPayStr
  817. if ("ExpectSalary".equals(name)) {
  818. resumeBaseRecInfo.setExpectantPayStr(text);
  819. }
  820. //最近工作单位 lastCompany
  821. if ("LastCompany".equals(name)) {
  822. resumeBaseRecInfo.setLastCompany(text);
  823. }
  824. //最近工作行业 lastIndustry
  825. if ("LastIndustry".equals(name)) {
  826. resumeBaseRecInfo.setLastIndustry(text);
  827. }
  828. //专业 major
  829. if ("LastDiscipline".equals(name)) {
  830. resumeBaseRecInfo.setMajor(text);
  831. }
  832. //性别 gender
  833. if ("Gender".equals(name)) {
  834. if ("1".equals(value) || "0".equals(value)) {
  835. resumeBaseRecInfo.setGender(Genders.getEnum(Integer.parseInt(value) + 1));
  836. }
  837. }
  838. //更新简历时间 updateResumeDate
  839. if ("ResumeUpdateTime".equals(name)) {
  840. resumeBaseRecInfo.setUpdateResumeDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  841. }
  842. //签发机关 idCardIssueOrg
  843. if ("CertificateGrantUnit".equals(name)) {
  844. resumeBaseRecInfo.setIdentityCardNo(text);
  845. }
  846. //证件有效期-开始时间 idCardBeginDate
  847. if ("CertificateValidityDate".equals(name)) {
  848. resumeBaseRecInfo.setIdCardBeginDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  849. }
  850. //证件有效期-结束时间 idCardEndDate
  851. if ("CertificateValidityOverDate".equals(name)) {
  852. resumeBaseRecInfo.setIdCardEndDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  853. }
  854. //到岗时间 arrivalTime
  855. if ("AvailableDate".equals(name)) {
  856. resumeBaseRecInfo.setArrivalTime(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  857. }
  858. //英文名 EnglishName
  859. if ("NameEn".equals(name)) {
  860. resumeBaseRecInfo.setEnglishName(text);
  861. }
  862. //户籍地址 domicileAddress
  863. if ("Address".equals(name)) {
  864. resumeBaseRecInfo.setDomicileAddress(text);
  865. }
  866. }
  867. String errorMsg = ",身份证号码、手机号为必填数据,请在北森维护数据后再次同步!";
  868. if (com.kingdee.util.StringUtils.isEmpty(resumeBaseRecInfo.getIdentityCardNo()) && com.kingdee.util.StringUtils.isEmpty(resumeBaseRecInfo.getPassportNo())) {
  869. throw new BOSException("身份证号码不能为空" + errorMsg);
  870. }
  871. if (com.kingdee.util.StringUtils.isEmpty(resumeBaseRecInfo.getMobilePhone())) {
  872. throw new BOSException("手机号码不能为空" + errorMsg);
  873. }
  874. IResumeBaseRec iResumeBaseRec = ResumeBaseRecFactory.getLocalInstance(ctx);
  875. IObjectPK save = iResumeBaseRec.save(resumeBaseRecInfo);
  876. logger.error("resumeBaseRecId--" + save);
  877. mapData.put("resumeBaseRecId", save.toString());
  878. mapData.put("name", resumeBaseRecInfo.getName());
  879. // } catch (Exception e) {
  880. // logger.error("简历基本信息报错信息:" + e.getMessage());
  881. // throw new RuntimeException(e);
  882. // }
  883. }
  884. /**
  885. * 简历-工作经历
  886. *
  887. * @param workExperience
  888. */
  889. public void saveWorkingExp(Context ctx, JSONArray workExperience, ResumeBaseRecInfo resumeBaseRecInfo) throws BOSException {
  890. logger.error("workExperience--" + workExperience);
  891. try {
  892. IWorkingExp iWorkingExp = WorkingExpFactory.getLocalInstance(ctx);
  893. WorkingExpCollection workingExpColl = iWorkingExp.getWorkingExpCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  894. if (!workingExpColl.isEmpty()) {
  895. iWorkingExp.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  896. }
  897. for (int i = 0; i < workExperience.size(); i++) {
  898. JSONArray array = workExperience.getJSONArray(i);
  899. WorkingExpInfo workingExpInfo = new WorkingExpInfo();
  900. //简历基本信息
  901. workingExpInfo.setResumeBase(resumeBaseRecInfo);
  902. for (int j = 0; j < array.size(); j++) {
  903. JSONObject data = array.getJSONObject(j);
  904. String name = data.getString("name");
  905. String value = data.getString("value");
  906. String text = data.getString("text");
  907. //dateStart 开始时间
  908. if ("StartDate".equals(name)) {
  909. workingExpInfo.setDateStart(DateTimeUtils.parseDate(text, "yyyy/MM"));
  910. }
  911. //dateEnd 结束时间
  912. if ("EndDate".equals(name)) {
  913. if ("至今".equals(text)) {
  914. text = "2199/12";
  915. }
  916. workingExpInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  917. }
  918. //company 公司名称
  919. if ("CompanyName".equals(name)) {
  920. workingExpInfo.setCompany(text);
  921. }
  922. //department 任职部门
  923. if ("Department".equals(name)) {
  924. workingExpInfo.setDepartment(text);
  925. }
  926. //jobCategory 职位类别
  927. if ("OgJobLevel".equals(name)) {
  928. workingExpInfo.setJobCategory(text);
  929. }
  930. //industry 所属行业
  931. if ("Industry".equals(name)) {
  932. workingExpInfo.setIndustry(text);
  933. }
  934. //position 职位名称
  935. if ("JobTitle".equals(name)) {
  936. workingExpInfo.setPosition(text);
  937. }
  938. //underlingNumber 下属人数
  939. if ("SubordinateNumber".equals(name)) {
  940. workingExpInfo.setUnderlingNumber(Integer.parseInt(text));
  941. }
  942. //monthPay 税前月薪
  943. if ("Salary".equals(name)) {
  944. workingExpInfo.setMonthPay(Integer.parseInt(text));
  945. }
  946. //certifier 证明人
  947. if ("ReferenceName".equals(name)) {
  948. workingExpInfo.setCertifier(text);
  949. }
  950. //leavingReason 离职原因
  951. if ("ReasonOfLeaving".equals(name)) {
  952. workingExpInfo.setLeavingReason(text);
  953. }
  954. //certifierPhone 证明人电话
  955. if ("ReferenceContact".equals(name)) {
  956. workingExpInfo.setCertifierPhone(text);
  957. }
  958. //monthPayStr 税前月薪
  959. if ("Salary".equals(name)) {
  960. workingExpInfo.setMonthPayStr(text);
  961. }
  962. //unitAddress 工作地点 OgJobArea
  963. if ("JobArea".equals(name)) {
  964. workingExpInfo.setUnitAddress(text);
  965. }
  966. }
  967. String leavingReason = workingExpInfo.getLeavingReason();
  968. if (com.kingdee.bos.rabbitmq.util.StringUtils.isEmpty(leavingReason)) {
  969. throw new BOSException("工作经历:离职原因不能为空!!");
  970. }
  971. iWorkingExp.save(workingExpInfo);
  972. }
  973. } catch (Exception e) {
  974. logger.error("简历-工作经历保存失败!" + e.getMessage());
  975. throw new BOSException(e);
  976. }
  977. }
  978. /**
  979. * 简历-教育经历
  980. *
  981. * @param education
  982. */
  983. public void saveEducationExpRE(Context ctx, JSONArray education, ResumeBaseRecInfo resumeBaseRecInfo) throws BOSException, EASBizException {
  984. logger.error("education--" + education);
  985. try {
  986. IEducationExpREC iEducationExpREC = EducationExpRECFactory.getLocalInstance(ctx);
  987. EducationExpRECCollection educationExpRECCollection = iEducationExpREC.getEducationExpRECCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  988. if (!educationExpRECCollection.isEmpty()) {
  989. iEducationExpREC.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  990. }
  991. //学历
  992. IDiploma iDiploma = DiplomaFactory.getLocalInstance(ctx);
  993. //学位
  994. IDegree iDegree = DegreeFactory.getLocalInstance(ctx);
  995. //学院类型
  996. Map<String, String> bchoolTypeMap = InitialValueUtils.getBchoolTypeMap();
  997. //最晚开始日期
  998. Date maxStartDate = null;
  999. for (int i = 0; i < education.size(); i++) {
  1000. JSONArray array = education.getJSONArray(i);
  1001. EducationExpRECInfo educationExpRECInfo = new EducationExpRECInfo();
  1002. //简历基本信息
  1003. educationExpRECInfo.setResumeBase(resumeBaseRecInfo);
  1004. for (int j = 0; j < array.size(); j++) {
  1005. JSONObject data = array.getJSONObject(j);
  1006. String name = data.getString("name");
  1007. String value = data.getString("value");
  1008. String text = data.getString("text");
  1009. //dateStart 开始时间
  1010. if ("StartDate".equals(name)) {
  1011. Date date = DateTimeUtils.parseDate(text, "yyyy/MM");
  1012. educationExpRECInfo.setDateStart(date);
  1013. }
  1014. //dateEnd 结束时间
  1015. if ("EndDate".equals(name)) {
  1016. if ("至今".equals(text)) {
  1017. text = "2199/12";
  1018. }
  1019. educationExpRECInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1020. }
  1021. //school 毕业学校
  1022. if ("SchoolName".equals(name)) {
  1023. educationExpRECInfo.setSchool(text);
  1024. }
  1025. //academicDiplomasF7 学位
  1026. if ("Degree".equals(name)) {
  1027. DegreeCollection degreeCollection = iDegree.getDegreeCollection("where beisenVal = '" + value + "'");
  1028. if (!degreeCollection.isEmpty()) {
  1029. educationExpRECInfo.setAcademicDiplomasF7(degreeCollection.get(0));
  1030. }
  1031. }
  1032. //major 专业
  1033. if ("MajorName".equals(name)) {
  1034. educationExpRECInfo.setMajor(text);
  1035. }
  1036. //degreeF7 学历
  1037. if ("EducationLevel".equals(name)) {
  1038. DiplomaCollection diplomaCollection = iDiploma.getDiplomaCollection("where beisenVal = '" + value + "'");
  1039. if (!diplomaCollection.isEmpty()) {
  1040. educationExpRECInfo.setDegreeF7(diplomaCollection.get(0));
  1041. }
  1042. }
  1043. //schoolType 学院类型
  1044. if ("SchoolType".equals(name)) {
  1045. if (bchoolTypeMap.containsKey(value)) {
  1046. educationExpRECInfo.setSchoolType(SchoolTypeEnum.getEnum(bchoolTypeMap.get(value)));
  1047. }
  1048. }
  1049. }
  1050. String errorMsg = ",入学时间、专业、学历、毕业院校为必填数据,请在北森维护数据后再次同步!";
  1051. Date dateStart = educationExpRECInfo.getDateStart();
  1052. if (dateStart == null) {
  1053. throw new BOSException("教育经历:入学时间不能为空" + errorMsg);
  1054. }
  1055. if (com.kingdee.util.StringUtils.isEmpty(educationExpRECInfo.getMajor())) {
  1056. throw new BOSException("教育经历:专业不能为空" + errorMsg);
  1057. }
  1058. if (com.kingdee.util.StringUtils.isEmpty(educationExpRECInfo.getSchool())) {
  1059. throw new BOSException("教育经历:毕业院校不能为空" + errorMsg);
  1060. }
  1061. if (educationExpRECInfo.getDegreeF7() == null) {
  1062. throw new BOSException("教育经历:学历不能为空" + errorMsg);
  1063. }
  1064. if (maxStartDate == null || maxStartDate.before(dateStart)) {
  1065. maxStartDate = dateStart;
  1066. resumeBaseRecInfo.setMajor(educationExpRECInfo.getMajor());
  1067. resumeBaseRecInfo.setSchool(educationExpRECInfo.getSchool());
  1068. }
  1069. iEducationExpREC.save(educationExpRECInfo);
  1070. }
  1071. } catch (Exception e) {
  1072. IResumeBaseRec iResumeBaseRec = ResumeBaseRecFactory.getLocalInstance(ctx);
  1073. iResumeBaseRec.delete(new ObjectUuidPK(resumeBaseRecInfo.getId()));
  1074. logger.error("简历-教育经历保存失败!" + e.getMessage());
  1075. throw new RuntimeException(e);
  1076. }
  1077. IResumeBaseRec iResumeBaseRec = ResumeBaseRecFactory.getLocalInstance(ctx);
  1078. iResumeBaseRec.save(resumeBaseRecInfo);
  1079. }
  1080. /**
  1081. * 简历-获奖经历
  1082. *
  1083. * @param awards
  1084. */
  1085. public void saveResumeRewardPunish(Context ctx, JSONArray awards, ResumeBaseRecInfo resumeBaseRecInfo) {
  1086. logger.error("awards--" + awards);
  1087. try {
  1088. IResumeRewardPunish iResumeRewardPunish = ResumeRewardPunishFactory.getLocalInstance(ctx);
  1089. ResumeRewardPunishCollection ResumeRewardPunishCollection = iResumeRewardPunish.getResumeRewardPunishCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1090. if (!ResumeRewardPunishCollection.isEmpty()) {
  1091. iResumeRewardPunish.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1092. }
  1093. for (int i = 0; i < awards.size(); i++) {
  1094. JSONArray array = awards.getJSONArray(i);
  1095. ResumeRewardPunishInfo ResumeRewardPunishInfo = new ResumeRewardPunishInfo();
  1096. //简历基本信息
  1097. ResumeRewardPunishInfo.setResumeBase(resumeBaseRecInfo);
  1098. for (int j = 0; j < array.size(); j++) {
  1099. JSONObject data = array.getJSONObject(j);
  1100. String name = data.getString("name");
  1101. String value = data.getString("value");
  1102. String text = data.getString("text");
  1103. //occurDate 获奖时间
  1104. if ("AwardTime".equals(name)) {
  1105. ResumeRewardPunishInfo.setOccurDate(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1106. }
  1107. //title 获奖名称
  1108. if ("AwardName".equals(name)) {
  1109. ResumeRewardPunishInfo.setTitle(text);
  1110. ResumeRewardPunishInfo.setName(text);
  1111. }
  1112. //description 描述
  1113. if ("AwardDescription".equals(name)) {
  1114. ResumeRewardPunishInfo.setDescription(text);
  1115. }
  1116. }
  1117. iResumeRewardPunish.save(ResumeRewardPunishInfo);
  1118. }
  1119. } catch (Exception e) {
  1120. logger.error("简历-获奖经历保存失败!" + e.getMessage());
  1121. }
  1122. }
  1123. /**
  1124. * 简历-项目经历
  1125. *
  1126. * @param project
  1127. */
  1128. public void saveProjectExp(Context ctx, JSONArray project, ResumeBaseRecInfo resumeBaseRecInfo) {
  1129. logger.error("project--" + project);
  1130. try {
  1131. IProjectExp iProjectExp = ProjectExpFactory.getLocalInstance(ctx);
  1132. ProjectExpCollection ProjectExpCollection = iProjectExp.getProjectExpCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1133. if (!ProjectExpCollection.isEmpty()) {
  1134. iProjectExp.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1135. }
  1136. for (int i = 0; i < project.size(); i++) {
  1137. JSONArray array = project.getJSONArray(i);
  1138. ProjectExpInfo ProjectExpInfo = new ProjectExpInfo();
  1139. //简历基本信息
  1140. ProjectExpInfo.setResumeBase(resumeBaseRecInfo);
  1141. for (int j = 0; j < array.size(); j++) {
  1142. JSONObject data = array.getJSONObject(j);
  1143. String name = data.getString("name");
  1144. String value = data.getString("value");
  1145. String text = data.getString("text");
  1146. //dateStart 开始时间
  1147. if ("StartDate".equals(name)) {
  1148. ProjectExpInfo.setDateStart(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1149. }
  1150. //dateEnd 结束时间
  1151. if ("EndDate".equals(name)) {
  1152. if ("至今".equals(text)) {
  1153. text = "2199/12";
  1154. }
  1155. ProjectExpInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1156. }
  1157. //customer 项目名称
  1158. if ("ProjectName".equals(name)) {
  1159. ProjectExpInfo.setCustomer(text);
  1160. }
  1161. //projectDescription 项目描述
  1162. if ("ProjectInfo".equals(name)) {
  1163. ProjectExpInfo.setProjectDescription(text);
  1164. }
  1165. }
  1166. iProjectExp.save(ProjectExpInfo);
  1167. }
  1168. } catch (Exception e) {
  1169. logger.error("简历-项目经历保存失败!" + e.getMessage());
  1170. }
  1171. }
  1172. /**
  1173. * 简历-培训经历
  1174. *
  1175. * @param train
  1176. */
  1177. public void saveTrainingExp(Context ctx, JSONArray train, ResumeBaseRecInfo resumeBaseRecInfo) {
  1178. logger.error("train--" + train);
  1179. try {
  1180. ITrainingExp iTrainingExp = TrainingExpFactory.getLocalInstance(ctx);
  1181. TrainingExpCollection TrainingExpCollection = iTrainingExp.getTrainingExpCollection("where resumeBaseInfo = '" + resumeBaseRecInfo.getId().toString() + "'");
  1182. if (!TrainingExpCollection.isEmpty()) {
  1183. iTrainingExp.delete("where resumeBaseInfo = '" + resumeBaseRecInfo.getId().toString() + "'");
  1184. }
  1185. for (int i = 0; i < train.size(); i++) {
  1186. JSONArray array = train.getJSONArray(i);
  1187. TrainingExpInfo TrainingExpInfo = new TrainingExpInfo();
  1188. //简历基本信息
  1189. TrainingExpInfo.setResumeBaseInfo(resumeBaseRecInfo);
  1190. for (int j = 0; j < array.size(); j++) {
  1191. JSONObject data = array.getJSONObject(j);
  1192. String name = data.getString("name");
  1193. String value = data.getString("value");
  1194. String text = data.getString("text");
  1195. //dateStart 开始时间
  1196. if ("StartDate".equals(name)) {
  1197. TrainingExpInfo.setDateStart(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1198. }
  1199. //dateEnd 结束时间
  1200. if ("EndDate".equals(name)) {
  1201. if ("至今".equals(text)) {
  1202. text = "2199/12";
  1203. }
  1204. TrainingExpInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1205. }
  1206. //trainingInstitution 培训机构
  1207. if ("OrgName".equals(name)) {
  1208. TrainingExpInfo.setTrainingInstitution(text);
  1209. }
  1210. //courseDescription 课程描述
  1211. if ("Description".equals(name)) {
  1212. TrainingExpInfo.setCourseDescription(text);
  1213. }
  1214. }
  1215. iTrainingExp.save(TrainingExpInfo);
  1216. }
  1217. } catch (Exception e) {
  1218. logger.error("简历-培训经历保存失败!" + e.getMessage());
  1219. }
  1220. }
  1221. /**
  1222. * 简历-获得证书
  1223. *
  1224. * @param certificate
  1225. */
  1226. public void saveCredential(Context ctx, JSONArray certificate, ResumeBaseRecInfo resumeBaseRecInfo) {
  1227. logger.error("certificate--" + certificate);
  1228. try {
  1229. ICredential iCredential = CredentialFactory.getLocalInstance(ctx);
  1230. CredentialCollection CredentialCollection = iCredential.getCredentialCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1231. if (!CredentialCollection.isEmpty()) {
  1232. iCredential.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1233. }
  1234. for (int i = 0; i < certificate.size(); i++) {
  1235. JSONArray array = certificate.getJSONArray(i);
  1236. CredentialInfo credentialInfo = new CredentialInfo();
  1237. //简历基本信息
  1238. credentialInfo.setResumeBase(resumeBaseRecInfo);
  1239. for (int j = 0; j < array.size(); j++) {
  1240. JSONObject data = array.getJSONObject(j);
  1241. String name = data.getString("name");
  1242. String value = data.getString("value");
  1243. String text = data.getString("text");
  1244. //date 证书发放日期
  1245. if ("ObtainDate".equals(name)) {
  1246. credentialInfo.setDate(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1247. }
  1248. //credentialName 证书名称
  1249. if ("CertificateName".equals(name)) {
  1250. credentialInfo.setCredentialName(text);
  1251. }
  1252. //issuer 证书发布机构
  1253. if ("Authority".equals(name)) {
  1254. credentialInfo.setIssuer(text);
  1255. }
  1256. //grade 证书成绩
  1257. if ("Score".equals(name)) {
  1258. credentialInfo.setGrade(text);
  1259. }
  1260. }
  1261. iCredential.save(credentialInfo);
  1262. }
  1263. } catch (Exception e) {
  1264. logger.error("简历-获得证书保存失败!" + e.getMessage());
  1265. }
  1266. }
  1267. /**
  1268. * 简历-语言能力
  1269. *
  1270. * @param lang
  1271. */
  1272. public void saveLanguageAbility(Context ctx, JSONArray lang, ResumeBaseRecInfo resumeBaseRecInfo) {
  1273. logger.error("lang--" + lang);
  1274. try {
  1275. ILanguageAbility iLanguageAbility = LanguageAbilityFactory.getLocalInstance(ctx);
  1276. LanguageAbilityCollection LanguageAbilityCollection = iLanguageAbility.getLanguageAbilityCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1277. if (!LanguageAbilityCollection.isEmpty()) {
  1278. iLanguageAbility.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1279. }
  1280. //熟练度
  1281. Map<String, String> proficiencyMap = InitialValueUtils.getProficiencyMap();
  1282. for (int i = 0; i < lang.size(); i++) {
  1283. JSONArray array = lang.getJSONArray(i);
  1284. LanguageAbilityInfo languageAbilityInfo = new LanguageAbilityInfo();
  1285. //简历基本信息
  1286. languageAbilityInfo.setResumeBase(resumeBaseRecInfo);
  1287. for (int j = 0; j < array.size(); j++) {
  1288. JSONObject data = array.getJSONObject(j);
  1289. String name = data.getString("name");
  1290. String value = data.getString("value");
  1291. String text = data.getString("text");
  1292. //listeningSpeaking 听说
  1293. if ("ListeningSpeakingAbility".equals(name)) {
  1294. if (proficiencyMap.containsKey(value)) {
  1295. languageAbilityInfo.setListeningSpeaking(ProficiencyEnum.getEnum(proficiencyMap.get(value)));
  1296. }
  1297. }
  1298. //readingWriting 读写
  1299. if ("ReadingWritingAbility".equals(name)) {
  1300. languageAbilityInfo.setReadingWriting(ProficiencyEnum.getEnum(proficiencyMap.get(value)));
  1301. }
  1302. //language 语言
  1303. if ("LanguageType".equals(name)) {
  1304. languageAbilityInfo.setLanguage(text);
  1305. }
  1306. //lv 语言等级
  1307. if ("LanguageLevel".equals(name)) {
  1308. languageAbilityInfo.setLv(text);
  1309. }
  1310. }
  1311. iLanguageAbility.save(languageAbilityInfo);
  1312. }
  1313. } catch (Exception e) {
  1314. logger.error("简历-语言能力保存失败!" + e.getMessage());
  1315. }
  1316. }
  1317. /**
  1318. * 简历-专业技能
  1319. *
  1320. * @param skill
  1321. */
  1322. public void saveProfessionalSkills(Context ctx, JSONArray skill, ResumeBaseRecInfo resumeBaseRecInfo) {
  1323. logger.error("skill--" + skill);
  1324. try {
  1325. IProfessionalSkills iProfessionalSkills = ProfessionalSkillsFactory.getLocalInstance(ctx);
  1326. ProfessionalSkillsCollection ProfessionalSkillsCollection = iProfessionalSkills.getProfessionalSkillsCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1327. if (!ProfessionalSkillsCollection.isEmpty()) {
  1328. iProfessionalSkills.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1329. }
  1330. for (int i = 0; i < skill.size(); i++) {
  1331. JSONArray array = skill.getJSONArray(i);
  1332. ProfessionalSkillsInfo professionalSkillsInfo = new ProfessionalSkillsInfo();
  1333. //简历基本信息
  1334. professionalSkillsInfo.setResumeBase(resumeBaseRecInfo);
  1335. for (int j = 0; j < array.size(); j++) {
  1336. JSONObject data = array.getJSONObject(j);
  1337. String name = data.getString("name");
  1338. String value = data.getString("value");
  1339. String text = data.getString("text");
  1340. //skillName 技能名称
  1341. if ("SkillName".equals(name)) {
  1342. professionalSkillsInfo.setSkillName(text);
  1343. }
  1344. //skillDescription 技能描述
  1345. if ("SkillDescription".equals(name)) {
  1346. professionalSkillsInfo.setSkillDescription(text);
  1347. }
  1348. }
  1349. iProfessionalSkills.save(professionalSkillsInfo);
  1350. }
  1351. } catch (Exception e) {
  1352. logger.error("简历-专业技能保存失败!" + e.getMessage());
  1353. }
  1354. }
  1355. /**
  1356. * 简历-社会关系
  1357. *
  1358. * @param
  1359. */
  1360. public void saveFamilyInfo(Context ctx, JSONArray family, ResumeBaseRecInfo resumeBaseRecInfo) {
  1361. logger.error("family--" + family);
  1362. try {
  1363. IResumeFamily familyIns = ResumeFamilyFactory.getLocalInstance(ctx);
  1364. ResumeFamilyCollection familyCol = familyIns.getResumeFamilyCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1365. //关系
  1366. IRelation relationIns = RelationFactory.getLocalInstance(ctx);
  1367. //简历基本信息
  1368. for (int i = 0; i < family.size(); i++) {
  1369. ResumeFamilyInfo familyInfo = new ResumeFamilyInfo();
  1370. if (familyCol.size() > i) {
  1371. familyInfo = familyCol.get(i);
  1372. }
  1373. familyInfo.setResumeBase(resumeBaseRecInfo);
  1374. JSONArray array = family.getJSONArray(i);
  1375. for (int j = 0; j < array.size(); j++) {
  1376. JSONObject data = array.getJSONObject(j);
  1377. String name = data.getString("name");
  1378. String value = data.getString("value");
  1379. String text = data.getString("text");
  1380. //姓名
  1381. if ("Name".equals(name)) {
  1382. familyInfo.setName(value);
  1383. }
  1384. // 与本人关系
  1385. if ("relation".equals(name)) {
  1386. RelationCollection relationCol = relationIns.getRelationCollection("where beisenVal = '" + value + "'");
  1387. if (!relationCol.isEmpty()) {
  1388. familyInfo.setRelation(relationCol.get(0));
  1389. }
  1390. }
  1391. if ("age".equals(name)) {
  1392. familyInfo.setAge(text);
  1393. }
  1394. //职务
  1395. if ("JobTitle".equals(name)) {
  1396. familyInfo.setSpecDuty(text);
  1397. }
  1398. //公司名
  1399. if ("CompanyName".equals(name)) {
  1400. familyInfo.setWorkUnit(text);
  1401. }
  1402. //telephone
  1403. if ("telephone".equals(name)) {
  1404. familyInfo.setOfficePhone(text);
  1405. }
  1406. familyIns.save(familyInfo);
  1407. }
  1408. }
  1409. } catch (Exception e) {
  1410. logger.error("社会关系保存失败!" + e.getMessage());
  1411. throw new RuntimeException(e);
  1412. }
  1413. }
  1414. /**
  1415. * coyle
  1416. *
  1417. * @param ctx
  1418. * @param billId
  1419. * @throws BOSException
  1420. * @throws EASBizException
  1421. */
  1422. @Override
  1423. protected void _syncRecuritmentToBeisen(Context ctx, String billId) throws BOSException, EASBizException {
  1424. super._syncRecuritmentToBeisen(ctx, billId);
  1425. IRecuritmentDemand dIns = RecuritmentDemandFactory.getLocalInstance(ctx);
  1426. RecuritmentDemandInfo recuritmentDemandInfo = dIns.getRecuritmentDemandInfo(new ObjectUuidPK(billId));
  1427. //更新或新增
  1428. try {
  1429. //测试环境或者线上环境
  1430. boolean isProductionEnv = false;
  1431. BeisenParamByProperties beisenParamByProperties = new BeisenParamByProperties();
  1432. Map<String, String> config = beisenParamByProperties.getConfig();
  1433. String isProductionEnvStr = config.get("isProductionEnv");// 线上环境
  1434. if (!StringUtils.isEmpty(isProductionEnvStr) && isProductionEnvStr.equals("true")) {
  1435. isProductionEnv = true;
  1436. }
  1437. RecruitmentDemandService recruitmentDemandService = new RecruitmentDemandService(isProductionEnv);
  1438. Object requirementId = recuritmentDemandInfo.get("requirementId");
  1439. if (ObjectUtils.allNotNull(requirementId)) {
  1440. recruitmentDemandService.updateRequirement(ctx, String.valueOf(requirementId), recuritmentDemandInfo);
  1441. } else {
  1442. recruitmentDemandService.createRecruitmentDemand(ctx, recuritmentDemandInfo);
  1443. }
  1444. } catch (Exception e) {
  1445. SelectorItemCollection selectorCol = new SelectorItemCollection();
  1446. selectorCol.add(new SelectorItemInfo("syncBeisenResult"));
  1447. String message = e.getMessage();
  1448. recuritmentDemandInfo.put("syncBeisenResult", "失败: " + message);
  1449. dIns.updatePartial(recuritmentDemandInfo, selectorCol);
  1450. throw new RuntimeException(e);
  1451. }
  1452. }
  1453. /**
  1454. * 招聘需求更新
  1455. * coyle
  1456. */
  1457. @Override
  1458. protected void _updateRecuritment(Context ctx, String startDate, String endDate, int offset) throws BOSException, EASBizException {
  1459. super._updateRecuritment(ctx, startDate, endDate, offset);
  1460. // 0. 参数校验与日期解析
  1461. DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  1462. LocalDate start = LocalDate.now();
  1463. LocalDate end = LocalDate.now();
  1464. //如果时间参数都为空,则使用offset参数
  1465. if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate)) {
  1466. if (offset > 0) {
  1467. //eDate增加offset天
  1468. end = end.plusDays(offset);
  1469. } else if (offset < 0) {
  1470. start = start.plusDays(offset);
  1471. }
  1472. }
  1473. if (!StringUtils.isEmpty(startDate)) {
  1474. //开始日期字定义,结束日期都是今天
  1475. start = LocalDate.parse(startDate, dateFormatter);
  1476. }
  1477. if (!StringUtils.isEmpty(endDate)) {
  1478. //开始日期,结束日期都是今天
  1479. end = LocalDate.parse(endDate, dateFormatter);
  1480. }
  1481. if (start.isAfter(end)) {
  1482. throw new BOSException("开始日期不能晚于结束日期");
  1483. }
  1484. // LocalDate 转 String (使用之前的 dateFormatter)
  1485. String startStr = toStartTime(start.format(dateFormatter));
  1486. String endStr = toEndTime(end.format(dateFormatter));
  1487. IRecuritmentDemand localInstance = RecuritmentDemandFactory.getLocalInstance(ctx);
  1488. EntityViewInfo ev = new EntityViewInfo();
  1489. FilterInfo filter = new FilterInfo();
  1490. filter.getFilterItems().add(new FilterItemInfo("requirementId", null, CompareType.NOTEMPTY));
  1491. filter.getFilterItems().add(new FilterItemInfo("lastUpdateTime", startStr, CompareType.GREATER_EQUALS));
  1492. filter.getFilterItems().add(new FilterItemInfo("lastUpdateTime", endStr, CompareType.LESS_EQUALS));
  1493. ev.setFilter(filter);
  1494. RecuritmentDemandCollection recuritmentDemandCollection = localInstance.getRecuritmentDemandCollection(ev);
  1495. for (int i = 0; i < recuritmentDemandCollection.size(); i++) {
  1496. RecuritmentDemandInfo recuritmentDemandInfo = recuritmentDemandCollection.get(i);
  1497. _syncRecuritmentToBeisen(ctx, recuritmentDemandInfo.getId().toString());
  1498. }
  1499. }
  1500. /**
  1501. * 将日期字符串转换为一天的开始时间(UTC格式)
  1502. *
  1503. * @param dateStr "yyyy-MM-dd"格式的日期字符串
  1504. * @return Moka API要求的时间格式
  1505. */
  1506. public static String toStartTime(String dateStr) {
  1507. LocalDate date = LocalDate.parse(dateStr);
  1508. LocalDateTime startOfDay = date.atStartOfDay();
  1509. return TIME_FORMATTER.format(startOfDay);
  1510. }
  1511. /**
  1512. * 将日期字符串转换为一天的结束时间(UTC格式)
  1513. *
  1514. * @param dateStr "yyyy-MM-dd"格式的日期字符串
  1515. * @return Moka API要求的时间格式
  1516. */
  1517. public static String toEndTime(String dateStr) {
  1518. LocalDate date = LocalDate.parse(dateStr);
  1519. LocalDateTime endOfDay = date.atTime(23, 59, 59);
  1520. return TIME_FORMATTER.format(endOfDay);
  1521. }
  1522. }