generated from dxfeng/secondev-chapanda-feishu
feat(beisen): 同步北森Offer数据到EB系统
- 新增BeiSenOffer实体类,用于接收北森系统Offer数据- 添加FieldConversion注解,用于字段值转换 - 实现OfferMapper接口,定义数据转换和查询方法 - 编写SyncBeiSenOfferCronJob服务类,处理Offer数据同步逻辑 - 创建OfferMapper.xml,定义SQL映射
This commit is contained in:
parent
87870622af
commit
b3c0d5f192
|
|
@ -0,0 +1,36 @@
|
|||
package com.weaver.seconddev.beisen.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2025/07/24
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface FieldConversion {
|
||||
/**
|
||||
* 关联的表名
|
||||
*
|
||||
* @return 表名
|
||||
*/
|
||||
String relatedTable();
|
||||
|
||||
/**
|
||||
* 默认值
|
||||
*
|
||||
* @return 默认值
|
||||
*/
|
||||
String defaultValue() default "";
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String remark() default "";
|
||||
}
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
package com.weaver.seconddev.beisen.entity;
|
||||
|
||||
import com.weaver.seconddev.beisen.annotation.FieldConversion;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2025/07/23
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class BeiSenOffer {
|
||||
|
||||
private String userID;
|
||||
private String approvalStatus;
|
||||
private LocalDateTime acceptTime;
|
||||
private LocalDateTime refuseTime;
|
||||
private String offerSender;
|
||||
private LocalDateTime offerSendTime;
|
||||
private String offerSendDate;
|
||||
private String remarks;
|
||||
private String hrDutyUserId;
|
||||
private String offerStatus;
|
||||
private String offerTemplate;
|
||||
private String copyEmailTo;
|
||||
private String offerSource;
|
||||
private Integer syncStatus;
|
||||
private String syncMsg;
|
||||
private String permissionBy;
|
||||
private String referrerUserID;
|
||||
private String blindCarbonCopy;
|
||||
private String reasonOfRefuseID;
|
||||
private String batchSendOfferResult;
|
||||
private String entryChangeType;
|
||||
private String sendOfferEmailTemplateType;
|
||||
|
||||
private String name;
|
||||
private Integer age;
|
||||
private String backupMail;
|
||||
private String emergencyContact;
|
||||
private String emergencyContactPhone;
|
||||
private String emergencyContactRelationship;
|
||||
private String iDNumber;
|
||||
private Integer iDType;
|
||||
private String lastSchool;
|
||||
private String lastSchoolCode;
|
||||
private String major;
|
||||
private String graduateDate;
|
||||
private String workYearCompanyTotal;
|
||||
private String workYearTotal;
|
||||
private String mobilePhone;
|
||||
private LocalDateTime birthday;
|
||||
private String birthplace;
|
||||
private String nationality;
|
||||
@FieldConversion(relatedTable = "uf_mzlx")
|
||||
private String nation;
|
||||
private String registAddress;
|
||||
@FieldConversion(relatedTable = "uf_zgxl_h")
|
||||
private String educationLevel;
|
||||
private LocalDateTime workDate;
|
||||
@FieldConversion(relatedTable = "uf_c_hklb")
|
||||
private String domicileType;
|
||||
@FieldConversion(relatedTable = "uf_hyzklx_m")
|
||||
private String marryCategory;
|
||||
private String gender;
|
||||
|
||||
private Long oIdDepartment;
|
||||
private String pOIdEmpAdmin;
|
||||
private String pOIdEmpReserve2;
|
||||
private String employType;
|
||||
private String employmentSource;
|
||||
private String employmentForm;
|
||||
private String employmentType;
|
||||
private LocalDateTime entryDate;
|
||||
private String oIdJobPosition;
|
||||
private String oIdJobLevel;
|
||||
private Long oIdOrganization;
|
||||
private String isCharge;
|
||||
private String oIdJobSequence;
|
||||
|
||||
@FieldConversion(relatedTable = "uf_dqlx_a")
|
||||
private String place;
|
||||
private String oIdJobPost;
|
||||
private String oidJobGrade;
|
||||
private String oIdProfessionalLine;
|
||||
private String probation;
|
||||
private LocalDateTime probationStopDate;
|
||||
private String firstParty;
|
||||
private String firstPartyCode;
|
||||
private String contactLength;
|
||||
private LocalDateTime terminateDate;
|
||||
private LocalDateTime signingDate;
|
||||
@FieldConversion(relatedTable = "uf_htlx")
|
||||
private String contractType;
|
||||
private String contractDueTimeType;
|
||||
private LocalDateTime effectiveDate;
|
||||
private String code;
|
||||
|
||||
private Long businessModifiedBy;
|
||||
private LocalDateTime businessModifiedTime;
|
||||
|
||||
private Double salaryAmount0;
|
||||
private Double salaryAmount2;
|
||||
private Double salaryAmount3;
|
||||
private Double salaryAmount4;
|
||||
private Double salaryAmount5;
|
||||
private Double salaryAmount6;
|
||||
private Double salaryAmount7;
|
||||
private Double salaryAmount8;
|
||||
private Double salaryAmount9;
|
||||
private Double salaryAmount10;
|
||||
private Double salaryAmount11;
|
||||
private Double salaryAmount12;
|
||||
private Double salaryAmount13;
|
||||
private Double salaryAmount14;
|
||||
private Double salaryAmount15;
|
||||
private Double salaryAmount16;
|
||||
private Double salaryAmount17;
|
||||
private Double salaryAmount18;
|
||||
private Double salaryAmount19;
|
||||
private Double salaryAmount20;
|
||||
|
||||
private Double basicSalaryBeforeFullTime;
|
||||
private Double basicSalaryAfterFullTime;
|
||||
private Double housingFundRadices;
|
||||
private Double socialSecurityRadices;
|
||||
private String salaryPackageID;
|
||||
|
||||
private String salaryLevels0;
|
||||
private String salaryRanks0;
|
||||
private String socialSecurityPlanCID;
|
||||
private String housingFundPlanCID;
|
||||
|
||||
private Double salaryAmount2BeforeFullTime;
|
||||
private Double salaryAmount2AfterFullTime;
|
||||
private Double salaryAmount3BeforeFullTime;
|
||||
private Double salaryAmount3AfterFullTime;
|
||||
private Double salaryAmount4BeforeFullTime;
|
||||
private Double salaryAmount4AfterFullTime;
|
||||
private Double salaryAmount5BeforeFullTime;
|
||||
private Double salaryAmount5AfterFullTime;
|
||||
private Double salaryAmount6BeforeFullTime;
|
||||
private Double salaryAmount6AfterFullTime;
|
||||
private Double salaryAmount7BeforeFullTime;
|
||||
private Double salaryAmount7AfterFullTime;
|
||||
private Double salaryAmount8BeforeFullTime;
|
||||
private Double salaryAmount8AfterFullTime;
|
||||
private Double salaryAmount9BeforeFullTime;
|
||||
private Double salaryAmount9AfterFullTime;
|
||||
private Double salaryAmount10BeforeFullTime;
|
||||
private Double salaryAmount10AfterFullTime;
|
||||
private Double salaryAmount11BeforeFullTime;
|
||||
private Double salaryAmount11AfterFullTime;
|
||||
private Double salaryAmount12BeforeFullTime;
|
||||
private Double salaryAmount12AfterFullTime;
|
||||
private Double salaryAmount13BeforeFullTime;
|
||||
private Double salaryAmount13AfterFullTime;
|
||||
private Double salaryAmount14BeforeFullTime;
|
||||
private Double salaryAmount14AfterFullTime;
|
||||
private Double salaryAmount15BeforeFullTime;
|
||||
private Double salaryAmount15AfterFullTime;
|
||||
private Double salaryAmount16BeforeFullTime;
|
||||
private Double salaryAmount16AfterFullTime;
|
||||
private Double salaryAmount17BeforeFullTime;
|
||||
private Double salaryAmount17AfterFullTime;
|
||||
private Double salaryAmount18BeforeFullTime;
|
||||
private Double salaryAmount18AfterFullTime;
|
||||
private Double salaryAmount19BeforeFullTime;
|
||||
private Double salaryAmount19AfterFullTime;
|
||||
private Double salaryAmount20BeforeFullTime;
|
||||
private Double salaryAmount20AfterFullTime;
|
||||
|
||||
private String currency;
|
||||
private String applicantId;
|
||||
private String applicantPosition;
|
||||
private String applicantPositionId;
|
||||
private String applyChannel;
|
||||
private LocalDateTime applyTime;
|
||||
private String applicantIdV6;
|
||||
private String applicantPositionIdV6;
|
||||
private String applyIdV6;
|
||||
private String recruitmentRequirement;
|
||||
private String requireDepartment;
|
||||
|
||||
private String objectId;
|
||||
private Map<String, String> customProperties;
|
||||
private Object translateProperties;
|
||||
private Object sysMartionProperties;
|
||||
|
||||
private Long createdBy;
|
||||
private LocalDateTime createdTime;
|
||||
private Long modifiedBy;
|
||||
private LocalDateTime modifiedTime;
|
||||
private Boolean stdIsDeleted;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.weaver.seconddev.beisen.entity;
|
||||
|
||||
public class FieldConversionInfo {
|
||||
private String relatedTable;
|
||||
private String defaultValue;
|
||||
|
||||
public FieldConversionInfo(String relatedTable, String defaultValue) {
|
||||
this.relatedTable = relatedTable;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public String getRelatedTable() {
|
||||
return relatedTable;
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,514 @@
|
|||
package com.weaver.seconddev.beisen.esb;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.hrm.dao.HrmCommonEmployeeDao;
|
||||
import com.weaver.ebuilder.form.client.service.emobile.IEtFormDatasetService;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.beisen.annotation.FieldConversion;
|
||||
import com.weaver.seconddev.beisen.entity.BeiSenOffer;
|
||||
import com.weaver.seconddev.beisen.entity.FieldConversionInfo;
|
||||
import com.weaver.seconddev.beisen.mapper.OfferMapper;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Token2BeiSenUtil;
|
||||
import com.weaver.seconddev.portal.entity.param.BaseParam;
|
||||
import com.weaver.seconddev.portal.mapper.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 constant.ApplicationConfigConstant;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2025/07/23
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("SyncBeiSenOfferCronJob")
|
||||
public class SyncBeiSenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
||||
@Autowired
|
||||
Token2BeiSenUtil http2BenSenUtil;
|
||||
|
||||
@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"));
|
||||
String startTime = String.valueOf(params.get("startTime"));
|
||||
String endDate = String.valueOf(params.get("endDate"));
|
||||
String endTime = String.valueOf(params.get("endTime"));
|
||||
// TODO 测试数据
|
||||
if (StringUtils.isBlank(startDate)) {
|
||||
startDate = "2025-06-01";
|
||||
}
|
||||
if (StringUtils.isBlank(startTime)) {
|
||||
startTime = "00:00:00";
|
||||
}
|
||||
//endDate = "2025-07-24";
|
||||
//endTime = "00:00:00";
|
||||
|
||||
String token = http2BenSenUtil.getToken();
|
||||
List<BeiSenOffer> beiSenOfferData = getBeiSenOfferData(token, startDate, startTime, endDate, endTime);
|
||||
|
||||
BaseParam baseParam = new BaseParam();
|
||||
JSONArray datas = new JSONArray();
|
||||
// 遍历offer数据,插入到EB表
|
||||
for (BeiSenOffer offer : beiSenOfferData) {
|
||||
String objectId = offer.getObjectId();
|
||||
// 判断是否已存在该数据 存在即跳过
|
||||
Long offerIdByObjectId = offerMapper.getOfferIdByObjectId(baseParam, objectId);
|
||||
if (offerIdByObjectId != null) {
|
||||
log.info("已存在该数据,跳过数据写入,objectId===" + objectId);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 转换字段值
|
||||
BeiSenOffer convertOffer = convertObjectFields(baseParam, offer);
|
||||
|
||||
|
||||
JSONObject mainDataObj = new JSONObject();
|
||||
mainDataObj.put("bsid", objectId);
|
||||
// 默认值
|
||||
mainDataObj.put("personnel_status_jcl", "1");
|
||||
mainDataObj.put("lrfs", "0");
|
||||
mainDataObj.put("rzzt", "0");
|
||||
mainDataObj.put("native_place", "中国");
|
||||
// TODO 待确认
|
||||
mainDataObj.put("zxjssl", "1");
|
||||
|
||||
|
||||
// 注解转换方式
|
||||
mainDataObj.put("location", 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("cor_offzt", convertOffer.getOfferStatus());
|
||||
mainDataObj.put("hjszd", convertOffer.getBirthplace());
|
||||
mainDataObj.put("zy", convertOffer.getMajor());
|
||||
mainDataObj.put("jjlxr", convertOffer.getEmergencyContact());
|
||||
mainDataObj.put("jjlxrdh", convertOffer.getEmergencyContactPhone());
|
||||
mainDataObj.put("username", convertOffer.getName());
|
||||
// TODO 待确认
|
||||
mainDataObj.put("sex", convertOffer.getGender());
|
||||
mainDataObj.put("mobile", convertOffer.getMobilePhone());
|
||||
mainDataObj.put("id_no", convertOffer.getIDNumber());
|
||||
mainDataObj.put("birthday", convertOffer.getBirthday());
|
||||
mainDataObj.put("age", convertOffer.getAge());
|
||||
mainDataObj.put("graduate_school", convertOffer.getLastSchool());
|
||||
mainDataObj.put("sl", convertOffer.getWorkYearCompanyTotal());
|
||||
mainDataObj.put("work_year", convertOffer.getWorkYearTotal());
|
||||
mainDataObj.put("zjlx", convertOffer.getIDType());
|
||||
mainDataObj.put("gryx", convertOffer.getBackupMail());
|
||||
mainDataObj.put("firstparty", convertOffer.getFirstParty());
|
||||
mainDataObj.put("qxlx", convertOffer.getContractDueTimeType());
|
||||
mainDataObj.put("htqxy", convertOffer.getContactLength());
|
||||
mainDataObj.put("lastSchoolCode", convertOffer.getLastSchoolCode());
|
||||
mainDataObj.put("sfbmfzr", convertOffer.getIsCharge());
|
||||
|
||||
|
||||
mainDataObj.put("gygx", convertOffer.getEmployType());
|
||||
// 薪酬数据
|
||||
mainDataObj.put("gjjjjjsh",convertOffer.getHousingFundRadices());
|
||||
mainDataObj.put("sbjjjsh",convertOffer.getSocialSecurityRadices());
|
||||
mainDataObj.put("xzba",convertOffer.getSalaryPackageID());
|
||||
mainDataObj.put("sbjjfan",convertOffer.getSocialSecurityPlanCID());
|
||||
mainDataObj.put("gjjjjfan",convertOffer.getHousingFundPlanCID());
|
||||
mainDataObj.put("zzqgwgzbz",convertOffer.getSalaryAmount2BeforeFullTime());
|
||||
mainDataObj.put("zzhgwgzbz",convertOffer.getSalaryAmount2AfterFullTime());
|
||||
mainDataObj.put("zzqjxgzbz",convertOffer.getSalaryAmount3BeforeFullTime());
|
||||
mainDataObj.put("zzhjxgzbz",convertOffer.getSalaryAmount3AfterFullTime());
|
||||
mainDataObj.put("zzqyjgzbz",convertOffer.getSalaryAmount4BeforeFullTime());
|
||||
mainDataObj.put("zzhyjgzbz",convertOffer.getSalaryAmount4AfterFullTime());
|
||||
mainDataObj.put("zzqzaqgzbtbz",convertOffer.getSalaryAmount5BeforeFullTime());
|
||||
mainDataObj.put("zzhnzaqgzbtbz",convertOffer.getSalaryAmount5AfterFullTime());
|
||||
mainDataObj.put("zzqgzbtbz",convertOffer.getSalaryAmount6BeforeFullTime());
|
||||
mainDataObj.put("zzhgzbtbz",convertOffer.getSalaryAmount6AfterFullTime());
|
||||
mainDataObj.put("qsfxrqi",convertOffer.getEffectiveDate());
|
||||
mainDataObj.put("bha",convertOffer.getCode());
|
||||
|
||||
|
||||
// 其他转换方式
|
||||
String probation = convertOffer.getProbation();
|
||||
mainDataObj.put("sfysyq", StringUtils.isBlank(probation) || "0".equals(probation) ? "1" : "0");
|
||||
mainDataObj.put("yjsyjsrq", DateUtil.formatDate(convertOffer.getProbationStopDate()));
|
||||
/*
|
||||
* 根据个人邮箱、证件号码、姓名判断,新入职人员,默认0:新增入职;
|
||||
* 有入职信息,默认1:离职重聘
|
||||
*/
|
||||
mainDataObj.put("rzlx", checkEntryType(baseParam, offer));
|
||||
String sqrEmpId = getEmployeeIdByOId(baseParam, convertOffer.getCreatedBy());
|
||||
mainDataObj.put("sqr", sqrEmpId);
|
||||
// 根据人员获取HR系统部门ID写入
|
||||
String deptIdByEmpId = getDeptIdByEmpId(baseParam, sqrEmpId);
|
||||
mainDataObj.put("sqbm", deptIdByEmpId);
|
||||
|
||||
//mainDataObj.put("gj", "");
|
||||
mainDataObj.put("sqsj", DateUtil.formatDateTime(convertOffer.getCreatedTime()));
|
||||
|
||||
|
||||
// TODO mainDataObj.put("jjlxrybrgx", convertOffer.getEmergencyContactRelationship());
|
||||
|
||||
// TODO mainDataObj.put("subcompany", convertOffer.getFirstParty());
|
||||
mainDataObj.put("personnel_status", "0".equals(probation) || StringUtils.isBlank(probation) ? "2" : "1");
|
||||
|
||||
String deptIdByOId = getDeptIdByOId(baseParam, convertOffer.getOIdDepartment());
|
||||
mainDataObj.put("department", deptIdByOId);
|
||||
|
||||
String pOIdEmpAdmin = getEmployeeIdByOId(baseParam, convertOffer.getPOIdEmpAdmin());
|
||||
mainDataObj.put("superior", pOIdEmpAdmin);
|
||||
|
||||
mainDataObj.put("graduate_date", Convert.toStr(convertOffer.getGraduateDate(), "").replace("/", "-"));
|
||||
|
||||
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);
|
||||
|
||||
// TODO mainDataObj.put("frgs", convertOffer.getFirstPartyCode());
|
||||
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)) {
|
||||
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));
|
||||
|
||||
|
||||
// TODO mainDataObj.put("employType", convertOffer.getEmployType());
|
||||
JSONObject dataObj = new JSONObject();
|
||||
dataObj.put("mainTable", mainDataObj);
|
||||
log.error("dataObj===" + dataObj);
|
||||
datas.add(dataObj);
|
||||
}
|
||||
Long objId = ebuilderBaseMapper.getObjIdByTableName(baseParam, "uf_jcl_rzgl");
|
||||
String userId = String.valueOf(params.get("userId"));
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
return WeaResult.fail("参数userId获取异常", true);
|
||||
}
|
||||
String insertMsg = insertEbTable(datas, String.valueOf(objId), userId);
|
||||
log.error("insertMsg===" + insertMsg);
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<>();
|
||||
actionMap.put("code", 200);
|
||||
actionMap.put("msg", "SyncBeiSenOfferCronJob");
|
||||
//actionMap.put("offer",offerArray);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 插入EB表数据
|
||||
*
|
||||
* @param datas
|
||||
* @return
|
||||
*/
|
||||
private String insertEbTable(JSONArray datas, String objId, String userId) {
|
||||
JSONObject dataJson = new JSONObject();
|
||||
JSONObject operationinfo = new JSONObject();
|
||||
operationinfo.put("fieldNoFindIgnore", "true");
|
||||
operationinfo.put("doAction", "false");
|
||||
JSONObject header = new JSONObject();
|
||||
header.put("objId", objId);
|
||||
|
||||
dataJson.put("datas", datas);
|
||||
dataJson.put("header", header);
|
||||
dataJson.put("operationinfo", operationinfo);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("datajson", dataJson);
|
||||
jsonObject.put("userid", userId);
|
||||
// 请求授权
|
||||
String papiCode = PapiUtil.getPapiCode(ApplicationConfigConstant.APP_URL, ApplicationConfigConstant.CORP_ID, "A1a");
|
||||
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);
|
||||
|
||||
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数据
|
||||
*
|
||||
* @param token
|
||||
* @param startDate
|
||||
* @param startTime
|
||||
* @param endDate
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
public static List<BeiSenOffer> getBeiSenOfferData(String token, String startDate, String startTime, String endDate, String endTime) {
|
||||
List<BeiSenOffer> offerArray = new ArrayList<>();
|
||||
String scrollId = "";
|
||||
boolean hasMore = true;
|
||||
|
||||
while (hasMore) {
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("startTime", startDate + "T" + startTime);
|
||||
bodyJson.put("stopTime", endDate + "T" + endTime);
|
||||
bodyJson.put("timeWindowQueryType", "1");
|
||||
if (StringUtils.isNotBlank(scrollId)) {
|
||||
bodyJson.put("scrollId", scrollId);
|
||||
}
|
||||
|
||||
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()
|
||||
//.charset("UTF-8") // 显式指定编码
|
||||
.body();
|
||||
// Bearer X4eTEiMr-1SzSRQHqY2MuRMnVgJbxp7kYKg3ZqTvwvYlD6CXfkfq-lGI_Rl3swX3E097-rkhE
|
||||
|
||||
if (StringUtils.isNotBlank(resultStr)) {
|
||||
try {
|
||||
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
|
||||
);
|
||||
offerArray.addAll(offerList);
|
||||
scrollId = returnJson.getString("scrollId");
|
||||
hasMore = StringUtils.isNotBlank(scrollId) && dataArray.size() > 0;
|
||||
} else {
|
||||
log.error("接口返回非200: " + resultStr);
|
||||
hasMore = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("解析 queryOfferByDateTime 响应失败: " + resultStr);
|
||||
hasMore = false;
|
||||
}
|
||||
} else {
|
||||
log.error("HTTP请求返回空响应");
|
||||
hasMore = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("HTTP请求异常: " + e.getMessage());
|
||||
hasMore = false;
|
||||
}
|
||||
}
|
||||
|
||||
return offerArray;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换对象中带有@FieldConversion注解的字段值
|
||||
*
|
||||
* @param baseParam 基础参数
|
||||
* @param obj 需要转换的对象
|
||||
* @return 转换后的对象
|
||||
*/
|
||||
public <T> T convertObjectFields(BaseParam baseParam, T obj) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Class<?> clazz = obj.getClass();
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
|
||||
for (Field field : fields) {
|
||||
// 检查字段是否有FieldConversion注解
|
||||
if (field.isAnnotationPresent(FieldConversion.class)) {
|
||||
FieldConversion annotation = field.getAnnotation(FieldConversion.class);
|
||||
String relatedTable = annotation.relatedTable();
|
||||
String defaultValue = annotation.defaultValue();
|
||||
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
Object fieldValue = field.get(obj);
|
||||
log.error("field: " + field);
|
||||
log.error("fieldValue: " + fieldValue);
|
||||
// 只处理String类型的字段
|
||||
if (fieldValue instanceof String) {
|
||||
String convertedValue = convertFieldValue(baseParam, relatedTable, (String) fieldValue, defaultValue);
|
||||
field.set(obj, convertedValue);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
// 处理访问异常
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表名和字段值进行转换
|
||||
*
|
||||
* @param tableName 关联的表名
|
||||
* @param fieldValue 字段值
|
||||
* @param defaultValue 默认值
|
||||
* @return 转换后的值
|
||||
*/
|
||||
private String convertFieldValue(BaseParam baseParam, String tableName, String fieldValue, String defaultValue) {
|
||||
if (StringUtils.isBlank(fieldValue)) {
|
||||
fieldValue = defaultValue;
|
||||
}
|
||||
if (StringUtils.isBlank(fieldValue)) {
|
||||
return null;
|
||||
}
|
||||
log.error("tableName: " + tableName);
|
||||
log.error("offerMapper is null: " + (offerMapper == null));
|
||||
return offerMapper.convertBeiSenField(baseParam, tableName, fieldValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段的注解信息
|
||||
*
|
||||
* @param obj 对象实例
|
||||
* @param fieldName 字段名
|
||||
* @return 注解信息
|
||||
*/
|
||||
public static FieldConversionInfo getFieldConversionInfo(Object obj, String fieldName) {
|
||||
if (obj == null || fieldName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Field field = obj.getClass().getDeclaredField(fieldName);
|
||||
if (field.isAnnotationPresent(FieldConversion.class)) {
|
||||
FieldConversion annotation = field.getAnnotation(FieldConversion.class);
|
||||
return new FieldConversionInfo(annotation.relatedTable(), annotation.defaultValue());
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据个人邮箱、证件号码、姓名判断,新入职人员,
|
||||
* 默认0:新增入职;
|
||||
* 有入职信息,默认1:离职重聘
|
||||
*
|
||||
* @param offer
|
||||
* @return
|
||||
*/
|
||||
public String checkEntryType(BaseParam baseParam, BeiSenOffer offer) {
|
||||
String entryType = "0";
|
||||
Integer entryCount = offerMapper.getEntryCount(baseParam, offer);
|
||||
if (entryCount > 0) {
|
||||
entryType = "1";
|
||||
}
|
||||
return entryType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据oId获取员工id
|
||||
*
|
||||
* @param baseParam
|
||||
* @param oId
|
||||
* @return
|
||||
*/
|
||||
public String getEmployeeIdByOId(BaseParam baseParam, Long oId) {
|
||||
Long employeeId = offerMapper.getEmployeeIdByOId(baseParam, oId);
|
||||
return employeeId == null ? null : employeeId.toString();
|
||||
}
|
||||
|
||||
public String getEmployeeIdByOId(BaseParam baseParam, String oId) {
|
||||
if (StringUtils.isNotBlank(oId)) {
|
||||
Long employeeId = offerMapper.getEmployeeIdByOId(baseParam, Long.parseLong(oId));
|
||||
return employeeId == null ? null : employeeId.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据员工id获取部门id
|
||||
*
|
||||
* @param baseParam
|
||||
* @param empId
|
||||
* @return
|
||||
*/
|
||||
public String getDeptIdByEmpId(BaseParam baseParam, String empId) {
|
||||
if (StringUtils.isNotBlank(empId)) {
|
||||
SimpleEmployee byId = hrmCommonEmployeeDao.getById(Long.parseLong(empId));
|
||||
if (null != byId) {
|
||||
return byId.getDepartmentId().toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据oId获取部门id
|
||||
*
|
||||
* @param baseParam
|
||||
* @param oId
|
||||
* @return
|
||||
*/
|
||||
public String getDeptIdByOId(BaseParam baseParam, Long oId) {
|
||||
Long deptId = offerMapper.getDepartmentIdByOId(baseParam, oId);
|
||||
return deptId == null ? null : deptId.toString();
|
||||
}
|
||||
|
||||
public List<Long> getDeptListByLevel(Long deptId) {
|
||||
return departMentService.getAllSuperDepIds(deptId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.weaver.seconddev.beisen.mapper;
|
||||
|
||||
import com.weaver.seconddev.beisen.entity.BeiSenOffer;
|
||||
import com.weaver.seconddev.portal.entity.param.BaseParam;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2025/07/24
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface OfferMapper {
|
||||
|
||||
String convertBeiSenField(@Param("param") BaseParam param, @Param("tableName") String tableName, @Param("value") String value);
|
||||
|
||||
Integer getEntryCount(@Param("param") BaseParam param,@Param("offer") BeiSenOffer offer);
|
||||
|
||||
Long getEmployeeIdByOId(@Param("param") BaseParam param,@Param("oId") Long oId);
|
||||
|
||||
Long getDepartmentIdByOId(@Param("param") BaseParam param,@Param("oId") Long oId);
|
||||
|
||||
Long getOfferIdByObjectId(@Param("param") BaseParam param,@Param("objectId") String objectId);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.weaver.seconddev.beisen.mapper.OfferMapper">
|
||||
|
||||
|
||||
<select id="convertBeiSenField" resultType="java.lang.String">
|
||||
select t1.jclid
|
||||
from ${param.e10_common}.${tableName} t1
|
||||
where t1.delete_type = 0 and t1.tenant_key = #{param.tenantKey}
|
||||
and t1.bsid = #{value}
|
||||
</select>
|
||||
|
||||
<select id="getEntryCount" resultType="java.lang.Integer">
|
||||
select count(t1.id)
|
||||
from ${param.e10_common}.uf_jcl_rzgl t1
|
||||
where t1.delete_type = 0 and t1.tenant_key = #{param.tenantKey}
|
||||
<if test=" offer.name !='' and offer.name !=null">
|
||||
and t1.username = #{offer.name}
|
||||
</if>
|
||||
<if test=" offer.iDNumber !='' and offer.iDNumber !=null">
|
||||
and t1.id_no = #{offer.iDNumber} and t1.id_type = #{offer.iDType}
|
||||
</if>
|
||||
<if test="offer.iDNumber == null or offer.iDNumber == ''">
|
||||
and t1.id_no is null
|
||||
</if>
|
||||
and t1.rzzt = 1
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getEmployeeIdByOId" resultType="java.lang.Long">
|
||||
select t1.glzzyg from ${param.e10_common}.uf_jcl_employee_information t1
|
||||
where t1.tenant_key = #{param.tenantKey} and t1.delete_type = 0
|
||||
and t1.oid = #{oId}
|
||||
</select>
|
||||
|
||||
<select id="getDepartmentIdByOId" resultType="java.lang.Long">
|
||||
select t1.id from ${param.eteams}.${param.table_dept_cus} t1
|
||||
where t1.tenant_key = #{param.tenantKey} and t1.delete_type = 0
|
||||
and t1.oid = #{oId}
|
||||
</select>
|
||||
<select id="getOfferIdByObjectId" resultType="java.lang.Long">
|
||||
select t1.id from ${param.e10_common}.uf_jcl_rzgl t1
|
||||
where t1.delete_type = 0 and t1.tenant_key = #{param.tenantKey}
|
||||
and t1.bsid = #{objectId}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue