导入开发

main
liuliang 3 days ago
parent 6b53f1239a
commit ae0612eaef

@ -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<List<DataForImportEntity>> dataList = req.getDataList();
Gson gson = new Gson();
log.error("ImportEmployeeAdvice info :[{}] ",gson.toJson(dataList));
for (List<DataForImportEntity> data:dataList){
for (DataForImportEntity entity:data){
if (entity.getDataKey().equals("手机号") && entity.getValue().equals("18816254117")){
entity.setErrorMsg("手机号重复");
}
}
}
log.error("ImportEmployeeAdvice info :[{}] ",req.toString());
}
}

@ -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<Map<String, Object>> personFormList = databaseUtils.getSqlList(sql);
Map<String,String> 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<String> formIdParamList = Lists.newArrayList();
@ -206,12 +206,16 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
* -
*/
FieldManageParam personCustomEntity = getFieldManageParam(personCustomfieldFormid,ModuleSource.hrm);
/**
*
*/
Map<String, String> mapping = getMapping();
List<Map<Object, Object>> personCustomFieldList = getFieldList(personCustomEntity,employee);
List<Map<Object, Object>> 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<Map<Object, Object>> personInfCustomFieldList = getFieldList(personInfCustomEntity,employee);
List<Map<Object, Object>> 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<Map<String, Object>> personFormList = databaseUtils.getSqlList(sql);
Map<String,String> 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<String> formIdParamList = Lists.newArrayList();
@ -298,6 +302,10 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
//员工信息主表-个人信息字段
List<Map<Object, Object>> mainFormPersonFieldList = employeeFieldList.stream().filter(e->fieldGroup.get(Constants.PERSONAL_INFORMATION).equals(e.get("groupId")) && "".equals(CommonUtils.null2String(e.get("subFormId")))).collect(Collectors.toList());
/**
*
*/
Map<String, String> mapping = getMapping();
/**
* -
*/
@ -306,7 +314,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
List<Map<Object, Object>> personCustomFieldList = getFieldList(personCustomEntity,employee);
//组装批量保存信息
List<Long> personCustomids = packageBatchSaveParamHaveDelete(personCustomFieldList,mainFormBasicFieldList,"-1");
List<Long> personCustomids = packageBatchSaveParamHaveDelete(personCustomFieldList,mainFormBasicFieldList,"-1",mapping);
/**
* -
@ -314,7 +322,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
FieldManageParam personInfCustomEntity = getFieldManageParam(personInfCustomFormid,ModuleSource.hruserinfo);
List<Map<Object, Object>> personInfCustomFieldList = getFieldList(personInfCustomEntity,employee);
//组装批量保存信息
List<Long> personInfCustomIds = packageBatchSaveParamHaveDelete(personInfCustomFieldList,mainFormPersonFieldList,"-1");
List<Long> 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<Map<String, Object>> personFormList = databaseUtils.getSqlList(sql);
Map<String,String> 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<String> formIdParamList = Lists.newArrayList();
@ -366,6 +374,11 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
Map<String,String> fieldGroup = fieldGroupList.stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString()));
formIdParamList.add(personCustomfieldFormid);
/**
*
*/
Map<String, String> mapping = getMapping();
/**
*
*/
@ -387,8 +400,8 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
List<Map<Object, Object>> infcustomFieldList = personInfCustomFieldList.stream().filter(e->!e.get("componentKey").equals("BaseField")).collect(Collectors.toList());
//组装员工信息
List<Long> deleteIds = packageBatchSaveParamHaveDelete(employeeFieldList,customFieldList,fieldGroup.get(Constants.BASIC_INFORMATION));
deleteIds.addAll(packageBatchSaveParamHaveDelete(employeeFieldList,infcustomFieldList,fieldGroup.get(Constants.PERSONAL_INFORMATION)));
List<Long> 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<Map<Object, Object>> packageList,List<Map<Object, Object>> conditionList,String groupId){
public void packageBatchSaveParam(List<Map<Object, Object>> packageList,List<Map<Object, Object>> conditionList,String groupId,Map<String, String> mapping){
for (Map<Object, Object> customField:conditionList){
List<Map<Object, Object>> list = packageList.stream().filter(e->e.get("dataKey").equals(customField.get("dataKey"))).collect(Collectors.toList());
List<Map<Object, Object>> list = Lists.newArrayList();
if ("-1".equals(groupId)){
//组装人力资源系统表packageList为人力资源数据conditionList为员工信息数据
for (Map<Object, Object> 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<Object, Object> 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<Object, Object> map = Maps.newHashMap();
map.putAll(customField);
@ -584,9 +623,35 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
* @param conditionList
* @param groupId
*/
public List<Long> packageBatchSaveParamHaveDelete(List<Map<Object, Object>> packageList,List<Map<Object, Object>> conditionList,String groupId){
public List<Long> packageBatchSaveParamHaveDelete(List<Map<Object, Object>> packageList,List<Map<Object, Object>> conditionList,String groupId,Map<String, String> mapping){
for (Map<Object, Object> customField:conditionList){
List<Map<Object, Object>> list = packageList.stream().filter(e->e.get("dataKey").equals(customField.get("dataKey"))).collect(Collectors.toList());
List<Map<Object, Object>> list = Lists.newArrayList();
if ("-1".equals(groupId)){
//组装人力资源系统表packageList为人力资源数据conditionList为员工信息数据
for (Map<Object, Object> 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<Object, Object> 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<Object, Object> map = Maps.newHashMap();
map.putAll(customField);
@ -606,8 +671,35 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
List<Long> ids = Lists.newArrayList();
for (int i=0;i<packageList.size();i++){
Map<Object, Object> packageMap = packageList.get(i);
List<Map<Object, Object>> list = conditionList.stream().filter(e->e.get("dataKey").equals(packageMap.get("dataKey"))).collect(Collectors.toList());
if (list.size() == 0){
List<Map<Object, Object>> list = Lists.newArrayList();
if ("-1".equals(groupId)){
//组装人力资源系统表packageList为人力资源数据conditionList为员工信息数据
for (Map<Object, Object> 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<Object, Object> 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<String,String> 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()));
return resultMap;
}
}

Loading…
Cancel
Save