北森接口代码调整 数据写入建模表 字段转换

This commit is contained in:
dxfeng 2025-03-20 09:21:47 +08:00
parent 26cc7d7fa4
commit 03742aa9e0
2 changed files with 74 additions and 91 deletions

View File

@ -70,49 +70,18 @@ public class EmployeeTrans {
switch (educationLevel) { switch (educationLevel) {
case "1": case "1":
// 本科 // 本科
educationLevelId = "7"; educationLevelId = "1";
break; break;
case "2": case "2":
// 硕士研究生 // 硕士研究生
educationLevelId = "8"; educationLevelId = "2";
break;
case "3":
// 高中
educationLevelId = "3";
break;
case "4":
// 中技中专/技校/职高
educationLevelId = "4";
break;
case "5":
// 大专
educationLevelId = "6";
break;
case "6":
// MBA
educationLevelId = "10";
break; break;
case "7": case "7":
// 博士研究生 // 博士研究生
educationLevelId = "9"; educationLevelId = "3";
break;
case "8":
// 初中
educationLevelId = "2";
break;
case "9":
// 小学
case "10":
// 保密
case "130":
// MPA
educationLevelId = "1";
break;
case "120":
// EMBA
educationLevelId = "11";
break; break;
default: default:
educationLevelId = "4";
break; break;
} }
return educationLevelId; return educationLevelId;

View File

@ -31,8 +31,8 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
private static final String APP_KEY = "EE7D602509E04A59AE5DEFF0841F6A1C"; private static final String APP_KEY = "EE7D602509E04A59AE5DEFF0841F6A1C";
private static final String APP_SECRET = "F5229D9D83BF45DEBFA1EF8DAC13C0339D0074419CFE45FA8BAC2A0B9D170798"; private static final String APP_SECRET = "F5229D9D83BF45DEBFA1EF8DAC13C0339D0074419CFE45FA8BAC2A0B9D170798";
private static final String EMPLOYEE_TABLE = "uf_sxszqbssjtz"; private static final String EMPLOYEE_TABLE = "uf_ybygzqbssjtz";
private static final String INTERNSHIP_TABLE = "uf_ybygzqbssjtz"; private static final String INTERNSHIP_TABLE = "uf_sxszqbssjtz";
private static final String OPERATE_ID = "1"; private static final String OPERATE_ID = "1";
@ -41,31 +41,38 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
@Override @Override
public void execute() { public void execute() {
String accessToken = getToken(); try {
// 获取近两天的数据 String accessToken = getToken();
String startTime = DateUtil.getYesterday() + "T00:00:00"; // 获取近两天的数据
String stopTime = DateUtil.getCurrentDate() + "T23:59:59"; String startTime = DateUtil.getYesterday() + "T00:00:00";
int[] empStatus = {1}; String stopTime = DateUtil.getCurrentDate() + "T23:59:59";
int[] employType = {0}; // TODO 测试使用
int[] internshipType = {2}; startTime = "2025-03-01T00:00:00";
List<Employee> employeeList = new ArrayList<>(); int[] empStatus = {1};
getPendingEmployment(startTime, stopTime, empStatus, employType, accessToken, "", employeeList); int[] employType = {0};
int[] internshipType = {2};
if (CollectionUtils.isNotEmpty(employeeList)) { List<Employee> employeeList = new ArrayList<>();
// 遍历待入职信息插入数据库 getPendingEmployment(startTime, stopTime, empStatus, employType, accessToken, "", employeeList);
for (Employee employee : employeeList) {
rs.writeLog("遍历待入职信息", employee.toString());
if (CollectionUtils.isNotEmpty(employeeList)) {
// 遍历待入职信息插入数据库
for (Employee employee : employeeList) {
rs.writeLog("遍历待入职信息===" + employee.toString());
insertEmployee(employee);
}
} }
}
List<Employee> internshipList = new ArrayList<>(); List<Employee> internshipList = new ArrayList<>();
getPendingEmployment(startTime, stopTime, empStatus, internshipType, accessToken, "", internshipList); getPendingEmployment(startTime, stopTime, empStatus, internshipType, accessToken, "", internshipList);
if (CollectionUtils.isNotEmpty(internshipList)) { if (CollectionUtils.isNotEmpty(internshipList)) {
// 遍历实习生信息插入数据库 // 遍历实习生信息插入数据库
for (Employee employee : internshipList) { for (Employee employee : internshipList) {
rs.writeLog("遍历实习生信息", employee.toString()); rs.writeLog("遍历实习生信息===" + employee.toString());
insertInternshipEmployee(employee);
}
} }
} catch (Exception e) {
rs.writeLog("同步失败", e.getMessage());
} }
@ -91,14 +98,14 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
if (StringUtils.isNotBlank(scrollId)) { if (StringUtils.isNotBlank(scrollId)) {
json.put("scrollId", scrollId); json.put("scrollId", scrollId);
} }
rs.writeLog("GetByTimeWindow,入参", json.toString()); rs.writeLog("GetByTimeWindow,入参===" + json.toString());
String response = HttpRequest.post(GET_EMPLOYMENT_URL) String response = HttpRequest.post(GET_EMPLOYMENT_URL)
.header("Authorization", "Bearer " + accessToken) .header("Authorization", "Bearer " + accessToken)
.body(json.toString()) .body(json.toString())
.contentType("application/json") .contentType("application/json")
.execute() .execute()
.body(); .body();
rs.writeLog("GetByTimeWindow,返参", response); rs.writeLog("GetByTimeWindow,返参===" + response);
JSONObject jsonObject = JSONObject.parseObject(response); JSONObject jsonObject = JSONObject.parseObject(response);
String code = jsonObject.getString("code"); String code = jsonObject.getString("code");
@ -107,7 +114,8 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
} }
scrollId = jsonObject.getString("scrollId"); scrollId = jsonObject.getString("scrollId");
JSONArray data = jsonObject.getJSONArray("data"); JSONArray data = jsonObject.getJSONArray("data");
if (data.size() == 0) { if (data == null || data.size() == 0) {
rs.writeLog("GetByTimeWindow,无数据");
return ""; return "";
} }
@ -115,7 +123,7 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
JSONObject dataObject = data.getJSONObject(i); JSONObject dataObject = data.getJSONObject(i);
JSONObject employeeInfo = dataObject.getJSONObject("employeeInfo"); JSONObject employeeInfo = dataObject.getJSONObject("employeeInfo");
JSONObject recordInfo = dataObject.getJSONObject("recordInfo"); JSONObject recordInfo = dataObject.getJSONObject("recordInfo");
String oIdDepartment = recordInfo.getString("oIdDepartment"); Long oIdDepartment = recordInfo.getLong("oIdDepartment");
String oIdJobPosition = recordInfo.getString("oIdJobPosition"); String oIdJobPosition = recordInfo.getString("oIdJobPosition");
Department department = getDepartment(oIdDepartment, accessToken); Department department = getDepartment(oIdDepartment, accessToken);
Position position = getPosition(oIdJobPosition, accessToken); Position position = getPosition(oIdJobPosition, accessToken);
@ -144,13 +152,13 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
json.put("grant_type", "client_credentials"); json.put("grant_type", "client_credentials");
json.put("app_key", APP_KEY); json.put("app_key", APP_KEY);
json.put("app_secret", APP_SECRET); json.put("app_secret", APP_SECRET);
rs.writeLog("获取token,入参", json.toString()); rs.writeLog("获取token,入参===" + json);
String response = HttpRequest.post(TOKEN_URL) String response = HttpRequest.post(TOKEN_URL)
.body(json.toString()) .body(json.toString())
.contentType("application/json") .contentType("application/json")
.execute() .execute()
.body(); .body();
rs.writeLog("获取token,返参", response); rs.writeLog("获取token,返参===" + response);
JSONObject jsonObject = JSONObject.parseObject(response); JSONObject jsonObject = JSONObject.parseObject(response);
String accessToken = jsonObject.getString("access_token"); String accessToken = jsonObject.getString("access_token");
@ -168,17 +176,17 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
* @param accessToken * @param accessToken
* @return * @return
*/ */
private Department getDepartment(String oId, String accessToken) { private Department getDepartment(Long oId, String accessToken) {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("oIds", new String[]{oId}); json.put("oIds", new Long[]{oId});
rs.writeLog("GET_DEPARTMENT_URL,入参", json.toString()); rs.writeLog("GET_DEPARTMENT_URL,入参===" + json);
String response = HttpRequest.post(GET_DEPARTMENT_URL) String response = HttpRequest.post(GET_DEPARTMENT_URL)
.header("Authorization", "Bearer " + accessToken) .header("Authorization", "Bearer " + accessToken)
.body(json.toString()) .body(json.toString())
.contentType("application/json") .contentType("application/json")
.execute() .execute()
.body(); .body();
rs.writeLog("GET_DEPARTMENT_URL,返参", response); rs.writeLog("GET_DEPARTMENT_URL,返参===" + response);
JSONObject jsonObject = JSONObject.parseObject(response); JSONObject jsonObject = JSONObject.parseObject(response);
String code = jsonObject.getString("code"); String code = jsonObject.getString("code");
@ -208,14 +216,14 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
private Position getPosition(String oId, String accessToken) { private Position getPosition(String oId, String accessToken) {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("oIds", new String[]{oId}); json.put("oIds", new String[]{oId});
rs.writeLog("GET_POSITION_URL,入参", json.toString()); rs.writeLog("GET_POSITION_URL,入参===" + json);
String response = HttpRequest.post(GET_POSITION_URL) String response = HttpRequest.post(GET_POSITION_URL)
.header("Authorization", "Bearer " + accessToken) .header("Authorization", "Bearer " + accessToken)
.body(json.toString()) .body(json.toString())
.contentType("application/json") .contentType("application/json")
.execute() .execute()
.body(); .body();
rs.writeLog("GET_POSITION_URL,返参", response); rs.writeLog("GET_POSITION_URL,返参===" + response);
JSONObject jsonObject = JSONObject.parseObject(response); JSONObject jsonObject = JSONObject.parseObject(response);
String code = jsonObject.getString("code"); String code = jsonObject.getString("code");
@ -257,14 +265,20 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
} else { } else {
objectId = UUID.randomUUID().toString(); objectId = UUID.randomUUID().toString();
} }
int formModeId = DataUtil.getModeIdByTableName(EMPLOYEE_TABLE);
// 构建插入数据 // 构建插入数据
insertData.put("xm", employee.getName()); insertData.put("xm", employee.getName());
insertData.put("xb", Util.null2String(employee.getGender())); insertData.put("xb", Util.null2String(employee.getGender()));
insertData.put("nl", String.valueOf(employee.getAge())); insertData.put("nl", String.valueOf(employee.getAge()));
// 政治面貌 // 政治面貌
rs.writeLog("政治面貌Status==" + employee.getPoliticalStatus());
String politicalStr = EmployeeTrans.getPoliticalStr(employee.getPoliticalStatus()); String politicalStr = EmployeeTrans.getPoliticalStr(employee.getPoliticalStatus());
rs.writeLog("政治面貌Str==" + politicalStr);
if (StringUtils.isNotBlank(politicalStr)) { if (StringUtils.isNotBlank(politicalStr)) {
insertData.put("zzmm", DataUtil.getSelectValue(EMPLOYEE_TABLE, "zzmm", politicalStr)); String zzmm = DataUtil.getSelectValue(String.valueOf(formModeId), "zzmm", politicalStr);
rs.writeLog("政治面貌Id==" + zzmm);
insertData.put("zzmm", zzmm);
} }
// 部门 // 部门
String departmentId = EmployeeTrans.getDepartmentId(employee.getDepartmentCode()); String departmentId = EmployeeTrans.getDepartmentId(employee.getDepartmentCode());
@ -290,7 +304,6 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
// 构建建模基本数据 // 构建建模基本数据
insertData.put("modeuuid", objectId); insertData.put("modeuuid", objectId);
int formModeId = DataUtil.getModeIdByTableName(EMPLOYEE_TABLE);
insertData.put("formmodeid", String.valueOf(formModeId)); insertData.put("formmodeid", String.valueOf(formModeId));
DataUtil.buildModeInsertFields(insertData, OPERATE_ID); DataUtil.buildModeInsertFields(insertData, OPERATE_ID);
@ -314,40 +327,41 @@ public class SyncBeiSenInfoJob extends BaseCronJob {
} else { } else {
objectId = UUID.randomUUID().toString(); objectId = UUID.randomUUID().toString();
} }
int formModeId = DataUtil.getModeIdByTableName(INTERNSHIP_TABLE);
// 构建插入数据 // 构建插入数据
insertData.put("xm", employee.getName()); insertData.put("xm", employee.getName());
insertData.put("xb", Util.null2String(employee.getGender())); insertData.put("xb", Util.null2String(employee.getGender()));
insertData.put("nl", String.valueOf(employee.getAge())); // insertData.put("nl", String.valueOf(employee.getAge()));
// 政治面貌 // 政治面貌
String politicalStr = EmployeeTrans.getPoliticalStr(employee.getPoliticalStatus()); //String politicalStr = EmployeeTrans.getPoliticalStr(employee.getPoliticalStatus());
if (StringUtils.isNotBlank(politicalStr)) { //if (StringUtils.isNotBlank(politicalStr)) {
insertData.put("zzmm", DataUtil.getSelectValue(INTERNSHIP_TABLE, "zzmm", politicalStr)); // insertData.put("zzmm", DataUtil.getSelectValue(formModeId, "zzmm", politicalStr));
} //}
// 部门 //// 部门
String departmentId = EmployeeTrans.getDepartmentId(employee.getDepartmentCode()); //String departmentId = EmployeeTrans.getDepartmentId(employee.getDepartmentCode());
if (StringUtils.isNotBlank(departmentId)) { //if (StringUtils.isNotBlank(departmentId)) {
insertData.put("ypbm", departmentId); // insertData.put("ypbm", departmentId);
} //}
// //
String jobtitleId = EmployeeTrans.getJobtitleId(employee.getPositionCode()); String jobtitleId = EmployeeTrans.getJobtitleId(employee.getPositionCode());
if (StringUtils.isNotBlank(jobtitleId)) { if (StringUtils.isNotBlank(jobtitleId)) {
insertData.put("ypgw", jobtitleId); insertData.put("gw", jobtitleId);
} }
// 学历 // 目前学历
String educationLevelId = EmployeeTrans.getEducationLevelId(employee.getEducationLevel()); String educationLevelId = EmployeeTrans.getEducationLevelId(employee.getEducationLevel());
if (StringUtils.isNotBlank(educationLevelId)) { if (StringUtils.isNotBlank(educationLevelId)) {
insertData.put("xl", educationLevelId); insertData.put("mqxl", educationLevelId);
} }
// 学校 // 就读学校
// TODO insertData.put("xx", employee.getLastSchool()); insertData.put("jdxx", employee.getLastSchool());
// 专业 // 就读专业
insertData.put("zy", employee.getMajor()); insertData.put("jdzy", employee.getMajor());
// 工作年限 // 工作年限
// 构建建模基本数据 // 构建建模基本数据
insertData.put("modeuuid", objectId); insertData.put("modeuuid", objectId);
int formModeId = DataUtil.getModeIdByTableName(INTERNSHIP_TABLE);
insertData.put("formmodeid", String.valueOf(formModeId)); insertData.put("formmodeid", String.valueOf(formModeId));
DataUtil.buildModeInsertFields(insertData, OPERATE_ID); DataUtil.buildModeInsertFields(insertData, OPERATE_ID);