diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/esb/SyncOrganizationPersonInfo.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/esb/SyncOrganizationPersonInfo.java index 56ce03e..12214ea 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/esb/SyncOrganizationPersonInfo.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/esb/SyncOrganizationPersonInfo.java @@ -371,7 +371,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa /** * 员工信息明细表数据同步处理 */ - syncAllYgxxDetailInfo(ygxxid,Long.parseLong(objId)); + syncAllYgxxDetailInfo(ygxxid,Long.parseLong(objId),tableUserName,formuserdataid); }else{ //更新组织员工数据 //遍历修正create_time、update_time @@ -495,7 +495,7 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa /** *更新员工信息表所有明细表 */ - updateAllYgxxDetailInfo(ygxxid,Long.parseLong(objId)); + updateAllYgxxDetailInfo(ygxxid,Long.parseLong(objId),tableUserName,FORM_DATA ); } //判断新增/更新数据是否都成功 //if(code==200&&code2==200&&code3==200&&code4==200&&code5==200){ @@ -549,8 +549,8 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa * 数据同步处理明细表 * @return */ - public void syncAllYgxxDetailInfo(String ygxxid,long objId){ - log.error("syncAllYgxxDetailInfo.ygxxid:{},objId:{}", ygxxid,objId); + public void syncAllYgxxDetailInfo(String ygxxid,long objId,String tableUserName,long formuserdataid){ + log.error("syncAllYgxxDetailInfo.ygxxid:{},objId:{},tableUserName:{}", ygxxid,objId,tableUserName); String uf_jcl_emp_gzll = recruitModuleUtils.getDetailTableNameByMasterId(objId, "uf_jcl_emp_gzll"); log.error("syncAllYgxxDetailInfo.uf_jcl_emp_gzll:{}", uf_jcl_emp_gzll); /** @@ -739,15 +739,72 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa qwInfo_new.remove("hiredate"); insert("hr_certification",qwInfo_new); } + + /** + * 查询是否有新增的明细表 + */ + List> newDetails = recruitModuleUtils.getDetailTableNameListByObjId(objId); + log.error("syncAllYgxxDetailInfo.newDetails:{}", newDetails); + if(CollectionUtils.isNotEmpty(newDetails)){ + for (Map newDetail : newDetails) { + /** + * 新增明细表 + * */ + log.error("syncAllYgxxDetailInfo.newDetail:{}", newDetail); + String newDetailsql = "select * from "+newDetail.get("tableName")+" where FORM_DATA_ID = '" + ygxxid + "' and delete_type=0"; + log.error("getYgxxDetailInfo.newDetailsql:{}", newDetailsql); + List> newDetailInfo = getYgxxDetailInfo(newDetailsql); + log.error("getYgxxDetailInfo.newDetailInfo:{}", newDetailInfo); + //先查询组织那边对应的明细表 + List> zzDetail = getZzDetail(tableUserName); + log.error("getYgxxDetailInfo.zzDetail:{}", zzDetail); + for (Map map : newDetailInfo) { + Map newDetailInfo_new = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + newDetailInfo_new.putAll(map); + newDetailInfo_new.put("form_data_id",formuserdataid); + /** + * 去除不存在的列 + */ + newDetailInfo_new.remove("classification"); + newDetailInfo_new.remove("classification_expire"); + newDetailInfo_new.remove("data_status"); + newDetailInfo_new.remove("is_top"); + cleanUpTime(newDetailInfo_new); + newDetailInfo_new.remove("hiredate"); + log.error("getYgxxDetailInfo.newDetailInfo_new:{}", newDetailInfo_new); + //插入新增明细表 + if(CollectionUtils.isNotEmpty(zzDetail)){ + for (Map objectMap : zzDetail) { + String table_name = String.valueOf(objectMap.get("table_name")); + String form_name = String.valueOf(objectMap.get("form_name")); + if(form_name.equals(newDetail.get("name"))){ + insert(table_name,newDetailInfo_new); + } + } + } + } + } + } } + /** + * 根据个人信息自定义主表查询明细表 + * @return + */ + public List> getZzDetail(String tableUserName){ + log.error("getZzDetail.tableUserName:{}", tableUserName); + String sql = "select table_name,form_name from form_table where form_id in (select id from sub_form where form_id in\n" + + "(select form_id from form_table where table_name= '"+ tableUserName +"' and tenant_key = '"+RecruitModuleUtils.getCurrentTenantKey()+"' )) and delete_type=0 "; + return getYgxxDetailInfo(sql); + } + /** * 数据同步处理明细表(更新) * @return */ - public void updateAllYgxxDetailInfo(String ygxxid,long objId){ - log.error("updateAllYgxxDetailInfo.ygxxid:{},objId:{}", ygxxid,objId); + public void updateAllYgxxDetailInfo(String ygxxid,long objId,String tableUserName,String FORM_DATA){ + log.error("updateAllYgxxDetailInfo.ygxxid:{},objId:{},tableUserName:{}", ygxxid,objId,tableUserName); //先删除原来记录(只能逻辑删除,更新时间也必须加上) String sql = "update hr_employment_record set delete_type = 1,update_time ='" + nowData + "' where USER_ID = "+ygxxid ; deleteDetailData(sql); @@ -992,6 +1049,67 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa qwInfo_new.remove("hiredate"); insert("hr_certification",qwInfo_new); } + + + /** + * 查询是否有新增的明细表 + */ + log.error("updateAllYgxxDetailInfo.objId:{}",objId); + List> newDetails = recruitModuleUtils.getDetailTableNameListByObjId(objId); + log.error("updateAllYgxxDetailInfo.newDetails:{}", newDetails); + /** + * 根据关联组织员工id查询个人信息表->自定义表->明细表 + */ + + if(CollectionUtils.isNotEmpty(newDetails)) { + for (Map newDetail : newDetails) { + /** + * 更新新增明细表 + * */ + log.error("updateAllYgxxDetailInfo.newDetail:{}", newDetail); + //先删除原来记录 + //先查询组织那边对应的明细表 + List> zzDetail = getZzDetail(tableUserName); + log.error("updateAllYgxxDetailInfo.zzDetail:{}", zzDetail); + for (Map map : zzDetail) { + sql = "update "+map.get("table_name")+" set delete_type = 1,is_delete=1,ft_status=1,update_time ='" + nowData + "' where form_data_id = "+FORM_DATA; + deleteDetailData(sql); + } + String newDetailsql = "select * from "+newDetail.get("tableName")+" where FORM_DATA_ID = '" + ygxxid + "' and delete_type=0"; + log.error("getYgxxDetailInfo.newDetailsql:{}", newDetailsql); + List> newDetailInfo = getYgxxDetailInfo(newDetailsql); + log.error("getYgxxDetailInfo.newDetailInfo222:{}", newDetailInfo); + for (Map map : newDetailInfo) { + Map newDetailInfo_new = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + newDetailInfo_new.putAll(map); + //跟换id值,然后主键冲突 + long primarykey = IdGenerator.generate(); + log.error("getYgxxDetailInfo.primarykey:{}", primarykey); + newDetailInfo_new.put("id",primarykey); + newDetailInfo_new.put("form_data_id",FORM_DATA); + /** + * 去除不存在的列 + */ + newDetailInfo_new.remove("classification"); + newDetailInfo_new.remove("classification_expire"); + newDetailInfo_new.remove("data_status"); + newDetailInfo_new.remove("is_top"); + + cleanUpTime(newDetailInfo_new); + newDetailInfo_new.remove("hiredate"); + log.error("getYgxxDetailInfo3333.newDetailInfo_new:{}", newDetailInfo_new); + if(CollectionUtils.isNotEmpty(zzDetail)){ + for (Map objectMap : zzDetail) { + String table_name = String.valueOf(objectMap.get("table_name")); + String form_name = String.valueOf(objectMap.get("form_name")); + if(form_name.equals(newDetail.get("name"))){ + insert(table_name,newDetailInfo_new); + } + } + } + } + } + } } /** @@ -1217,9 +1335,6 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa long create_time =0L; long update_time =0L; long hiredate_time =0L; - Date parsedDate1 = new Date(); - Date parsedDate2 = new Date(); - Date parsedDate3 = new Date(); String createDate =nowData; String updateDate =nowData; String hiredate =nowData; @@ -1229,7 +1344,6 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa create_time = Long.parseLong(time); Date date = new Date(create_time); createDate = sdf.format(date); - //parsedDate1 = new Date(sdf.parse(createDate).getTime()); }else { createDate = time; } @@ -1240,7 +1354,6 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa update_time = Long.parseLong(time); Date date = new Date(update_time); updateDate = sdf.format(date); - //parsedDate2 = new Date(sdf.parse(updateDate).getTime()); }else { updateDate = time; } @@ -1251,7 +1364,6 @@ public class SyncOrganizationPersonInfo implements EsbServerlessRpcRemoteInterfa hiredate_time = Long.parseLong(time); Date date = new Date(hiredate_time); hiredate = sdf2.format(date); - //parsedDate3 = new Date(sdf2.parse(hiredate).getTime()); }else { hiredate = time; } diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeRelationServiceImpl.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeRelationServiceImpl.java index b3863d1..9b0981a 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeRelationServiceImpl.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeRelationServiceImpl.java @@ -1585,7 +1585,9 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService { continue; } if (obj.getTableName().startsWith(originTableName)) { - tableName = obj.getTableName(); + tableName = obj.getName(); + log.info("getDetailTableNameByMasterId.obj:{}",obj); + log.info("getDetailTableNameByMasterId.obj:{}",obj.getShowName()); } } log.info("getDetailTableNameByMasterId.tableName:{}",tableName); diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/RecruitModuleUtils.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/RecruitModuleUtils.java index e642d13..735a08c 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/RecruitModuleUtils.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/RecruitModuleUtils.java @@ -328,5 +328,40 @@ public class RecruitModuleUtils { log.info("getDetailTableNameByMasterId.tableName:{}",tableName); return tableName; } + + /** + * 获取明细表名称(列表) + * @param objId + * @return + */ + public List> getDetailTableNameListByObjId(long objId) { + log.info("getDetailTableNameListByObjId.objId:{}",objId); + List> list = new ArrayList<>(); + RemoteEBObjService remoteEBService = publishKitRuntimeUtil.buildRpcService(RemoteEBObjService.class, "ebuilderform", getEbAppId("uf_jcl_employee_information_apptag")); + log.info("getDetailTableNameListByObjId.remoteEBService:{}",remoteEBService); + List detailForms = remoteEBService.getAllTablesByMasterId(objId, RecruitModuleUtils.getCurrentTenantKey()); + log.info("getDetailTableNameListByObjId.detailForms:{}",detailForms); + if (CollectionUtils.isEmpty(detailForms)) { + return null; + } + + for (Obj obj : detailForms) { + //DataKey不为空的才是明细表 + if (StringUtils.isEmpty(obj.getDataKey())) { + continue; + } + log.info("getDetailTableNameListByObjId.obj:{}",obj); + if (!obj.getTableName().startsWith("uf_jcl_emp_gzll")&&!obj.getTableName().startsWith("uf_jcl_emp_jyjl")&&!obj.getTableName().startsWith("uf_jcl_emp_jtxx") + &&!obj.getTableName().startsWith("uf_jcl_emp_bzyjl")&&!obj.getTableName().startsWith("uf_jcl_emp_pxjl")&&!obj.getTableName().startsWith("uf_jcl_emp_yynl") + &&!obj.getTableName().startsWith("uf_jcl_emp_qwjgzgrz")) { + Map map = new HashMap<>(); + map.put("tableName",obj.getTableName()); + map.put("name",obj.getName()); + list.add(map); + } + } + log.info("getDetailTableNameListByObjId.list:{}",list); + return list; + } }