Parcourir la source

离职同步北森

9060 il y a 3 semaines
Parent
commit
a80dc0d5c1

+ 75 - 0
src/com/kingdee/eas/hr/affair/app/ResignBizBillControllerBeanExEx.java

@@ -0,0 +1,75 @@
+package com.kingdee.eas.hr.affair.app;
+
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
+import com.kingdee.bos.util.BOSUuid;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.recuritment.task.ResignBeisenFacadeFactory;
+import com.kingdee.eas.hr.affair.*;
+import com.kingdee.eas.hr.base.HRBillBaseEntryInfo;
+import com.kingdee.eas.hr.base.HRBillBaseInfo;
+import com.kingdee.eas.hr.base.HRBillStateEnum;
+import com.kingdee.eas.hr.base.IHRBillBase;
+import com.kingdee.eas.hr.base.app.plan.SHRActionVerifyByPersonPlanTool;
+import com.kingdee.eas.hr.base.app.util.MetaDataServerUtil;
+import com.kingdee.eas.hr.base.app.util.SHRBizBillAttachmentReverseUtils;
+import com.kingdee.eas.hr.base.app.util.SHRSameDatePersonChangeUtil;
+import com.kingdee.eas.hr.base.util.AffairBizExtendCustomerTool;
+import com.kingdee.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * 离职单拓展
+ * 20241110
+ * @author coyle
+ *
+ */
+public class ResignBizBillControllerBeanExEx extends ResignBizBillControllerBean {
+	private static Logger logger = LoggerFactory.getLogger(ResignBizBillControllerBeanExEx.class);
+
+//	@Override
+//	protected IObjectPK _submit(Context ctx, IObjectValue model) throws BOSException, EASBizException {
+//		return super._submit(ctx, model);
+//
+//		IEnactmentService enactService = EnactmentServiceFactory.createEnactService(ctx);
+//		enactService.createProcInst()
+//
+//	}
+//	@Override
+//	protected void _doWithOtherChangeEffect(Context ctx, HRAffairBizBillEntryInfo entry)
+//			throws BOSException, EASBizException {
+//		super._doWithOtherChangeEffect(ctx, entry);
+//		// 生成电子证明
+////		CreateCertification.createCert(ctx, entry.getId().toString(),0);
+//	}
+
+	/**
+	 * 离职生效
+	 * @param ctx
+	 * @param billID
+	 * @throws BOSException
+	 * @throws EASBizException
+	 */
+	@Override
+	protected void _auditEntryEffect(Context ctx, BOSUuid billID) throws BOSException, EASBizException {
+		super._auditEntryEffect(ctx,billID);
+		if (billID != null) {
+			ResignBizBillInfo billInfo = this.getResignBizBillInfo(ctx,new ObjectUuidPK(billID));
+			//ResignBizBillEntryCollection collection = billInfo.getEntrys();
+			BOSUuid id = billInfo.getId();
+			ResignBeisenFacadeFactory.getLocalInstance(ctx).syncBeisenReserveTalentPool(id.toString(), billInfo);
+		}
+	}
+	@Override
+	protected void _untiCheckBizBill(Context ctx, String billId) throws BOSException, EASBizException {
+		super._untiCheckBizBill(ctx,billId);
+		if (!StringUtils.isEmpty(billId)) {
+			ResignBizBillInfo billInfo = this.getResignBizBillInfo(ctx,new ObjectUuidPK(billId));
+			BOSUuid id =billInfo.getId();
+			ResignBeisenFacadeFactory.getLocalInstance(ctx).syncUnBeisenReserveTalentPool(id.toString(),billInfo);
+		}
+	}
+}

+ 48 - 0
websrc/com/kingdee/eas/custom/recuritment/task/handler/ResignBizBillHrManListHandlerEx.java

