diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/importAdvice/ImportEmployeeAdvice.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/importAdvice/ImportEmployeeAdvice.java index 6b24e3c..a87ab0d 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/importAdvice/ImportEmployeeAdvice.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/importAdvice/ImportEmployeeAdvice.java @@ -6,18 +6,30 @@ import com.weaver.ebuilder.form.client.service.batch.dto.BaseImportDataAdviceDto import com.weaver.ebuilder.form.client.service.batch.dto.DataForImportEntity; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import java.util.List; -@Component +/** + * 员工信息导入校验 + */ @Slf4j +@Service("importEmployeeAdvice_jcl") public class ImportEmployeeAdvice implements ImportDataAdvice { @Override public void dataAdvice(BaseImportDataAdviceDto req) { List> dataList = req.getDataList(); Gson gson = new Gson(); - log.error("ImportEmployeeAdvice info :[{}] ",gson.toJson(dataList)); + for (List data:dataList){ + for (DataForImportEntity entity:data){ + if (entity.getDataKey().equals("手机号") && entity.getValue().equals("18816254117")){ + entity.setErrorMsg("手机号重复"); + } + } + } + + log.error("ImportEmployeeAdvice info :[{}] ",req.toString()); } } diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java index 53842d1..998505f 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java @@ -174,13 +174,13 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic paramList.add(Constants.EMPLOYEE_INFORMATION); String employee_form_id = CommonUtils.null2String(databaseUtils.getSqlList(sql,paramList).get(0).get("form_id")); - sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo'"; + sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo' and delete_type='0'"; List> personFormList = databaseUtils.getSqlList(sql); Map personFormMap = personFormList.stream().collect(Collectors.toMap(e->e.get("module").toString(),e->e.get("id").toString())); //基本信息自定义字段表 String personCustomfieldFormid=personFormMap.get("hrm"); //人力资源-个人信息自定义字段 - String personInfCustomFormid=personFormMap.get("hrm"); + String personInfCustomFormid=personFormMap.get("hruserinfo"); List formIdParamList = Lists.newArrayList(); @@ -206,12 +206,16 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic * 人力资源-基本信息自定义字段 */ FieldManageParam personCustomEntity = getFieldManageParam(personCustomfieldFormid,ModuleSource.hrm); + /** + * 映射表数据 + */ + Map mapping = getMapping(); List> personCustomFieldList = getFieldList(personCustomEntity,employee); List> customFieldList = personCustomFieldList.stream().filter(e->!e.get("componentKey").equals("BaseField")).collect(Collectors.toList()); //组装批量保存信息 - packageBatchSaveParam(personCustomFieldList,mainFormBasicFieldList,"-1"); + packageBatchSaveParam(personCustomFieldList,mainFormBasicFieldList,"-1",mapping); /** * 人力资源-个人信息自定义字段 @@ -220,12 +224,12 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic List> personInfCustomFieldList = getFieldList(personInfCustomEntity,employee); List> infcustomFieldList = personInfCustomFieldList.stream().filter(e->!e.get("componentKey").equals("BaseField")).collect(Collectors.toList()); //组装批量保存信息 - packageBatchSaveParam(personInfCustomFieldList,mainFormPersonFieldList,"-1"); + packageBatchSaveParam(personInfCustomFieldList,mainFormPersonFieldList,"-1",mapping); //组装员工信息 - packageBatchSaveParam(employeeFieldList,customFieldList,fieldGroup.get(Constants.BASIC_INFORMATION)); - packageBatchSaveParam(employeeFieldList,infcustomFieldList,fieldGroup.get(Constants.PERSONAL_INFORMATION)); + packageBatchSaveParam(employeeFieldList,customFieldList,fieldGroup.get(Constants.BASIC_INFORMATION),mapping); + packageBatchSaveParam(employeeFieldList,infcustomFieldList,fieldGroup.get(Constants.PERSONAL_INFORMATION),mapping); @@ -270,13 +274,13 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic paramList.add(Constants.EMPLOYEE_INFORMATION); String employee_form_id = CommonUtils.null2String(databaseUtils.getSqlList(sql,paramList).get(0).get("form_id")); - sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo'"; + sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo' and delete_type='0'"; List> personFormList = databaseUtils.getSqlList(sql); Map personFormMap = personFormList.stream().collect(Collectors.toMap(e->e.get("module").toString(),e->e.get("id").toString())); //基本信息自定义字段表 String personCustomfieldFormid=personFormMap.get("hrm"); //人力资源-个人信息自定义字段 - String personInfCustomFormid=personFormMap.get("hrm"); + String personInfCustomFormid=personFormMap.get("hruserinfo"); List formIdParamList = Lists.newArrayList(); @@ -298,6 +302,10 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic //员工信息主表-个人信息字段 List> mainFormPersonFieldList = employeeFieldList.stream().filter(e->fieldGroup.get(Constants.PERSONAL_INFORMATION).equals(e.get("groupId")) && "".equals(CommonUtils.null2String(e.get("subFormId")))).collect(Collectors.toList()); + /** + * 映射表数据 + */ + Map mapping = getMapping(); /** * 人力资源-基本信息自定义字段 */ @@ -306,7 +314,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic List> personCustomFieldList = getFieldList(personCustomEntity,employee); //组装批量保存信息 - List personCustomids = packageBatchSaveParamHaveDelete(personCustomFieldList,mainFormBasicFieldList,"-1"); + List personCustomids = packageBatchSaveParamHaveDelete(personCustomFieldList,mainFormBasicFieldList,"-1",mapping); /** * 人力资源-个人信息自定义字段 @@ -314,7 +322,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic FieldManageParam personInfCustomEntity = getFieldManageParam(personInfCustomFormid,ModuleSource.hruserinfo); List> personInfCustomFieldList = getFieldList(personInfCustomEntity,employee); //组装批量保存信息 - List personInfCustomIds = packageBatchSaveParamHaveDelete(personInfCustomFieldList,mainFormPersonFieldList,"-1"); + List personInfCustomIds = packageBatchSaveParamHaveDelete(personInfCustomFieldList,mainFormPersonFieldList,"-1",mapping); log.error("personCustomFieldList : [{}]",personCustomFieldList); @@ -350,13 +358,13 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic paramList.add(Constants.EMPLOYEE_INFORMATION); String employee_form_id = CommonUtils.null2String(databaseUtils.getSqlList(sql,paramList).get(0).get("form_id")); - sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo'"; + sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo' and delete_type='0'"; List> personFormList = databaseUtils.getSqlList(sql); Map personFormMap = personFormList.stream().collect(Collectors.toMap(e->e.get("module").toString(),e->e.get("id").toString())); //基本信息自定义字段表 String personCustomfieldFormid=personFormMap.get("hrm"); //人力资源-个人信息自定义字段 - String personInfCustomFormid=personFormMap.get("hrm"); + String personInfCustomFormid=personFormMap.get("hruserinfo"); List formIdParamList = Lists.newArrayList(); @@ -366,6 +374,11 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic Map fieldGroup = fieldGroupList.stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString())); formIdParamList.add(personCustomfieldFormid); + /** + * 映射表数据 + */ + Map mapping = getMapping(); + /** * 员工信息表所有字段 */ @@ -387,8 +400,8 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic List> infcustomFieldList = personInfCustomFieldList.stream().filter(e->!e.get("componentKey").equals("BaseField")).collect(Collectors.toList()); //组装员工信息 - List deleteIds = packageBatchSaveParamHaveDelete(employeeFieldList,customFieldList,fieldGroup.get(Constants.BASIC_INFORMATION)); - deleteIds.addAll(packageBatchSaveParamHaveDelete(employeeFieldList,infcustomFieldList,fieldGroup.get(Constants.PERSONAL_INFORMATION))); + List deleteIds = packageBatchSaveParamHaveDelete(employeeFieldList,customFieldList,fieldGroup.get(Constants.BASIC_INFORMATION),mapping); + deleteIds.addAll(packageBatchSaveParamHaveDelete(employeeFieldList,infcustomFieldList,fieldGroup.get(Constants.PERSONAL_INFORMATION),mapping)); @@ -558,9 +571,35 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic * @param conditionList * @param groupId */ - public void packageBatchSaveParam(List> packageList,List> conditionList,String groupId){ + public void packageBatchSaveParam(List> packageList,List> conditionList,String groupId,Map mapping){ for (Map customField:conditionList){ - List> list = packageList.stream().filter(e->e.get("dataKey").equals(customField.get("dataKey"))).collect(Collectors.toList()); + List> list = Lists.newArrayList(); + if ("-1".equals(groupId)){ + //组装人力资源系统表,packageList为人力资源数据,conditionList为员工信息数据 + for (Map packageMap :packageList){ + String dataKey = CommonUtils.null2String(packageMap.get("dataKey")); + String conditionKey = CommonUtils.null2String(customField.get("dataKey")); + if (mapping.get(conditionKey) != null && !"".equals(mapping.get(conditionKey))){ + conditionKey = mapping.get(conditionKey); + } + if (dataKey.equals(conditionKey)){ + list.add(packageMap); + } + } + }else { + //组装员工信息 + //组装人力资源系统表,packageList为员工信息数据,conditionList为人力资源数据 + for (Map packageMap :packageList){ + String dataKey = CommonUtils.null2String(packageMap.get("dataKey")); + String conditionKey = CommonUtils.null2String(customField.get("dataKey")); + if (mapping.get(dataKey) != null && !"".equals(mapping.get(dataKey))){ + dataKey = mapping.get(dataKey); + } + if (dataKey.equals(conditionKey)){ + list.add(packageMap); + } + } + } if (list.size() == 0){ Map map = Maps.newHashMap(); map.putAll(customField); @@ -584,9 +623,35 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic * @param conditionList * @param groupId */ - public List packageBatchSaveParamHaveDelete(List> packageList,List> conditionList,String groupId){ + public List packageBatchSaveParamHaveDelete(List> packageList,List> conditionList,String groupId,Map mapping){ for (Map customField:conditionList){ - List> list = packageList.stream().filter(e->e.get("dataKey").equals(customField.get("dataKey"))).collect(Collectors.toList()); + List> list = Lists.newArrayList(); + if ("-1".equals(groupId)){ + //组装人力资源系统表,packageList为人力资源数据,conditionList为员工信息数据 + for (Map packageMap :packageList){ + String dataKey = CommonUtils.null2String(packageMap.get("dataKey")); + String conditionKey = CommonUtils.null2String(customField.get("dataKey")); + if (mapping.get(conditionKey) != null && !"".equals(mapping.get(conditionKey))){ + conditionKey = mapping.get(conditionKey); + } + if (dataKey.equals(conditionKey)){ + list.add(packageMap); + } + } + }else { + //组装员工信息 + //组装人力资源系统表,packageList为员工信息数据,conditionList为人力资源数据 + for (Map packageMap :packageList){ + String dataKey = CommonUtils.null2String(packageMap.get("dataKey")); + String conditionKey = CommonUtils.null2String(customField.get("dataKey")); + if (mapping.get(dataKey) != null && !"".equals(mapping.get(dataKey))){ + dataKey = mapping.get(dataKey); + } + if (dataKey.equals(conditionKey)){ + list.add(packageMap); + } + } + } if (list.size() == 0){ Map map = Maps.newHashMap(); map.putAll(customField); @@ -606,8 +671,35 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic List ids = Lists.newArrayList(); for (int i=0;i packageMap = packageList.get(i); - List> list = conditionList.stream().filter(e->e.get("dataKey").equals(packageMap.get("dataKey"))).collect(Collectors.toList()); - if (list.size() == 0){ + List> list = Lists.newArrayList(); + if ("-1".equals(groupId)){ + //组装人力资源系统表,packageList为人力资源数据,conditionList为员工信息数据 + for (Map customField :conditionList){ + String dataKey = CommonUtils.null2String(packageMap.get("dataKey")); + String conditionKey = CommonUtils.null2String(customField.get("dataKey")); + if (mapping.get(conditionKey) != null && !"".equals(mapping.get(conditionKey))){ + conditionKey = mapping.get(conditionKey); + } + if (dataKey.equals(conditionKey)){ + list.add(packageMap); + } + } + }else { + //组装员工信息 + //组装人力资源系统表,packageList为员工信息数据,conditionList为人力资源数据 + for (Map customField :conditionList){ + String dataKey = CommonUtils.null2String(packageMap.get("dataKey")); + String conditionKey = CommonUtils.null2String(customField.get("dataKey")); + if (mapping.get(dataKey) != null && !"".equals(mapping.get(dataKey))){ + dataKey = mapping.get(dataKey); + } + if (dataKey.equals(conditionKey)){ + list.add(packageMap); + } + } + } + + if (list.size() == 0 && !packageMap.get("componentKey").equals("BaseField")){ ids.add(Long.valueOf(packageMap.get("fieldId").toString())); packageList.remove(i); i--; @@ -659,5 +751,16 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic return result; } + /** + * 获得key名映射 + * @return + */ + public Map getMapping(){ + String sql = "select ygxxzdkey,rlxtzdkey from uf_jcl_zdtbysb"; + List> recordList = databaseUtils.getSqlList(sql); + Map resultMap = recordList.stream().collect(Collectors.toMap(e->e.get("ygxxzdkey").toString(),e -> e.get("rlxtzdkey").toString())); + + return resultMap; + } }