明细表+映射表 数据同步优化

This commit is contained in:
Administrator 2025-04-23 15:36:23 +08:00
parent 36c0369e9a
commit c8fcd8bd73
2 changed files with 105 additions and 47 deletions

View File

@ -116,7 +116,7 @@ public class SyncAllOrgPersonInfo implements EsbServerlessRpcRemoteInterface {
/**
* 映射表数据
*/
Map<String, String> mapping = getMapping();
Map<String, Object> mapping = getMapping();
log.error("SyncOrganizationPersonInfo.mapping:{}", mapping);
for (Map<String, Object> employee_info : employee_infos) {
String ygxxid = employee_info.get("id")!=null?String.valueOf(employee_info.get("id").toString()):"";
@ -143,8 +143,8 @@ public class SyncAllOrgPersonInfo implements EsbServerlessRpcRemoteInterface {
employee_new.put(key,getIgnoreCase(employee_info, key));
}
//补充映射表字段
if(mapping.containsKey(key)){
employee_new.put(mapping.get(key),getIgnoreCase(employee_info, key));
if (containsKeyIgnoreCase(mapping,key)) {
employee_new.put(key,getIgnoreCase(employee_info, String.valueOf(mapping.get(key))));
}
}
}
@ -191,8 +191,13 @@ public class SyncAllOrgPersonInfo implements EsbServerlessRpcRemoteInterface {
userInfo_new.put(key,getIgnoreCase(employee_info, key));
}
//补充映射表字段
if(mapping.containsKey(key)){
userInfo_new.put(mapping.get(key),getIgnoreCase(employee_info, key));
if (containsKeyIgnoreCase(mapping,key)) {
userInfo_new.put(key,getIgnoreCase(employee_info, String.valueOf(mapping.get(key))));
}
//籍贯字段处理
if(key.equalsIgnoreCase("native_place")){
log.error("SyncOrganizationPersonInfo.native_place333:{}", key);
userInfo_new.put(key,getNativePlaceName(getIgnoreCase(employee_info, key)));
}
}
}
@ -227,7 +232,42 @@ public class SyncAllOrgPersonInfo implements EsbServerlessRpcRemoteInterface {
rs.put("flowV3",result);
return WeaResult.success(rs);
}
/**
* 根据籍贯id获取系统城市表中的中文名称
* @return
*/
public String getNativePlaceName(String native_place){
String name = "";
if(StringUtils.isNotBlank(native_place)){
log.info("getNativePlaceName-native_place{}",native_place);
String sql = "select name from eteams.administrative_area where id in ( "+native_place+")";
log.info("getNativePlaceName-sql{}",sql);
List<Map<String, Object>> recordList = databaseUtils.getSqlList(sql);
List<String> listOfNativeName = recordList.stream()
.map(map -> map.get("name").toString())
.collect(Collectors.toList());
name = joinStringsWithSlash(listOfNativeName);
log.info("getNativePlaceName-name{}",name);
}
return name;
}
public static String joinStringsWithSlash(List<String> list) {
if (list == null || list.isEmpty()) {
return "";
}
StringBuilder joined = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
if (i > 0) {
joined.append("/");
}
joined.append(list.get(i));
}
return joined.toString();
}
/**
* 更新所有员工信息明细表
@ -436,10 +476,10 @@ public class SyncAllOrgPersonInfo implements EsbServerlessRpcRemoteInterface {
* 获得key名映射
* @return
*/
public Map<String,String> getMapping(){
public Map<String,Object> getMapping(){
String sql = "select ygxxzdkey,rlxtzdkey from uf_jcl_zdtbysb";
List<Map<String, Object>> recordList = databaseUtils.getSqlList(sql);
Map<String, String> resultMap = recordList.stream().collect(Collectors.toMap(e->e.get("ygxxzdkey").toString(),e -> e.get("rlxtzdkey").toString()));
Map<String, Object> resultMap = recordList.stream().collect(Collectors.toMap(e->e.get("rlxtzdkey").toString(),e -> e.get("ygxxzdkey").toString()));
return resultMap;
}
@ -507,14 +547,20 @@ public class SyncAllOrgPersonInfo implements EsbServerlessRpcRemoteInterface {
String createDate ="";
String updateDate ="";
if(StringUtils.isNotBlank(getIgnoreCase(employee_info, "create_time"))){
create_time = Long.valueOf(getIgnoreCase(employee_info, "create_time"));
Date date = new Date(create_time);
createDate = sdf.format(date);
String time = getIgnoreCase(employee_info, "create_time");
if(!time.contains("-")){
create_time = Long.parseLong(time);
Date date = new Date(create_time);
createDate = sdf.format(date);
}
}
if(StringUtils.isNotBlank(getIgnoreCase(employee_info, "update_time"))){
update_time = Long.valueOf(getIgnoreCase(employee_info, "update_time"));
Date date = new Date(update_time);
updateDate = sdf.format(date);
String time = getIgnoreCase(employee_info, "update_time");
if(!time.contains("-")){
update_time = Long.parseLong(time);
Date date = new Date(update_time);
updateDate = sdf.format(date);
}
}
employee_info.put("create_time",createDate);
employee_info.put("update_time",updateDate);

View File

@ -120,7 +120,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
/**
* 映射表数据
*/
Map<String, String> mapping = getMapping();
Map<String, Object> mapping = getMapping();
log.error("SyncOrganizationPersonInfo.mapping:{}", mapping);
//判断是否为空新增or更新
if(StringUtils.isBlank(glzzyg)){
@ -130,6 +130,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
List<String> listOfEmployee = employeeColumns.stream()
.map(map -> map.get("column_name").toString())
.collect(Collectors.toList());
log.error("SyncOrganizationPersonInfo.listOfEmployee:{}", listOfEmployee);
// 遍历并移除(不包含则移除掉)
Map<String, Object> employee_new = new HashMap<>();
for (String key : listOfEmployee) {
@ -140,8 +141,9 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
employee_new.put(key,getIgnoreCase(employee_info, key));
}
//补充映射表字段
if(mapping.containsKey(key)){
employee_new.put(mapping.get(key),getIgnoreCase(employee_info, key));
if (containsKeyIgnoreCase(mapping,key)) {
log.error("SyncOrganizationPersonInfo.mapping.containsKey:{}", key);
employee_new.put(key,getIgnoreCase(employee_info, String.valueOf(mapping.get(key))));
}
}
}
@ -181,6 +183,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
.collect(Collectors.toList());
// 遍历并移除(不包含则移除掉)
Map<String, Object> userInfo_new = new HashMap<>();
log.error("SyncOrganizationPersonInfo.listOfUserInfoColumns:{}", listOfUserInfoColumns);
for (String key : listOfUserInfoColumns) {
if (containsKeyIgnoreCase(employee_info,key)) {
if("delete_type".equalsIgnoreCase(key)||"IS_DELETE".equalsIgnoreCase(key)){
@ -189,12 +192,14 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
userInfo_new.put(key,getIgnoreCase(employee_info, key));
}
//补充映射表字段
if(mapping.containsKey(key)){
userInfo_new.put(mapping.get(key),getIgnoreCase(employee_info, key));
if (containsKeyIgnoreCase(mapping,key)) {
log.error("SyncOrganizationPersonInfo.mapping_key:{}", key);
userInfo_new.put(key,getIgnoreCase(employee_info, String.valueOf(mapping.get(key))));
}
//籍贯字段处理
if(key.equalsIgnoreCase("native_place")){
userInfo_new.put(key,getNativePlaceName(key));
log.error("SyncOrganizationPersonInfo.native_place:{}", key);
userInfo_new.put(key,getNativePlaceName(getIgnoreCase(employee_info, key)));
}
}
}
@ -244,8 +249,8 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
employee_new.put(key,getIgnoreCase(employee_info, key));
}
//补充映射表字段
if(mapping.containsKey(key)){
employee_new.put(mapping.get(key),getIgnoreCase(employee_info, key));
if (containsKeyIgnoreCase(mapping,key)) {
employee_new.put(key,getIgnoreCase(employee_info, String.valueOf(mapping.get(key))));
}
}
}
@ -289,8 +294,14 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
userInfo_new.put(key,getIgnoreCase(employee_info, key));
}
//补充映射表字段
if(mapping.containsKey(key)){
userInfo_new.put(mapping.get(key),getIgnoreCase(employee_info, key));
if (containsKeyIgnoreCase(mapping,key)) {
log.error("SyncOrganizationPersonInfo.mapping_key222:{}", key);
userInfo_new.put(key,getIgnoreCase(employee_info, String.valueOf(mapping.get(key))));
}
//籍贯字段处理
if(key.equalsIgnoreCase("native_place")){
log.error("SyncOrganizationPersonInfo.native_place2222:{}", key);
userInfo_new.put(key,getNativePlaceName(getIgnoreCase(employee_info, key)));
}
}
}
@ -358,8 +369,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
}
}
gzllInfo_new.put("USER_ID",ygxxid);
gzllInfo_new.put("CREATE_TIME",nowData);
gzllInfo_new.put("update_time",nowData);
cleanUpTime(map);
}
//插入组织工作履历表
insert("hr_employment_record",gzllInfo_new);
@ -386,8 +396,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
}
}
jyjlInfo_new.put("employee_id",ygxxid);
jyjlInfo_new.put("CREATE_TIME",nowData);
jyjlInfo_new.put("update_time",nowData);
cleanUpTime(map);
}
//插入教育经历表
insert("hr_education",jyjlInfo_new);
@ -414,8 +423,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
}
}
jtxxInfo_new.put("employee_id",ygxxid);
jtxxInfo_new.put("CREATE_TIME",nowData);
jtxxInfo_new.put("update_time",nowData);
cleanUpTime(map);
}
//插入家庭信息表
insert("hr_family",jtxxInfo_new);
@ -442,8 +450,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
}
}
bzInfo_new.put("Employeeid",ygxxid);
bzInfo_new.put("CREATE_TIME",nowData);
bzInfo_new.put("update_time",nowData);
cleanUpTime(map);
}
//插入家庭信息表
insert("hr_rewards_before",bzInfo_new);
@ -470,8 +477,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
}
}
pxInfo_new.put("employee_id",ygxxid);
pxInfo_new.put("CREATE_TIME",nowData);
pxInfo_new.put("update_time",nowData);
cleanUpTime(map);
}
//插入培训表
insert("hr_train",pxInfo_new);
@ -498,8 +504,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
}
}
yyInfo_new.put("employee_id",ygxxid);
yyInfo_new.put("CREATE_TIME",nowData);
yyInfo_new.put("update_time",nowData);
cleanUpTime(map);
}
//插入培训表
insert("hr_language",yyInfo_new);
@ -526,8 +531,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
}
}
qwInfo_new.put("employee_id",ygxxid);
qwInfo_new.put("CREATE_TIME",nowData);
qwInfo_new.put("update_time",nowData);
cleanUpTime(map);
}
//插入权威机构表
insert("hr_certification",qwInfo_new);
@ -740,10 +744,10 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
* 获得key名映射
* @return
*/
public Map<String,String> getMapping(){
public Map<String,Object> getMapping(){
String sql = "select ygxxzdkey,rlxtzdkey from uf_jcl_zdtbysb";
List<Map<String, Object>> recordList = databaseUtils.getSqlList(sql);
Map<String, String> resultMap = recordList.stream().collect(Collectors.toMap(e->e.get("ygxxzdkey").toString(),e -> e.get("rlxtzdkey").toString()));
Map<String, Object> resultMap = recordList.stream().collect(Collectors.toMap(e->e.get("rlxtzdkey").toString(),e -> e.get("ygxxzdkey").toString()));
return resultMap;
}
@ -757,11 +761,13 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
if(StringUtils.isNotBlank(native_place)){
log.info("getNativePlaceName-native_place{}",native_place);
String sql = "select name from eteams.administrative_area where id in ( "+native_place+")";
log.info("getNativePlaceName-sql{}",sql);
List<Map<String, Object>> recordList = databaseUtils.getSqlList(sql);
List<String> listOfNativeName = recordList.stream()
.map(map -> map.get("name").toString())
.collect(Collectors.toList());
name = joinStringsWithSlash(listOfNativeName);
log.info("getNativePlaceName-name{}",name);
}
return name;
@ -843,17 +849,23 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long create_time =0L;
long update_time =0L;
String createDate ="";
String updateDate ="";
String createDate =nowData;
String updateDate =nowData;
if(StringUtils.isNotBlank(getIgnoreCase(employee_info, "create_time"))){
create_time = Long.valueOf(getIgnoreCase(employee_info, "create_time"));
Date date = new Date(create_time);
createDate = sdf.format(date);
String time = getIgnoreCase(employee_info, "create_time");
if(!time.contains("-")){
create_time = Long.parseLong(time);
Date date = new Date(create_time);
createDate = sdf.format(date);
}
}
if(StringUtils.isNotBlank(getIgnoreCase(employee_info, "update_time"))){
update_time = Long.valueOf(getIgnoreCase(employee_info, "update_time"));
Date date = new Date(update_time);
updateDate = sdf.format(date);
String time = getIgnoreCase(employee_info, "update_time");
if(!time.contains("-")){
update_time = Long.parseLong(time);
Date date = new Date(update_time);
updateDate = sdf.format(date);
}
}
employee_info.put("create_time",createDate);
employee_info.put("update_time",updateDate);