RecuritmentFacadeControllerBean.java 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588
  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. // 使用Map定义简历部分与处理方法的对应关系
  560. Map<String, TriConsumer<Context, JSONArray, ResumeBaseRecInfo>> sectionHandlers = new LinkedHashMap<>();
  561. //sectionHandlers.put("personProfile", this::saveResumeBaseRec);
  562. sectionHandlers.put("workExperience", this::saveWorkingExp);
  563. //sectionHandlers.put("education", this::saveEducationExpRE);
  564. sectionHandlers.put("project", this::saveProjectExp);
  565. sectionHandlers.put("train", this::saveTrainingExp);
  566. sectionHandlers.put("certificate", this::saveCredential);
  567. sectionHandlers.put("lang", this::saveLanguageAbility);
  568. sectionHandlers.put("skill", this::saveProfessionalSkills);
  569. sectionHandlers.put("awards", this::saveResumeRewardPunish);
  570. //
  571. sectionHandlers.put("family", this::saveFamilyInfo);
  572. // 遍历处理所有简历部分
  573. sectionHandlers.forEach((sectionKey, handler) -> {
  574. //判断是否存key
  575. if (resumeJson.containsKey(sectionKey)) {
  576. JSONArray sectionData = resumeJson.getJSONArray(sectionKey);
  577. if (sectionData != null && !sectionData.isEmpty()) {
  578. handler.accept(ctx, sectionData, resumeInfo);
  579. }
  580. }
  581. });
  582. return mapData;
  583. }
  584. ///**
  585. // * 根据申请Id获取标准简历文件
  586. // *
  587. // * @param applyId
  588. // * @return
  589. // */
  590. //public JSONObject getStandardResumeFileUrlByApplyId(String applyId) throws IOException {
  591. // String param = "?applyId=" + applyId;
  592. // BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  593. // JSONObject jsonObject = beisenApiClient.callGetApi(BeisenParam.GET_STANDERDRESUMEFILURLBYAPPLYID + param, new JSONObject());
  594. // return jsonObject;
  595. //}
  596. //
  597. ///**
  598. // * 根据申请Id获取标准简历文件
  599. // *
  600. // * @param applyId
  601. // * @return
  602. // */
  603. //public JSONObject getInterviewEvaluationFile(String applyId) throws IOException {
  604. // String param = "?applyId=" + applyId;
  605. // BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  606. // JSONObject jsonObject = beisenApiClient.callGetApi(BeisenParam.GET_INTERVIEWEVALUATIONFILE + param, new JSONObject());
  607. // return jsonObject;
  608. //}
  609. /**
  610. * 根据申请Id获取标准简历
  611. *
  612. * @param applyId
  613. * @return
  614. */
  615. public JSONObject getResumeByApplyId(String applyId) throws IOException {
  616. String param = "?applyId=" + applyId;
  617. BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  618. JSONObject jsonObject = beisenApiClient.callGetApi(BeisenParam.GET_RESUMEBYAPPLYID + param, new JSONObject());
  619. return jsonObject;
  620. }
  621. /**
  622. * 招聘管理简历基本信息
  623. *
  624. * @param personProfile
  625. */
  626. public void saveResumeBaseRec(Context ctx, JSONArray personProfile, ResumeBaseRecInfo resumeBaseRecInfo, Map mapData) throws BOSException, EASBizException, ParseException, IOException {
  627. logger.error("personProfile--" + personProfile);
  628. BeisenParamByProperties beisenParamByProperties = new BeisenParamByProperties();
  629. Map<String, String> config = beisenParamByProperties.getConfig();
  630. //招聘业务组织
  631. HROrgUnitInfo hrOrgUnitInfo = new HROrgUnitInfo();
  632. hrOrgUnitInfo.setId(BOSUuid.read("00000000-0000-0000-0000-000000000000CCE7AED4"));
  633. resumeBaseRecInfo.setHrOrgUnit(hrOrgUnitInfo);
  634. //来源方式 INTEGRATESYSTEM=集成系统
  635. resumeBaseRecInfo.setSourceMethod(ResumeSourceMethod.INTEGRATESYSTEM);
  636. //招聘状态 WAITING 待筛选
  637. resumeBaseRecInfo.setResumeStatus(ResumeStatusEnum.WAITING);
  638. //招聘状态 0001 待筛选
  639. IResumeState iResumeState = ResumeStateFactory.getLocalInstance(ctx);
  640. ResumeStateInfo resumeStateInfo = iResumeState.getResumeStateInfo("where number = '0001'");
  641. resumeBaseRecInfo.setResumeState(resumeStateInfo);
  642. //入库时间
  643. resumeBaseRecInfo.setWarehouseEntry(new Date());
  644. //国籍
  645. INationality iNationality = NationalityFactory.getLocalInstance(ctx);
  646. //学历
  647. IDiploma iDiploma = DiplomaFactory.getLocalInstance(ctx);
  648. //政治面貌
  649. IPoliticalFace iPoliticalFace = PoliticalFaceFactory.getLocalInstance(ctx);
  650. //民族
  651. IFolk iFolk = FolkFactory.getLocalInstance(ctx);
  652. //婚姻状况
  653. IWed iWed = WedFactory.getLocalInstance(ctx);
  654. //血型
  655. Map<String, String> bloodTypeMap = InitialValueUtils.bloodTypeMap;
  656. String carType = "";//证件类型
  657. String carno = "";//证件号
  658. for (int i = 0; i < personProfile.size(); i++) {
  659. JSONObject data = personProfile.getJSONObject(i);
  660. String name = data.getString("name");
  661. String value = data.getString("value");
  662. String text = data.getString("text");
  663. //姓名
  664. if ("Name".equals(name)) {
  665. resumeBaseRecInfo.setName(text);
  666. }
  667. //参加工作时间
  668. if ("WorkStartTime".equals(name)) {
  669. resumeBaseRecInfo.setWorkDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  670. }
  671. //参加工作年限 workSeniority
  672. if ("YearsOfWork".equals(name) && !com.kingdee.util.StringUtils.isEmpty(text)) {
  673. resumeBaseRecInfo.setWorkSeniority(text);
  674. }
  675. //工作年限 YearsOfWork
  676. if ("YearsOfWork".equals(name) && !com.kingdee.util.StringUtils.isEmpty(text)) {
  677. resumeBaseRecInfo.setWorkSeniority(text);
  678. }
  679. //身份证号码 identityCardNo
  680. if ("CertificateNumber".equals(name)) {
  681. carno = text;
  682. if ("身份证".equals(carType)) {
  683. resumeBaseRecInfo.setIdentityCardNo(carno);
  684. resumeBaseRecInfo.setPassportNo("");
  685. } else {
  686. resumeBaseRecInfo.setPassportNo(carno);
  687. }
  688. }
  689. //证件类型
  690. if ("CertificateType".equals(name)) {
  691. carType = text;
  692. if ("身份证".equals(text)) {
  693. resumeBaseRecInfo.setIdentityCardNo(carno);
  694. resumeBaseRecInfo.setPassportNo("");
  695. } else {
  696. resumeBaseRecInfo.setPassportNo(carno);
  697. }
  698. }
  699. //出生年月 birthday
  700. if ("Birthday".equals(name)) {
  701. resumeBaseRecInfo.setBirthday(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  702. }
  703. //户口所在地 domicilePlace
  704. if ("AccountArea".equals(name)) {
  705. resumeBaseRecInfo.setDomicilePlace(text);
  706. }
  707. //QQ QQ
  708. if ("QQ".equals(name)) {
  709. resumeBaseRecInfo.setQQ(text);
  710. }
  711. //身高 stature
  712. if ("Height".equals(name)) {
  713. resumeBaseRecInfo.setStature(text);
  714. }
  715. //现居住地 nowResidence
  716. if ("LivingArea".equals(name)) {
  717. resumeBaseRecInfo.setNowResidence(text);
  718. }
  719. //手机号 mobilePhone
  720. if ("Mobile".equals(name)) {
  721. resumeBaseRecInfo.setMobilePhone(text);
  722. }
  723. //家庭电话 fixedPhone
  724. if ("Telephone".equals(name)) {
  725. resumeBaseRecInfo.setFixedPhone(text);
  726. }
  727. //邮件 email
  728. if ("Email".equals(name)) {
  729. resumeBaseRecInfo.setEmail(text);
  730. }
  731. //目前年薪 annualPay
  732. if ("Salary".equals(name)) {
  733. resumeBaseRecInfo.setAnnualPay(text);
  734. }
  735. //目前工作状态 currentWorkingStatus
  736. if ("JobHunting".equals(name)) {
  737. resumeBaseRecInfo.setCurrentWorkingStatus(CurrentWorkingStatusEnum.getEnum(Integer.parseInt(value) - 1));
  738. }
  739. //期望年薪 expectantPay
  740. if ("ExpectSalary".equals(name)) {
  741. resumeBaseRecInfo.setExpectantPay(Integer.parseInt(text));
  742. }
  743. //职业目标 careerGoal
  744. if ("CareerGoals".equals(name)) {
  745. resumeBaseRecInfo.setCareerGoal(text);
  746. }
  747. //自我评价 selfEvaluation
  748. if ("Evaluation".equals(name)) {
  749. resumeBaseRecInfo.setSelfEvaluation(text);
  750. }
  751. //国籍 national
  752. if ("Nationality".equals(name)) {
  753. NationalityCollection nationalityCollection = iNationality.getNationalityCollection("where name like '%" + text + "%'");
  754. if (nationalityCollection.size() > 0) {
  755. resumeBaseRecInfo.setNational(nationalityCollection.get(0));
  756. }
  757. }
  758. //籍贯 nativePlace
  759. if ("NativeArea".equals(name)) {
  760. resumeBaseRecInfo.setNativePlace(text);
  761. }
  762. //年龄 age
  763. if ("OceanAge".equals(name)) {
  764. resumeBaseRecInfo.setAge(Integer.parseInt(text));
  765. }
  766. //最高学历 hDegree
  767. if ("EducationLevel".equals(name)) {
  768. DiplomaCollection diplomaCollection = iDiploma.getDiplomaCollection("where beisenVal = '" + value + "'");
  769. if (!diplomaCollection.isEmpty()) {
  770. resumeBaseRecInfo.setHDegree(diplomaCollection.get(0));
  771. }
  772. }
  773. //政治面貌 politicalFace
  774. if ("Polity".equals(name)) {
  775. PoliticalFaceCollection politicalFaceCollection = iPoliticalFace.getPoliticalFaceCollection("where beisenVal = '" + value + "'");
  776. if (!politicalFaceCollection.isEmpty()) {
  777. resumeBaseRecInfo.setPoliticalFace(politicalFaceCollection.get(0));
  778. }
  779. }
  780. //婚姻状况 wed 北森已停用字段
  781. if (config.get("WedState").equals(name)) {
  782. WedCollection wedCollection = iWed.getWedCollection("where beisenVal = '" + value + "'");
  783. if (!wedCollection.isEmpty()) {
  784. resumeBaseRecInfo.setWed(wedCollection.get(0));
  785. }
  786. }
  787. //民族 folk
  788. if ("Nation".equals(name)) {
  789. FolkCollection folkCollection = iFolk.getFolkCollection("where beisenVal = '" + value + "'");
  790. if (!folkCollection.isEmpty()) {
  791. resumeBaseRecInfo.setFolk(folkCollection.get(0));
  792. }
  793. }
  794. //毕业学校 school
  795. if ("LastSchool".equals(name)) {
  796. if (com.kingdee.util.StringUtils.isEmpty(text)) {
  797. throw new BOSException("毕业学校不能为空!");
  798. }
  799. resumeBaseRecInfo.setName(text);
  800. }
  801. //血型 bloodType
  802. if ("BloodType".equals(name)) {
  803. String hDegree = bloodTypeMap.getOrDefault(value, "90");
  804. resumeBaseRecInfo.setBloodType(BloodType.getEnum(hDegree));
  805. }
  806. //紧急联系人 emergencyContact
  807. if ("EmergencyContact".equals(name)) {
  808. resumeBaseRecInfo.setEmergencyContact(text);
  809. }
  810. //紧急联系人电话 emergencyContactPhone
  811. if ("EmergencyPhone".equals(name)) {
  812. resumeBaseRecInfo.setEmergencyContactPhone(text);
  813. }
  814. //期望月薪 expectantPayStr
  815. if ("ExpectSalary".equals(name)) {
  816. resumeBaseRecInfo.setExpectantPayStr(text);
  817. }
  818. //最近工作单位 lastCompany
  819. if ("LastCompany".equals(name)) {
  820. resumeBaseRecInfo.setLastCompany(text);
  821. }
  822. //最近工作行业 lastIndustry
  823. if ("LastIndustry".equals(name)) {
  824. resumeBaseRecInfo.setLastIndustry(text);
  825. }
  826. //专业 major
  827. if ("LastDiscipline".equals(name)) {
  828. resumeBaseRecInfo.setMajor(text);
  829. }
  830. //性别 gender
  831. if ("Gender".equals(name)) {
  832. if ("1".equals(value) || "0".equals(value)) {
  833. resumeBaseRecInfo.setGender(Genders.getEnum(Integer.parseInt(value) + 1));
  834. }
  835. }
  836. //更新简历时间 updateResumeDate
  837. if ("ResumeUpdateTime".equals(name)) {
  838. resumeBaseRecInfo.setUpdateResumeDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  839. }
  840. //签发机关 idCardIssueOrg
  841. if ("CertificateGrantUnit".equals(name)) {
  842. resumeBaseRecInfo.setIdentityCardNo(text);
  843. }
  844. //证件有效期-开始时间 idCardBeginDate
  845. if ("CertificateValidityDate".equals(name)) {
  846. resumeBaseRecInfo.setIdCardBeginDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  847. }
  848. //证件有效期-结束时间 idCardEndDate
  849. if ("CertificateValidityOverDate".equals(name)) {
  850. resumeBaseRecInfo.setIdCardEndDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  851. }
  852. //到岗时间 arrivalTime
  853. if ("AvailableDate".equals(name)) {
  854. resumeBaseRecInfo.setArrivalTime(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  855. }
  856. //英文名 EnglishName
  857. if ("NameEn".equals(name)) {
  858. resumeBaseRecInfo.setEnglishName(text);
  859. }
  860. //户籍地址 domicileAddress
  861. if ("Address".equals(name)) {
  862. resumeBaseRecInfo.setDomicileAddress(text);
  863. }
  864. }
  865. String errorMsg = ",身份证号码、手机号为必填数据,请在北森维护数据后再次同步!";
  866. if (com.kingdee.util.StringUtils.isEmpty(resumeBaseRecInfo.getIdentityCardNo()) && com.kingdee.util.StringUtils.isEmpty(resumeBaseRecInfo.getPassportNo())) {
  867. throw new BOSException("身份证号码不能为空" + errorMsg);
  868. }
  869. if (com.kingdee.util.StringUtils.isEmpty(resumeBaseRecInfo.getMobilePhone())) {
  870. throw new BOSException("手机号码不能为空" + errorMsg);
  871. }
  872. IResumeBaseRec iResumeBaseRec = ResumeBaseRecFactory.getLocalInstance(ctx);
  873. IObjectPK save = iResumeBaseRec.save(resumeBaseRecInfo);
  874. logger.error("resumeBaseRecId--" + save);
  875. mapData.put("resumeBaseRecId", save.toString());
  876. mapData.put("name", resumeBaseRecInfo.getName());
  877. // } catch (Exception e) {
  878. // logger.error("简历基本信息报错信息:" + e.getMessage());
  879. // throw new RuntimeException(e);
  880. // }
  881. }
  882. /**
  883. * 简历-工作经历
  884. *
  885. * @param workExperience
  886. */
  887. public void saveWorkingExp(Context ctx, JSONArray workExperience, ResumeBaseRecInfo resumeBaseRecInfo) {
  888. logger.error("workExperience--" + workExperience);
  889. try {
  890. IWorkingExp iWorkingExp = WorkingExpFactory.getLocalInstance(ctx);
  891. WorkingExpCollection workingExpColl = iWorkingExp.getWorkingExpCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  892. if (!workingExpColl.isEmpty()) {
  893. iWorkingExp.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  894. }
  895. for (int i = 0; i < workExperience.size(); i++) {
  896. JSONArray array = workExperience.getJSONArray(i);
  897. WorkingExpInfo workingExpInfo = new WorkingExpInfo();
  898. //简历基本信息
  899. workingExpInfo.setResumeBase(resumeBaseRecInfo);
  900. for (int j = 0; j < array.size(); j++) {
  901. JSONObject data = array.getJSONObject(j);
  902. String name = data.getString("name");
  903. String value = data.getString("value");
  904. String text = data.getString("text");
  905. //dateStart 开始时间
  906. if ("StartDate".equals(name)) {
  907. workingExpInfo.setDateStart(DateTimeUtils.parseDate(text, "yyyy/MM"));
  908. }
  909. //dateEnd 结束时间
  910. if ("EndDate".equals(name)) {
  911. if ("至今".equals(text)) {
  912. text = "2199/12";
  913. }
  914. workingExpInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  915. }
  916. //company 公司名称
  917. if ("CompanyName".equals(name)) {
  918. workingExpInfo.setCompany(text);
  919. }
  920. //department 任职部门
  921. if ("Department".equals(name)) {
  922. workingExpInfo.setDepartment(text);
  923. }
  924. //jobCategory 职位类别
  925. if ("OgJobLevel".equals(name)) {
  926. workingExpInfo.setJobCategory(text);
  927. }
  928. //industry 所属行业
  929. if ("Industry".equals(name)) {
  930. workingExpInfo.setIndustry(text);
  931. }
  932. //position 职位名称
  933. if ("JobTitle".equals(name)) {
  934. workingExpInfo.setPosition(text);
  935. }
  936. //underlingNumber 下属人数
  937. if ("SubordinateNumber".equals(name)) {
  938. workingExpInfo.setUnderlingNumber(Integer.parseInt(text));
  939. }
  940. //monthPay 税前月薪
  941. if ("Salary".equals(name)) {
  942. workingExpInfo.setMonthPay(Integer.parseInt(text));
  943. }
  944. //certifier 证明人
  945. if ("ReferenceName".equals(name)) {
  946. workingExpInfo.setCertifier(text);
  947. }
  948. //leavingReason 离职原因
  949. if ("ReasonOfLeaving".equals(name)) {
  950. workingExpInfo.setLeavingReason(text);
  951. }
  952. //certifierPhone 证明人电话
  953. if ("ReferenceContact".equals(name)) {
  954. workingExpInfo.setCertifierPhone(text);
  955. }
  956. //monthPayStr 税前月薪
  957. if ("Salary".equals(name)) {
  958. workingExpInfo.setMonthPayStr(text);
  959. }
  960. //unitAddress 工作地点 OgJobArea
  961. if ("JobArea".equals(name)) {
  962. workingExpInfo.setUnitAddress(text);
  963. }
  964. }
  965. iWorkingExp.save(workingExpInfo);
  966. }
  967. } catch (Exception e) {
  968. logger.error("简历-工作经历保存失败!" + e.getMessage());
  969. }
  970. }
  971. /**
  972. * 简历-教育经历
  973. *
  974. * @param education
  975. */
  976. public void saveEducationExpRE(Context ctx, JSONArray education, ResumeBaseRecInfo resumeBaseRecInfo) throws BOSException, EASBizException {
  977. logger.error("education--" + education);
  978. try {
  979. IEducationExpREC iEducationExpREC = EducationExpRECFactory.getLocalInstance(ctx);
  980. EducationExpRECCollection educationExpRECCollection = iEducationExpREC.getEducationExpRECCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  981. if (!educationExpRECCollection.isEmpty()) {
  982. iEducationExpREC.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  983. }
  984. //学历
  985. IDiploma iDiploma = DiplomaFactory.getLocalInstance(ctx);
  986. //学位
  987. IDegree iDegree = DegreeFactory.getLocalInstance(ctx);
  988. //学院类型
  989. Map<String, String> bchoolTypeMap = InitialValueUtils.getBchoolTypeMap();
  990. //最晚开始日期
  991. Date maxStartDate = null;
  992. for (int i = 0; i < education.size(); i++) {
  993. JSONArray array = education.getJSONArray(i);
  994. EducationExpRECInfo educationExpRECInfo = new EducationExpRECInfo();
  995. //简历基本信息
  996. educationExpRECInfo.setResumeBase(resumeBaseRecInfo);
  997. for (int j = 0; j < array.size(); j++) {
  998. JSONObject data = array.getJSONObject(j);
  999. String name = data.getString("name");
  1000. String value = data.getString("value");
  1001. String text = data.getString("text");
  1002. //dateStart 开始时间
  1003. if ("StartDate".equals(name)) {
  1004. Date date = DateTimeUtils.parseDate(text, "yyyy/MM");
  1005. educationExpRECInfo.setDateStart(date);
  1006. }
  1007. //dateEnd 结束时间
  1008. if ("EndDate".equals(name)) {
  1009. if ("至今".equals(text)) {
  1010. text = "2199/12";
  1011. }
  1012. educationExpRECInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1013. }
  1014. //school 毕业学校
  1015. if ("SchoolName".equals(name)) {
  1016. educationExpRECInfo.setSchool(text);
  1017. }
  1018. //academicDiplomasF7 学位
  1019. if ("Degree".equals(name)) {
  1020. DegreeCollection degreeCollection = iDegree.getDegreeCollection("where beisenVal = '" + value + "'");
  1021. if (!degreeCollection.isEmpty()) {
  1022. educationExpRECInfo.setAcademicDiplomasF7(degreeCollection.get(0));
  1023. }
  1024. }
  1025. //major 专业
  1026. if ("MajorName".equals(name)) {
  1027. educationExpRECInfo.setMajor(text);
  1028. }
  1029. //degreeF7 学历
  1030. if ("EducationLevel".equals(name)) {
  1031. DiplomaCollection diplomaCollection = iDiploma.getDiplomaCollection("where beisenVal = '" + value + "'");
  1032. if (!diplomaCollection.isEmpty()) {
  1033. educationExpRECInfo.setDegreeF7(diplomaCollection.get(0));
  1034. }
  1035. }
  1036. //schoolType 学院类型
  1037. if ("SchoolType".equals(name)) {
  1038. if (bchoolTypeMap.containsKey(value)) {
  1039. educationExpRECInfo.setSchoolType(SchoolTypeEnum.getEnum(bchoolTypeMap.get(value)));
  1040. }
  1041. }
  1042. }
  1043. String errorMsg = ",入学时间、专业、学历、毕业院校为必填数据,请在北森维护数据后再次同步!";
  1044. Date dateStart = educationExpRECInfo.getDateStart();
  1045. if (dateStart == null) {
  1046. throw new BOSException("教育经历:入学时间不能为空" + errorMsg);
  1047. }
  1048. if (com.kingdee.util.StringUtils.isEmpty(educationExpRECInfo.getMajor())) {
  1049. throw new BOSException("教育经历:专业不能为空" + errorMsg);
  1050. }
  1051. if (com.kingdee.util.StringUtils.isEmpty(educationExpRECInfo.getSchool())) {
  1052. throw new BOSException("教育经历:毕业院校不能为空" + errorMsg);
  1053. }
  1054. if (educationExpRECInfo.getDegreeF7() == null) {
  1055. throw new BOSException("教育经历:学历不能为空" + errorMsg);
  1056. }
  1057. if (maxStartDate == null || maxStartDate.before(dateStart)) {
  1058. maxStartDate = dateStart;
  1059. resumeBaseRecInfo.setMajor(educationExpRECInfo.getMajor());
  1060. resumeBaseRecInfo.setSchool(educationExpRECInfo.getSchool());
  1061. }
  1062. iEducationExpREC.save(educationExpRECInfo);
  1063. }
  1064. } catch (Exception e) {
  1065. IResumeBaseRec iResumeBaseRec = ResumeBaseRecFactory.getLocalInstance(ctx);
  1066. iResumeBaseRec.delete(new ObjectUuidPK(resumeBaseRecInfo.getId()));
  1067. logger.error("简历-教育经历保存失败!" + e.getMessage());
  1068. throw new RuntimeException(e);
  1069. }
  1070. IResumeBaseRec iResumeBaseRec = ResumeBaseRecFactory.getLocalInstance(ctx);
  1071. iResumeBaseRec.save(resumeBaseRecInfo);
  1072. }
  1073. /**
  1074. * 简历-获奖经历
  1075. *
  1076. * @param awards
  1077. */
  1078. public void saveResumeRewardPunish(Context ctx, JSONArray awards, ResumeBaseRecInfo resumeBaseRecInfo) {
  1079. logger.error("awards--" + awards);
  1080. try {
  1081. IResumeRewardPunish iResumeRewardPunish = ResumeRewardPunishFactory.getLocalInstance(ctx);
  1082. ResumeRewardPunishCollection ResumeRewardPunishCollection = iResumeRewardPunish.getResumeRewardPunishCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1083. if (!ResumeRewardPunishCollection.isEmpty()) {
  1084. iResumeRewardPunish.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1085. }
  1086. for (int i = 0; i < awards.size(); i++) {
  1087. JSONArray array = awards.getJSONArray(i);
  1088. ResumeRewardPunishInfo ResumeRewardPunishInfo = new ResumeRewardPunishInfo();
  1089. //简历基本信息
  1090. ResumeRewardPunishInfo.setResumeBase(resumeBaseRecInfo);
  1091. for (int j = 0; j < array.size(); j++) {
  1092. JSONObject data = array.getJSONObject(j);
  1093. String name = data.getString("name");
  1094. String value = data.getString("value");
  1095. String text = data.getString("text");
  1096. //occurDate 获奖时间
  1097. if ("AwardTime".equals(name)) {
  1098. ResumeRewardPunishInfo.setOccurDate(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1099. }
  1100. //title 获奖名称
  1101. if ("AwardName".equals(name)) {
  1102. ResumeRewardPunishInfo.setTitle(text);
  1103. ResumeRewardPunishInfo.setName(text);
  1104. }
  1105. //description 描述
  1106. if ("AwardDescription".equals(name)) {
  1107. ResumeRewardPunishInfo.setDescription(text);
  1108. }
  1109. }
  1110. iResumeRewardPunish.save(ResumeRewardPunishInfo);
  1111. }
  1112. } catch (Exception e) {
  1113. logger.error("简历-获奖经历保存失败!" + e.getMessage());
  1114. }
  1115. }
  1116. /**
  1117. * 简历-项目经历
  1118. *
  1119. * @param project
  1120. */
  1121. public void saveProjectExp(Context ctx, JSONArray project, ResumeBaseRecInfo resumeBaseRecInfo) {
  1122. logger.error("project--" + project);
  1123. try {
  1124. IProjectExp iProjectExp = ProjectExpFactory.getLocalInstance(ctx);
  1125. ProjectExpCollection ProjectExpCollection = iProjectExp.getProjectExpCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1126. if (!ProjectExpCollection.isEmpty()) {
  1127. iProjectExp.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1128. }
  1129. for (int i = 0; i < project.size(); i++) {
  1130. JSONArray array = project.getJSONArray(i);
  1131. ProjectExpInfo ProjectExpInfo = new ProjectExpInfo();
  1132. //简历基本信息
  1133. ProjectExpInfo.setResumeBase(resumeBaseRecInfo);
  1134. for (int j = 0; j < array.size(); j++) {
  1135. JSONObject data = array.getJSONObject(j);
  1136. String name = data.getString("name");
  1137. String value = data.getString("value");
  1138. String text = data.getString("text");
  1139. //dateStart 开始时间
  1140. if ("StartDate".equals(name)) {
  1141. ProjectExpInfo.setDateStart(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1142. }
  1143. //dateEnd 结束时间
  1144. if ("EndDate".equals(name)) {
  1145. if ("至今".equals(text)) {
  1146. text = "2199/12";
  1147. }
  1148. ProjectExpInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1149. }
  1150. //customer 项目名称
  1151. if ("ProjectName".equals(name)) {
  1152. ProjectExpInfo.setCustomer(text);
  1153. }
  1154. //projectDescription 项目描述
  1155. if ("ProjectInfo".equals(name)) {
  1156. ProjectExpInfo.setProjectDescription(text);
  1157. }
  1158. }
  1159. iProjectExp.save(ProjectExpInfo);
  1160. }
  1161. } catch (Exception e) {
  1162. logger.error("简历-项目经历保存失败!" + e.getMessage());
  1163. }
  1164. }
  1165. /**
  1166. * 简历-培训经历
  1167. *
  1168. * @param train
  1169. */
  1170. public void saveTrainingExp(Context ctx, JSONArray train, ResumeBaseRecInfo resumeBaseRecInfo) {
  1171. logger.error("train--" + train);
  1172. try {
  1173. ITrainingExp iTrainingExp = TrainingExpFactory.getLocalInstance(ctx);
  1174. TrainingExpCollection TrainingExpCollection = iTrainingExp.getTrainingExpCollection("where resumeBaseInfo = '" + resumeBaseRecInfo.getId().toString() + "'");
  1175. if (!TrainingExpCollection.isEmpty()) {
  1176. iTrainingExp.delete("where resumeBaseInfo = '" + resumeBaseRecInfo.getId().toString() + "'");
  1177. }
  1178. for (int i = 0; i < train.size(); i++) {
  1179. JSONArray array = train.getJSONArray(i);
  1180. TrainingExpInfo TrainingExpInfo = new TrainingExpInfo();
  1181. //简历基本信息
  1182. TrainingExpInfo.setResumeBaseInfo(resumeBaseRecInfo);
  1183. for (int j = 0; j < array.size(); j++) {
  1184. JSONObject data = array.getJSONObject(j);
  1185. String name = data.getString("name");
  1186. String value = data.getString("value");
  1187. String text = data.getString("text");
  1188. //dateStart 开始时间
  1189. if ("StartDate".equals(name)) {
  1190. TrainingExpInfo.setDateStart(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1191. }
  1192. //dateEnd 结束时间
  1193. if ("EndDate".equals(name)) {
  1194. if ("至今".equals(text)) {
  1195. text = "2199/12";
  1196. }
  1197. TrainingExpInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1198. }
  1199. //trainingInstitution 培训机构
  1200. if ("OrgName".equals(name)) {
  1201. TrainingExpInfo.setTrainingInstitution(text);
  1202. }
  1203. //courseDescription 课程描述
  1204. if ("Description".equals(name)) {
  1205. TrainingExpInfo.setCourseDescription(text);
  1206. }
  1207. }
  1208. iTrainingExp.save(TrainingExpInfo);
  1209. }
  1210. } catch (Exception e) {
  1211. logger.error("简历-培训经历保存失败!" + e.getMessage());
  1212. }
  1213. }
  1214. /**
  1215. * 简历-获得证书
  1216. *
  1217. * @param certificate
  1218. */
  1219. public void saveCredential(Context ctx, JSONArray certificate, ResumeBaseRecInfo resumeBaseRecInfo) {
  1220. logger.error("certificate--" + certificate);
  1221. try {
  1222. ICredential iCredential = CredentialFactory.getLocalInstance(ctx);
  1223. CredentialCollection CredentialCollection = iCredential.getCredentialCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1224. if (!CredentialCollection.isEmpty()) {
  1225. iCredential.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1226. }
  1227. for (int i = 0; i < certificate.size(); i++) {
  1228. JSONArray array = certificate.getJSONArray(i);
  1229. CredentialInfo credentialInfo = new CredentialInfo();
  1230. //简历基本信息
  1231. credentialInfo.setResumeBase(resumeBaseRecInfo);
  1232. for (int j = 0; j < array.size(); j++) {
  1233. JSONObject data = array.getJSONObject(j);
  1234. String name = data.getString("name");
  1235. String value = data.getString("value");
  1236. String text = data.getString("text");
  1237. //date 证书发放日期
  1238. if ("ObtainDate".equals(name)) {
  1239. credentialInfo.setDate(DateTimeUtils.parseDate(text, "yyyy/MM"));
  1240. }
  1241. //credentialName 证书名称
  1242. if ("CertificateName".equals(name)) {
  1243. credentialInfo.setCredentialName(text);
  1244. }
  1245. //issuer 证书发布机构
  1246. if ("Authority".equals(name)) {
  1247. credentialInfo.setIssuer(text);
  1248. }
  1249. //grade 证书成绩
  1250. if ("Score".equals(name)) {
  1251. credentialInfo.setGrade(text);
  1252. }
  1253. }
  1254. iCredential.save(credentialInfo);
  1255. }
  1256. } catch (Exception e) {
  1257. logger.error("简历-获得证书保存失败!" + e.getMessage());
  1258. }
  1259. }
  1260. /**
  1261. * 简历-语言能力
  1262. *
  1263. * @param lang
  1264. */
  1265. public void saveLanguageAbility(Context ctx, JSONArray lang, ResumeBaseRecInfo resumeBaseRecInfo) {
  1266. logger.error("lang--" + lang);
  1267. try {
  1268. ILanguageAbility iLanguageAbility = LanguageAbilityFactory.getLocalInstance(ctx);
  1269. LanguageAbilityCollection LanguageAbilityCollection = iLanguageAbility.getLanguageAbilityCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1270. if (!LanguageAbilityCollection.isEmpty()) {
  1271. iLanguageAbility.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1272. }
  1273. //熟练度
  1274. Map<String, String> proficiencyMap = InitialValueUtils.getProficiencyMap();
  1275. for (int i = 0; i < lang.size(); i++) {
  1276. JSONArray array = lang.getJSONArray(i);
  1277. LanguageAbilityInfo languageAbilityInfo = new LanguageAbilityInfo();
  1278. //简历基本信息
  1279. languageAbilityInfo.setResumeBase(resumeBaseRecInfo);
  1280. for (int j = 0; j < array.size(); j++) {
  1281. JSONObject data = array.getJSONObject(j);
  1282. String name = data.getString("name");
  1283. String value = data.getString("value");
  1284. String text = data.getString("text");
  1285. //listeningSpeaking 听说
  1286. if ("ListeningSpeakingAbility".equals(name)) {
  1287. if (proficiencyMap.containsKey(value)) {
  1288. languageAbilityInfo.setListeningSpeaking(ProficiencyEnum.getEnum(proficiencyMap.get(value)));
  1289. }
  1290. }
  1291. //readingWriting 读写
  1292. if ("ReadingWritingAbility".equals(name)) {
  1293. languageAbilityInfo.setReadingWriting(ProficiencyEnum.getEnum(proficiencyMap.get(value)));
  1294. }
  1295. //language 语言
  1296. if ("LanguageType".equals(name)) {
  1297. languageAbilityInfo.setLanguage(text);
  1298. }
  1299. //lv 语言等级
  1300. if ("LanguageLevel".equals(name)) {
  1301. languageAbilityInfo.setLv(text);
  1302. }
  1303. }
  1304. iLanguageAbility.save(languageAbilityInfo);
  1305. }
  1306. } catch (Exception e) {
  1307. logger.error("简历-语言能力保存失败!" + e.getMessage());
  1308. }
  1309. }
  1310. /**
  1311. * 简历-专业技能
  1312. *
  1313. * @param skill
  1314. */
  1315. public void saveProfessionalSkills(Context ctx, JSONArray skill, ResumeBaseRecInfo resumeBaseRecInfo) {
  1316. logger.error("skill--" + skill);
  1317. try {
  1318. IProfessionalSkills iProfessionalSkills = ProfessionalSkillsFactory.getLocalInstance(ctx);
  1319. ProfessionalSkillsCollection ProfessionalSkillsCollection = iProfessionalSkills.getProfessionalSkillsCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1320. if (!ProfessionalSkillsCollection.isEmpty()) {
  1321. iProfessionalSkills.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1322. }
  1323. for (int i = 0; i < skill.size(); i++) {
  1324. JSONArray array = skill.getJSONArray(i);
  1325. ProfessionalSkillsInfo professionalSkillsInfo = new ProfessionalSkillsInfo();
  1326. //简历基本信息
  1327. professionalSkillsInfo.setResumeBase(resumeBaseRecInfo);
  1328. for (int j = 0; j < array.size(); j++) {
  1329. JSONObject data = array.getJSONObject(j);
  1330. String name = data.getString("name");
  1331. String value = data.getString("value");
  1332. String text = data.getString("text");
  1333. //skillName 技能名称
  1334. if ("SkillName".equals(name)) {
  1335. professionalSkillsInfo.setSkillName(text);
  1336. }
  1337. //skillDescription 技能描述
  1338. if ("SkillDescription".equals(name)) {
  1339. professionalSkillsInfo.setSkillDescription(text);
  1340. }
  1341. }
  1342. iProfessionalSkills.save(professionalSkillsInfo);
  1343. }
  1344. } catch (Exception e) {
  1345. logger.error("简历-专业技能保存失败!" + e.getMessage());
  1346. }
  1347. }
  1348. /**
  1349. * 简历-社会关系
  1350. *
  1351. * @param
  1352. */
  1353. public void saveFamilyInfo(Context ctx, JSONArray family, ResumeBaseRecInfo resumeBaseRecInfo) {
  1354. logger.error("family--" + family);
  1355. try {
  1356. IResumeFamily familyIns = ResumeFamilyFactory.getLocalInstance(ctx);
  1357. ResumeFamilyCollection familyCol = familyIns.getResumeFamilyCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1358. //关系
  1359. IRelation relationIns = RelationFactory.getLocalInstance(ctx);
  1360. //简历基本信息
  1361. for (int i = 0; i < family.size(); i++) {
  1362. ResumeFamilyInfo familyInfo = new ResumeFamilyInfo();
  1363. if (familyCol.size() > i) {
  1364. familyInfo = familyCol.get(i);
  1365. }
  1366. familyInfo.setResumeBase(resumeBaseRecInfo);
  1367. JSONArray array = family.getJSONArray(i);
  1368. for (int j = 0; j < array.size(); j++) {
  1369. JSONObject data = array.getJSONObject(j);
  1370. String name = data.getString("name");
  1371. String value = data.getString("value");
  1372. String text = data.getString("text");
  1373. //姓名
  1374. if ("Name".equals(name)) {
  1375. familyInfo.setName(value);
  1376. }
  1377. // 与本人关系
  1378. if ("relation".equals(name)) {
  1379. RelationCollection relationCol = relationIns.getRelationCollection("where beisenVal = '" + value + "'");
  1380. if (!relationCol.isEmpty()) {
  1381. familyInfo.setRelation(relationCol.get(0));
  1382. }
  1383. }
  1384. if ("age".equals(name)) {
  1385. familyInfo.setAge(text);
  1386. }
  1387. //职务
  1388. if ("JobTitle".equals(name)) {
  1389. familyInfo.setSpecDuty(text);
  1390. }
  1391. //公司名
  1392. if ("CompanyName".equals(name)) {
  1393. familyInfo.setWorkUnit(text);
  1394. }
  1395. //telephone
  1396. if ("telephone".equals(name)) {
  1397. familyInfo.setOfficePhone(text);
  1398. }
  1399. familyIns.save(familyInfo);
  1400. }
  1401. }
  1402. } catch (Exception e) {
  1403. logger.error("社会关系保存失败!" + e.getMessage());
  1404. throw new RuntimeException(e);
  1405. }
  1406. }
  1407. /**
  1408. * coyle
  1409. *
  1410. * @param ctx
  1411. * @param billId
  1412. * @throws BOSException
  1413. * @throws EASBizException
  1414. */
  1415. @Override
  1416. protected void _syncRecuritmentToBeisen(Context ctx, String billId) throws BOSException, EASBizException {
  1417. super._syncRecuritmentToBeisen(ctx, billId);
  1418. IRecuritmentDemand dIns = RecuritmentDemandFactory.getLocalInstance(ctx);
  1419. RecuritmentDemandInfo recuritmentDemandInfo = dIns.getRecuritmentDemandInfo(new ObjectUuidPK(billId));
  1420. //更新或新增
  1421. try {
  1422. //测试环境或者线上环境
  1423. boolean isProductionEnv = false;
  1424. BeisenParamByProperties beisenParamByProperties = new BeisenParamByProperties();
  1425. Map<String, String> config = beisenParamByProperties.getConfig();
  1426. String isProductionEnvStr = config.get("isProductionEnv");// 线上环境
  1427. if (!StringUtils.isEmpty(isProductionEnvStr) && isProductionEnvStr.equals("true")) {
  1428. isProductionEnv = true;
  1429. }
  1430. RecruitmentDemandService recruitmentDemandService = new RecruitmentDemandService(isProductionEnv);
  1431. Object requirementId = recuritmentDemandInfo.get("requirementId");
  1432. if (ObjectUtils.allNotNull(requirementId)) {
  1433. recruitmentDemandService.updateRequirement(ctx, String.valueOf(requirementId), recuritmentDemandInfo);
  1434. } else {
  1435. recruitmentDemandService.createRecruitmentDemand(ctx, recuritmentDemandInfo);
  1436. }
  1437. } catch (Exception e) {
  1438. SelectorItemCollection selectorCol = new SelectorItemCollection();
  1439. selectorCol.add(new SelectorItemInfo("syncBeisenResult"));
  1440. String message = e.getMessage();
  1441. recuritmentDemandInfo.put("syncBeisenResult", "失败: " + message);
  1442. dIns.updatePartial(recuritmentDemandInfo, selectorCol);
  1443. throw new RuntimeException(e);
  1444. }
  1445. }
  1446. /**
  1447. * 招聘需求更新
  1448. * coyle
  1449. */
  1450. @Override
  1451. protected void _updateRecuritment(Context ctx, String startDate, String endDate, int offset) throws BOSException, EASBizException {
  1452. super._updateRecuritment(ctx, startDate, endDate, offset);
  1453. // 0. 参数校验与日期解析
  1454. DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  1455. LocalDate start = LocalDate.now();
  1456. LocalDate end = LocalDate.now();
  1457. //如果时间参数都为空,则使用offset参数
  1458. if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate)) {
  1459. if (offset > 0) {
  1460. //eDate增加offset天
  1461. end = end.plusDays(offset);
  1462. } else if (offset < 0) {
  1463. start = start.plusDays(offset);
  1464. }
  1465. }
  1466. if (!StringUtils.isEmpty(startDate)) {
  1467. //开始日期字定义,结束日期都是今天
  1468. start = LocalDate.parse(startDate, dateFormatter);
  1469. }
  1470. if (!StringUtils.isEmpty(endDate)) {
  1471. //开始日期,结束日期都是今天
  1472. end = LocalDate.parse(endDate, dateFormatter);
  1473. }
  1474. if (start.isAfter(end)) {
  1475. throw new BOSException("开始日期不能晚于结束日期");
  1476. }
  1477. // LocalDate 转 String (使用之前的 dateFormatter)
  1478. String startStr = toStartTime(start.format(dateFormatter));
  1479. String endStr = toEndTime(end.format(dateFormatter));
  1480. IRecuritmentDemand localInstance = RecuritmentDemandFactory.getLocalInstance(ctx);
  1481. EntityViewInfo ev = new EntityViewInfo();
  1482. FilterInfo filter = new FilterInfo();
  1483. filter.getFilterItems().add(new FilterItemInfo("requirementId", null, CompareType.NOTEMPTY));
  1484. filter.getFilterItems().add(new FilterItemInfo("lastUpdateTime", startStr, CompareType.GREATER_EQUALS));
  1485. filter.getFilterItems().add(new FilterItemInfo("lastUpdateTime", endStr, CompareType.LESS_EQUALS));
  1486. ev.setFilter(filter);
  1487. RecuritmentDemandCollection recuritmentDemandCollection = localInstance.getRecuritmentDemandCollection(ev);
  1488. for (int i = 0; i < recuritmentDemandCollection.size(); i++) {
  1489. RecuritmentDemandInfo recuritmentDemandInfo = recuritmentDemandCollection.get(i);
  1490. _syncRecuritmentToBeisen(ctx, recuritmentDemandInfo.getId().toString());
  1491. }
  1492. }
  1493. /**
  1494. * 将日期字符串转换为一天的开始时间(UTC格式)
  1495. *
  1496. * @param dateStr "yyyy-MM-dd"格式的日期字符串
  1497. * @return Moka API要求的时间格式
  1498. */
  1499. public static String toStartTime(String dateStr) {
  1500. LocalDate date = LocalDate.parse(dateStr);
  1501. LocalDateTime startOfDay = date.atStartOfDay();
  1502. return TIME_FORMATTER.format(startOfDay);
  1503. }
  1504. /**
  1505. * 将日期字符串转换为一天的结束时间(UTC格式)
  1506. *
  1507. * @param dateStr "yyyy-MM-dd"格式的日期字符串
  1508. * @return Moka API要求的时间格式
  1509. */
  1510. public static String toEndTime(String dateStr) {
  1511. LocalDate date = LocalDate.parse(dateStr);
  1512. LocalDateTime endOfDay = date.atTime(23, 59, 59);
  1513. return TIME_FORMATTER.format(endOfDay);
  1514. }
  1515. }