BeisenFacadeOSFService.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. package com.kingdee.eas.custom.recuritment.task.osf;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.google.common.collect.Maps;
  5. import com.kingdee.bos.BOSException;
  6. import com.kingdee.bos.Context;
  7. import com.kingdee.bos.bsf.service.app.IHRMsfService;
  8. import com.kingdee.bos.rabbitmq.guava.Lists;
  9. import com.kingdee.eas.common.EASBizException;
  10. import com.kingdee.eas.custom.beisen.utils.BeisenApiClient;
  11. import com.kingdee.eas.custom.beisen.utils.BeisenParam;
  12. import com.kingdee.eas.custom.recuritment.task.osf.database.MobileTypeEnum;
  13. import com.kingdee.eas.util.app.DbUtil;
  14. import com.kingdee.jdbc.rowset.IRowSet;
  15. import com.kingdee.util.enums.DynamicEnum;
  16. import org.apache.commons.lang3.StringUtils;
  17. import java.io.IOException;
  18. import java.sql.Date;
  19. import java.sql.SQLException;
  20. import java.text.SimpleDateFormat;
  21. import java.util.List;
  22. import java.util.Map;
  23. /**
  24. * 237
  25. * description: BeisenFacadeOSFService <br>
  26. * date: 2025/7/2 16:51 <br>
  27. * author: lhbj <br>
  28. * version: 1.0 <br>
  29. */
  30. public class BeisenFacadeOSFService implements IHRMsfService {
  31. @Override
  32. public Object process(Context context, Map<String, Object> map) throws EASBizException, BOSException {
  33. String mack = (String) map.get("mack");
  34. JSONObject result = null;
  35. try {
  36. if ("syncBeisenReserveTalentPool".equals(mack)) {
  37. String resignBizBillID = (String) map.get("resignBizBillID");
  38. result = _syncBeisenReserveTalentPool(context, resignBizBillID);
  39. }
  40. }catch (Exception e){
  41. e.printStackTrace();
  42. result=new JSONObject();
  43. result.put("errMsg",e.getMessage());
  44. }
  45. return result;
  46. }
  47. protected JSONObject _syncBeisenReserveTalentPool(Context ctx, String resignBizBillID) throws BOSException, SQLException, IOException {
  48. BeisenApiClient client = BeisenApiClient.getInstance();
  49. JSONArray dataArray = new JSONArray();
  50. dataArray.addAll(this.getPersonData(ctx, resignBizBillID));
  51. JSONObject jsonObject = client.callApi(BeisenParam.POST_CREATEORUPDATEAPPLICANT, dataArray);
  52. return jsonObject;
  53. }
  54. /**
  55. * shr系统数据组装北森请求参数
  56. *
  57. * @param ctx
  58. * @param resignBizBillID
  59. * @return
  60. * @throws BOSException
  61. * @throws SQLException
  62. */
  63. protected List<Map<String, Object>> getPersonData(Context ctx, String resignBizBillID) throws BOSException, SQLException {
  64. StringBuilder sql = new StringBuilder();
  65. sql.append("");
  66. sql.append(" select prm.faddress address,p.fbirthday birthday, ");
  67. sql.append(" p.fname_l2 pName,p.fnumber pNumber, ");
  68. sql.append(" re1.fenterDate enterDate,rbe.fleftcompanydate leftcompanydate,rbe.FBIZDATE bizDate, ");
  69. sql.append(" poli.fname_l2 poliName,poli.fnumber poliNumber, poli.CFBeisenVal poliBeisenVal, ");
  70. sql.append(" wed.fname_l2 webName,wed.fnumber webNumber, wed.CFBeisenVal wedBeisenVal, ");
  71. sql.append(" folk.fname_l2 folkName,folk.Fnumber folkNumber, folk.CFBeisenVal folkBeisenVal, ");
  72. sql.append(" dip.fnumber dipNumber,dip.fname_l2 dipName, dip.CFBeisenVal dipBeisenVal, ");
  73. sql.append(" p.CFDyxlbyxx dyxlbyxx,p.FWorkLocation workLocation, ");
  74. sql.append(" p.fidcardbegindate idCardbeginDate,p.fidcardenddate idCardendDate, ");
  75. sql.append(" p.FHeight height, (isnull(p.fgender,3)-1) gender, ");
  76. sql.append(" isnull(p.fidcardno,p.fpassportno) idCardNO, (case when p.fidcardno is null then 1 else 2 end) isIdCard, ");
  77. sql.append(" prm.femail email,prm.FLinkTelNum linkTelNum, ");
  78. sql.append(" p.FIDCardIssueOrg idCardIssueOrg,rbe.FDescription description, ");
  79. sql.append(" pos.fname_l2 posName,pos.Fnumber posNumber, ");
  80. sql.append(" p.CFDyxlbysj dyxlbysj,p.FnativePlace_l2 nativePlace, ");
  81. sql.append(" p.fofficePhone officePhone, prm.FNCell NCell,p.FhjAddress hjAddress,");
  82. sql.append(" nl.fname_l2 nlName,nl.fnumber nlNumber,nl.CFBeisenVal nlBeisenVal,");
  83. sql.append(" prm.FLinkName linkName,");
  84. sql.append(" '' ");
  85. sql.append(" from T_BD_Person p ");
  86. sql.append(" inner join T_HR_ResignBizBillEntry rbe on rbe.fpersonid=p.fid ");
  87. sql.append(" inner join (select re1.fpersonid,max(re1.fbizdate) fbizdate,min(re1.FENTERDATE) fenterDate from T_HR_ResignBizBillEntry re1 ");
  88. sql.append(" group by re1.fpersonid) re1 on rbe.fpersonid=re1.fpersonid and re1.fbizdate=rbe.fbizdate ");
  89. sql.append(" inner join T_HR_ResignBizBill rb on rb.fid = rbe.FBILLID and rb.FBILLSTATE = 3 ");
  90. sql.append(" left join T_ORG_Position pos on pos.fid = rbe.FPositionID ");
  91. sql.append(" left join T_BD_HRPolitical poli on poli.fid=p.fpoliticalfaceid ");
  92. sql.append(" left join T_BD_HRWed wed on wed.fid=p.fwedid ");
  93. sql.append(" left join T_BD_HRFolk folk on folk.fid=p.ffolkid ");
  94. sql.append(" left join T_BD_HRDiploma dip on dip.fid=p.FHighestDegreeID ");
  95. sql.append(" left join T_HR_PERSONCONTACTMETHOD prm on prm.fpersonid=p.fid ");
  96. sql.append(" left join T_BD_Nationality nl on nl.fid=p.FNationalityID ");
  97. sql.append(" where rb.FBILLSTATE = 3 ");
  98. if (StringUtils.isNotBlank(resignBizBillID)) {
  99. sql.append(" and rb.fid='" + resignBizBillID + "' ");
  100. } else {
  101. sql.append(" and rbe.cfsyncStatus = 0 ");
  102. }
  103. IRowSet rowSet = DbUtil.executeQuery(ctx, sql.toString());
  104. List<Map<String, Object>> list = Lists.newArrayList();
  105. while (rowSet.next()) {
  106. Map<String, Object> map = Maps.newHashMap();
  107. Map<String, Object> standardResume = Maps.newHashMap();
  108. map.put("standardResume", standardResume);
  109. //现居住地址(可邮寄
  110. String address = rowSet.getString("address");
  111. standardResume.put("extxianjuzhudizhikeyouji_433899_1099396040", this.setValue(address));
  112. //addressTX 通信地址 现居住地 OgLivingArea
  113. standardResume.put("OgLivingArea", this.setValue(address));
  114. //height 身高 身高(厘米) Height
  115. String height = rowSet.getString("height");
  116. standardResume.put("Height", this.setValue(height));
  117. //婚姻状况
  118. String webName = rowSet.getString("webName");
  119. String webNumber = rowSet.getString("webNumber");
  120. String webBeisenVal = rowSet.getString("webBeisenVal");
  121. standardResume.put("exthunyinzhuangkuang_433899_1285520393", this.setValue(webBeisenVal));
  122. //政治面貌
  123. String poliName = rowSet.getString("poliName");
  124. String poliNumber = rowSet.getString("poliNumber");
  125. String poliBeisenVal = rowSet.getString("poliBeisenVal");
  126. standardResume.put("Polity", this.setValue(webBeisenVal));
  127. //姓名,工号
  128. String pName = rowSet.getString("pName");
  129. String pNumber = rowSet.getString("pNumber");
  130. standardResume.put("Name", this.setValue(pName));
  131. standardResume.put("JobNumber", this.setValue(pNumber));
  132. //出生日期 OgBirthday
  133. Date birthday = rowSet.getDate("birthday");
  134. standardResume.put("birthday", this.setValue(birthday));
  135. standardResume.put("OgBirthday", this.setValue(birthday));
  136. //手机号
  137. String NCell = rowSet.getString("NCell");
  138. standardResume.put("Mobile", this.setValue(NCell));
  139. //手机号类型
  140. standardResume.put("MobileType", this.setValue(MobileTypeEnum.CHINESE_MAINLAND.getKey()));
  141. //dyxlbyxx 毕业学校 毕业学校 OgLastSchool
  142. String dyxlbyxx = rowSet.getString("dyxlbyxx");
  143. standardResume.put("OgLastSchool", this.setValue(dyxlbyxx));
  144. //毕业时间
  145. Date dyxlbysj = rowSet.getDate("dyxlbysj");
  146. standardResume.put("GraduationDate", this.setValue(dyxlbysj));
  147. standardResume.put("OgGraduationDate", this.setValue(dyxlbyxx));
  148. //HighestDegreeID 最高学历 第一学历 OgFirstEducationLevel string 是 是 第一学历-文本
  149. String dipNumber = rowSet.getString("dipNumber");
  150. String dipName = rowSet.getString("dipName");
  151. String dipBeisenVal = rowSet.getString("dipBeisenVal");
  152. standardResume.put("OgFirstEducationLevel", this.setValue(dipBeisenVal));
  153. standardResume.put("LastEducationLevel", this.setValue(dipBeisenVal));
  154. //idCardBeginDate 身份证开始日期 证件生效日期 CertificateValidityDate
  155. //idCardEndDate 身份证截止日期 证件失效日期 CertificateValidityOverDate
  156. Date idCardbeginDate = rowSet.getDate("idCardbeginDate");
  157. Date idCardendDate = rowSet.getDate("idCardendDate");
  158. standardResume.put("CertificateValidityDate", this.setValue(idCardbeginDate));
  159. standardResume.put("CertificateValidityOverDate", this.setValue(idCardendDate));
  160. String idCardIssueOrg = rowSet.getString("idCardIssueOrg");
  161. standardResume.put("CertificateGrantUnit", this.setValue(idCardIssueOrg));
  162. //hjAddress 户口所在地 户口所在地 AccountArea
  163. String hjAddress = rowSet.getString("hjAddress");
  164. standardResume.put("AccountArea", this.setValue(hjAddress));
  165. standardResume.put("OgAccountArea", this.setValue(hjAddress));
  166. //籍贯
  167. standardResume.put("NativeArea", this.setValue(1));
  168. //民族
  169. String folkName = rowSet.getString("folkName");
  170. String folkNumber = rowSet.getString("folkNumber");
  171. String folkBeisenVal = rowSet.getString("folkBeisenVal");
  172. standardResume.put("Nation", this.setValue(folkBeisenVal));
  173. standardResume.put("OgNation", this.setValue(folkBeisenVal));
  174. String email = rowSet.getString("email");
  175. standardResume.put("OgEmail", this.setValue(email));
  176. standardResume.put("email", this.setValue(email));
  177. standardResume.put("EmailLower", this.setValue(email.toLowerCase()));
  178. //国籍
  179. String nlBeisenVal = rowSet.getString("nlBeisenVal");
  180. standardResume.put("Nationality", this.setValue(nlBeisenVal));
  181. Date enterDate = rowSet.getDate("enterDate");
  182. standardResume.put("EntryDate", this.setValue(enterDate));
  183. Date leftcompanydate = rowSet.getDate("leftcompanydate");
  184. standardResume.put("LastWorkDate", this.setValue(leftcompanydate));
  185. String description = rowSet.getString("description");
  186. standardResume.put("CancelJobReason", this.setValue(description));
  187. String bizDate = rowSet.getString("bizDate");
  188. String workLocation = rowSet.getString("workLocation");
  189. DynamicEnum dynamicEnum = DynamicEnum.getEnum("com.kingdee.eas.custom.WorkLocation", workLocation);
  190. standardResume.put("WorkArea", this.setValue(workLocation));
  191. //证件类型 CertificateType integer 是 是
  192. String idCardNO = rowSet.getString("idCardNO");
  193. standardResume.put("CertificateNumber", this.setValue(idCardNO));
  194. String isIdCard = rowSet.getString("isIdCard");
  195. standardResume.put("CertificateType", this.setValue(isIdCard));
  196. String gender = rowSet.getString("gender");
  197. standardResume.put("Gender", this.setValue(gender));
  198. standardResume.put("OgGender", this.setValue(gender));
  199. String linkTelNum = rowSet.getString("linkTelNum");
  200. standardResume.put("EmergencyPhone", this.setValue(linkTelNum));
  201. String linkName = rowSet.getString("linkName");
  202. standardResume.put("EmergencyContact", this.setValue(linkName));
  203. String posName = rowSet.getString("posName");
  204. String posNumber = rowSet.getString("posNumber");
  205. String nativePlace = rowSet.getString("nativePlace");
  206. String officePhone = rowSet.getString("officePhone");
  207. list.add(map);
  208. }
  209. return list;
  210. }
  211. public Map<String, Object> setValue(Integer val) {
  212. return this.setValue(val.toString());
  213. }
  214. public Map<String, Object> setValue(Date val) {
  215. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
  216. return this.setValue(dateFormat.format(val));
  217. }
  218. public Map<String, Object> setValue(Date val, SimpleDateFormat dateFormat) {
  219. return this.setValue(dateFormat.format(val));
  220. }
  221. public Map<String, Object> setValue(String val) {
  222. return this.setValue("value", val);
  223. }
  224. public Map<String, Object> setValue(String key, Object val) {
  225. Map<String, Object> map = Maps.newHashMap();
  226. map.put(key, val);
  227. return map;
  228. }
  229. protected Map<String, String> getBeisenTalentPool(Context ctx) throws BOSException, SQLException {
  230. Map<String, String> map = Maps.newHashMap();
  231. IRowSet rowSet = DbUtil.executeQuery(ctx, "select top 1 cftalentPoolId,cftalentPoolType from CT_REC_BeisenTalentPool where cfstdIsDeleted='0' and cfisLieftTalentPool = 0 ");
  232. if (rowSet.next()) {
  233. String talentPoolId = rowSet.getString("cftalentPoolId");
  234. String talentPoolType = rowSet.getString("cftalentPoolType");
  235. map.put("talentPoolId", talentPoolId);
  236. map.put("talentPoolType", talentPoolType);
  237. return map;
  238. } else {
  239. throw new IllegalArgumentException("未匹配到北森离职人才库,请先在sHR系统中维护好“北森人才库”数据");
  240. }
  241. }
  242. }