新增根据表名获得e-builder信息接口,将人力资源字段同步给员工信息
This commit is contained in:
parent
21aa5f19e1
commit
0823f962a6
|
|
@ -0,0 +1,36 @@
|
|||
package com.weaver.seconddev.jcl.common;
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.jcl.common.service.CommonService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 聚才林公共接口
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/jcl/common")
|
||||
public class JclCommonController {
|
||||
|
||||
@Autowired
|
||||
CommonService commonService;
|
||||
/**
|
||||
* 根据表名获得模块id、应用id及模块下的表单视图id
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/getTableContainInformation")
|
||||
@ResponseBody
|
||||
public WeaResult<Map<String, Object>> getTableContainInformation(@RequestParam("tableNames") String tableNames){
|
||||
Map<String, Object> tableInfomationmap = commonService.getTableContainInformation(tableNames);
|
||||
|
||||
return WeaResult.success(tableInfomationmap);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,4 +6,6 @@ public interface CommonService {
|
|||
Map<String, Object> updateCommon(Map<String,Object> param);
|
||||
|
||||
Map<String, Object> insertCommon(Map<String,Object> param);
|
||||
|
||||
Map<String, Object> getTableContainInformation(String tableNames);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.weaver.seconddev.jcl.common.service.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.weaver.seconddev.jcl.common.service.CommonService;
|
||||
import com.weaver.seconddev.jcl.organization.util.CommonUtils;
|
||||
import com.weaver.seconddev.jcl.organization.util.DatabaseUtils;
|
||||
|
|
@ -10,6 +12,8 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
|
|
@ -61,4 +65,35 @@ public class CommonServiceImpl implements CommonService {
|
|||
log.error("needInsertDate: [{}]",dataList);
|
||||
return databaseUtils.execute(insertSql,dataList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getTableContainInformation(String tableNames) {
|
||||
String[] tableNameArr = tableNames.split(",");
|
||||
List<String> list = Lists.newArrayList();
|
||||
for (String tableName:tableNameArr){
|
||||
list.add("'"+tableName+"'");
|
||||
}
|
||||
String sql = "select id,app_id,form_id,table_name from ebdf_obj where table_name in ("+String.join(",",list)+") and delete_type='0'";
|
||||
log.error("getTableContainInformation sql "+sql);
|
||||
List<Map<String, String>> objList = CommonUtils.convertList(databaseUtils.getSqlList(sql));
|
||||
|
||||
|
||||
Set<String> formIdList = objList.stream().map(e->"'"+e.get("form_id").toString()+"'").collect(Collectors.toSet());
|
||||
sql = "select id,name,form_id from form_layout_multiple where form_id in ("+String.join(",",formIdList)+") and delete_type='0'";
|
||||
log.error("getTableContainInformation sql "+sql);
|
||||
List<Map<String, String>> multipleIds = CommonUtils.convertList(databaseUtils.getSqlList(sql));
|
||||
log.error("multipleIds :[{}] "+multipleIds);
|
||||
Map<String,Object> resultMap = Maps.newHashMap();
|
||||
Gson gson = new Gson();
|
||||
for (Map<String, String> objMap:objList){
|
||||
String form_id = CommonUtils.null2String(objMap.get("form_id"));
|
||||
log.error("form_id :[{}] "+form_id);
|
||||
List<Map<String, String>> havemultipleIds = multipleIds.stream().filter(e->CommonUtils.null2String(e.get("form_id")).equals(form_id)).collect(Collectors.toList());
|
||||
log.error("havemultipleIds :[{}] "+havemultipleIds);
|
||||
objMap.put("multiple",gson.toJson(havemultipleIds));
|
||||
resultMap.put(objMap.get("table_name"),objMap);
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,4 +110,21 @@ public class EmployeeInformationController extends EmployeeCommonController {
|
|||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将人力信息字段同步给员工信息
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/synchronousFieldByHrm")
|
||||
@ResponseBody
|
||||
public WeaResult<Map<String, Object>> synchronousFieldByHrm(){
|
||||
Map<String, Object> actionMap = new HashMap<>();
|
||||
List<String> errorMessage = employeeInformationService.synchronousFieldByHrm(this.getCurrentUser());
|
||||
if (errorMessage.size() > 0){
|
||||
return WeaResult.fail(errorMessage.toString(),true);
|
||||
}else {
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.weaver.seconddev.jcl.organization.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.jcl.organization.service.EmployeeInformationService;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 初始化员工信息和人力资源基本信息以及个人信息自定义字段的同步
|
||||
*/
|
||||
@Service("synchronousFieldInitialization_jcl")
|
||||
public class SynchronousFieldInitialization implements EsbServerlessRpcRemoteInterface {
|
||||
|
||||
@Autowired
|
||||
EmployeeInformationService employeeInformationService;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
List<String> errorList = employeeInformationService.synchronousField(new SimpleEmployee());
|
||||
|
||||
if (errorList.size() > 0){
|
||||
return WeaResult.fail(errorList.toString(),true);
|
||||
}else {
|
||||
return WeaResult.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.weaver.seconddev.jcl.organization.importAdvice;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.weaver.ebuilder.form.client.service.batch.advice.ImportDataAdvice;
|
||||
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 java.util.List;
|
||||
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
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));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,8 @@ public interface EmployeeInformationService {
|
|||
|
||||
List<String> synchronousFieldByEmployee(SimpleEmployee employee);
|
||||
|
||||
List<String> synchronousFieldByHrm(SimpleEmployee employee);
|
||||
|
||||
/**
|
||||
* 获得字段信息
|
||||
* @param entity
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
List<String> errorMessage = Lists.newArrayList();
|
||||
WeaResult<Map<String, Object>> result = batchSaveInformation(employee_form_id,employeeFieldList,dataList,ModuleSource.ebuilderform,null,null);
|
||||
if (result.getCode() != 200){
|
||||
errorMessage.add(result.getMsg());
|
||||
errorMessage.add("员工信息表"+result.getMsg());
|
||||
}
|
||||
|
||||
//保存人力资源-基本信息
|
||||
|
|
@ -231,14 +231,14 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
customParam.put("formId",personCustomfieldFormid);
|
||||
WeaResult<Map<String, Object>> result2 = batchSaveInformation(personCustomfieldFormid,personCustomFieldList,null,ModuleSource.hrm,customParam,null);
|
||||
if (result2.getCode() != 200){
|
||||
errorMessage.add(result2.getMsg());
|
||||
errorMessage.add("人力资源基本信息自定义表"+result2.getMsg());
|
||||
}
|
||||
//保存人力资源-个人信息
|
||||
Map<String, Object> customParam2 = Maps.newHashMap();
|
||||
customParam2.put("apiModule","hr");
|
||||
WeaResult<Map<String, Object>> result3 = batchSaveInformation(personInfCustomFormid,personInfCustomFieldList,null,ModuleSource.hruserinfo,customParam2,null);
|
||||
if (result3.getCode() != 200){
|
||||
errorMessage.add(result3.getMsg());
|
||||
errorMessage.add("人力资源个人信息自定义表"+result3.getMsg());
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
|
|
@ -312,18 +312,86 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
customParam.put("formId",personCustomfieldFormid);
|
||||
WeaResult<Map<String, Object>> result2 = batchSaveInformation(personCustomfieldFormid,personCustomFieldList,null,ModuleSource.hrm,customParam,personCustomids);
|
||||
if (result2.getCode() != 200){
|
||||
errorMessage.add(result2.getMsg());
|
||||
errorMessage.add("基本信息表"+result2.getMsg());
|
||||
}
|
||||
//保存人力资源-个人信息
|
||||
Map<String, Object> customParam2 = Maps.newHashMap();
|
||||
customParam2.put("apiModule","hr");
|
||||
WeaResult<Map<String, Object>> result3 = batchSaveInformation(personInfCustomFormid,personInfCustomFieldList,null,ModuleSource.hruserinfo,customParam2,personInfCustomIds);
|
||||
if (result3.getCode() != 200){
|
||||
errorMessage.add(result3.getMsg());
|
||||
errorMessage.add("个人信息表"+result3.getMsg());
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> synchronousFieldByHrm(SimpleEmployee employee) {
|
||||
String sql = "select form_id from form_table where table_name=? and delete_type='0'";
|
||||
List<String> paramList = Lists.newArrayList();
|
||||
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'";
|
||||
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");
|
||||
|
||||
|
||||
List<String> formIdParamList = Lists.newArrayList();
|
||||
formIdParamList.add(employee_form_id);
|
||||
sql = "select id,group_name from form_field_group where form_id=? and delete_type='0'";
|
||||
List<Map<String, Object>> fieldGroupList = databaseUtils.getSqlList(sql,formIdParamList);
|
||||
Map<String,String> fieldGroup = fieldGroupList.stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString()));
|
||||
formIdParamList.add(personCustomfieldFormid);
|
||||
|
||||
/**
|
||||
* 员工信息表所有字段
|
||||
*/
|
||||
FieldManageParam ownEntity = getFieldManageParam(employee_form_id,ModuleSource.ebuilderform);
|
||||
List<Map<Object, Object>> employeeFieldList = getFieldList(ownEntity,employee);
|
||||
/**
|
||||
* 人力资源-基本信息自定义字段
|
||||
*/
|
||||
FieldManageParam personCustomEntity = getFieldManageParam(personCustomfieldFormid,ModuleSource.hrm);
|
||||
|
||||
|
||||
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());
|
||||
/**
|
||||
* 人力资源-个人信息自定义字段
|
||||
*/
|
||||
FieldManageParam personInfCustomEntity = getFieldManageParam(personInfCustomFormid,ModuleSource.hruserinfo);
|
||||
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());
|
||||
|
||||
//组装员工信息
|
||||
List<Long> deleteIds = packageBatchSaveParamHaveDelete(employeeFieldList,customFieldList,fieldGroup.get(Constants.BASIC_INFORMATION));
|
||||
deleteIds.addAll(packageBatchSaveParamHaveDelete(employeeFieldList,infcustomFieldList,fieldGroup.get(Constants.PERSONAL_INFORMATION)));
|
||||
|
||||
|
||||
|
||||
log.error("employeeFieldList : [{}]",employeeFieldList);
|
||||
log.error("personCustomFieldList : [{}]",personCustomFieldList);
|
||||
log.error("personInfCustomFieldList : [{}]",personInfCustomFieldList);
|
||||
|
||||
/**
|
||||
* 批量保存
|
||||
*/
|
||||
//员工信息表
|
||||
sql = "select b.id formtableid,a.* from sub_form a left join form_table b on a.id=b.form_id where a.form_id=?";
|
||||
List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee_form_id));
|
||||
List<String> errorMessage = Lists.newArrayList();
|
||||
WeaResult<Map<String, Object>> result = batchSaveInformation(employee_form_id,employeeFieldList,dataList,ModuleSource.ebuilderform,null,deleteIds);
|
||||
if (result.getCode() != 200){
|
||||
errorMessage.add("员工信息表"+result.getMsg());
|
||||
}
|
||||
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<Object, Object>> getFieldList(FieldManageParam entity,SimpleEmployee employee) {
|
||||
|
||||
|
|
|
|||
|
|
@ -477,4 +477,16 @@ public class CommonUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static List<Map<String, String>> convertList(List<Map<String, Object>> objList){
|
||||
List<Map<String, String>> resultList = Lists.newArrayList();
|
||||
for (Map<String, Object> map:objList){
|
||||
Map<String,String> resultMap = Maps.newHashMap();
|
||||
for (Map.Entry<String, Object> entry :map.entrySet()){
|
||||
resultMap.put(entry.getKey(),CommonUtils.null2String(entry.getValue()));
|
||||
}
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@ public class Constants {
|
|||
/**
|
||||
* 员工信息表
|
||||
*/
|
||||
public static final String EMPLOYEE_INFORMATION="uf_ygxxglfzcswd";
|
||||
public static final String EMPLOYEE_INFORMATION="uf_jcl_employee_information";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -343,6 +343,7 @@ public class DatabaseUtils {
|
|||
return recordList;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
|
|
|
|||
Loading…
Reference in New Issue