代码合并-Lee

This commit is contained in:
dxfeng 2025-10-14 09:40:27 +08:00
parent 7188ba5a7f
commit b47a30c621
4 changed files with 63 additions and 57 deletions

View File

@ -71,8 +71,11 @@ public class BeiSenOffer {
private String pOIdEmpAdmin; private String pOIdEmpAdmin;
private String pOIdEmpReserve2; private String pOIdEmpReserve2;
private String employType; private String employType;
@FieldConversion(relatedTable = "uf_ryly")
private String employmentSource; private String employmentSource;
@FieldConversion(relatedTable = "uf_ygxs_bs")
private String employmentForm; private String employmentForm;
@FieldConversion(relatedTable = "uf_rylb")
private String employmentType; private String employmentType;
private LocalDateTime entryDate; private LocalDateTime entryDate;
private String oIdJobPosition; private String oIdJobPosition;

View File

@ -2,9 +2,12 @@ package com.weaver.seconddev.beisen.esb;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.weaver.common.base.entity.result.WeaResult; 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.common.hrm.dao.HrmCommonEmployeeDao;
import com.weaver.ebuilder.form.client.service.emobile.IEtFormDatasetService; import com.weaver.ebuilder.form.client.service.emobile.IEtFormDatasetService;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface; 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.mapper.portal.EbuilderBaseMapper;
import com.weaver.seconddev.portal.util.DateUtil; import com.weaver.seconddev.portal.util.DateUtil;
import com.weaver.seconddev.portal.util.PapiUtil; import com.weaver.seconddev.portal.util.PapiUtil;
import com.weaver.teams.domain.user.SimpleEmployee;
import com.weaver.workflow.common.cfg.org.service.DepartMentService; import com.weaver.workflow.common.cfg.org.service.DepartMentService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -44,23 +46,25 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
@Autowired @Autowired
Token2BeiSenUtil http2BenSenUtil; Token2BeiSenUtil http2BenSenUtil;
@Autowired
OfferMapper offerMapper;
@Autowired
private ComInfoCache comInfoCache;
@Autowired @Autowired
IEtFormDatasetService etFormDatasetService; IEtFormDatasetService etFormDatasetService;
@Autowired
OfferMapper offerMapper;
@Autowired @Autowired
HrmCommonEmployeeDao hrmCommonEmployeeDao; HrmCommonEmployeeDao hrmCommonEmployeeDao;
@Autowired @Autowired
DepartMentService departMentService; DepartMentService departMentService;
@Autowired @Autowired
EbuilderBaseMapper ebuilderBaseMapper; EbuilderBaseMapper ebuilderBaseMapper;
@Override @Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) { public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
//etFormDatasetService.deleteData( params) //etFormDatasetService.deleteData( params)
String startDate = String.valueOf(params.get("startDate")); String startDate = String.valueOf(params.get("startDate"));
@ -82,6 +86,7 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
BaseParam baseParam = new BaseParam(); BaseParam baseParam = new BaseParam();
JSONArray datas = new JSONArray(); JSONArray datas = new JSONArray();
log.error("beiSenOfferData:{}", JSONObject.toJSONString(beiSenOfferData));
// 遍历offer数据插入到EB表 // 遍历offer数据插入到EB表
for (BeiSenOffer offer : beiSenOfferData) { for (BeiSenOffer offer : beiSenOfferData) {
String objectId = offer.getObjectId(); String objectId = offer.getObjectId();
@ -108,12 +113,16 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
// 注解转换方式 // 注解转换方式
mainDataObj.put("location", convertOffer.getPlace()); // mainDataObj.put("location", convertOffer.getPlace());
mainDataObj.put("htgzdd", convertOffer.getPlace());
mainDataObj.put("marital_status", convertOffer.getMarryCategory()); mainDataObj.put("marital_status", convertOffer.getMarryCategory());
mainDataObj.put("nation", convertOffer.getNation()); mainDataObj.put("nation", convertOffer.getNation());
mainDataObj.put("householdtype", convertOffer.getDomicileType()); mainDataObj.put("householdtype", convertOffer.getDomicileType());
mainDataObj.put("education", convertOffer.getEducationLevel()); mainDataObj.put("education", convertOffer.getEducationLevel());
mainDataObj.put("htlx", convertOffer.getContractType()); mainDataObj.put("htlx", convertOffer.getContractType());
mainDataObj.put("rylb", convertOffer.getEmploymentType());
mainDataObj.put("yglx", convertOffer.getEmploymentForm());
mainDataObj.put("ryly", convertOffer.getEmploymentSource());
// 直接写入北森数据 // 直接写入北森数据
@ -124,10 +133,11 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
mainDataObj.put("jjlxrdh", convertOffer.getEmergencyContactPhone()); mainDataObj.put("jjlxrdh", convertOffer.getEmergencyContactPhone());
mainDataObj.put("username", convertOffer.getName()); mainDataObj.put("username", convertOffer.getName());
// TODO 待确认 // 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("mobile", convertOffer.getMobilePhone());
mainDataObj.put("id_no", convertOffer.getIDNumber()); 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("age", convertOffer.getAge());
mainDataObj.put("graduate_school", convertOffer.getLastSchool()); mainDataObj.put("graduate_school", convertOffer.getLastSchool());
mainDataObj.put("sl", convertOffer.getWorkYearCompanyTotal()); mainDataObj.put("sl", convertOffer.getWorkYearCompanyTotal());
@ -189,7 +199,7 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
String sqrEmpId = getEmployeeIdByOId(baseParam, convertOffer.getCreatedBy()); String sqrEmpId = getEmployeeIdByOId(baseParam, convertOffer.getCreatedBy());
mainDataObj.put("sqr", sqrEmpId); mainDataObj.put("sqr", sqrEmpId);
// 根据人员获取HR系统部门ID写入 // 根据人员获取HR系统部门ID写入
String deptIdByEmpId = getDeptIdByEmpId(baseParam, sqrEmpId); String deptIdByEmpId = getDeptIdByEmpId(sqrEmpId);
mainDataObj.put("sqbm", deptIdByEmpId); mainDataObj.put("sqbm", deptIdByEmpId);
//mainDataObj.put("gj", ""); //mainDataObj.put("gj", "");
@ -211,8 +221,6 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
mainDataObj.put("first_work_date", DateUtil.formatDate(convertOffer.getWorkDate())); mainDataObj.put("first_work_date", DateUtil.formatDate(convertOffer.getWorkDate()));
// TODO mainDataObj.put("rylb", convertOffer.getEmploymentType());
String pOIdEmpReserve2 = getEmployeeIdByOId(baseParam, convertOffer.getPOIdEmpReserve2()); String pOIdEmpReserve2 = getEmployeeIdByOId(baseParam, convertOffer.getPOIdEmpReserve2());
mainDataObj.put("other_superior", pOIdEmpReserve2); mainDataObj.put("other_superior", pOIdEmpReserve2);
@ -221,26 +229,20 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
mainDataObj.put("frgs", legalEntityCompany.getId()); mainDataObj.put("frgs", legalEntityCompany.getId());
} }
mainDataObj.put("htzzrq", DateUtil.formatDate(convertOffer.getTerminateDate())); mainDataObj.put("htzzrq", DateUtil.formatDate(convertOffer.getTerminateDate()));
// TODO
List<Long> deptListByLevel = new ArrayList<>(); 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)) { if (StringUtils.isNotBlank(deptIdByOId)) {
deptListByLevel.add(Long.parseLong(deptIdByOId));
List<Long> deptListByLevel1 = getDeptListByLevel(Long.parseLong(deptIdByOId)); List<Long> deptListByLevel1 = getDeptListByLevel(Long.parseLong(deptIdByOId));
deptListByLevel.addAll(0, deptListByLevel1); deptListByLevel.addAll(0, deptListByLevel1);
} }
mainDataObj.put("yjbm", deptListByLevel.get(0)); mainDataObj.put("yjbm", deptListByLevel.size() >= 1 ? deptListByLevel.get(deptListByLevel.size() - 1) : null);
mainDataObj.put("ejbm", deptListByLevel.get(1)); mainDataObj.put("ejbm", deptListByLevel.size() >= 2 ? deptListByLevel.get(deptListByLevel.size() - 2) : null);
mainDataObj.put("sanbm", deptListByLevel.get(2)); mainDataObj.put("sanbm", deptListByLevel.size() >= 3 ? deptListByLevel.get(deptListByLevel.size() - 3) : null);
mainDataObj.put("sijbm", deptListByLevel.get(3)); mainDataObj.put("sijbm", deptListByLevel.size() >= 4 ? deptListByLevel.get(deptListByLevel.size() - 4) : null);
mainDataObj.put("wjbm", deptListByLevel.get(4)); mainDataObj.put("wjbm", deptListByLevel.size() >= 5 ? deptListByLevel.get(deptListByLevel.size() - 5) : null);
mainDataObj.put("ljbm", deptListByLevel.get(5)); mainDataObj.put("ljbm", deptListByLevel.size() >= 6 ? deptListByLevel.get(deptListByLevel.size() - 6) : null);
// TODO mainDataObj.put("employType", convertOffer.getEmployType()); // TODO mainDataObj.put("employType", convertOffer.getEmployType());
@ -291,16 +293,11 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
String papiToken = PapiUtil.getPapiToken(ApplicationConfigConstant.APP_URL, ApplicationConfigConstant.ORGANIZATION_APP_KEY, ApplicationConfigConstant.ORGANIZATION_APP_SECRET, papiCode); String papiToken = PapiUtil.getPapiToken(ApplicationConfigConstant.APP_URL, ApplicationConfigConstant.ORGANIZATION_APP_KEY, ApplicationConfigConstant.ORGANIZATION_APP_SECRET, papiCode);
jsonObject.put("access_token", papiToken); 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") return HttpRequest.post(ApplicationConfigConstant.APP_URL + "/papi/openapi/api/ebuilder/form/dataset/v2/saveFormData").header("Content-Type", "application/json").body(jsonObject.toJSONString()).execute().body();
.header("Content-Type", "application/json")
.body(jsonObject.toJSONString())
.execute()
.body();
} }
/** /**
* 获取北森系统offer数据 * 获取北森系统offer数据
* *
@ -328,11 +325,7 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
try { try {
String url = Constants.beishenHost + Constants.offerUrl; String url = Constants.beishenHost + Constants.offerUrl;
String resultStr = HttpRequest.post(url) String resultStr = HttpRequest.post(url).header("Content-Type", "application/json").header("Authorization", "Bearer " + token).body(bodyJson.toJSONString()).execute()
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + token)
.body(bodyJson.toJSONString())
.execute()
//.charset("UTF-8") // 显式指定编码 //.charset("UTF-8") // 显式指定编码
.body(); .body();
// Bearer X4eTEiMr-1SzSRQHqY2MuRMnVgJbxp7kYKg3ZqTvwvYlD6CXfkfq-lGI_Rl3swX3E097-rkhE // Bearer X4eTEiMr-1SzSRQHqY2MuRMnVgJbxp7kYKg3ZqTvwvYlD6CXfkfq-lGI_Rl3swX3E097-rkhE
@ -342,10 +335,7 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
JSONObject returnJson = JSONObject.parseObject(resultStr); JSONObject returnJson = JSONObject.parseObject(resultStr);
if ("200".equals(returnJson.getString("code"))) { if ("200".equals(returnJson.getString("code"))) {
JSONArray dataArray = returnJson.getJSONArray("data"); JSONArray dataArray = returnJson.getJSONArray("data");
List<BeiSenOffer> offerList = JSONArray.parseArray( List<BeiSenOffer> offerList = JSONArray.parseArray(dataArray.toJSONString(), BeiSenOffer.class);
dataArray.toJSONString(),
BeiSenOffer.class
);
offerArray.addAll(offerList); offerArray.addAll(offerList);
scrollId = returnJson.getString("scrollId"); scrollId = returnJson.getString("scrollId");
hasMore = StringUtils.isNotBlank(scrollId) && dataArray.size() > 0; hasMore = StringUtils.isNotBlank(scrollId) && dataArray.size() > 0;
@ -429,7 +419,6 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
return null; return null;
} }
log.error("tableName: " + tableName); log.error("tableName: " + tableName);
log.error("offerMapper is null: " + (offerMapper == null));
return offerMapper.convertBeiSenField(baseParam, tableName, fieldValue); return offerMapper.convertBeiSenField(baseParam, tableName, fieldValue);
} }
@ -499,15 +488,16 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
/** /**
* 根据员工id获取部门id * 根据员工id获取部门id
* *
* @param baseParam
* @param empId * @param empId
* @return * @return
*/ */
public String getDeptIdByEmpId(BaseParam baseParam, String empId) { public String getDeptIdByEmpId(String empId) {
if (StringUtils.isNotBlank(empId)) { if (StringUtils.isNotBlank(empId)) {
SimpleEmployee byId = hrmCommonEmployeeDao.getById(Long.parseLong(empId)); HrmEmployeeComInfo hrmEmployeeInfo = comInfoCache.getCacheById(HrmEmployeeComInfo.class, Long.parseLong(empId));
if (null != byId) { // SimpleEmployee byId = hrmCommonEmployeeDao.getById(Long.parseLong(empId));
return byId.getDepartmentId().toString(); log.error("getDeptIdByEmpId:{}", JSON.toJSONString(hrmEmployeeInfo));
if (null != hrmEmployeeInfo) {
return String.valueOf(hrmEmployeeInfo.getDepartment());
} }
} }
return null; return null;
@ -521,13 +511,25 @@ public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
* @return * @return
*/ */
public String getDeptIdByOId(BaseParam baseParam, Long oId) { public String getDeptIdByOId(BaseParam baseParam, Long oId) {
Long deptId = offerMapper.getDepartmentIdByOId(baseParam, oId); try {
return deptId == null ? null : deptId.toString(); 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) { 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;
}
} }
} }

