RecuritmentFacadeControllerBean.java 69 KB

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