diff --git a/src/com/engine/hzzx/entity/EmployeeTrans.java b/src/com/engine/hzzx/entity/EmployeeTrans.java index f303b89..aa21b6d 100644 --- a/src/com/engine/hzzx/entity/EmployeeTrans.java +++ b/src/com/engine/hzzx/entity/EmployeeTrans.java @@ -70,49 +70,18 @@ public class EmployeeTrans { switch (educationLevel) { case "1": // 本科 - educationLevelId = "7"; + educationLevelId = "1"; break; case "2": // 硕士研究生 - educationLevelId = "8"; - break; - case "3": - // 高中 - educationLevelId = "3"; - break; - case "4": - // 中技(中专/技校/职高) - educationLevelId = "4"; - break; - case "5": - // 大专 - educationLevelId = "6"; - break; - case "6": - // MBA - educationLevelId = "10"; + educationLevelId = "2"; break; case "7": // 博士研究生 - educationLevelId = "9"; - break; - case "8": - // 初中 - educationLevelId = "2"; - break; - case "9": - // 小学 - case "10": - // 保密 - case "130": - // MPA - educationLevelId = "1"; - break; - case "120": - // EMBA - educationLevelId = "11"; + educationLevelId = "3"; break; default: + educationLevelId = "4"; break; } return educationLevelId; diff --git a/src/weaver/interfaces/hzzx/cronjob/SyncBeiSenInfoJob.java b/src/weaver/interfaces/hzzx/cronjob/SyncBeiSenInfoJob.java index 3f8f6f0..fff0b1a 100644 --- a/src/weaver/interfaces/hzzx/cronjob/SyncBeiSenInfoJob.java +++ b/src/weaver/interfaces/hzzx/cronjob/SyncBeiSenInfoJob.java @@ -31,8 +31,8 @@ public class SyncBeiSenInfoJob extends BaseCronJob { private static final String APP_KEY = "EE7D602509E04A59AE5DEFF0841F6A1C"; private static final String APP_SECRET = "F5229D9D83BF45DEBFA1EF8DAC13C0339D0074419CFE45FA8BAC2A0B9D170798"; - private static final String EMPLOYEE_TABLE = "uf_sxszqbssjtz"; - private static final String INTERNSHIP_TABLE = "uf_ybygzqbssjtz"; + private static final String EMPLOYEE_TABLE = "uf_ybygzqbssjtz"; + private static final String INTERNSHIP_TABLE = "uf_sxszqbssjtz"; private static final String OPERATE_ID = "1"; @@ -41,31 +41,38 @@ public class SyncBeiSenInfoJob extends BaseCronJob { @Override public void execute() { - String accessToken = getToken(); - // 获取近两天的数据 - String startTime = DateUtil.getYesterday() + "T00:00:00"; - String stopTime = DateUtil.getCurrentDate() + "T23:59:59"; - int[] empStatus = {1}; - int[] employType = {0}; - int[] internshipType = {2}; - List employeeList = new ArrayList<>(); - getPendingEmployment(startTime, stopTime, empStatus, employType, accessToken, "", employeeList); - - if (CollectionUtils.isNotEmpty(employeeList)) { - // 遍历待入职信息,插入数据库 - for (Employee employee : employeeList) { - rs.writeLog("遍历待入职信息", employee.toString()); + try { + String accessToken = getToken(); + // 获取近两天的数据 + String startTime = DateUtil.getYesterday() + "T00:00:00"; + String stopTime = DateUtil.getCurrentDate() + "T23:59:59"; + // TODO 测试使用 + startTime = "2025-03-01T00:00:00"; + int[] empStatus = {1}; + int[] employType = {0}; + int[] internshipType = {2}; + List employeeList = new ArrayList<>(); + getPendingEmployment(startTime, stopTime, empStatus, employType, accessToken, "", employeeList); + if (CollectionUtils.isNotEmpty(employeeList)) { + // 遍历待入职信息,插入数据库 + for (Employee employee : employeeList) { + rs.writeLog("遍历待入职信息===" + employee.toString()); + insertEmployee(employee); + } } - } - List internshipList = new ArrayList<>(); - getPendingEmployment(startTime, stopTime, empStatus, internshipType, accessToken, "", internshipList); - if (CollectionUtils.isNotEmpty(internshipList)) { - // 遍历实习生信息,插入数据库 - for (Employee employee : internshipList) { - rs.writeLog("遍历实习生信息", employee.toString()); + List internshipList = new ArrayList<>(); + getPendingEmployment(startTime, stopTime, empStatus, internshipType, accessToken, "", internshipList); + if (CollectionUtils.isNotEmpty(internshipList)) { + // 遍历实习生信息,插入数据库 + for (Employee employee : internshipList) { + 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)) { json.put("scrollId", scrollId); } - rs.writeLog("GetByTimeWindow,入参", json.toString()); + rs.writeLog("GetByTimeWindow,入参===" + json.toString()); String response = HttpRequest.post(GET_EMPLOYMENT_URL) .header("Authorization", "Bearer " + accessToken) .body(json.toString()) .contentType("application/json") .execute() .body(); - rs.writeLog("GetByTimeWindow,返参", response); + rs.writeLog("GetByTimeWindow,返参===" + response); JSONObject jsonObject = JSONObject.parseObject(response); String code = jsonObject.getString("code"); @@ -107,7 +114,8 @@ public class SyncBeiSenInfoJob extends BaseCronJob { } scrollId = jsonObject.getString("scrollId"); JSONArray data = jsonObject.getJSONArray("data"); - if (data.size() == 0) { + if (data == null || data.size() == 0) { + rs.writeLog("GetByTimeWindow,无数据"); return ""; } @@ -115,7 +123,7 @@ public class SyncBeiSenInfoJob extends BaseCronJob { JSONObject dataObject = data.getJSONObject(i); JSONObject employeeInfo = dataObject.getJSONObject("employeeInfo"); JSONObject recordInfo = dataObject.getJSONObject("recordInfo"); - String oIdDepartment = recordInfo.getString("oIdDepartment"); + Long oIdDepartment = recordInfo.getLong("oIdDepartment"); String oIdJobPosition = recordInfo.getString("oIdJobPosition"); Department department = getDepartment(oIdDepartment, accessToken); Position position = getPosition(oIdJobPosition, accessToken); @@ -144,13 +152,13 @@ public class SyncBeiSenInfoJob extends BaseCronJob { json.put("grant_type", "client_credentials"); json.put("app_key", APP_KEY); json.put("app_secret", APP_SECRET); - rs.writeLog("获取token,入参", json.toString()); + rs.writeLog("获取token,入参===" + json); String response = HttpRequest.post(TOKEN_URL) .body(json.toString()) .contentType("application/json") .execute() .body(); - rs.writeLog("获取token,返参", response); + rs.writeLog("获取token,返参===" + response); JSONObject jsonObject = JSONObject.parseObject(response); String accessToken = jsonObject.getString("access_token"); @@ -168,17 +176,17 @@ public class SyncBeiSenInfoJob extends BaseCronJob { * @param accessToken * @return */ - private Department getDepartment(String oId, String accessToken) { + private Department getDepartment(Long oId, String accessToken) { JSONObject json = new JSONObject(); - json.put("oIds", new String[]{oId}); - rs.writeLog("GET_DEPARTMENT_URL,入参", json.toString()); + json.put("oIds", new Long[]{oId}); + rs.writeLog("GET_DEPARTMENT_URL,入参===" + json); String response = HttpRequest.post(GET_DEPARTMENT_URL) .header("Authorization", "Bearer " + accessToken) .body(json.toString()) .contentType("application/json") .execute() .body(); - rs.writeLog("GET_DEPARTMENT_URL,返参", response); + rs.writeLog("GET_DEPARTMENT_URL,返参===" + response); JSONObject jsonObject = JSONObject.parseObject(response); String code = jsonObject.getString("code"); @@ -208,14 +216,14 @@ public class SyncBeiSenInfoJob extends BaseCronJob { private Position getPosition(String oId, String accessToken) { JSONObject json = new JSONObject(); 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) .header("Authorization", "Bearer " + accessToken) .body(json.toString()) .contentType("application/json") .execute() .body(); - rs.writeLog("GET_POSITION_URL,返参", response); + rs.writeLog("GET_POSITION_URL,返参===" + response); JSONObject jsonObject = JSONObject.parseObject(response); String code = jsonObject.getString("code"); @@ -257,14 +265,20 @@ public class SyncBeiSenInfoJob extends BaseCronJob { } else { objectId = UUID.randomUUID().toString(); } + int formModeId = DataUtil.getModeIdByTableName(EMPLOYEE_TABLE); + // 构建插入数据 insertData.put("xm", employee.getName()); insertData.put("xb", Util.null2String(employee.getGender())); insertData.put("nl", String.valueOf(employee.getAge())); // 政治面貌 + rs.writeLog("政治面貌Status==" + employee.getPoliticalStatus()); String politicalStr = EmployeeTrans.getPoliticalStr(employee.getPoliticalStatus()); + rs.writeLog("政治面貌Str==" + 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()); @@ -290,7 +304,6 @@ public class SyncBeiSenInfoJob extends BaseCronJob { // 构建建模基本数据 insertData.put("modeuuid", objectId); - int formModeId = DataUtil.getModeIdByTableName(EMPLOYEE_TABLE); insertData.put("formmodeid", String.valueOf(formModeId)); DataUtil.buildModeInsertFields(insertData, OPERATE_ID); @@ -314,40 +327,41 @@ public class SyncBeiSenInfoJob extends BaseCronJob { } else { objectId = UUID.randomUUID().toString(); } + int formModeId = DataUtil.getModeIdByTableName(INTERNSHIP_TABLE); + // 构建插入数据 insertData.put("xm", employee.getName()); 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()); - if (StringUtils.isNotBlank(politicalStr)) { - insertData.put("zzmm", DataUtil.getSelectValue(INTERNSHIP_TABLE, "zzmm", politicalStr)); - } - // 部门 - String departmentId = EmployeeTrans.getDepartmentId(employee.getDepartmentCode()); - if (StringUtils.isNotBlank(departmentId)) { - insertData.put("ypbm", departmentId); - } - // 职位 + //String politicalStr = EmployeeTrans.getPoliticalStr(employee.getPoliticalStatus()); + //if (StringUtils.isNotBlank(politicalStr)) { + // insertData.put("zzmm", DataUtil.getSelectValue(formModeId, "zzmm", politicalStr)); + //} + //// 部门 + //String departmentId = EmployeeTrans.getDepartmentId(employee.getDepartmentCode()); + //if (StringUtils.isNotBlank(departmentId)) { + // insertData.put("ypbm", departmentId); + //} + // 岗位 String jobtitleId = EmployeeTrans.getJobtitleId(employee.getPositionCode()); if (StringUtils.isNotBlank(jobtitleId)) { - insertData.put("ypgw", jobtitleId); + insertData.put("gw", jobtitleId); } - // 学历 + // 目前学历 String educationLevelId = EmployeeTrans.getEducationLevelId(employee.getEducationLevel()); if (StringUtils.isNotBlank(educationLevelId)) { - insertData.put("xl", educationLevelId); + insertData.put("mqxl", educationLevelId); } - // 学校 - // TODO insertData.put("xx", employee.getLastSchool()); - // 专业 - insertData.put("zy", employee.getMajor()); + // 就读学校 + insertData.put("jdxx", employee.getLastSchool()); + // 就读专业 + insertData.put("jdzy", employee.getMajor()); // 工作年限 // 构建建模基本数据 insertData.put("modeuuid", objectId); - int formModeId = DataUtil.getModeIdByTableName(INTERNSHIP_TABLE); insertData.put("formmodeid", String.valueOf(formModeId)); DataUtil.buildModeInsertFields(insertData, OPERATE_ID);