View File

@ -20,7 +20,7 @@ public interface OfferMapper {
Long getEmployeeIdByOId(@Param("param") BaseParam param,@Param("oId") Long oId); Long getEmployeeIdByOId(@Param("param") BaseParam param,@Param("oId") Long oId);
Long getDepartmentIdByOId(@Param("param") BaseParam param,@Param("oId") Long oId); Long getDepartmentIdByOId(@Param("param") BaseParam param,@Param("oId") String oId);
Long getOfferIdByObjectId(@Param("param") BaseParam param,@Param("objectId") String objectId); Long getOfferIdByObjectId(@Param("param") BaseParam param,@Param("objectId") String objectId);

View File

@ -17,9 +17,9 @@
<if test=" offer.name !='' and offer.name !=null"> <if test=" offer.name !='' and offer.name !=null">
and t1.username = #{offer.name} and t1.username = #{offer.name}
</if> </if>
<if test=" offer.iDNumber !='' and offer.iDNumber !=null"> <!-- <if test=" offer.iDNumber !='' and offer.iDNumber !=null">-->
and t1.id_no = #{offer.iDNumber} and t1.id_type = #{offer.iDType} <!-- and t1.id_no = #{offer.iDNumber} and t1.zjlx = #{offer.iDType}-->
</if> <!-- </if>-->
<if test="offer.iDNumber == null or offer.iDNumber == ''"> <if test="offer.iDNumber == null or offer.iDNumber == ''">
and t1.id_no is null and t1.id_no is null
</if> </if>
@ -34,7 +34,8 @@
</select> </select>
<select id="getDepartmentIdByOId" resultType="java.lang.Long"> <select id="getDepartmentIdByOId" resultType="java.lang.Long">
select t1.id from ${param.eteams}.${param.table_dept_cus} t1 select t2.id from ${param.eteams}.${param.table_dept_cus} t1
left join ${param.eteams}.department t2 on t2.formdata=t1.id
where t1.tenant_key = #{param.tenantKey} and t1.delete_type = 0 where t1.tenant_key = #{param.tenantKey} and t1.delete_type = 0
and t1.oid = #{oId} and t1.oid = #{oId}
</select> </select>