|
|
|
|
@ -2,9 +2,12 @@ package com.weaver.seconddev.beisen.esb;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.weaver.common.base.entity.result.WeaResult;
|
|
|
|
|
import com.weaver.common.cache.tablecache.impl.ComInfoCache;
|
|
|
|
|
import com.weaver.common.hrm.cache.HrmEmployeeComInfo;
|
|
|
|
|
import com.weaver.common.hrm.dao.HrmCommonEmployeeDao;
|
|
|
|
|
import com.weaver.ebuilder.form.client.service.emobile.IEtFormDatasetService;
|
|
|
|
|
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
|
|
|
|
@ -20,7 +23,6 @@ import com.weaver.seconddev.portal.entity.param.BaseParam;
|
|
|
|
|
import com.weaver.seconddev.portal.mapper.portal.EbuilderBaseMapper;
|
|
|
|
|
import com.weaver.seconddev.portal.util.DateUtil;
|
|
|
|
|
import com.weaver.seconddev.portal.util.PapiUtil;
|
|
|
|
|
import com.weaver.teams.domain.user.SimpleEmployee;
|
|
|
|
|
import com.weaver.workflow.common.cfg.org.service.DepartMentService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
@ -44,23 +46,25 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
@Autowired
|
|
|
|
|
Token2BeiSenUtil http2BenSenUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
OfferMapper offerMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ComInfoCache comInfoCache;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
IEtFormDatasetService etFormDatasetService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
OfferMapper offerMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
HrmCommonEmployeeDao hrmCommonEmployeeDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
DepartMentService departMentService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
EbuilderBaseMapper ebuilderBaseMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
|
|
|
|
|
|
|
|
|
//etFormDatasetService.deleteData( params)
|
|
|
|
|
|
|
|
|
|
String startDate = String.valueOf(params.get("startDate"));
|
|
|
|
|
@ -82,6 +86,7 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
|
|
|
|
|
BaseParam baseParam = new BaseParam();
|
|
|
|
|
JSONArray datas = new JSONArray();
|
|
|
|
|
log.error("beiSenOfferData:{}", JSONObject.toJSONString(beiSenOfferData));
|
|
|
|
|
// 遍历offer数据,插入到EB表
|
|
|
|
|
for (BeiSenOffer offer : beiSenOfferData) {
|
|
|
|
|
String objectId = offer.getObjectId();
|
|
|
|
|
@ -105,15 +110,25 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
mainDataObj.put("native_place", "中国");
|
|
|
|
|
// TODO 待确认
|
|
|
|
|
mainDataObj.put("zxjssl", "1");
|
|
|
|
|
// 信息采集状态
|
|
|
|
|
mainDataObj.put("xxcjzt", "0");
|
|
|
|
|
// 入职准备状态
|
|
|
|
|
mainDataObj.put("rzzbzt", "0");
|
|
|
|
|
// 入职签到状态
|
|
|
|
|
mainDataObj.put("rzqdzt", "0");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 注解转换方式
|
|
|
|
|
mainDataObj.put("location", convertOffer.getPlace());
|
|
|
|
|
// mainDataObj.put("location", convertOffer.getPlace());
|
|
|
|
|
mainDataObj.put("htgzdd", convertOffer.getPlace());
|
|
|
|
|
mainDataObj.put("marital_status", convertOffer.getMarryCategory());
|
|
|
|
|
mainDataObj.put("nation", convertOffer.getNation());
|
|
|
|
|
mainDataObj.put("householdtype", convertOffer.getDomicileType());
|
|
|
|
|
mainDataObj.put("education", convertOffer.getEducationLevel());
|
|
|
|
|
mainDataObj.put("htlx", convertOffer.getContractType());
|
|
|
|
|
mainDataObj.put("rylb", convertOffer.getEmploymentType());
|
|
|
|
|
mainDataObj.put("yglx", convertOffer.getEmploymentForm());
|
|
|
|
|
mainDataObj.put("ryly", convertOffer.getEmploymentSource());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 直接写入北森数据
|
|
|
|
|
@ -124,10 +139,11 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
mainDataObj.put("jjlxrdh", convertOffer.getEmergencyContactPhone());
|
|
|
|
|
mainDataObj.put("username", convertOffer.getName());
|
|
|
|
|
// TODO 待确认
|
|
|
|
|
mainDataObj.put("sex", convertOffer.getGender());
|
|
|
|
|
String gender = convertOffer.getGender();
|
|
|
|
|
mainDataObj.put("sex", "0".equals(gender) ? "male" : "1".equals(gender) ? "female" : null);
|
|
|
|
|
mainDataObj.put("mobile", convertOffer.getMobilePhone());
|
|
|
|
|
mainDataObj.put("id_no", convertOffer.getIDNumber());
|
|
|
|
|
mainDataObj.put("birthday", convertOffer.getBirthday());
|
|
|
|
|
mainDataObj.put("birthday", DateUtil.formatDate(convertOffer.getBirthday()));
|
|
|
|
|
mainDataObj.put("age", convertOffer.getAge());
|
|
|
|
|
mainDataObj.put("graduate_school", convertOffer.getLastSchool());
|
|
|
|
|
mainDataObj.put("sl", convertOffer.getWorkYearCompanyTotal());
|
|
|
|
|
@ -181,6 +197,9 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
String probation = convertOffer.getProbation();
|
|
|
|
|
mainDataObj.put("sfysyq", StringUtils.isBlank(probation) || "0".equals(probation) ? "1" : "0");
|
|
|
|
|
mainDataObj.put("yjsyjsrq", DateUtil.formatDate(convertOffer.getProbationStopDate()));
|
|
|
|
|
// 入职日期
|
|
|
|
|
mainDataObj.put("hiredate", DateUtil.formatDate(convertOffer.getEntryDate()));
|
|
|
|
|
mainDataObj.put("htksrq", DateUtil.formatDate(convertOffer.getEffectiveDate()));
|
|
|
|
|
/*
|
|
|
|
|
* 根据个人邮箱、证件号码、姓名判断,新入职人员,默认0:新增入职;
|
|
|
|
|
* 有入职信息,默认1:离职重聘
|
|
|
|
|
@ -189,7 +208,7 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
String sqrEmpId = getEmployeeIdByOId(baseParam, convertOffer.getCreatedBy());
|
|
|
|
|
mainDataObj.put("sqr", sqrEmpId);
|
|
|
|
|
// 根据人员获取HR系统部门ID写入
|
|
|
|
|
String deptIdByEmpId = getDeptIdByEmpId(baseParam, sqrEmpId);
|
|
|
|
|
String deptIdByEmpId = getDeptIdByEmpId(sqrEmpId);
|
|
|
|
|
mainDataObj.put("sqbm", deptIdByEmpId);
|
|
|
|
|
|
|
|
|
|
//mainDataObj.put("gj", "");
|
|
|
|
|
@ -211,8 +230,6 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
|
|
|
|
|
mainDataObj.put("first_work_date", DateUtil.formatDate(convertOffer.getWorkDate()));
|
|
|
|
|
|
|
|
|
|
// TODO mainDataObj.put("rylb", convertOffer.getEmploymentType());
|
|
|
|
|
|
|
|
|
|
String pOIdEmpReserve2 = getEmployeeIdByOId(baseParam, convertOffer.getPOIdEmpReserve2());
|
|
|
|
|
mainDataObj.put("other_superior", pOIdEmpReserve2);
|
|
|
|
|
|
|
|
|
|
@ -221,26 +238,20 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
mainDataObj.put("frgs", legalEntityCompany.getId());
|
|
|
|
|
}
|
|
|
|
|
mainDataObj.put("htzzrq", DateUtil.formatDate(convertOffer.getTerminateDate()));
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
|
|
List<Long> deptListByLevel = new ArrayList<>();
|
|
|
|
|
deptListByLevel.add(null);
|
|
|
|
|
deptListByLevel.add(null);
|
|
|
|
|
deptListByLevel.add(null);
|
|
|
|
|
deptListByLevel.add(null);
|
|
|
|
|
deptListByLevel.add(null);
|
|
|
|
|
deptListByLevel.add(null);
|
|
|
|
|
if (StringUtils.isNotBlank(deptIdByOId)) {
|
|
|
|
|
deptListByLevel.add(Long.parseLong(deptIdByOId));
|
|
|
|
|
List<Long> deptListByLevel1 = getDeptListByLevel(Long.parseLong(deptIdByOId));
|
|
|
|
|
deptListByLevel.addAll(0, deptListByLevel1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mainDataObj.put("yjbm", deptListByLevel.get(0));
|
|
|
|
|
mainDataObj.put("ejbm", deptListByLevel.get(1));
|
|
|
|
|
mainDataObj.put("sanbm", deptListByLevel.get(2));
|
|
|
|
|
mainDataObj.put("sijbm", deptListByLevel.get(3));
|
|
|
|
|
mainDataObj.put("wjbm", deptListByLevel.get(4));
|
|
|
|
|
mainDataObj.put("ljbm", deptListByLevel.get(5));
|
|
|
|
|
mainDataObj.put("yjbm", deptListByLevel.size() >= 1 ? deptListByLevel.get(deptListByLevel.size() - 1) : null);
|
|
|
|
|
mainDataObj.put("ejbm", deptListByLevel.size() >= 2 ? deptListByLevel.get(deptListByLevel.size() - 2) : null);
|
|
|
|
|
mainDataObj.put("sanbm", deptListByLevel.size() >= 3 ? deptListByLevel.get(deptListByLevel.size() - 3) : null);
|
|
|
|
|
mainDataObj.put("sijbm", deptListByLevel.size() >= 4 ? deptListByLevel.get(deptListByLevel.size() - 4) : null);
|
|
|
|
|
mainDataObj.put("wjbm", deptListByLevel.size() >= 5 ? deptListByLevel.get(deptListByLevel.size() - 5) : null);
|
|
|
|
|
mainDataObj.put("ljbm", deptListByLevel.size() >= 6 ? deptListByLevel.get(deptListByLevel.size() - 6) : null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO mainDataObj.put("employType", convertOffer.getEmployType());
|
|
|
|
|
@ -291,16 +302,11 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
String papiToken = PapiUtil.getPapiToken(ApplicationConfigConstant.APP_URL, ApplicationConfigConstant.ORGANIZATION_APP_KEY, ApplicationConfigConstant.ORGANIZATION_APP_SECRET, papiCode);
|
|
|
|
|
jsonObject.put("access_token", papiToken);
|
|
|
|
|
|
|
|
|
|
log.error("jsonObject===" + jsonObject);
|
|
|
|
|
log.error("jsonObject:{}", jsonObject.toJSONString());
|
|
|
|
|
|
|
|
|
|
return HttpRequest.post(ApplicationConfigConstant.APP_URL + "/papi/openapi/api/ebuilder/form/dataset/v2/saveFormData")
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.body(jsonObject.toJSONString())
|
|
|
|
|
.execute()
|
|
|
|
|
.body();
|
|
|
|
|
return HttpRequest.post(ApplicationConfigConstant.APP_URL + "/papi/openapi/api/ebuilder/form/dataset/v2/saveFormData").header("Content-Type", "application/json").body(jsonObject.toJSONString()).execute().body();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取北森系统offer数据
|
|
|
|
|
*
|
|
|
|
|
@ -328,11 +334,7 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
try {
|
|
|
|
|
String url = Constants.beishenHost + Constants.offerUrl;
|
|
|
|
|
|
|
|
|
|
String resultStr = HttpRequest.post(url)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.header("Authorization", "Bearer " + token)
|
|
|
|
|
.body(bodyJson.toJSONString())
|
|
|
|
|
.execute()
|
|
|
|
|
String resultStr = HttpRequest.post(url).header("Content-Type", "application/json").header("Authorization", "Bearer " + token).body(bodyJson.toJSONString()).execute()
|
|
|
|
|
//.charset("UTF-8") // 显式指定编码
|
|
|
|
|
.body();
|
|
|
|
|
// Bearer X4eTEiMr-1SzSRQHqY2MuRMnVgJbxp7kYKg3ZqTvwvYlD6CXfkfq-lGI_Rl3swX3E097-rkhE
|
|
|
|
|
@ -342,10 +344,7 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
JSONObject returnJson = JSONObject.parseObject(resultStr);
|
|
|
|
|
if ("200".equals(returnJson.getString("code"))) {
|
|
|
|
|
JSONArray dataArray = returnJson.getJSONArray("data");
|
|
|
|
|
List<BeiSenOffer> offerList = JSONArray.parseArray(
|
|
|
|
|
dataArray.toJSONString(),
|
|
|
|
|
BeiSenOffer.class
|
|
|
|
|
);
|
|
|
|
|
List<BeiSenOffer> offerList = JSONArray.parseArray(dataArray.toJSONString(), BeiSenOffer.class);
|
|
|
|
|
offerArray.addAll(offerList);
|
|
|
|
|
scrollId = returnJson.getString("scrollId");
|
|
|
|
|
hasMore = StringUtils.isNotBlank(scrollId) && dataArray.size() > 0;
|
|
|
|
|
@ -429,7 +428,6 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
log.error("tableName: " + tableName);
|
|
|
|
|
log.error("offerMapper is null: " + (offerMapper == null));
|
|
|
|
|
return offerMapper.convertBeiSenField(baseParam, tableName, fieldValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -499,15 +497,16 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
/**
|
|
|
|
|
* 根据员工id获取部门id
|
|
|
|
|
*
|
|
|
|
|
* @param baseParam
|
|
|
|
|
* @param empId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String getDeptIdByEmpId(BaseParam baseParam, String empId) {
|
|
|
|
|
public String getDeptIdByEmpId(String empId) {
|
|
|
|
|
if (StringUtils.isNotBlank(empId)) {
|
|
|
|
|
SimpleEmployee byId = hrmCommonEmployeeDao.getById(Long.parseLong(empId));
|
|
|
|
|
if (null != byId) {
|
|
|
|
|
return byId.getDepartmentId().toString();
|
|
|
|
|
HrmEmployeeComInfo hrmEmployeeInfo = comInfoCache.getCacheById(HrmEmployeeComInfo.class, Long.parseLong(empId));
|
|
|
|
|
// SimpleEmployee byId = hrmCommonEmployeeDao.getById(Long.parseLong(empId));
|
|
|
|
|
log.error("getDeptIdByEmpId:{}", JSON.toJSONString(hrmEmployeeInfo));
|
|
|
|
|
if (null != hrmEmployeeInfo) {
|
|
|
|
|
return String.valueOf(hrmEmployeeInfo.getDepartment());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
@ -521,13 +520,25 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String getDeptIdByOId(BaseParam baseParam, Long oId) {
|
|
|
|
|
Long deptId = offerMapper.getDepartmentIdByOId(baseParam, oId);
|
|
|
|
|
return deptId == null ? null : deptId.toString();
|
|
|
|
|
try {
|
|
|
|
|
Long deptId = offerMapper.getDepartmentIdByOId(baseParam, String.valueOf(oId));
|
|
|
|
|
|
|
|
|
|
String result = deptId == null ? null : deptId.toString();
|
|
|
|
|
return result;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("getDeptIdByOId:{}", e.getMessage());
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Long> getDeptListByLevel(Long deptId) {
|
|
|
|
|
return departMentService.getAllSuperDepIds(deptId);
|
|
|
|
|
List<Long> allSuperDepIds = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
allSuperDepIds = departMentService.getAllSuperDepIds(deptId);
|
|
|
|
|
return allSuperDepIds;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("getDeptListByLevel:{}", e.getMessage());
|
|
|
|
|
return allSuperDepIds;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|