@@ -0,0 +1,48 @@
+package com.kingdee.eas.custom.recuritment.task.handler;
+
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
+import com.kingdee.bos.util.BOSUuid;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.recuritment.task.ResignBeisenFacadeFactory;
+import com.kingdee.eas.hr.affair.ResignBizBillFactory;
+import com.kingdee.eas.hr.affair.ResignBizBillInfo;
+import com.kingdee.eas.hr.base.HRBillStateEnum;
+import com.kingdee.shr.base.syssetting.context.SHRContext;
+import com.kingdee.shr.base.syssetting.exception.SHRWebException;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * description: ResignBizBillHrManListHandlerEx <br>
+ * date: 2025/7/10 9:26 <br>
+ * author: lhbj <br>
+ * version: 1.0 <br>
+ */
+public class ResignBizBillHrManListHandlerEx extends com.kingdee.shr.affair.web.handler.hrman.ResignBizBillHrManListHandler{
+
+    public String enableAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+        String billId = this.getBillId(request);
+        String[] ids = billId.split(",");
+        Context ctx = SHRContext.getInstance().getContext();
+        try {
+            for(String id : ids) {
+                ResignBizBillInfo billInfo = ResignBizBillFactory.getLocalInstance(ctx).getResignBizBillInfo(new ObjectUuidPK(id));
+                HRBillStateEnum stateEnum = billInfo.getBillState();
+                if(HRBillStateEnum.AUDITED.equals(stateEnum)) {
+                    ResignBeisenFacadeFactory.getLocalInstance(ctx).syncBeisenReserveTalentPool(id.toString(), billInfo);
+                }else {
+                    ResignBeisenFacadeFactory.getLocalInstance(ctx).syncUnBeisenReserveTalentPool(id.toString(), billInfo);
+                }
+            }
+        } catch (BOSException e) {
+            e.printStackTrace();
+        } catch (EASBizException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 423 - 94
websrc/com/kingdee/eas/custom/recuritment/task/osf/BeisenFacadeOSFService.java

@@ -10,7 +10,10 @@ 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.beisen.utils.BeisenParamByProperties;
+import com.kingdee.eas.custom.recuritment.bizEnum.ExecuteResultEnum;
 import com.kingdee.eas.custom.recuritment.task.osf.database.MobileTypeEnum;
+import com.kingdee.eas.util.ExceptionUtil;
 import com.kingdee.eas.util.app.DbUtil;
 import com.kingdee.jdbc.rowset.IRowSet;
 import com.kingdee.util.enums.DynamicEnum;
@@ -20,6 +23,7 @@ import java.io.IOException;
 import java.sql.Date;
 import java.sql.SQLException;
 import java.text.SimpleDateFormat;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
@@ -31,34 +35,300 @@ import java.util.Map;
  * version: 1.0 <br>
  */
 public class BeisenFacadeOSFService implements IHRMsfService {
-
+    String syncBeisenReserveTalentPool ="syncBeisenReserveTalentPool";
+    String syncUnBeisenReserveTalentPool ="syncUnBeisenReserveTalentPool";
     @Override
     public Object process(Context context, Map<String, Object> map) throws EASBizException, BOSException {
         String mack = (String) map.get("mack");
         JSONObject result = null;
         try {
-            if ("syncBeisenReserveTalentPool".equals(mack)) {
+            if (syncBeisenReserveTalentPool.equals(mack)) {
                 String resignBizBillID = (String) map.get("resignBizBillID");
                 result = _syncBeisenReserveTalentPool(context, resignBizBillID);
+            }else if(syncUnBeisenReserveTalentPool.equals(mack)){
+                String resignBizBillID = (String) map.get("resignBizBillID");
+                result = _syncUnBeisenReserveTalentPool(context, resignBizBillID);
+            }else {
+                result = new JSONObject();
+                result.put("errMsg", "未找到实现方法");
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
-            result=new JSONObject();
-            result.put("errMsg",e.getMessage());
+            result = new JSONObject();
+            result.put("errMsg", e.getMessage());
         }
         return result;
     }
 
-    protected JSONObject _syncBeisenReserveTalentPool(Context ctx, String resignBizBillID) throws BOSException, SQLException, IOException {
+    /**
+     * 入职
+     *
+     * @param ctx
+     * @param resignBizBillID
+     * @return
+     * @throws BOSException
+     * @throws SQLException
+     * @throws IOException
+     */
+    protected JSONObject _syncBeisenEmpenrollbizTalentPool(Context ctx, String resignBizBillID) throws BOSException, SQLException, IOException {
+
+        return null;
+    }
+
+    /**
+     * 离职-审核通过
+     *
+     * @param ctx
+     * @param resignBizBillID
+     * @return
+     * @throws BOSException
+     * @throws SQLException
+     * @throws IOException
+     */
+    protected JSONObject _syncBeisenReserveTalentPool(Context ctx, String resignBizBillID) throws Exception {
+        JSONObject result = null;
+        StringBuilder sql = new StringBuilder();
+        sql.append(" select top 1 rbr.CFApplyId,rbr.CFCandidateId from T_REC_Offer offer ");
+        sql.append(" left join T_REC_ResumeBaseRec rbr on offer.FResumeBaseRecID=rbr.fid ");
+        sql.append(" where offer.FPERSONID in(select fpersonid from T_HR_ResignBizBillEntry where fbillid=?) order by offer.fsendDate desc ");
+        IRowSet rs = DbUtil.executeQuery(ctx, sql.toString(), new String[]{resignBizBillID});
+        String CFApplyId = "";
+        String CFCandidateId = "";
+        while (rs.next()) {
+            CFCandidateId = rs.getString("CFCandidateId");
+            CFApplyId = rs.getString("CFApplyId");
+        }
+        if (StringUtils.isNotBlank(CFCandidateId)) {
+            result =this.TransferPhase(ctx,BeisenParam.BEISEN_CONFIG_RESERVE_STATUSID,resignBizBillID,CFCandidateId,CFApplyId);
+        } else {
+            result =this.CreateOrUpdateApplicant(ctx, resignBizBillID);
+        }
+        return result;
+    }
+    /**
+     * 离职-反审批
+     * @param ctx
+     * @param resignBizBillID
+     * @return
+     * @throws BOSException
+     * @throws SQLException
+     * @throws IOException
+     */
+    protected JSONObject _syncUnBeisenReserveTalentPool(Context ctx, String resignBizBillID) throws Exception {
+        JSONObject result = null;
+        StringBuilder sql = new StringBuilder();
+        sql.append(" select top 1 rbr.CFApplyId,rbr.CFCandidateId from T_REC_Offer offer ");
+        sql.append(" left join T_REC_ResumeBaseRec rbr on offer.FResumeBaseRecID=rbr.fid ");
+        sql.append(" where offer.FPERSONID in(select fpersonid from T_HR_ResignBizBillEntry where fbillid=?) order by offer.fsendDate desc ");
+        IRowSet rs = DbUtil.executeQuery(ctx, sql.toString(), new String[]{resignBizBillID});
+        String CFApplyId = "";
+        String CFCandidateId = "";
+        while (rs.next()) {
+            CFCandidateId = rs.getString("CFCandidateId");
+            CFApplyId = rs.getString("CFApplyId");
+        }
+        if (StringUtils.isNotBlank(CFApplyId)) {
+            result =this.TransferPhase(ctx,BeisenParam.BEISEN_CONFIG_UNRESERVE_STATUSID,resignBizBillID,CFCandidateId,CFApplyId);
+        } else {
+            result =this.removeApplicantFromTalentPool(ctx, resignBizBillID);
+        }
+        return result;
+    }
+
+    /**
+     * 移出人才库
+     * @param ctx
+     * @param resignBizBillID
+     * @return
+     * @throws Exception
+     */
+    protected JSONObject removeApplicantFromTalentPool(Context ctx, String resignBizBillID) throws Exception {
+
+        JSONObject result = new JSONObject();
+        ExecuteResultEnum syncStatus = ExecuteResultEnum.SUCCESS;
+        try {
+            IRowSet rowSet = DbUtil.executeQuery(ctx,"select CFCandidateId,CFSyncBeisenResult from T_HR_ResignBizBillEntry where fbillid=?",new String[]{resignBizBillID});
+            List<String> candidateIds = Lists.newArrayList();
+
+            while (rowSet.next()){
+
+                String CFSyncBeisenResult = rowSet.getString("CFSyncBeisenResult");
+                String CFCandidateId = rowSet.getString("CFCandidateId");
+                if (StringUtils.isBlank(CFCandidateId)&&StringUtils.isNotBlank(CFSyncBeisenResult)) {
+                    JSONObject jsonObject = JSONObject.parseObject(CFSyncBeisenResult);
+                    if (null != jsonObject && 200 == jsonObject.getInteger("code")) {
+                        JSONObject jsonObjectSync = this.GetApplicantIdBySyncId(jsonObject);
+                        result.put("GetApplicantIdBySyncId", jsonObjectSync);
+                        if (null != jsonObjectSync && 200 == jsonObjectSync.getInteger("code")) {
+                            JSONObject dataSync = jsonObjectSync.getJSONObject("data");
+                            if (null != dataSync) {
+                                String candidateId= dataSync.getString("applicantId");
+                                candidateIds.add(candidateId);
+                                syncStatus = ExecuteResultEnum.SUCCESS;
+                            }
+                        }
+                    }
+                }
+                if (StringUtils.isNotBlank(CFCandidateId)) {
+                    candidateIds.add(CFCandidateId);
+                }
+            }
+            if(!candidateIds.isEmpty()) {
+                result.put("candidateIds",candidateIds);
+                //离职人才库id
+                Map<String, String> objectMap = this.getBeisenTalentPool(ctx);
+                String talentPoolId=objectMap.get("talentPoolId");
+                BeisenApiClient client = BeisenApiClient.getInstance();
+                JSONObject jsonData = new JSONObject();
+                BeisenParamByProperties byProperties = new BeisenParamByProperties();
+                Map<String, String> config = byProperties.getConfig();
+                jsonData.put("talentPoolId", talentPoolId);
+                jsonData.put("applicantIds", candidateIds);
+                System.out.println(jsonData.toJSONString());
+                JSONObject jsonObject = client.callApi(BeisenParam.POST_REMOVEAPPLICANTFROMTALENTPOOL_URL, jsonData);
+                result.put("POST_REMOVEAPPLICANTFROMTALENTPOOL_URL", jsonObject);
+                if (null != jsonObject && 200 == jsonObject.getInteger("code")) {
+                    syncStatus = ExecuteResultEnum.SUCCESS;
+                } else {
+                    syncStatus = ExecuteResultEnum.ERROR;
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            syncStatus = ExecuteResultEnum.ERROR;
+            throw e;
+        } finally {
+            List<String> candidateIds = (List<String>) result.get("candidateIds");
+            if(null!=candidateIds&&(!candidateIds.isEmpty())) {
+                updateSyncBeisenResultBillId(ctx, resignBizBillID, syncStatus, candidateIds.get(0), result.getJSONObject("POST_TRANSFERPHASE_DATA"));
+            }else {
+                updateSyncBeisenResultBillId(ctx, resignBizBillID, syncStatus, "", result.getJSONObject("POST_TRANSFERPHASE_DATA"));
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 转移阶段状态
+     *
+     * @param ctx
+     * @param resignBizBillID 离职
+     * @param candidateId     应聘者id
+     * @param applyId         申请Id
+     * @return
+     * @throws Exception
+     */
+    public JSONObject TransferPhase(Context ctx,String STATUSID, String resignBizBillID, String candidateId, String applyId) throws Exception {
+        JSONObject result = new JSONObject();
+        ExecuteResultEnum syncStatus = ExecuteResultEnum.SUCCESS;
+
+        try {
+
+            BeisenApiClient client = BeisenApiClient.getInstance();
+            JSONObject jsonData = new JSONObject();
+            BeisenParamByProperties byProperties = new BeisenParamByProperties();
+            Map<String, String> config = byProperties.getConfig();
+
+            JSONArray applyIds = new JSONArray();
+            applyIds.add(applyId);
+            jsonData.put("applyIds", applyIds);
+            jsonData.put("phaseId", config.get(BeisenParam.BEISEN_CONFIG_PHASEID));
+            jsonData.put("statusId", config.get(STATUSID));
+            System.out.println(jsonData.toJSONString());
+            JSONObject jsonObject = client.callApi(BeisenParam.POST_TRANSFERPHASE_URL, jsonData);
+            result.put("POST_TRANSFERPHASE_DATA",jsonObject);
+            if (null != jsonObject && 200 == jsonObject.getInteger("code")) {
+                syncStatus = ExecuteResultEnum.SUCCESS;
+            }else {
+                syncStatus = ExecuteResultEnum.ERROR;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            syncStatus = ExecuteResultEnum.ERROR;
+            throw e;
+        } finally {
+            updateSyncBeisenResultBillId(ctx,resignBizBillID,syncStatus,candidateId,result.getJSONObject("POST_TRANSFERPHASE_DATA"));
+        }
+        return result;
+    }
+
+    /**
+     * 创建应聘者
+     *
+     * @param ctx
+     * @param resignBizBillID
+     * @return
+     * @throws Exception
+     */
+    public JSONObject CreateOrUpdateApplicant(Context ctx, String resignBizBillID) throws Exception {
+        JSONObject result = new JSONObject();
+        ExecuteResultEnum syncStatus = ExecuteResultEnum.ERROR;
+        result.put("code", "ses");
+        result.put("msg", "");
+        String candidateId = "";
+        try {
+            Map<String, String> objectMap = this.getBeisenTalentPool(ctx);
+            BeisenApiClient client = BeisenApiClient.getInstance();
+            Map<String, Object> personData = this.getPersonData(ctx, resignBizBillID);
+            String code = (String) result.get("code");
+            if ("ses".equals(code)) {
+                Map<String, Object> data = (Map<String, Object>) personData.get("data");
+                if(null!=data&&(!data.isEmpty())) {
+                    JSONObject jsonData = new JSONObject();
+                    jsonData.putAll(data);
+                    jsonData.put("talentPoolIds", objectMap.values());
+                    BeisenParamByProperties byProperties = new BeisenParamByProperties();
+                    Map<String, String> config = byProperties.getConfig();
+                    jsonData.put("channelId", config.get(BeisenParam.BEISEN_CONFIG_CHANNELID));
+                    //jsonData.put("acquireMannerId",2);
+                    System.out.println(jsonData.toJSONString());
+                    JSONObject jsonObject = client.callApi(BeisenParam.POST_CREATEORUPDATEAPPLICANT_URL, jsonData);
+                    result.put("POST_CREATEORUPDATEAPPLICANT_DATA", jsonObject);
+                    result.put("personData", personData);
+                    if (null != jsonObject && 200 == jsonObject.getInteger("code")) {
+                        JSONObject jsonObjectSync = this.GetApplicantIdBySyncId(jsonObject);
+                        result.put("GetApplicantIdBySyncId", jsonObjectSync);
+                        if (null != jsonObjectSync && 200 == jsonObjectSync.getInteger("code")) {
+                            JSONObject dataSync = jsonObjectSync.getJSONObject("data");
+                            if (null != dataSync) {
+                                candidateId = dataSync.getString("applicantId");
+                                syncStatus = ExecuteResultEnum.SUCCESS;
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            syncStatus = ExecuteResultEnum.ERROR;
+            result.put("msg", ExceptionUtil.getExcLinkStackTrace(e));
+            result.put("code", "err");
+            throw e;
+        } finally {
+            updateSyncBeisenResultBillId(ctx, resignBizBillID, syncStatus, candidateId, result.getJSONObject("POST_CREATEORUPDATEAPPLICANT_DATA"));
+        }
+        return result;
+    }
+
+    /**
+     * 根据同步Id获取应聘者Id
+     *
+     * @param jsonObject
+     * @return
+     */
+    public JSONObject GetApplicantIdBySyncId(JSONObject jsonObject) throws 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;
+        String syncId = "";
+        if (null != jsonObject) {
+            syncId = jsonObject.getString("data");
+        }
+        JSONObject object = client.callApi(BeisenParam.POST_GETAPPLICANTIDBYSYNCID_URL + "?syncId=" + syncId, jsonObject);
+        return object;
     }
 
     /**
-     * shr绯荤粺鏁版嵁缁勮�鍖楁.璇锋眰鍙傛暟
+     * shr系统数据组装北森请求参数
      *
      * @param ctx
      * @param resignBizBillID
@@ -66,20 +336,24 @@ public class BeisenFacadeOSFService implements IHRMsfService {
      * @throws BOSException
      * @throws SQLException
      */
-    protected List<Map<String, Object>> getPersonData(Context ctx, String resignBizBillID) throws BOSException, SQLException {
+    protected Map<String, Object> getPersonData(Context ctx, String resignBizBillID) throws BOSException, SQLException {
+
+        Map<String, Object> result = Maps.newHashMap();
+        result.put("code", "ses");
+        result.put("msg", "");
         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(" wed.fname_l2 wedName,wed.fnumber wedNumber, 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(" p.FHeight height, (case when (isnull(p.fgender,3)-1)>0 then (isnull(p.fgender,3)-1) else 1 end) gender, ");
+        sql.append(" isnull(p.fidcardno,p.fpassportno) idCardNO, (case when p.fidcardno is null then 2 else 1 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, ");
@@ -87,13 +361,15 @@ public class BeisenFacadeOSFService implements IHRMsfService {
         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(" inner join T_HR_ResignBizBill rb on rb.fid = rbe.FBILLID ");
+
+        sql.append(" 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 ");
@@ -101,12 +377,11 @@ public class BeisenFacadeOSFService implements IHRMsfService {
         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  ");
+        sql.append(" where rb.FBILLSTATE = 3");
         if (StringUtils.isNotBlank(resignBizBillID)) {
             sql.append(" and rb.fid='" + resignBizBillID + "' ");
         } else {
-            sql.append(" and rbe.cfsyncStatus = 0 ");
+            sql.append(" and rbe.CFSyncStatus != 1  ");
         }
         IRowSet rowSet = DbUtil.executeQuery(ctx, sql.toString());
         List<Map<String, Object>> list = Lists.newArrayList();
@@ -115,121 +390,176 @@ public class BeisenFacadeOSFService implements IHRMsfService {
 
             Map<String, Object> standardResume = Maps.newHashMap();
             map.put("standardResume", standardResume);
-            //鐜板眳浣忓湴鍧€锛堝彲閭�瘎
+            Map<String, Object> personProfile = Maps.newHashMap();
+            standardResume.put("personProfile", personProfile);
+            //现居住地址(可邮寄{"code":400,"data":"00000000-0000-0000-0000-000000000000","message":"值不在数据源的范围内,字段名:Gender,值:-1"}
             String address = rowSet.getString("address");
-            standardResume.put("extxianjuzhudizhikeyouji_433899_1099396040", this.setValue(address));
-            //addressTX	閫氫俊鍦板潃	鐜板眳浣忓湴	OgLivingArea
-            standardResume.put("OgLivingArea", this.setValue(address));
-            //height	韬�珮	韬�珮(鍘樼背)	Height
+            personProfile.put("extxianjuzhudizhikeyouji_433899_1099396040", this.setValue(address));
+
+            //addressTX	通信地址	现居住地	OgLivingArea
+            //personProfile.put("OgLivingArea", this.setValue(address));
+
+            //height	身高	身高(厘米)	Height
             String height = rowSet.getString("height");
-            standardResume.put("Height", this.setValue(height));
+            if (StringUtils.isNotBlank(height)) {
+                personProfile.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 wedName = rowSet.getString("wedName");
+            String wedNumber = rowSet.getString("wedNumber");
+            String wedBeisenVal = rowSet.getString("wedBeisenVal");
+            if (StringUtils.isNotBlank(wedBeisenVal)) {
+                personProfile.put("exthunyinzhuangkuang_433899_1285520393", this.setValue(wedBeisenVal));
+            }
 
-            //鏀挎不闈㈣矊
+            //政治面貌
             String poliName = rowSet.getString("poliName");
             String poliNumber = rowSet.getString("poliNumber");
             String poliBeisenVal = rowSet.getString("poliBeisenVal");
-            standardResume.put("Polity", this.setValue(webBeisenVal));
-            //濮撳悕锛屽伐鍙�
+            if (StringUtils.isNotBlank(wedBeisenVal)) {
+                personProfile.put("Polity", this.setValue(poliBeisenVal));
+            }
+            //姓名,工号
             String pName = rowSet.getString("pName");
             String pNumber = rowSet.getString("pNumber");
-            standardResume.put("Name", this.setValue(pName));
-            standardResume.put("JobNumber", this.setValue(pNumber));
-            //鍑虹敓鏃ユ湡	OgBirthday
+            personProfile.put("Name", this.setValue(pName));
+            //personProfile.put("JobNumber", this.setValue(pNumber));
+            //出生日期	OgBirthday
             Date birthday = rowSet.getDate("birthday");
-            standardResume.put("birthday", this.setValue(birthday));
-            standardResume.put("OgBirthday", this.setValue(birthday));
-            //鎵嬫満鍙�
+            if (null != birthday) {
+                personProfile.put("birthday", this.setValue(birthday));
+                personProfile.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
+            if (StringUtils.isNotBlank(NCell)) {
+                personProfile.put("Mobile", this.setValue(NCell));
+                //手机号类型
+                personProfile.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	鏄�	鏄�	绗�竴瀛﹀巻-鏂囨湰
+            //personProfile.put("OgLastSchool", this.setValue(dyxlbyxx));
+            //毕业时间
+//            Date dyxlbysj = rowSet.getDate("dyxlbysj");
+//            if(null!=dyxlbysj) {
+//                personProfile.put("GraduationDate", this.setValue(dyxlbysj));
+//               // personProfile.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));
-            //姘戞棌
+            //personProfile.put("OgFirstEducationLevel", this.setValue(dipBeisenVal));
+            //personProfile.put("LastEducationLevel", this.setValue(dipBeisenVal));
+            //idCardBeginDate	身份证开始日期	证件生效日期	CertificateValidityDate
+            //idCardEndDate	身份证截止日期	证件失效日期	CertificateValidityOverDate
+//            Date idCardbeginDate = rowSet.getDate("idCardbeginDate");
+//            Date idCardendDate = rowSet.getDate("idCardendDate");
+//            if(null!=idCardbeginDate && null!=idCardendDate) {
+//                personProfile.put("CertificateValidityDate", this.setValue(idCardbeginDate));
+//                personProfile.put("CertificateValidityOverDate", this.setValue(idCardendDate));
+//            }
+//            String idCardIssueOrg = rowSet.getString("idCardIssueOrg");
+//            personProfile.put("CertificateGrantUnit", this.setValue(idCardIssueOrg));
+
+
+            //籍贯
+            personProfile.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));
+            if(StringUtils.isNotBlank(folkBeisenVal)) {
+                personProfile.put("Nation", 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()));
 
-            //鍥界睄
+            personProfile.put("Email", this.setValue(email));
+
+
+            //国籍
             String nlBeisenVal = rowSet.getString("nlBeisenVal");
-            standardResume.put("Nationality", this.setValue(nlBeisenVal));
+            personProfile.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	是	是
 
-            //璇佷欢绫诲瀷	CertificateType	integer	鏄�	鏄�
             String idCardNO = rowSet.getString("idCardNO");
-            standardResume.put("CertificateNumber", this.setValue(idCardNO));
+            personProfile.put("CertificateNumber", this.setValue(idCardNO));
             String isIdCard = rowSet.getString("isIdCard");
-            standardResume.put("CertificateType", this.setValue(isIdCard));
+            personProfile.put("CertificateType", this.setValue(isIdCard));
 
             String gender = rowSet.getString("gender");
-            standardResume.put("Gender", this.setValue(gender));
-            standardResume.put("OgGender", this.setValue(gender));
+            personProfile.put("Gender", this.setValue(gender));
+            //personProfile.put("OgGender", this.setValue(gender));
 
             String linkTelNum = rowSet.getString("linkTelNum");
-            standardResume.put("EmergencyPhone", this.setValue(linkTelNum));
+            personProfile.put("EmergencyPhone", this.setValue(linkTelNum));
             String linkName = rowSet.getString("linkName");
-            standardResume.put("EmergencyContact", this.setValue(linkName));
+            personProfile.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");
+
+            if (StringUtils.isBlank(idCardNO)) {
+                result.put("code", "err");
+                String msg = (String) result.get("msg");
+                result.put("msg", msg + "身份正号与护照号不能同时为空!");
+                continue;
+            }
+            if (StringUtils.isBlank(email) && StringUtils.isBlank(NCell)) {
+                result.put("code", "err");
+                String msg = (String) result.get("msg");
+                result.put("msg", msg + "邮箱与手机号不能同时为空!");
+                continue;
+            }
+            result.put("data", map);
             list.add(map);
         }
-        return list;
+        return result;
+    }
+
+    /**
+     * syncStatus	同步北森状态	业务枚举	CFSyncStatus
+     * syncBeisenResult	同步北森结果	字符串	CFSyncBeisenResult
+     */
+    public void updateSyncBeisenResultBillId(Context ctx, String id, ExecuteResultEnum syncStatus, String candidateId, JSONObject jsonData) throws BOSException {
+        String syncBeisenResult="";
+        if(null!=jsonData) {
+            syncBeisenResult = jsonData.toJSONString();
+        }
+            DbUtil.execute(ctx,
+                    "update T_HR_ResignBizBillEntry set CFSyncBeisenResult=?,CFCandidateId=?,CFSyncStatus=? where FBILLID =?",
+                    new String[]{syncBeisenResult, candidateId, syncStatus.getValue(), id}
+            );
+
+    }
+    /**
+     * syncStatus	同步北森状态	业务枚举	CFSyncStatus
+     * syncBeisenResult	同步北森结果	字符串	CFSyncBeisenResult
+     */
+    public void updateSyncBeisenResultEntryId(Context ctx, String id, ExecuteResultEnum syncStatus, String candidateId, JSONObject jsonData) throws BOSException {
+        String syncBeisenResult = jsonData.toJSONString();
+
+        DbUtil.execute(ctx,
+                "update T_HR_ResignBizBillEntry set CFSyncBeisenResult=?,CFCandidateId=?,CFSyncStatus=? where fid =?",
+                new String[]{syncBeisenResult, candidateId, syncStatus.getValue(), id}
+        );
     }
 
     public Map<String, Object> setValue(Integer val) {
@@ -251,21 +581,20 @@ public class BeisenFacadeOSFService implements IHRMsfService {
 
     public Map<String, Object> setValue(String key, Object val) {
         Map<String, Object> map = Maps.newHashMap();
-        map.put(key, val);
+        map.put(key, (null == val ? "" : val));
         return map;
     }
 
     protected Map<String, String> getBeisenTalentPool(Context ctx) throws BOSException, SQLException {
         Map<String, String> map = Maps.newHashMap();
-        IRowSet rowSet = DbUtil.executeQuery(ctx, "select top 1 cftalentPoolId,cftalentPoolType from CT_REC_BeisenTalentPool where cfstdIsDeleted='0' and cfisLieftTalentPool = 0 ");
+        IRowSet rowSet = DbUtil.executeQuery(ctx, "select top 1 cftalentPoolId,cftalentPoolType from CT_REC_BeisenTalentPool where cfstdIsDeleted='0' and cfisLieftTalentPool = 0 and FNumber='离职人才库' ");
         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("鏈�尮閰嶅埌鍖楁.绂昏亴浜烘墠搴擄紝璇峰厛鍦╯HR绯荤粺涓�淮鎶ゅソ鈥滃寳妫�汉鎵嶅簱鈥濇暟鎹�");
+            throw new IllegalArgumentException("未匹配到北森离职人才库,请先在sHR系统中维护好“北森人才库”数据");
         }
     }