package com.kingdee.eas.custom.recuritment.task.osf; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Maps; import com.kingdee.bos.BOSException; import com.kingdee.bos.Context; import com.kingdee.bos.bsf.service.app.IHRMsfService; import com.kingdee.bos.rabbitmq.guava.Lists; import com.kingdee.eas.common.EASBizException; import com.kingdee.eas.custom.beisen.utils.BeisenApiClient; import com.kingdee.eas.custom.beisen.utils.BeisenParam; import com.kingdee.eas.custom.recuritment.task.osf.database.MobileTypeEnum; import com.kingdee.eas.util.app.DbUtil; import com.kingdee.jdbc.rowset.IRowSet; import com.kingdee.util.enums.DynamicEnum; import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.sql.Date; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.List; import java.util.Map; /** * 237 * description: BeisenFacadeOSFService
* date: 2025/7/2 16:51
* author: lhbj
* version: 1.0
*/ public class BeisenFacadeOSFService implements IHRMsfService { @Override public Object process(Context context, Map map) throws EASBizException, BOSException { String mack = (String) map.get("mack"); JSONObject result = null; try { if ("syncBeisenReserveTalentPool".equals(mack)) { String resignBizBillID = (String) map.get("resignBizBillID"); result = _syncBeisenReserveTalentPool(context, resignBizBillID); } }catch (Exception e){ e.printStackTrace(); result=new JSONObject(); result.put("errMsg",e.getMessage()); } return result; } protected JSONObject _syncBeisenReserveTalentPool(Context ctx, String resignBizBillID) throws BOSException, SQLException, IOException { BeisenApiClient client = BeisenApiClient.getInstance(); JSONArray dataArray = new JSONArray(); dataArray.addAll(this.getPersonData(ctx, resignBizBillID)); JSONObject jsonObject = client.callApi(BeisenParam.POST_CREATEORUPDATEAPPLICANT, dataArray); return jsonObject; } /** * shr系统数据组装北森请求参数 * * @param ctx * @param resignBizBillID * @return * @throws BOSException * @throws SQLException */ protected List> getPersonData(Context ctx, String resignBizBillID) throws BOSException, SQLException { StringBuilder sql = new StringBuilder(); sql.append(""); sql.append(" select prm.faddress address,p.fbirthday birthday, "); sql.append(" p.fname_l2 pName,p.fnumber pNumber, "); sql.append(" re1.fenterDate enterDate,rbe.fleftcompanydate leftcompanydate,rbe.FBIZDATE bizDate, "); sql.append(" poli.fname_l2 poliName,poli.fnumber poliNumber, poli.CFBeisenVal poliBeisenVal, "); sql.append(" wed.fname_l2 webName,wed.fnumber webNumber, wed.CFBeisenVal wedBeisenVal, "); sql.append(" folk.fname_l2 folkName,folk.Fnumber folkNumber, folk.CFBeisenVal folkBeisenVal, "); sql.append(" dip.fnumber dipNumber,dip.fname_l2 dipName, dip.CFBeisenVal dipBeisenVal, "); sql.append(" p.CFDyxlbyxx dyxlbyxx,p.FWorkLocation workLocation, "); sql.append(" p.fidcardbegindate idCardbeginDate,p.fidcardenddate idCardendDate, "); sql.append(" p.FHeight height, (isnull(p.fgender,3)-1) gender, "); sql.append(" isnull(p.fidcardno,p.fpassportno) idCardNO, (case when p.fidcardno is null then 1 else 2 end) isIdCard, "); sql.append(" prm.femail email,prm.FLinkTelNum linkTelNum, "); sql.append(" p.FIDCardIssueOrg idCardIssueOrg,rbe.FDescription description, "); sql.append(" pos.fname_l2 posName,pos.Fnumber posNumber, "); sql.append(" p.CFDyxlbysj dyxlbysj,p.FnativePlace_l2 nativePlace, "); sql.append(" p.fofficePhone officePhone, prm.FNCell NCell,p.FhjAddress hjAddress,"); sql.append(" nl.fname_l2 nlName,nl.fnumber nlNumber,nl.CFBeisenVal nlBeisenVal,"); sql.append(" prm.FLinkName linkName,"); sql.append(" '' "); sql.append(" from T_BD_Person p "); sql.append(" inner join T_HR_ResignBizBillEntry rbe on rbe.fpersonid=p.fid "); sql.append(" inner join (select re1.fpersonid,max(re1.fbizdate) fbizdate,min(re1.FENTERDATE) fenterDate from T_HR_ResignBizBillEntry re1 "); sql.append(" group by re1.fpersonid) re1 on rbe.fpersonid=re1.fpersonid and re1.fbizdate=rbe.fbizdate "); sql.append(" inner join T_HR_ResignBizBill rb on rb.fid = rbe.FBILLID and rb.FBILLSTATE = 3 "); sql.append(" left join T_ORG_Position pos on pos.fid = rbe.FPositionID "); sql.append(" left join T_BD_HRPolitical poli on poli.fid=p.fpoliticalfaceid "); sql.append(" left join T_BD_HRWed wed on wed.fid=p.fwedid "); sql.append(" left join T_BD_HRFolk folk on folk.fid=p.ffolkid "); sql.append(" left join T_BD_HRDiploma dip on dip.fid=p.FHighestDegreeID "); sql.append(" left join T_HR_PERSONCONTACTMETHOD prm on prm.fpersonid=p.fid "); sql.append(" left join T_BD_Nationality nl on nl.fid=p.FNationalityID "); sql.append(" where rb.FBILLSTATE = 3 "); if (StringUtils.isNotBlank(resignBizBillID)) { sql.append(" and rb.fid='" + resignBizBillID + "' "); } else { sql.append(" and rbe.cfsyncStatus = 0 "); } IRowSet rowSet = DbUtil.executeQuery(ctx, sql.toString()); List> list = Lists.newArrayList(); while (rowSet.next()) { Map map = Maps.newHashMap(); Map standardResume = Maps.newHashMap(); map.put("standardResume", standardResume); //现居住地址(可邮寄 String address = rowSet.getString("address"); standardResume.put("extxianjuzhudizhikeyouji_433899_1099396040", this.setValue(address)); //addressTX 通信地址 现居住地 OgLivingArea standardResume.put("OgLivingArea", this.setValue(address)); //height 身高 身高(厘米) Height String height = rowSet.getString("height"); standardResume.put("Height", this.setValue(height)); //婚姻状况 String webName = rowSet.getString("webName"); String webNumber = rowSet.getString("webNumber"); String webBeisenVal = rowSet.getString("webBeisenVal"); standardResume.put("exthunyinzhuangkuang_433899_1285520393", this.setValue(webBeisenVal)); //政治面貌 String poliName = rowSet.getString("poliName"); String poliNumber = rowSet.getString("poliNumber"); String poliBeisenVal = rowSet.getString("poliBeisenVal"); standardResume.put("Polity", this.setValue(webBeisenVal)); //姓名,工号 String pName = rowSet.getString("pName"); String pNumber = rowSet.getString("pNumber"); standardResume.put("Name", this.setValue(pName)); standardResume.put("JobNumber", this.setValue(pNumber)); //出生日期 OgBirthday Date birthday = rowSet.getDate("birthday"); standardResume.put("birthday", this.setValue(birthday)); standardResume.put("OgBirthday", this.setValue(birthday)); //手机号 String NCell = rowSet.getString("NCell"); standardResume.put("Mobile", this.setValue(NCell)); //手机号类型 standardResume.put("MobileType", this.setValue(MobileTypeEnum.CHINESE_MAINLAND.getKey())); //dyxlbyxx 毕业学校 毕业学校 OgLastSchool String dyxlbyxx = rowSet.getString("dyxlbyxx"); standardResume.put("OgLastSchool", this.setValue(dyxlbyxx)); //毕业时间 Date dyxlbysj = rowSet.getDate("dyxlbysj"); standardResume.put("GraduationDate", this.setValue(dyxlbysj)); standardResume.put("OgGraduationDate", this.setValue(dyxlbyxx)); //HighestDegreeID 最高学历 第一学历 OgFirstEducationLevel string 是 是 第一学历-文本 String dipNumber = rowSet.getString("dipNumber"); String dipName = rowSet.getString("dipName"); String dipBeisenVal = rowSet.getString("dipBeisenVal"); standardResume.put("OgFirstEducationLevel", this.setValue(dipBeisenVal)); standardResume.put("LastEducationLevel", this.setValue(dipBeisenVal)); //idCardBeginDate 身份证开始日期 证件生效日期 CertificateValidityDate //idCardEndDate 身份证截止日期 证件失效日期 CertificateValidityOverDate Date idCardbeginDate = rowSet.getDate("idCardbeginDate"); Date idCardendDate = rowSet.getDate("idCardendDate"); standardResume.put("CertificateValidityDate", this.setValue(idCardbeginDate)); standardResume.put("CertificateValidityOverDate", this.setValue(idCardendDate)); String idCardIssueOrg = rowSet.getString("idCardIssueOrg"); standardResume.put("CertificateGrantUnit", this.setValue(idCardIssueOrg)); //hjAddress 户口所在地 户口所在地 AccountArea String hjAddress = rowSet.getString("hjAddress"); standardResume.put("AccountArea", this.setValue(hjAddress)); standardResume.put("OgAccountArea", this.setValue(hjAddress)); //籍贯 standardResume.put("NativeArea", this.setValue(1)); //民族 String folkName = rowSet.getString("folkName"); String folkNumber = rowSet.getString("folkNumber"); String folkBeisenVal = rowSet.getString("folkBeisenVal"); standardResume.put("Nation", this.setValue(folkBeisenVal)); standardResume.put("OgNation", this.setValue(folkBeisenVal)); String email = rowSet.getString("email"); standardResume.put("OgEmail", this.setValue(email)); standardResume.put("email", this.setValue(email)); standardResume.put("EmailLower", this.setValue(email.toLowerCase())); //国籍 String nlBeisenVal = rowSet.getString("nlBeisenVal"); standardResume.put("Nationality", this.setValue(nlBeisenVal)); Date enterDate = rowSet.getDate("enterDate"); standardResume.put("EntryDate", this.setValue(enterDate)); Date leftcompanydate = rowSet.getDate("leftcompanydate"); standardResume.put("LastWorkDate", this.setValue(leftcompanydate)); String description = rowSet.getString("description"); standardResume.put("CancelJobReason", this.setValue(description)); String bizDate = rowSet.getString("bizDate"); String workLocation = rowSet.getString("workLocation"); DynamicEnum dynamicEnum = DynamicEnum.getEnum("com.kingdee.eas.custom.WorkLocation", workLocation); standardResume.put("WorkArea", this.setValue(workLocation)); //证件类型 CertificateType integer 是 是 String idCardNO = rowSet.getString("idCardNO"); standardResume.put("CertificateNumber", this.setValue(idCardNO)); String isIdCard = rowSet.getString("isIdCard"); standardResume.put("CertificateType", this.setValue(isIdCard)); String gender = rowSet.getString("gender"); standardResume.put("Gender", this.setValue(gender)); standardResume.put("OgGender", this.setValue(gender)); String linkTelNum = rowSet.getString("linkTelNum"); standardResume.put("EmergencyPhone", this.setValue(linkTelNum)); String linkName = rowSet.getString("linkName"); standardResume.put("EmergencyContact", this.setValue(linkName)); String posName = rowSet.getString("posName"); String posNumber = rowSet.getString("posNumber"); String nativePlace = rowSet.getString("nativePlace"); String officePhone = rowSet.getString("officePhone"); list.add(map); } return list; } public Map setValue(Integer val) { return this.setValue(val.toString()); } public Map setValue(Date val) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); return this.setValue(dateFormat.format(val)); } public Map setValue(Date val, SimpleDateFormat dateFormat) { return this.setValue(dateFormat.format(val)); } public Map setValue(String val) { return this.setValue("value", val); } public Map setValue(String key, Object val) { Map map = Maps.newHashMap(); map.put(key, val); return map; } protected Map getBeisenTalentPool(Context ctx) throws BOSException, SQLException { Map map = Maps.newHashMap(); IRowSet rowSet = DbUtil.executeQuery(ctx, "select top 1 cftalentPoolId,cftalentPoolType from CT_REC_BeisenTalentPool where cfstdIsDeleted='0' and cfisLieftTalentPool = 0 "); if (rowSet.next()) { String talentPoolId = rowSet.getString("cftalentPoolId"); String talentPoolType = rowSet.getString("cftalentPoolType"); map.put("talentPoolId", talentPoolId); map.put("talentPoolType", talentPoolType); return map; } else { throw new IllegalArgumentException("未匹配到北森离职人才库,请先在sHR系统中维护好“北森人才库”数据"); } } }