RecuritmentFacadeControllerBean.java 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230
  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.metadata.entity.*;
  9. import com.kingdee.bos.metadata.query.util.CompareType;
  10. import com.kingdee.bos.util.BOSUuid;
  11. import com.kingdee.eas.basedata.hraux.*;
  12. import com.kingdee.eas.basedata.org.HROrgUnitInfo;
  13. import com.kingdee.eas.basedata.person.BloodType;
  14. import com.kingdee.eas.basedata.person.Genders;
  15. import com.kingdee.eas.common.EASBizException;
  16. import com.kingdee.eas.csinterface.agent.service.base.util.DateTimeUtils;
  17. import com.kingdee.eas.custom.beisen.utils.BeisenApiClient;
  18. import com.kingdee.eas.custom.beisen.utils.BeisenParam;
  19. import com.kingdee.eas.custom.beisen.utils.BeisenParamByProperties;
  20. import com.kingdee.eas.custom.recuritment.ApplicantBeisenCollection;
  21. import com.kingdee.eas.custom.recuritment.ApplicantBeisenFactory;
  22. import com.kingdee.eas.custom.recuritment.ApplicantBeisenInfo;
  23. import com.kingdee.eas.custom.recuritment.IApplicantBeisen;
  24. import com.kingdee.eas.custom.recuritment.bizEnum.ExecuteResultEnum;
  25. import com.kingdee.eas.custom.recuritment.utils.AttachmentUtils;
  26. import com.kingdee.eas.custom.recuritment.utils.InitialValueUtils;
  27. import com.kingdee.eas.hr.base.IRelation;
  28. import com.kingdee.eas.hr.base.RelationCollection;
  29. import com.kingdee.eas.hr.base.RelationFactory;
  30. import com.kingdee.shr.recuritment.*;
  31. import com.kingdee.util.StringUtils;
  32. import org.apache.commons.lang3.ObjectUtils;
  33. import org.apache.log4j.Logger;
  34. import org.apache.logging.log4j.util.TriConsumer;
  35. import java.io.IOException;
  36. import java.text.ParseException;
  37. import java.time.LocalDate;
  38. import java.time.LocalDateTime;
  39. import java.time.format.DateTimeFormatter;
  40. import java.util.*;
  41. public class RecuritmentFacadeControllerBean extends AbstractRecuritmentFacadeControllerBean {
  42. private static final Logger logger = Logger.getLogger(RecuritmentFacadeControllerBean.class);
  43. // 北京时区/shanghai时区
  44. // private static final ZoneId BEIJING_ZONE = ZoneId.of("Asia/Shanghai");
  45. private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  46. /**
  47. * 同步北森简历和附件
  48. *
  49. * @param ctx
  50. * @param billId 单据ID
  51. * @throws BOSException
  52. * @throws EASBizException
  53. */
  54. @Override
  55. protected void _syncBeisenResume(Context ctx, String billId) throws BOSException, EASBizException {
  56. super._syncBeisenResume(ctx, billId);
  57. //北森应聘者
  58. IApplicantBeisen iApplicantBeisen = ApplicantBeisenFactory.getLocalInstance(ctx);
  59. FilterInfo filterInfo = new FilterInfo();
  60. FilterItemCollection filterItems = filterInfo.getFilterItems();
  61. if (!StringUtils.isEmpty(billId)) {
  62. filterItems.add(new FilterItemInfo("id", billId));
  63. } else {
  64. filterItems.add(new FilterItemInfo("syncStatus", "0"));
  65. }
  66. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, null, null);
  67. ApplicantBeisenCollection applicantBeisenCollection = iApplicantBeisen.getApplicantBeisenCollection(entityViewInfo);
  68. //同步结果
  69. int errorSize = 0;
  70. int successSize = 0;
  71. Map msgMap = new HashMap();
  72. for (int i = 0; i < applicantBeisenCollection.size(); i++) {
  73. ApplicantBeisenInfo applicantBeisenInfo = applicantBeisenCollection.get(i);
  74. //申请id
  75. String applyId = applicantBeisenInfo.getApplyId();
  76. //应聘者id
  77. String candidateId = applicantBeisenInfo.getCandidateId();
  78. try {
  79. IResumeBaseRec iResumeBaseRec = ResumeBaseRecFactory.getLocalInstance(ctx);
  80. ResumeBaseRecCollection collection = iResumeBaseRec.getResumeBaseRecCollection("select * ,resumeState.number where applyId = '" + applyId + "'");
  81. // 1. 获取简历基础信息
  82. ResumeBaseRecInfo resumeInfo = collection.get(0);
  83. if (resumeInfo == null) {
  84. resumeInfo = new ResumeBaseRecInfo();
  85. resumeInfo.put("applyId", applyId);
  86. resumeInfo.put("candidateId", candidateId);
  87. } else if (!"0001".equals(resumeInfo.getResumeState().getNumber())) {
  88. continue;
  89. }
  90. //通过申请ID获取招聘需求
  91. RecuritmentDemandInfo recuritmentDemandInfo = getRecuritmentByApplyId(ctx, applyId);
  92. //招聘需求
  93. resumeInfo.setRecuritmentDemand(recuritmentDemandInfo);
  94. //招聘职位
  95. resumeInfo.setDepartment(recuritmentDemandInfo.getDepartment());
  96. //招聘部门
  97. resumeInfo.setRecuritPosition(recuritmentDemandInfo.getRecuritPosition());
  98. //北森应聘者-需求管理
  99. applicantBeisenInfo.setRecuritment(recuritmentDemandInfo);
  100. // 2. 获取 标准简历数据
  101. JSONObject resumeJson = getResumeByApplyId(applyId);
  102. logger.error("resumeJson--" + resumeJson);
  103. Integer code = resumeJson.getInteger("code");
  104. if (200 == code) {
  105. JSONObject data = resumeJson.getJSONObject("data");
  106. // 3. 处理简历各部分数据
  107. processResumeSections(ctx, data, resumeInfo);
  108. //删除附件信息
  109. AttachmentUtils.deleteAttachment(ctx, resumeInfo.getId().toString());
  110. // 根据申请Id获取并处理简历文件
  111. processResumeFile(applyId, ctx, resumeInfo, "标准简历");
  112. // 获取并处理面试评价文件
  113. processResumeFile(applyId, ctx, resumeInfo, "面试评价");
  114. applicantBeisenInfo.setSyncResult("同步成功!");
  115. applicantBeisenInfo.setSyncStatus(ExecuteResultEnum.SUCCESS);
  116. successSize++;
  117. } else {
  118. throw new BOSException(resumeJson.getString("message"));
  119. }
  120. iApplicantBeisen.save(applicantBeisenInfo);
  121. } catch (Exception e) {
  122. applicantBeisenInfo.setSyncStatus(ExecuteResultEnum.ERROR);
  123. applicantBeisenInfo.setSyncResult("简历处理失败: " + e.getMessage());
  124. iApplicantBeisen.save(applicantBeisenInfo);
  125. errorSize++;
  126. logger.error("简历处理失败: " + e.getMessage(), e);
  127. }
  128. }
  129. logger.error("成功条数" + successSize);
  130. logger.error("失败条数" + errorSize);
  131. }
  132. /**
  133. * 通过申请ID获取需求管理
  134. *
  135. * @param applyId
  136. */
  137. public RecuritmentDemandInfo getRecuritmentByApplyId(Context ctx, String applyId) throws IOException, BOSException {
  138. BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  139. JSONObject pamas = new JSONObject();
  140. JSONArray applyIds = new JSONArray();
  141. applyIds.add(applyId);
  142. pamas.put("applyIds", applyIds);
  143. String jobId = "";
  144. //根据申请ID获取申请信息
  145. JSONObject applyJson = beisenApiClient.callApi(BeisenParam.GET_APPLYLIST_APPLYID, pamas);
  146. logger.error("applyJson--" + applyJson);
  147. if (200 == applyJson.getInteger("code")) {
  148. JSONArray data = applyJson.getJSONArray("data");
  149. JSONObject applyData = data.getJSONObject(0);
  150. //职位ID
  151. jobId = applyData.getString("jobId");
  152. } else {
  153. throw new BOSException("根据申请ID获取申请信息失败,原因:" + applyJson.get("message"));
  154. }
  155. logger.error("jobId--" + jobId);
  156. //根据ID获取获取数据单条
  157. JSONObject entityPamas = new JSONObject();
  158. entityPamas.put("id", jobId);
  159. entityPamas.put("metaObjectName", "Recruitment.Job");
  160. JSONObject entity = beisenApiClient.callApi(BeisenParam.GET_ENTITY, entityPamas);
  161. logger.error("entity--" + entity);
  162. if (200 != applyJson.getInteger("code")) {
  163. throw new BOSException("根据ID获取获取数据单条失败,原因:" + entity.get("message"));
  164. }
  165. JSONObject entityData = entity.getJSONObject("data");
  166. //根据招聘需求ID获取招聘需求
  167. JSONObject columns = entityData.getJSONObject("columns");
  168. JSONObject recruit = columns.getJSONObject("RecruitRequirementIds");
  169. if (recruit == null) {
  170. throw new BOSException("未查询到需求IDRecruitRequirementIds");
  171. }
  172. String recruitRequirementId = recruit.getString("value");
  173. //招聘需求
  174. IRecuritmentDemand iRecuritmentDemand = RecuritmentDemandFactory.getLocalInstance(ctx);
  175. if (StringUtils.isEmpty(recruitRequirementId)) {
  176. throw new BOSException("通过applyId[" + applyId + "]未查询到招聘需求!");
  177. }
  178. logger.error("requirementId--" + recruitRequirementId);
  179. //招聘需求
  180. RecuritmentDemandCollection recuritmentDemandCollection = iRecuritmentDemand.getRecuritmentDemandCollection("where requirementId='" + recruitRequirementId + "'");
  181. if (recuritmentDemandCollection.isEmpty()) {
  182. throw new BOSException("sHR未查询到对应的招聘需求,北森需求ID:" + recruitRequirementId);
  183. }
  184. return recuritmentDemandCollection.get(0);
  185. }
  186. /**
  187. * 处理简历文件或面试评价文件
  188. *
  189. * @param applyId 申请ID
  190. * @param ctx 上下文
  191. * @param resumeInfo 简历信息
  192. * @param fileType 文件类型("标准简历"或"面试评价")
  193. */
  194. private void processResumeFile(String applyId, Context ctx, ResumeBaseRecInfo resumeInfo, String fileType) {
  195. logger.error("processResumeFile--");
  196. try {
  197. // 根据文件类型获取对应的文件信息
  198. JSONObject fileInfo = "标准简历".equals(fileType) ? getStandardResumeFileUrlByApplyId(applyId) : getInterviewEvaluationFile(applyId);
  199. logger.error("fileInfo--" + fileInfo);
  200. if (fileInfo == null) {
  201. throw new BOSException("获取{}文件信息失败: 返回结果为null" + fileType);
  202. }
  203. Integer code = fileInfo.getInteger("code");
  204. if (!Integer.valueOf(200).equals(code)) {
  205. throw new BOSException("获取{" + fileType + "}文件失败: 返回code={" + code + "}");
  206. }
  207. JSONObject data = fileInfo.getJSONObject("data");
  208. if (data == null) {
  209. throw new BOSException("获取{" + fileType + "}文件失败: data字段为空");
  210. }
  211. String downloadUrl = data.getString("downloadUrl");
  212. String dfsPath = data.getString("dfsPath");
  213. if (com.kingdee.bos.rabbitmq.util.StringUtils.isBlank(downloadUrl) || com.kingdee.bos.rabbitmq.util.StringUtils.isBlank(dfsPath)) {
  214. throw new BOSException("获取{" + fileType + "}文件失败: downloadUrl或dfsPath为空");
  215. }
  216. // 处理文件名
  217. String fileName = AttachmentUtils.extractFileNameFromPath(dfsPath);
  218. String fileExtension = AttachmentUtils.extractFileExtension(fileName);
  219. String customFileName = "北森" + fileType + "." + fileExtension;
  220. // 获取文件内容并保存
  221. byte[] fileData = AttachmentUtils.getBytesByNetURL("https:" + downloadUrl);
  222. if (fileData == null || fileData.length == 0) {
  223. throw new BOSException("获取{" + fileType + "}文件内容失败: 下载内容为空");
  224. }
  225. AttachmentUtils.insertAttachment(ctx, customFileName, resumeInfo, fileData);
  226. logger.info("{" + fileType + "}文件处理成功: {" + customFileName + "}");
  227. } catch (Exception e) {
  228. logger.error("处理" + fileType + "文件时发生异常", e);
  229. }
  230. }
  231. /**
  232. * 处理简历各部分数据
  233. */
  234. private void processResumeSections(Context ctx, JSONObject resumeJson, ResumeBaseRecInfo resumeInfo) throws BOSException, EASBizException, ParseException, IOException {
  235. JSONArray personProfile = resumeJson.getJSONArray("personProfile");
  236. saveResumeBaseRec(ctx, personProfile, resumeInfo);
  237. JSONArray education = resumeJson.getJSONArray("education");
  238. saveEducationExpRE(ctx, education, resumeInfo);
  239. // 使用Map定义简历部分与处理方法的对应关系
  240. Map<String, TriConsumer<Context, JSONArray, ResumeBaseRecInfo>> sectionHandlers = new LinkedHashMap<>();
  241. //sectionHandlers.put("personProfile", this::saveResumeBaseRec);
  242. sectionHandlers.put("workExperience", this::saveWorkingExp);
  243. //sectionHandlers.put("education", this::saveEducationExpRE);
  244. sectionHandlers.put("project", this::saveProjectExp);
  245. sectionHandlers.put("train", this::saveTrainingExp);
  246. sectionHandlers.put("certificate", this::saveCredential);
  247. sectionHandlers.put("lang", this::saveLanguageAbility);
  248. sectionHandlers.put("skill", this::saveProfessionalSkills);
  249. sectionHandlers.put("awards", this::saveResumeRewardPunish);
  250. //
  251. sectionHandlers.put("family", this::saveFamilyInfo);
  252. // 遍历处理所有简历部分
  253. sectionHandlers.forEach((sectionKey, handler) -> {
  254. //判断是否存key
  255. if (resumeJson.containsKey(sectionKey)) {
  256. JSONArray sectionData = resumeJson.getJSONArray(sectionKey);
  257. if (sectionData != null && !sectionData.isEmpty()) {
  258. handler.accept(ctx, sectionData, resumeInfo);
  259. }
  260. }
  261. });
  262. }
  263. /**
  264. * 根据申请Id获取标准简历文件
  265. *
  266. * @param applyId
  267. * @return
  268. */
  269. public JSONObject getStandardResumeFileUrlByApplyId(String applyId) throws IOException {
  270. String param = "?applyId=" + applyId;
  271. BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  272. JSONObject jsonObject = beisenApiClient.callGetApi(BeisenParam.GET_STANDERDRESUMEFILURLBYAPPLYID + param, new JSONObject());
  273. return jsonObject;
  274. }
  275. /**
  276. * 根据申请Id获取标准简历文件
  277. *
  278. * @param applyId
  279. * @return
  280. */
  281. public JSONObject getInterviewEvaluationFile(String applyId) throws IOException {
  282. String param = "?applyId=" + applyId;
  283. BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  284. JSONObject jsonObject = beisenApiClient.callGetApi(BeisenParam.GET_INTERVIEWEVALUATIONFILE + param, new JSONObject());
  285. return jsonObject;
  286. }
  287. /**
  288. * 根据申请Id获取标准简历
  289. *
  290. * @param applyId
  291. * @return
  292. */
  293. public JSONObject getResumeByApplyId(String applyId) throws IOException {
  294. String param = "?applyId=" + applyId;
  295. BeisenApiClient beisenApiClient = BeisenApiClient.getInstance();
  296. JSONObject jsonObject = beisenApiClient.callGetApi(BeisenParam.GET_RESUMEBYAPPLYID + param, new JSONObject());
  297. return jsonObject;
  298. }
  299. /**
  300. * 招聘管理简历基本信息
  301. *
  302. * @param personProfile
  303. */
  304. public void saveResumeBaseRec(Context ctx, JSONArray personProfile, ResumeBaseRecInfo resumeBaseRecInfo) throws BOSException, EASBizException, ParseException, IOException {
  305. logger.error("personProfile--" + personProfile);
  306. BeisenParamByProperties beisenParamByProperties = new BeisenParamByProperties();
  307. Map<String, String> config = beisenParamByProperties.getConfig();
  308. //招聘业务组织
  309. HROrgUnitInfo hrOrgUnitInfo = new HROrgUnitInfo();
  310. hrOrgUnitInfo.setId(BOSUuid.read("00000000-0000-0000-0000-000000000000CCE7AED4"));
  311. resumeBaseRecInfo.setHrOrgUnit(hrOrgUnitInfo);
  312. //来源方式 INTEGRATESYSTEM=集成系统
  313. resumeBaseRecInfo.setSourceMethod(ResumeSourceMethod.INTEGRATESYSTEM);
  314. //招聘状态 WAITING 待筛选
  315. resumeBaseRecInfo.setResumeStatus(ResumeStatusEnum.WAITING);
  316. //招聘状态 0001 待筛选
  317. IResumeState iResumeState = ResumeStateFactory.getLocalInstance(ctx);
  318. ResumeStateInfo resumeStateInfo = iResumeState.getResumeStateInfo("where number = '0001'");
  319. resumeBaseRecInfo.setResumeState(resumeStateInfo);
  320. //入库时间
  321. resumeBaseRecInfo.setWarehouseEntry(new Date());
  322. //国籍
  323. INationality iNationality = NationalityFactory.getLocalInstance(ctx);
  324. //学历
  325. IDiploma iDiploma = DiplomaFactory.getLocalInstance(ctx);
  326. //政治面貌
  327. IPoliticalFace iPoliticalFace = PoliticalFaceFactory.getLocalInstance(ctx);
  328. //民族
  329. IFolk iFolk = FolkFactory.getLocalInstance(ctx);
  330. //婚姻状况
  331. IWed iWed = WedFactory.getLocalInstance(ctx);
  332. //血型
  333. Map<String, String> bloodTypeMap = InitialValueUtils.bloodTypeMap;
  334. String carType = "";//证件类型
  335. String carno = "";//证件号
  336. for (int i = 0; i < personProfile.size(); i++) {
  337. JSONObject data = personProfile.getJSONObject(i);
  338. String name = data.getString("name");
  339. String value = data.getString("value");
  340. String text = data.getString("text");
  341. //姓名
  342. if ("Name".equals(name)) {
  343. resumeBaseRecInfo.setName(text);
  344. }
  345. //参加工作时间
  346. if ("WorkStartTime".equals(name)) {
  347. resumeBaseRecInfo.setWorkDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  348. }
  349. //参加工作年限 workSeniority
  350. if ("YearsOfWork".equals(name)) {
  351. resumeBaseRecInfo.setWorkSeniority(text);
  352. }
  353. //身份证号码 identityCardNo
  354. if ("CertificateNumber".equals(name)) {
  355. carno = text;
  356. if ("身份证".equals(carType)) {
  357. resumeBaseRecInfo.setIdentityCardNo(carno);
  358. resumeBaseRecInfo.setPassportNo("");
  359. } else {
  360. resumeBaseRecInfo.setPassportNo(carno);
  361. }
  362. }
  363. //证件类型
  364. if ("CertificateType".equals(name)) {
  365. carType = text;
  366. if ("身份证".equals(text)) {
  367. resumeBaseRecInfo.setIdentityCardNo(carno);
  368. resumeBaseRecInfo.setPassportNo("");
  369. } else {
  370. resumeBaseRecInfo.setPassportNo(carno);
  371. }
  372. }
  373. //出生年月 birthday
  374. if ("Birthday".equals(name)) {
  375. resumeBaseRecInfo.setBirthday(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  376. }
  377. //户口所在地 domicilePlace
  378. if ("AccountArea".equals(name)) {
  379. resumeBaseRecInfo.setDomicilePlace(text);
  380. }
  381. //QQ QQ
  382. if ("QQ".equals(name)) {
  383. resumeBaseRecInfo.setQQ(text);
  384. }
  385. //身高 stature
  386. if ("Height".equals(name)) {
  387. resumeBaseRecInfo.setStature(text);
  388. }
  389. //现居住地 nowResidence
  390. if ("LivingArea".equals(name)) {
  391. resumeBaseRecInfo.setNowResidence(text);
  392. }
  393. //手机号 mobilePhone
  394. if ("Mobile".equals(name)) {
  395. resumeBaseRecInfo.setMobilePhone(text);
  396. }
  397. //家庭电话 fixedPhone
  398. if ("Telephone".equals(name)) {
  399. resumeBaseRecInfo.setFixedPhone(text);
  400. }
  401. //邮件 email
  402. if ("Email".equals(name)) {
  403. resumeBaseRecInfo.setEmail(text);
  404. }
  405. //目前年薪 annualPay
  406. if ("Salary".equals(name)) {
  407. resumeBaseRecInfo.setAnnualPay(text);
  408. }
  409. //目前工作状态 currentWorkingStatus
  410. if ("JobHunting".equals(name)) {
  411. resumeBaseRecInfo.setCurrentWorkingStatus(CurrentWorkingStatusEnum.getEnum(Integer.parseInt(value) - 1));
  412. }
  413. //期望年薪 expectantPay
  414. if ("ExpectSalary".equals(name)) {
  415. resumeBaseRecInfo.setExpectantPay(Integer.parseInt(text));
  416. }
  417. //职业目标 careerGoal
  418. if ("CareerGoals".equals(name)) {
  419. resumeBaseRecInfo.setCareerGoal(text);
  420. }
  421. //自我评价 selfEvaluation
  422. if ("Evaluation".equals(name)) {
  423. resumeBaseRecInfo.setSelfEvaluation(text);
  424. }
  425. //国籍 national
  426. if ("Nationality".equals(name)) {
  427. NationalityCollection nationalityCollection = iNationality.getNationalityCollection("where name like '%" + text + "%'");
  428. if (nationalityCollection.size() > 0) {
  429. resumeBaseRecInfo.setNational(nationalityCollection.get(0));
  430. }
  431. }
  432. //籍贯 nativePlace
  433. if ("NativeArea".equals(name)) {
  434. resumeBaseRecInfo.setNativePlace(text);
  435. }
  436. //年龄 age
  437. if ("OceanAge".equals(name)) {
  438. resumeBaseRecInfo.setAge(Integer.parseInt(text));
  439. }
  440. //最高学历 hDegree
  441. if ("EducationLevel".equals(name)) {
  442. DiplomaCollection diplomaCollection = iDiploma.getDiplomaCollection("where beisenVal = '" + value + "'");
  443. if (!diplomaCollection.isEmpty()) {
  444. resumeBaseRecInfo.setHDegree(diplomaCollection.get(0));
  445. }
  446. }
  447. //政治面貌 politicalFace
  448. if ("Polity".equals(name)) {
  449. PoliticalFaceCollection politicalFaceCollection = iPoliticalFace.getPoliticalFaceCollection("where beisenVal = '" + value + "'");
  450. if (!politicalFaceCollection.isEmpty()) {
  451. resumeBaseRecInfo.setPoliticalFace(politicalFaceCollection.get(0));
  452. }
  453. }
  454. //婚姻状况 wed 北森已停用字段
  455. if (config.get("WedState").equals(name)) {
  456. WedCollection wedCollection = iWed.getWedCollection("where beisenVal = '" + value + "'");
  457. if (!wedCollection.isEmpty()) {
  458. resumeBaseRecInfo.setWed(wedCollection.get(0));
  459. }
  460. }
  461. //民族 folk
  462. if ("Nation".equals(name)) {
  463. FolkCollection folkCollection = iFolk.getFolkCollection("where beisenVal = '" + value + "'");
  464. if (!folkCollection.isEmpty()) {
  465. resumeBaseRecInfo.setFolk(folkCollection.get(0));
  466. }
  467. }
  468. //毕业学校 school
  469. if ("LastSchool".equals(name)) {
  470. if (StringUtils.isEmpty(text)) {
  471. throw new BOSException("毕业学校不能为空!");
  472. }
  473. resumeBaseRecInfo.setName(text);
  474. }
  475. //血型 bloodType
  476. if ("BloodType".equals(name)) {
  477. String hDegree = bloodTypeMap.getOrDefault(value, "90");
  478. resumeBaseRecInfo.setBloodType(BloodType.getEnum(hDegree));
  479. }
  480. //紧急联系人 emergencyContact
  481. if ("EmergencyContact".equals(name)) {
  482. resumeBaseRecInfo.setEmergencyContact(text);
  483. }
  484. //紧急联系人电话 emergencyContactPhone
  485. if ("EmergencyPhone".equals(name)) {
  486. resumeBaseRecInfo.setEmergencyContactPhone(text);
  487. }
  488. //期望月薪 expectantPayStr
  489. if ("ExpectSalary".equals(name)) {
  490. resumeBaseRecInfo.setExpectantPayStr(text);
  491. }
  492. //最近工作单位 lastCompany
  493. if ("LastCompany".equals(name)) {
  494. resumeBaseRecInfo.setLastCompany(text);
  495. }
  496. //最近工作行业 lastIndustry
  497. if ("LastIndustry".equals(name)) {
  498. resumeBaseRecInfo.setLastIndustry(text);
  499. }
  500. //专业 major
  501. if ("LastDiscipline".equals(name)) {
  502. resumeBaseRecInfo.setMajor(text);
  503. }
  504. //性别 gender
  505. if ("Gender".equals(name)) {
  506. if ("1".equals(value) || "0".equals(value)) {
  507. resumeBaseRecInfo.setGender(Genders.getEnum(Integer.parseInt(value) + 1));
  508. }
  509. }
  510. //更新简历时间 updateResumeDate
  511. if ("ResumeUpdateTime".equals(name)) {
  512. resumeBaseRecInfo.setUpdateResumeDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  513. }
  514. //签发机关 idCardIssueOrg
  515. if ("CertificateGrantUnit".equals(name)) {
  516. resumeBaseRecInfo.setIdentityCardNo(text);
  517. }
  518. //证件有效期-开始时间 idCardBeginDate
  519. if ("CertificateValidityDate".equals(name)) {
  520. resumeBaseRecInfo.setIdCardBeginDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  521. }
  522. //证件有效期-结束时间 idCardEndDate
  523. if ("CertificateValidityOverDate".equals(name)) {
  524. resumeBaseRecInfo.setIdCardEndDate(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  525. }
  526. //到岗时间 arrivalTime
  527. if ("AvailableDate".equals(name)) {
  528. resumeBaseRecInfo.setArrivalTime(DateTimeUtils.parseDate(text, "yyyy/MM/dd"));
  529. }
  530. //英文名 EnglishName
  531. if ("NameEn".equals(name)) {
  532. resumeBaseRecInfo.setEnglishName(text);
  533. }
  534. //户籍地址 domicileAddress
  535. if ("Address".equals(name)) {
  536. resumeBaseRecInfo.setDomicileAddress(text);
  537. }
  538. }
  539. String errorMsg = ",身份证号码、手机号为必填数据,请在北森维护数据后再次同步!";
  540. if (StringUtils.isEmpty(resumeBaseRecInfo.getIdentityCardNo()) && StringUtils.isEmpty(resumeBaseRecInfo.getPassportNo())) {
  541. throw new BOSException("身份证号码不能为空" + errorMsg);
  542. }
  543. if (StringUtils.isEmpty(resumeBaseRecInfo.getMobilePhone())) {
  544. throw new BOSException("手机号码不能为空" + errorMsg);
  545. }
  546. IResumeBaseRec iResumeBaseRec = ResumeBaseRecFactory.getLocalInstance(ctx);
  547. IObjectPK save = iResumeBaseRec.save(resumeBaseRecInfo);
  548. logger.error("resumeBaseRecId--" + save);
  549. // } catch (Exception e) {
  550. // logger.error("简历基本信息报错信息:" + e.getMessage());
  551. // throw new RuntimeException(e);
  552. // }
  553. }
  554. /**
  555. * 简历-工作经历
  556. *
  557. * @param workExperience
  558. */
  559. public void saveWorkingExp(Context ctx, JSONArray workExperience, ResumeBaseRecInfo resumeBaseRecInfo) {
  560. logger.error("workExperience--" + workExperience);
  561. try {
  562. IWorkingExp iWorkingExp = WorkingExpFactory.getLocalInstance(ctx);
  563. WorkingExpCollection workingExpColl = iWorkingExp.getWorkingExpCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  564. if (!workingExpColl.isEmpty()) {
  565. iWorkingExp.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  566. }
  567. for (int i = 0; i < workExperience.size(); i++) {
  568. JSONArray array = workExperience.getJSONArray(i);
  569. WorkingExpInfo workingExpInfo = new WorkingExpInfo();
  570. //简历基本信息
  571. workingExpInfo.setResumeBase(resumeBaseRecInfo);
  572. for (int j = 0; j < array.size(); j++) {
  573. JSONObject data = array.getJSONObject(j);
  574. String name = data.getString("name");
  575. String value = data.getString("value");
  576. String text = data.getString("text");
  577. //dateStart 开始时间
  578. if ("StartDate".equals(name)) {
  579. workingExpInfo.setDateStart(DateTimeUtils.parseDate(text, "yyyy/MM"));
  580. }
  581. //dateEnd 结束时间
  582. if ("EndDate".equals(name)) {
  583. if ("至今".equals(text)) {
  584. text = "2199/12";
  585. }
  586. workingExpInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  587. }
  588. //company 公司名称
  589. if ("CompanyName".equals(name)) {
  590. workingExpInfo.setCompany(text);
  591. }
  592. //department 任职部门
  593. if ("Department".equals(name)) {
  594. workingExpInfo.setDepartment(text);
  595. }
  596. //jobCategory 职位类别
  597. if ("OgJobLevel".equals(name)) {
  598. workingExpInfo.setJobCategory(text);
  599. }
  600. //industry 所属行业
  601. if ("Industry".equals(name)) {
  602. workingExpInfo.setIndustry(text);
  603. }
  604. //position 职位名称
  605. if ("JobTitle".equals(name)) {
  606. workingExpInfo.setPosition(text);
  607. }
  608. //underlingNumber 下属人数
  609. if ("SubordinateNumber".equals(name)) {
  610. workingExpInfo.setUnderlingNumber(Integer.parseInt(text));
  611. }
  612. //monthPay 税前月薪
  613. if ("Salary".equals(name)) {
  614. workingExpInfo.setMonthPay(Integer.parseInt(text));
  615. }
  616. //certifier 证明人
  617. if ("ReferenceName".equals(name)) {
  618. workingExpInfo.setCertifier(text);
  619. }
  620. //leavingReason 离职原因
  621. if ("ReasonOfLeaving".equals(name)) {
  622. workingExpInfo.setLeavingReason(text);
  623. }
  624. //certifierPhone 证明人电话
  625. if ("ReferenceContact".equals(name)) {
  626. workingExpInfo.setCertifierPhone(text);
  627. }
  628. //monthPayStr 税前月薪
  629. if ("Salary".equals(name)) {
  630. workingExpInfo.setMonthPayStr(text);
  631. }
  632. //unitAddress 工作地点 OgJobArea
  633. if ("JobArea".equals(name)) {
  634. workingExpInfo.setUnitAddress(text);
  635. }
  636. }
  637. iWorkingExp.save(workingExpInfo);
  638. }
  639. } catch (Exception e) {
  640. logger.error("简历-工作经历保存失败!" + e.getMessage());
  641. }
  642. }
  643. /**
  644. * 简历-教育经历
  645. *
  646. * @param education
  647. */
  648. public void saveEducationExpRE(Context ctx, JSONArray education, ResumeBaseRecInfo resumeBaseRecInfo) throws BOSException, EASBizException {
  649. logger.error("education--" + education);
  650. try {
  651. IEducationExpREC iEducationExpREC = EducationExpRECFactory.getLocalInstance(ctx);
  652. EducationExpRECCollection educationExpRECCollection = iEducationExpREC.getEducationExpRECCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  653. if (!educationExpRECCollection.isEmpty()) {
  654. iEducationExpREC.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  655. }
  656. //学历
  657. IDiploma iDiploma = DiplomaFactory.getLocalInstance(ctx);
  658. //学位
  659. IDegree iDegree = DegreeFactory.getLocalInstance(ctx);
  660. //学院类型
  661. Map<String, String> bchoolTypeMap = InitialValueUtils.getBchoolTypeMap();
  662. for (int i = 0; i < education.size(); i++) {
  663. JSONArray array = education.getJSONArray(i);
  664. EducationExpRECInfo educationExpRECInfo = new EducationExpRECInfo();
  665. //简历基本信息
  666. educationExpRECInfo.setResumeBase(resumeBaseRecInfo);
  667. for (int j = 0; j < array.size(); j++) {
  668. JSONObject data = array.getJSONObject(j);
  669. String name = data.getString("name");
  670. String value = data.getString("value");
  671. String text = data.getString("text");
  672. //dateStart 开始时间
  673. if ("StartDate".equals(name)) {
  674. educationExpRECInfo.setDateStart(DateTimeUtils.parseDate(text, "yyyy/MM"));
  675. }
  676. //dateEnd 结束时间
  677. if ("EndDate".equals(name)) {
  678. if ("至今".equals(text)) {
  679. text = "2199/12";
  680. }
  681. educationExpRECInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  682. }
  683. //school 毕业学校
  684. if ("SchoolName".equals(name)) {
  685. educationExpRECInfo.setSchool(text);
  686. }
  687. //academicDiplomasF7 学位
  688. if ("Degree".equals(name)) {
  689. DegreeCollection degreeCollection = iDegree.getDegreeCollection("where beisenVal = '" + value + "'");
  690. if (!degreeCollection.isEmpty()) {
  691. educationExpRECInfo.setAcademicDiplomasF7(degreeCollection.get(0));
  692. }
  693. }
  694. //major 专业
  695. if ("MajorName".equals(name)) {
  696. educationExpRECInfo.setMajor(text);
  697. }
  698. //degreeF7 学历
  699. if ("EducationLevel".equals(name)) {
  700. DiplomaCollection diplomaCollection = iDiploma.getDiplomaCollection("where beisenVal = '" + value + "'");
  701. if (!diplomaCollection.isEmpty()) {
  702. educationExpRECInfo.setDegreeF7(diplomaCollection.get(0));
  703. }
  704. }
  705. //schoolType 学院类型
  706. if ("SchoolType".equals(name)) {
  707. if (bchoolTypeMap.containsKey(value)) {
  708. educationExpRECInfo.setSchoolType(SchoolTypeEnum.getEnum(bchoolTypeMap.get(value)));
  709. }
  710. }
  711. }
  712. String errorMsg = ",入学时间、专业、学历、毕业院校为必填数据,请在北森维护数据后再次同步!";
  713. Date dateStart = educationExpRECInfo.getDateStart();
  714. if (dateStart == null) {
  715. throw new BOSException("教育经历:入学时间不能为空" + errorMsg);
  716. }
  717. if (StringUtils.isEmpty(educationExpRECInfo.getMajor())) {
  718. throw new BOSException("教育经历:专业不能为空" + errorMsg);
  719. }
  720. if (StringUtils.isEmpty(educationExpRECInfo.getSchool())) {
  721. throw new BOSException("教育经历:毕业院校不能为空" + errorMsg);
  722. }
  723. if (educationExpRECInfo.getDegreeF7() == null) {
  724. throw new BOSException("教育经历:学历不能为空" + errorMsg);
  725. }
  726. iEducationExpREC.save(educationExpRECInfo);
  727. }
  728. } catch (Exception e) {
  729. IResumeBaseRec iResumeBaseRec = ResumeBaseRecFactory.getLocalInstance(ctx);
  730. iResumeBaseRec.delete(new ObjectUuidPK(resumeBaseRecInfo.getId()));
  731. logger.error("简历-教育经历保存失败!" + e.getMessage());
  732. throw new RuntimeException(e);
  733. }
  734. }
  735. /**
  736. * 简历-获奖经历
  737. *
  738. * @param awards
  739. */
  740. public void saveResumeRewardPunish(Context ctx, JSONArray awards, ResumeBaseRecInfo resumeBaseRecInfo) {
  741. logger.error("awards--" + awards);
  742. try {
  743. IResumeRewardPunish iResumeRewardPunish = ResumeRewardPunishFactory.getLocalInstance(ctx);
  744. ResumeRewardPunishCollection ResumeRewardPunishCollection = iResumeRewardPunish.getResumeRewardPunishCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  745. if (!ResumeRewardPunishCollection.isEmpty()) {
  746. iResumeRewardPunish.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  747. }
  748. for (int i = 0; i < awards.size(); i++) {
  749. JSONArray array = awards.getJSONArray(i);
  750. ResumeRewardPunishInfo ResumeRewardPunishInfo = new ResumeRewardPunishInfo();
  751. //简历基本信息
  752. ResumeRewardPunishInfo.setResumeBase(resumeBaseRecInfo);
  753. for (int j = 0; j < array.size(); j++) {
  754. JSONObject data = array.getJSONObject(j);
  755. String name = data.getString("name");
  756. String value = data.getString("value");
  757. String text = data.getString("text");
  758. //occurDate 获奖时间
  759. if ("AwardTime".equals(name)) {
  760. ResumeRewardPunishInfo.setOccurDate(DateTimeUtils.parseDate(text, "yyyy/MM"));
  761. }
  762. //title 获奖名称
  763. if ("AwardName".equals(name)) {
  764. ResumeRewardPunishInfo.setTitle(text);
  765. ResumeRewardPunishInfo.setName(text);
  766. }
  767. //description 描述
  768. if ("AwardDescription".equals(name)) {
  769. ResumeRewardPunishInfo.setDescription(text);
  770. }
  771. }
  772. iResumeRewardPunish.save(ResumeRewardPunishInfo);
  773. }
  774. } catch (Exception e) {
  775. logger.error("简历-获奖经历保存失败!" + e.getMessage());
  776. }
  777. }
  778. /**
  779. * 简历-项目经历
  780. *
  781. * @param project
  782. */
  783. public void saveProjectExp(Context ctx, JSONArray project, ResumeBaseRecInfo resumeBaseRecInfo) {
  784. logger.error("project--" + project);
  785. try {
  786. IProjectExp iProjectExp = ProjectExpFactory.getLocalInstance(ctx);
  787. ProjectExpCollection ProjectExpCollection = iProjectExp.getProjectExpCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  788. if (!ProjectExpCollection.isEmpty()) {
  789. iProjectExp.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  790. }
  791. for (int i = 0; i < project.size(); i++) {
  792. JSONArray array = project.getJSONArray(i);
  793. ProjectExpInfo ProjectExpInfo = new ProjectExpInfo();
  794. //简历基本信息
  795. ProjectExpInfo.setResumeBase(resumeBaseRecInfo);
  796. for (int j = 0; j < array.size(); j++) {
  797. JSONObject data = array.getJSONObject(j);
  798. String name = data.getString("name");
  799. String value = data.getString("value");
  800. String text = data.getString("text");
  801. //dateStart 开始时间
  802. if ("StartDate".equals(name)) {
  803. ProjectExpInfo.setDateStart(DateTimeUtils.parseDate(text, "yyyy/MM"));
  804. }
  805. //dateEnd 结束时间
  806. if ("EndDate".equals(name)) {
  807. if ("至今".equals(text)) {
  808. text = "2199/12";
  809. }
  810. ProjectExpInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  811. }
  812. //customer 项目名称
  813. if ("ProjectName".equals(name)) {
  814. ProjectExpInfo.setCustomer(text);
  815. }
  816. //projectDescription 项目描述
  817. if ("ProjectInfo".equals(name)) {
  818. ProjectExpInfo.setProjectDescription(text);
  819. }
  820. }
  821. iProjectExp.save(ProjectExpInfo);
  822. }
  823. } catch (Exception e) {
  824. logger.error("简历-项目经历保存失败!" + e.getMessage());
  825. }
  826. }
  827. /**
  828. * 简历-培训经历
  829. *
  830. * @param train
  831. */
  832. public void saveTrainingExp(Context ctx, JSONArray train, ResumeBaseRecInfo resumeBaseRecInfo) {
  833. logger.error("train--" + train);
  834. try {
  835. ITrainingExp iTrainingExp = TrainingExpFactory.getLocalInstance(ctx);
  836. TrainingExpCollection TrainingExpCollection = iTrainingExp.getTrainingExpCollection("where resumeBaseInfo = '" + resumeBaseRecInfo.getId().toString() + "'");
  837. if (!TrainingExpCollection.isEmpty()) {
  838. iTrainingExp.delete("where resumeBaseInfo = '" + resumeBaseRecInfo.getId().toString() + "'");
  839. }
  840. for (int i = 0; i < train.size(); i++) {
  841. JSONArray array = train.getJSONArray(i);
  842. TrainingExpInfo TrainingExpInfo = new TrainingExpInfo();
  843. //简历基本信息
  844. TrainingExpInfo.setResumeBaseInfo(resumeBaseRecInfo);
  845. for (int j = 0; j < array.size(); j++) {
  846. JSONObject data = array.getJSONObject(j);
  847. String name = data.getString("name");
  848. String value = data.getString("value");
  849. String text = data.getString("text");
  850. //dateStart 开始时间
  851. if ("StartDate".equals(name)) {
  852. TrainingExpInfo.setDateStart(DateTimeUtils.parseDate(text, "yyyy/MM"));
  853. }
  854. //dateEnd 结束时间
  855. if ("EndDate".equals(name)) {
  856. if ("至今".equals(text)) {
  857. text = "2199/12";
  858. }
  859. TrainingExpInfo.setDateEnd(DateTimeUtils.parseDate(text, "yyyy/MM"));
  860. }
  861. //trainingInstitution 培训机构
  862. if ("OrgName".equals(name)) {
  863. TrainingExpInfo.setTrainingInstitution(text);
  864. }
  865. //courseDescription 课程描述
  866. if ("Description".equals(name)) {
  867. TrainingExpInfo.setCourseDescription(text);
  868. }
  869. }
  870. iTrainingExp.save(TrainingExpInfo);
  871. }
  872. } catch (Exception e) {
  873. logger.error("简历-培训经历保存失败!" + e.getMessage());
  874. }
  875. }
  876. /**
  877. * 简历-获得证书
  878. *
  879. * @param certificate
  880. */
  881. public void saveCredential(Context ctx, JSONArray certificate, ResumeBaseRecInfo resumeBaseRecInfo) {
  882. logger.error("certificate--" + certificate);
  883. try {
  884. ICredential iCredential = CredentialFactory.getLocalInstance(ctx);
  885. CredentialCollection CredentialCollection = iCredential.getCredentialCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  886. if (!CredentialCollection.isEmpty()) {
  887. iCredential.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  888. }
  889. for (int i = 0; i < certificate.size(); i++) {
  890. JSONArray array = certificate.getJSONArray(i);
  891. CredentialInfo credentialInfo = new CredentialInfo();
  892. //简历基本信息
  893. credentialInfo.setResumeBase(resumeBaseRecInfo);
  894. for (int j = 0; j < array.size(); j++) {
  895. JSONObject data = array.getJSONObject(j);
  896. String name = data.getString("name");
  897. String value = data.getString("value");
  898. String text = data.getString("text");
  899. //date 证书发放日期
  900. if ("ObtainDate".equals(name)) {
  901. credentialInfo.setDate(DateTimeUtils.parseDate(text, "yyyy/MM"));
  902. }
  903. //credentialName 证书名称
  904. if ("CertificateName".equals(name)) {
  905. credentialInfo.setCredentialName(text);
  906. }
  907. //issuer 证书发布机构
  908. if ("Authority".equals(name)) {
  909. credentialInfo.setIssuer(text);
  910. }
  911. //grade 证书成绩
  912. if ("Score".equals(name)) {
  913. credentialInfo.setGrade(text);
  914. }
  915. }
  916. iCredential.save(credentialInfo);
  917. }
  918. } catch (Exception e) {
  919. logger.error("简历-获得证书保存失败!" + e.getMessage());
  920. }
  921. }
  922. /**
  923. * 简历-语言能力
  924. *
  925. * @param lang
  926. */
  927. public void saveLanguageAbility(Context ctx, JSONArray lang, ResumeBaseRecInfo resumeBaseRecInfo) {
  928. logger.error("lang--" + lang);
  929. try {
  930. ILanguageAbility iLanguageAbility = LanguageAbilityFactory.getLocalInstance(ctx);
  931. LanguageAbilityCollection LanguageAbilityCollection = iLanguageAbility.getLanguageAbilityCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  932. if (!LanguageAbilityCollection.isEmpty()) {
  933. iLanguageAbility.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  934. }
  935. //熟练度
  936. Map<String, String> proficiencyMap = InitialValueUtils.getProficiencyMap();
  937. for (int i = 0; i < lang.size(); i++) {
  938. JSONArray array = lang.getJSONArray(i);
  939. LanguageAbilityInfo languageAbilityInfo = new LanguageAbilityInfo();
  940. //简历基本信息
  941. languageAbilityInfo.setResumeBase(resumeBaseRecInfo);
  942. for (int j = 0; j < array.size(); j++) {
  943. JSONObject data = array.getJSONObject(j);
  944. String name = data.getString("name");
  945. String value = data.getString("value");
  946. String text = data.getString("text");
  947. //listeningSpeaking 听说
  948. if ("ListeningSpeakingAbility".equals(name)) {
  949. if (proficiencyMap.containsKey(value)) {
  950. languageAbilityInfo.setListeningSpeaking(ProficiencyEnum.getEnum(proficiencyMap.get(value)));
  951. }
  952. }
  953. //readingWriting 读写
  954. if ("ReadingWritingAbility".equals(name)) {
  955. languageAbilityInfo.setReadingWriting(ProficiencyEnum.getEnum(proficiencyMap.get(value)));
  956. }
  957. //language 语言
  958. if ("LanguageType".equals(name)) {
  959. languageAbilityInfo.setLanguage(text);
  960. }
  961. //lv 语言等级
  962. if ("LanguageLevel".equals(name)) {
  963. languageAbilityInfo.setLv(text);
  964. }
  965. }
  966. iLanguageAbility.save(languageAbilityInfo);
  967. }
  968. } catch (Exception e) {
  969. logger.error("简历-语言能力保存失败!" + e.getMessage());
  970. }
  971. }
  972. /**
  973. * 简历-专业技能
  974. *
  975. * @param skill
  976. */
  977. public void saveProfessionalSkills(Context ctx, JSONArray skill, ResumeBaseRecInfo resumeBaseRecInfo) {
  978. logger.error("skill--" + skill);
  979. try {
  980. IProfessionalSkills iProfessionalSkills = ProfessionalSkillsFactory.getLocalInstance(ctx);
  981. ProfessionalSkillsCollection ProfessionalSkillsCollection = iProfessionalSkills.getProfessionalSkillsCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  982. if (!ProfessionalSkillsCollection.isEmpty()) {
  983. iProfessionalSkills.delete("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  984. }
  985. for (int i = 0; i < skill.size(); i++) {
  986. JSONArray array = skill.getJSONArray(i);
  987. ProfessionalSkillsInfo professionalSkillsInfo = new ProfessionalSkillsInfo();
  988. //简历基本信息
  989. professionalSkillsInfo.setResumeBase(resumeBaseRecInfo);
  990. for (int j = 0; j < array.size(); j++) {
  991. JSONObject data = array.getJSONObject(j);
  992. String name = data.getString("name");
  993. String value = data.getString("value");
  994. String text = data.getString("text");
  995. //skillName 技能名称
  996. if ("SkillName".equals(name)) {
  997. professionalSkillsInfo.setSkillName(text);
  998. }
  999. //skillDescription 技能描述
  1000. if ("SkillDescription".equals(name)) {
  1001. professionalSkillsInfo.setSkillDescription(text);
  1002. }
  1003. }
  1004. iProfessionalSkills.save(professionalSkillsInfo);
  1005. }
  1006. } catch (Exception e) {
  1007. logger.error("简历-专业技能保存失败!" + e.getMessage());
  1008. }
  1009. }
  1010. /**
  1011. * 简历-社会关系
  1012. *
  1013. * @param
  1014. */
  1015. public void saveFamilyInfo(Context ctx, JSONArray family, ResumeBaseRecInfo resumeBaseRecInfo) {
  1016. logger.error("family--" + family);
  1017. try {
  1018. IResumeFamily familyIns = ResumeFamilyFactory.getLocalInstance(ctx);
  1019. ResumeFamilyCollection familyCol = familyIns.getResumeFamilyCollection("where resumeBase = '" + resumeBaseRecInfo.getId().toString() + "'");
  1020. //关系
  1021. IRelation relationIns = RelationFactory.getLocalInstance(ctx);
  1022. //简历基本信息
  1023. for (int i = 0; i < family.size(); i++) {
  1024. ResumeFamilyInfo familyInfo = new ResumeFamilyInfo();
  1025. if (familyCol.size() > i) {
  1026. familyInfo = familyCol.get(i);
  1027. }
  1028. familyInfo.setResumeBase(resumeBaseRecInfo);
  1029. JSONArray array = family.getJSONArray(i);
  1030. for (int j = 0; j < array.size(); j++) {
  1031. JSONObject data = array.getJSONObject(j);
  1032. String name = data.getString("name");
  1033. String value = data.getString("value");
  1034. String text = data.getString("text");
  1035. //姓名
  1036. if ("Name".equals(name)) {
  1037. familyInfo.setName(value);
  1038. }
  1039. // 与本人关系
  1040. if ("relation".equals(name)) {
  1041. RelationCollection relationCol = relationIns.getRelationCollection("where beisenVal = '" + value + "'");
  1042. if (!relationCol.isEmpty()) {
  1043. familyInfo.setRelation(relationCol.get(0));
  1044. }
  1045. }
  1046. if ("age".equals(name)) {
  1047. familyInfo.setAge(text);
  1048. }
  1049. //职务
  1050. if ("JobTitle".equals(name)) {
  1051. familyInfo.setSpecDuty(text);
  1052. }
  1053. //公司名
  1054. if ("CompanyName".equals(name)) {
  1055. familyInfo.setWorkUnit(text);
  1056. }
  1057. //telephone
  1058. if ("telephone".equals(name)) {
  1059. familyInfo.setOfficePhone(text);
  1060. }
  1061. familyIns.save(familyInfo);
  1062. }
  1063. }
  1064. } catch (Exception e) {
  1065. logger.error("社会关系保存失败!" + e.getMessage());
  1066. throw new RuntimeException(e);
  1067. }
  1068. }
  1069. @Override
  1070. protected void _syncRecuritmentToBeisen(Context ctx, String billId) throws BOSException, EASBizException {
  1071. super._syncRecuritmentToBeisen(ctx, billId);
  1072. IRecuritmentDemand dIns = RecuritmentDemandFactory.getLocalInstance(ctx);
  1073. RecuritmentDemandInfo recuritmentDemandInfo = dIns.getRecuritmentDemandInfo(new ObjectUuidPK(billId));
  1074. RecruitmentDemandService recruitmentDemandService = new RecruitmentDemandService(false);
  1075. //更新或新增
  1076. try {
  1077. Object requirementId = recuritmentDemandInfo.get("requirementId");
  1078. if (ObjectUtils.allNotNull(requirementId)) {
  1079. recruitmentDemandService.updateRequirement(ctx, String.valueOf(requirementId), recuritmentDemandInfo);
  1080. } else {
  1081. recruitmentDemandService.createRecruitmentDemand(ctx, recuritmentDemandInfo);
  1082. }
  1083. } catch (Exception e) {
  1084. SelectorItemCollection selectorCol = new SelectorItemCollection();
  1085. selectorCol.add(new SelectorItemInfo("syncBeisenResult"));
  1086. String message = e.getMessage();
  1087. recuritmentDemandInfo.put("syncBeisenResult", "失败: " + message);
  1088. dIns.updatePartial(recuritmentDemandInfo, selectorCol);
  1089. throw new RuntimeException(e);
  1090. }
  1091. }
  1092. /**
  1093. * 招聘需求更新
  1094. * coyle
  1095. */
  1096. @Override
  1097. protected void _updateRecuritment(Context ctx, String startDate, String endDate, int offset) throws BOSException, EASBizException {
  1098. super._updateRecuritment(ctx, startDate, endDate, offset);
  1099. // 0. 参数校验与日期解析
  1100. DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  1101. LocalDate start = LocalDate.now();
  1102. LocalDate end = LocalDate.now();
  1103. //如果时间参数都为空,则使用offset参数
  1104. if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate)) {
  1105. if (offset > 0) {
  1106. //eDate增加offset天
  1107. end = end.plusDays(offset);
  1108. } else if (offset < 0) {
  1109. start = start.plusDays(offset);
  1110. }
  1111. }
  1112. if (!StringUtils.isEmpty(startDate)) {
  1113. //开始日期字定义,结束日期都是今天
  1114. start = LocalDate.parse(startDate, dateFormatter);
  1115. }
  1116. if (!StringUtils.isEmpty(endDate)) {
  1117. //开始日期,结束日期都是今天
  1118. end = LocalDate.parse(endDate, dateFormatter);
  1119. }
  1120. if (start.isAfter(end)) {
  1121. throw new BOSException("开始日期不能晚于结束日期");
  1122. }
  1123. // LocalDate 转 String (使用之前的 dateFormatter)
  1124. String startStr = toStartTime(start.format(dateFormatter));
  1125. String endStr = toEndTime(end.format(dateFormatter));
  1126. IRecuritmentDemand localInstance = RecuritmentDemandFactory.getLocalInstance(ctx);
  1127. EntityViewInfo ev = new EntityViewInfo();
  1128. FilterInfo filter = new FilterInfo();
  1129. filter.getFilterItems().add(new FilterItemInfo("requirementId", null, CompareType.NOTEMPTY));
  1130. filter.getFilterItems().add(new FilterItemInfo("lastUpdateTime", startStr, CompareType.GREATER_EQUALS));
  1131. filter.getFilterItems().add(new FilterItemInfo("lastUpdateTime", endStr, CompareType.LESS_EQUALS));
  1132. ev.setFilter(filter);
  1133. RecuritmentDemandCollection recuritmentDemandCollection = localInstance.getRecuritmentDemandCollection(ev);
  1134. for (int i = 0; i < recuritmentDemandCollection.size(); i++) {
  1135. RecuritmentDemandInfo recuritmentDemandInfo = recuritmentDemandCollection.get(i);
  1136. _syncRecuritmentToBeisen(ctx, recuritmentDemandInfo.getId().toString());
  1137. }
  1138. }
  1139. /**
  1140. * 将日期字符串转换为一天的开始时间(UTC格式)
  1141. *
  1142. * @param dateStr "yyyy-MM-dd"格式的日期字符串
  1143. * @return Moka API要求的时间格式
  1144. */
  1145. public static String toStartTime(String dateStr) {
  1146. LocalDate date = LocalDate.parse(dateStr);
  1147. LocalDateTime startOfDay = date.atStartOfDay();
  1148. return TIME_FORMATTER.format(startOfDay);
  1149. }
  1150. /**
  1151. * 将日期字符串转换为一天的结束时间(UTC格式)
  1152. *
  1153. * @param dateStr "yyyy-MM-dd"格式的日期字符串
  1154. * @return Moka API要求的时间格式
  1155. */
  1156. public static String toEndTime(String dateStr) {
  1157. LocalDate date = LocalDate.parse(dateStr);
  1158. LocalDateTime endOfDay = date.atTime(23, 59, 59);
  1159. return TIME_FORMATTER.format(endOfDay);
  1160. }
  1161. }