适配多租户
This commit is contained in:
parent
d2250dcea8
commit
f2d2130bfe
|
|
@ -33,6 +33,7 @@ import com.weaver.jucailin.organization.service.EmployeeInformationService;
|
|||
import com.weaver.jucailin.organization.util.CommonUtils;
|
||||
import com.weaver.jucailin.organization.util.Constants;
|
||||
import com.weaver.jucailin.organization.util.DatabaseUtils;
|
||||
import com.weaver.jucailin.organization.util.RecruitModuleUtils;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
|
@ -66,22 +67,33 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
private FormAuthenticationService formAuthenticationService;
|
||||
@Autowired
|
||||
private EbuilderConditionBuilder ebuilderConditionBuilder;
|
||||
@Autowired
|
||||
RecruitModuleUtils recruitModuleUtils;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> synchronousField(SimpleEmployee employee) {
|
||||
Map<String, String> uf_jcl_employee_information_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.EMPLOYEE_INFORMATION);
|
||||
String uf_jcl_employee_information = uf_jcl_employee_information_Info.get("table_name");
|
||||
|
||||
Map<String, String> uf_jcl_employee_xxbgsq_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.EMPLOYEE_XXBGSQ);
|
||||
String uf_jcl_employee_xxbgsq = uf_jcl_employee_xxbgsq_Info.get("table_name");
|
||||
|
||||
Map<String, String> uf_jcl_rzgl_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.UF_JCL_RZGL);
|
||||
String uf_jcl_rzgl = uf_jcl_rzgl_Info.get("table_name");
|
||||
|
||||
List<String> paramList = Lists.newArrayList();
|
||||
paramList.add("'"+ Constants.EMPLOYEE_INFORMATION+"'");
|
||||
paramList.add("'"+Constants.EMPLOYEE_XXBGSQ+"'");
|
||||
paramList.add("'"+Constants.UF_JCL_RZGL+"'");
|
||||
paramList.add("'"+ uf_jcl_employee_information+"'");
|
||||
paramList.add("'"+uf_jcl_employee_xxbgsq+"'");
|
||||
paramList.add("'"+uf_jcl_rzgl+"'");
|
||||
String sql = "select form_id,table_name from form_table where table_name in ("+String.join(",",paramList)+") and delete_type='0'";
|
||||
Map<String,String> formMap = databaseUtils.getSqlList(sql).stream().collect(Collectors.toMap(e->e.get("table_name").toString(),e->e.get("form_id").toString()));
|
||||
String employee_form_id = formMap.get(Constants.EMPLOYEE_INFORMATION);
|
||||
String employee_form_id = formMap.get(uf_jcl_employee_information);
|
||||
|
||||
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);
|
||||
sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo' and delete_type='0' and tenant_key=?";
|
||||
List<Map<String, Object>> personFormList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee.getTenantKey()));
|
||||
Map<String,String> personFormMap = personFormList.stream().collect(Collectors.toMap(e->e.get("module").toString(),e->e.get("id").toString()));
|
||||
//基本信息自定义字段表
|
||||
String personCustomfieldFormid=personFormMap.get("hrm");
|
||||
|
|
@ -91,8 +103,8 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
|
||||
List<String> formIdParamList = Lists.newArrayList();
|
||||
formIdParamList.add(employee_form_id);
|
||||
formIdParamList.add(formMap.get(Constants.EMPLOYEE_XXBGSQ));
|
||||
formIdParamList.add(formMap.get(Constants.UF_JCL_RZGL));
|
||||
formIdParamList.add(formMap.get(uf_jcl_employee_xxbgsq));
|
||||
formIdParamList.add(formMap.get(uf_jcl_rzgl));
|
||||
sql = "select id,group_name,form_id from form_field_group where form_id in ("+String.join(",",formIdParamList)+") and delete_type='0'";
|
||||
List<Map<String, Object>> fieldGroupList = databaseUtils.getSqlList(sql);
|
||||
Map<String,List<Map<String, Object>>> fieldGroupBy = fieldGroupList.stream().collect(Collectors.groupingBy(e->e.get("form_id").toString()));
|
||||
|
|
@ -224,17 +236,27 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
|
||||
@Override
|
||||
public List<String> synchronousFieldByEmployee(SimpleEmployee employee) {
|
||||
Map<String, String> uf_jcl_employee_information_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.EMPLOYEE_INFORMATION);
|
||||
String uf_jcl_employee_information = uf_jcl_employee_information_Info.get("table_name");
|
||||
|
||||
Map<String, String> uf_jcl_employee_xxbgsq_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.EMPLOYEE_XXBGSQ);
|
||||
String uf_jcl_employee_xxbgsq = uf_jcl_employee_xxbgsq_Info.get("table_name");
|
||||
|
||||
Map<String, String> uf_jcl_rzgl_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.UF_JCL_RZGL);
|
||||
String uf_jcl_rzgl = uf_jcl_rzgl_Info.get("table_name");
|
||||
|
||||
|
||||
List<String> paramList = Lists.newArrayList();
|
||||
paramList.add("'"+Constants.EMPLOYEE_INFORMATION+"'");
|
||||
paramList.add("'"+Constants.EMPLOYEE_XXBGSQ+"'");
|
||||
paramList.add("'"+Constants.UF_JCL_RZGL+"'");
|
||||
paramList.add("'"+uf_jcl_employee_information+"'");
|
||||
paramList.add("'"+uf_jcl_employee_xxbgsq+"'");
|
||||
paramList.add("'"+uf_jcl_rzgl+"'");
|
||||
String sql = "select form_id,table_name from form_table where table_name in ("+String.join(",",paramList)+") and delete_type='0'";
|
||||
Map<String,String> formMap = databaseUtils.getSqlList(sql).stream().collect(Collectors.toMap(e->e.get("table_name").toString(),e->e.get("form_id").toString()));
|
||||
String employee_form_id = formMap.get(Constants.EMPLOYEE_INFORMATION);
|
||||
String employee_form_id = formMap.get(uf_jcl_employee_information);
|
||||
|
||||
|
||||
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);
|
||||
sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo' and delete_type='0' and tenant_key=?";
|
||||
List<Map<String, Object>> personFormList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee.getTenantKey()));
|
||||
Map<String,String> personFormMap = personFormList.stream().collect(Collectors.toMap(e->e.get("module").toString(),e->e.get("id").toString()));
|
||||
//基本信息自定义字段表
|
||||
String personCustomfieldFormid=personFormMap.get("hrm");
|
||||
|
|
@ -244,8 +266,8 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
|
||||
List<String> formIdParamList = Lists.newArrayList();
|
||||
formIdParamList.add(employee_form_id);
|
||||
formIdParamList.add(formMap.get(Constants.EMPLOYEE_XXBGSQ));
|
||||
formIdParamList.add(formMap.get(Constants.UF_JCL_RZGL));
|
||||
formIdParamList.add(formMap.get(uf_jcl_employee_xxbgsq));
|
||||
formIdParamList.add(formMap.get(uf_jcl_rzgl));
|
||||
sql = "select id,group_name,form_id from form_field_group where form_id in ("+String.join(",",formIdParamList)+") and delete_type='0'";
|
||||
List<Map<String, Object>> fieldGroupList = databaseUtils.getSqlList(sql);
|
||||
Map<String,List<Map<String, Object>>> fieldGroupBy = fieldGroupList.stream().collect(Collectors.groupingBy(e->e.get("form_id").toString()));
|
||||
|
|
@ -354,17 +376,26 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
|
||||
@Override
|
||||
public List<String> synchronousFieldByHrm(SimpleEmployee employee) {
|
||||
Map<String, String> uf_jcl_employee_information_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.EMPLOYEE_INFORMATION);
|
||||
String uf_jcl_employee_information = uf_jcl_employee_information_Info.get("table_name");
|
||||
|
||||
Map<String, String> uf_jcl_employee_xxbgsq_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.EMPLOYEE_XXBGSQ);
|
||||
String uf_jcl_employee_xxbgsq = uf_jcl_employee_xxbgsq_Info.get("table_name");
|
||||
|
||||
Map<String, String> uf_jcl_rzgl_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.UF_JCL_RZGL);
|
||||
String uf_jcl_rzgl = uf_jcl_rzgl_Info.get("table_name");
|
||||
|
||||
List<String> paramList = Lists.newArrayList();
|
||||
paramList.add("'"+Constants.EMPLOYEE_INFORMATION+"'");
|
||||
paramList.add("'"+Constants.EMPLOYEE_XXBGSQ+"'");
|
||||
paramList.add("'"+Constants.UF_JCL_RZGL+"'");
|
||||
paramList.add("'"+uf_jcl_employee_information+"'");
|
||||
paramList.add("'"+uf_jcl_employee_xxbgsq+"'");
|
||||
paramList.add("'"+uf_jcl_rzgl+"'");
|
||||
String sql = "select form_id,table_name from form_table where table_name in ("+String.join(",",paramList)+") and delete_type='0'";
|
||||
Map<String,String> formMap = databaseUtils.getSqlList(sql).stream().collect(Collectors.toMap(e->e.get("table_name").toString(),e->e.get("form_id").toString()));
|
||||
String employee_form_id = formMap.get(Constants.EMPLOYEE_INFORMATION);
|
||||
String employee_form_id = formMap.get(uf_jcl_employee_information);
|
||||
|
||||
|
||||
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);
|
||||
sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo' and delete_type='0' and tenant_key=";
|
||||
List<Map<String, Object>> personFormList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee.getTenantKey()));
|
||||
Map<String,String> personFormMap = personFormList.stream().collect(Collectors.toMap(e->e.get("module").toString(),e->e.get("id").toString()));
|
||||
//基本信息自定义字段表
|
||||
String personCustomfieldFormid=personFormMap.get("hrm");
|
||||
|
|
@ -374,8 +405,8 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
|
||||
List<String> formIdParamList = Lists.newArrayList();
|
||||
formIdParamList.add(employee_form_id);
|
||||
formIdParamList.add(formMap.get(Constants.EMPLOYEE_XXBGSQ));
|
||||
formIdParamList.add(formMap.get(Constants.UF_JCL_RZGL));
|
||||
formIdParamList.add(formMap.get(uf_jcl_employee_xxbgsq));
|
||||
formIdParamList.add(formMap.get(uf_jcl_rzgl));
|
||||
sql = "select id,group_name,form_id from form_field_group where form_id in ("+String.join(",",formIdParamList)+") and delete_type='0'";
|
||||
List<Map<String, Object>> fieldGroupList = databaseUtils.getSqlList(sql);
|
||||
Map<String,List<Map<String, Object>>> fieldGroupBy = fieldGroupList.stream().collect(Collectors.groupingBy(e->e.get("form_id").toString()));
|
||||
|
|
@ -516,6 +547,15 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
*/
|
||||
public List<String> synchronousOurForm(Map<String,Object> param){
|
||||
|
||||
Map<String, String> uf_jcl_employee_information_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.EMPLOYEE_INFORMATION);
|
||||
String uf_jcl_employee_information = uf_jcl_employee_information_Info.get("table_name");
|
||||
|
||||
Map<String, String> uf_jcl_employee_xxbgsq_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.EMPLOYEE_XXBGSQ);
|
||||
String uf_jcl_employee_xxbgsq = uf_jcl_employee_xxbgsq_Info.get("table_name");
|
||||
|
||||
Map<String, String> uf_jcl_rzgl_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.UF_JCL_RZGL);
|
||||
String uf_jcl_rzgl = uf_jcl_rzgl_Info.get("table_name");
|
||||
|
||||
SimpleEmployee employee = (SimpleEmployee)param.get("employee");
|
||||
List<Map<Object, Object>> employeeFieldList = (List<Map<Object, Object>>)param.get("employeeFieldList");
|
||||
Map<String,List<Map<String, Object>>> fieldGroupBy = (Map<String,List<Map<String, Object>>>)param.get("fieldGroupBy");
|
||||
|
|
@ -531,7 +571,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
/**
|
||||
* 员工信息表所有字段
|
||||
*/
|
||||
Map<String,String> fieldGroup = fieldGroupBy.get(formMap.get(Constants.EMPLOYEE_INFORMATION)).stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString()));
|
||||
Map<String,String> fieldGroup = fieldGroupBy.get(formMap.get(uf_jcl_employee_information)).stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString()));
|
||||
|
||||
//员工信息主表-基本信息字段
|
||||
List<Map<Object, Object>> mainFormBasicFieldList = employeeFieldList.stream().filter(e->e.get("groupId").equals(fieldGroup.get(Constants.BASIC_INFORMATION)) && "".equals(CommonUtils.null2String(e.get("subFormId")))).collect(Collectors.toList());
|
||||
|
|
@ -547,10 +587,10 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
/**
|
||||
* 入职管理字段
|
||||
*/
|
||||
String hireManageMentId = CommonUtils.null2String(formMap.get(Constants.UF_JCL_RZGL));
|
||||
String hireManageMentId = CommonUtils.null2String(formMap.get(uf_jcl_rzgl));
|
||||
FieldManageParam ownEntity = getFieldManageParam(hireManageMentId,ModuleSource.ebuilderform);
|
||||
List<Map<Object, Object>> hireManageMentFieldList = getFieldList(ownEntity,employee);
|
||||
Map<String,String> hireManageMentFieldGroup = fieldGroupBy.get(formMap.get(Constants.UF_JCL_RZGL)).stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString()));
|
||||
Map<String,String> hireManageMentFieldGroup = fieldGroupBy.get(formMap.get(uf_jcl_rzgl)).stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString()));
|
||||
|
||||
|
||||
Map<String,Object> result1 = packageBatchSaveParamHaveDelete(hireManageMentFieldList,mainFormBasicFieldList,hireManageMentFieldGroup.get(Constants.BASIC_INFORMATION),null,employeeBasicFieldList,allSubFormList);
|
||||
|
|
@ -567,10 +607,10 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
/**
|
||||
* 信息变更字段
|
||||
*/
|
||||
String informationChangeId = CommonUtils.null2String(formMap.get(Constants.EMPLOYEE_XXBGSQ));
|
||||
String informationChangeId = CommonUtils.null2String(formMap.get(uf_jcl_employee_xxbgsq));
|
||||
FieldManageParam informationEntity = getFieldManageParam(informationChangeId,ModuleSource.ebuilderform);
|
||||
List<Map<Object, Object>> informationChangeFieldList = getFieldList(informationEntity,employee);
|
||||
Map<String,String> informationChangeFieldGroup = fieldGroupBy.get(formMap.get(Constants.EMPLOYEE_XXBGSQ)).stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString()));
|
||||
Map<String,String> informationChangeFieldGroup = fieldGroupBy.get(formMap.get(uf_jcl_employee_xxbgsq)).stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString()));
|
||||
|
||||
|
||||
Map<String,Object> informationChangeResult1 = packageBatchSaveParamHaveDelete(informationChangeFieldList,mainFormBasicFieldList,informationChangeFieldGroup.get(Constants.BASIC_INFORMATION),null,employeeBasicFieldList,allSubFormList);
|
||||
|
|
@ -587,12 +627,12 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
List<String> errorMessage = Lists.newArrayList();
|
||||
|
||||
//保存入职管理
|
||||
WeaResult<Map<String, Object>> result = batchSaveInformation(CommonUtils.null2String(formMap.get(Constants.UF_JCL_RZGL)),hireManageMentFieldList,detailFormDataList.get(formMap.get(Constants.UF_JCL_RZGL)),ModuleSource.ebuilderform,null,hireManageMentdeleteIds,employee,hireManageMentPersonAddForms);
|
||||
WeaResult<Map<String, Object>> result = batchSaveInformation(CommonUtils.null2String(formMap.get(uf_jcl_employee_xxbgsq)),hireManageMentFieldList,detailFormDataList.get(formMap.get(uf_jcl_employee_xxbgsq)),ModuleSource.ebuilderform,null,hireManageMentdeleteIds,employee,hireManageMentPersonAddForms);
|
||||
if (result.getCode() != 200){
|
||||
errorMessage.add("入职管理"+result.getMsg());
|
||||
}
|
||||
//保存信息变更
|
||||
WeaResult<Map<String, Object>> informationChangeResult = batchSaveInformation(CommonUtils.null2String(formMap.get(Constants.EMPLOYEE_XXBGSQ)),informationChangeFieldList,detailFormDataList.get(formMap.get(Constants.EMPLOYEE_XXBGSQ)),ModuleSource.ebuilderform,null,informationChangedeleteIds,employee,informationChangeAddForms);
|
||||
WeaResult<Map<String, Object>> informationChangeResult = batchSaveInformation(CommonUtils.null2String(formMap.get(uf_jcl_rzgl)),informationChangeFieldList,detailFormDataList.get(formMap.get(uf_jcl_rzgl)),ModuleSource.ebuilderform,null,informationChangedeleteIds,employee,informationChangeAddForms);
|
||||
if (informationChangeResult.getCode() != 200){
|
||||
errorMessage.add("信息变更申请表"+informationChangeResult.getMsg());
|
||||
}
|
||||
|
|
@ -883,6 +923,10 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
@Override
|
||||
public Map<String, Object> queryData(SimpleEmployee simpleEmployee,String tableName,String rootdata) {
|
||||
Map<String,Object> resultMap = Maps.newHashMap();
|
||||
if (tableName.equals("uf_jcl_employee_information")){
|
||||
Map<String, String> uf_jcl_employee_information_Info = recruitModuleUtils.getEbTableInfo("uf_jcl_employee_information_apptag", Constants.EMPLOYEE_INFORMATION);
|
||||
tableName = uf_jcl_employee_information_Info.get("table_name");
|
||||
}
|
||||
String sql = "select id,app_id,form_id from ebdf_obj where table_name='"+tableName+"' and delete_type='0'";
|
||||
List<Map<String, Object>> recordList = databaseUtils.getSqlList(sql);
|
||||
String objId = CommonUtils.null2String(recordList.get(0).get("id"));
|
||||
|
|
|
|||
|
|
@ -19,17 +19,17 @@ public class Constants {
|
|||
/**
|
||||
* 员工信息表
|
||||
*/
|
||||
public static final String EMPLOYEE_INFORMATION="uf_jcl_employee_information";
|
||||
public static final String EMPLOYEE_INFORMATION="uf_jcl_employee_information_tag";
|
||||
/**
|
||||
* 信息变更
|
||||
*/
|
||||
public static final String EMPLOYEE_XXBGSQ = "uf_jcl_employee_xxbgsq";
|
||||
public static final String EMPLOYEE_XXBGSQ = "uf_jcl_employee_xxbgsq_tag";
|
||||
|
||||
|
||||
/**
|
||||
* 入职管理
|
||||
*/
|
||||
public static final String UF_JCL_RZGL="uf_jcl_rzgl";
|
||||
public static final String UF_JCL_RZGL="uf_jcl_rzgl_tag";
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,323 @@
|
|||
package com.weaver.jucailin.organization.util;
|
||||
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.alibaba.nacos.common.utils.MapUtils;
|
||||
import com.weaver.common.authority.service.AuthorityService;
|
||||
import com.weaver.common.baseserver.info.BaseEnvInfoService;
|
||||
import com.weaver.common.ln.util.TimeUtil;
|
||||
import com.weaver.ebuilder.form.client.entity.obj.Obj;
|
||||
import com.weaver.ebuilder.form.client.service.obj.RemoteEBObjService;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import com.weaver.framework.rpc.context.impl.TenantRpcContext;
|
||||
import com.weaver.teams.api.tenant.Tenant;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import com.weaver.teams.security.context.TenantContext;
|
||||
import com.weaver.teams.security.context.UserContext;
|
||||
import com.weaver.utils.SentinelEnvUntil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author: xuxy
|
||||
* @createDate: 2025/6/3
|
||||
* @description: 模块业务数据工具类, 和业务有关
|
||||
*/
|
||||
@Component
|
||||
public class RecruitModuleUtils {
|
||||
/**
|
||||
* 静态变量的注入方法注意写法不同。
|
||||
*/
|
||||
|
||||
private static BaseEnvInfoService baseEnvInfoService;
|
||||
|
||||
private static AuthorityService authorityService;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RecruitModuleUtils.class);
|
||||
|
||||
@RpcReference(group = "ebuilderform")
|
||||
RemoteEBObjService remoteEBObjService;
|
||||
@Autowired
|
||||
public void setBaseEnvInfoService(BaseEnvInfoService baseEnvInfoService) {
|
||||
RecruitModuleUtils.baseEnvInfoService = baseEnvInfoService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setAuthorityService(AuthorityService authorityService) {
|
||||
RecruitModuleUtils.authorityService = authorityService;
|
||||
}
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RecruitModuleUtils.class);
|
||||
|
||||
/**
|
||||
* 获取当前用户id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Long getCurrentUserId() {
|
||||
SimpleEmployee simpleEmployee = getCurrentUser();
|
||||
if (!Objects.isNull(simpleEmployee)) {
|
||||
return getCurrentUser().getId();
|
||||
}
|
||||
return Convert.toLong(TenantRpcContext.getCurrentEmployeeId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static SimpleEmployee getCurrentUser() {
|
||||
return UserContext.getCurrentUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getCurrentUserIdStr() {
|
||||
return Convert.toStr(getCurrentUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前租户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Tenant getCurrentTenant() {
|
||||
return TenantContext.getCurrentTenant();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前租户 key
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getCurrentTenantKey() {
|
||||
Tenant tenant = TenantContext.getCurrentTenant();
|
||||
if (tenant == null) {
|
||||
String tenantKey = TenantRpcContext.getTenantKey();
|
||||
LOGGER.info("无法获取租户,改为取rpc租户信息:{}", tenantKey);
|
||||
return tenantKey;
|
||||
}
|
||||
return tenant.getTenantKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前租户 key
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getCurrentTenantKeyNoLog() {
|
||||
Tenant tenant = TenantContext.getCurrentTenant();
|
||||
if (tenant == null) {
|
||||
String tenantKey = TenantRpcContext.getTenantKey();
|
||||
return tenantKey;
|
||||
}
|
||||
return tenant.getTenantKey();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 是否启用微搜模块
|
||||
*
|
||||
* @param tenantKey
|
||||
* @return
|
||||
*/
|
||||
public static boolean isESDisplayModule(String tenantKey) {
|
||||
LOGGER.info("是否启用微搜模块" + tenantKey);
|
||||
return isDisplayModule("esearch", tenantKey);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定租户下指定模块是否为展示模块
|
||||
*
|
||||
* @param module 模块标识
|
||||
* @param tenantKey 租户识别码
|
||||
* @return 模块是否展示 true:展示,false:不展示
|
||||
*/
|
||||
public static boolean isDisplayModule(String module, String tenantKey) {
|
||||
try {
|
||||
//线上风险应急措施,如果上线之后调用api 有问题时,配置下sentinel.modules.check=false (默认为true)
|
||||
if (!SentinelEnvUntil.isEnabledModules()) {
|
||||
return true;
|
||||
}
|
||||
boolean isOpen = baseEnvInfoService.checkDisplayModule(module, tenantKey);
|
||||
LOGGER.info("---判断模块是否启用---module:" + module + "---tenantKey:" + tenantKey + "---isOpen:" + isOpen);
|
||||
return isOpen;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("isDisplayModule 接口异常", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// public static List<Long> getSalaryManagers(String roleIds, String tenantKey) {
|
||||
// //获取招聘-查看薪资权限
|
||||
// if (StringUtils.isBlank(roleIds)) {
|
||||
// roleIds = "874501495305977857";
|
||||
// }
|
||||
//
|
||||
// LOGGER.info("招聘管理员角色Id。RCRT_ROLE_MANAGER={}", roleIds);
|
||||
// List<Long> managers = authorityService.getRoleAllUser(RecruitConvertUtil.strToList(roleIds), tenantKey);
|
||||
// LOGGER.info("招聘管理员。RCRT_ROLE_MANAGER={},tenantKey={},managers={}", roleIds, tenantKey,
|
||||
// JSON.toJSONString(managers));
|
||||
// return managers;
|
||||
// }
|
||||
|
||||
|
||||
public static void removeRPCContext() {
|
||||
TenantRpcContext.removeTargetTenantKey();
|
||||
TenantRpcContext.removeTargetEmployeeId();
|
||||
TenantRpcContext.removeAttachmentTenantKey();
|
||||
}
|
||||
|
||||
|
||||
public static List<String> allToUnderline(List<String> strings) {
|
||||
return strings.stream()
|
||||
.map(StrUtil::toUnderlineCase)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据出生日期计算年龄-暂时废弃,由eb函数公式自行计算
|
||||
*/
|
||||
public static Integer calculateAgeByDateStr(Object birthday) {
|
||||
if (!(birthday instanceof String)) {
|
||||
return null;
|
||||
}
|
||||
if (StringUtils.isBlank((String) birthday)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Calendar nowCalendar = Calendar.getInstance();
|
||||
nowCalendar.setTime(new Date());
|
||||
Calendar birthdayCalendar = Calendar.getInstance();
|
||||
Date birthdayDate = TimeUtil.getString2Date((String) birthday, "yyyy-MM-dd");
|
||||
birthdayCalendar.setTime(birthdayDate);
|
||||
return (Integer) (nowCalendar.get(Calendar.YEAR) - birthdayCalendar.get(Calendar.YEAR));
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("计算年龄异常", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void logError(String format, Object... o) {
|
||||
LOGGER.error(format, o);
|
||||
}
|
||||
|
||||
public static void logError(Logger logger, String info, Exception e) {
|
||||
logger.error(info, e);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 排除Eb系统字段
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public static Map removeEBSysField(Map map) {
|
||||
if (MapUtils.isNotEmpty(map)) {
|
||||
map.remove("id");//移除拷贝来的系统字段
|
||||
map.remove("form_data_id");
|
||||
map.remove("data_status");
|
||||
map.remove("creator");
|
||||
map.remove("create_time");
|
||||
map.remove("updater");
|
||||
map.remove("update_time");
|
||||
map.remove("obj_id");
|
||||
map.remove("name");
|
||||
|
||||
//对应驼峰
|
||||
map.remove("formDataId");
|
||||
map.remove("createTime");
|
||||
map.remove("updateTime");
|
||||
map.remove("objId");
|
||||
map.remove("dataStatus");
|
||||
map.remove("uniqueKey");
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据应用标签和租户key获取当前租户下对应标签的应用
|
||||
*/
|
||||
public String getEbAppId(String appTag){
|
||||
String appId = "";
|
||||
String sql = "select id from ebda_app where tag = '"+appTag+"' and tenant_key = '" + RecruitModuleUtils.getCurrentTenantKey()+"'";
|
||||
log.error("getEbAppId.sql:{}", sql);
|
||||
Map<String, Object> rs = databaseUtils.execute("LOGIC", "weaver-ebuilder-form-service", sql);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(rs);
|
||||
log.error("getEbAppId.recordList:{}", recordList);
|
||||
if(CollectionUtils.isNotEmpty(recordList)){
|
||||
appId = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
log.error("getEbAppId.appId:{}", appId);
|
||||
return appId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据应用id和表单tag获取当前租户下对应表单id和表名
|
||||
*/
|
||||
public Map<String,String> getEbTableInfo(String appTag,String objTag){
|
||||
Map<String,String> map = new HashMap<>();
|
||||
String appId = getEbAppId(appTag);
|
||||
log.error("getEbTableName.appId:{}", appId);
|
||||
String sql = "select id, table_name from ebdf_obj where tag = '"+objTag+"' and tenant_key = '"+RecruitModuleUtils.getCurrentTenantKey()+"' and app_id = "+appId;
|
||||
log.error("getEbTableName.sql:{}", sql);
|
||||
Map<String, Object> rs = databaseUtils.execute("LOGIC", "weaver-ebuilder-form-service", sql);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(rs);
|
||||
log.error("getEbTableName.recordList:{}", recordList);
|
||||
if(CollectionUtils.isNotEmpty(recordList)){
|
||||
String objId = String.valueOf(recordList.get(0).get("id"));
|
||||
String table_name = String.valueOf(recordList.get(0).get("table_name"));
|
||||
map.put("objId",objId);
|
||||
map.put("table_name",table_name);
|
||||
}
|
||||
log.error("getEbTableName.map:{}", map);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取明细表名称
|
||||
* @param objId
|
||||
* @param originTableName
|
||||
* @return
|
||||
*/
|
||||
public String getDetailTableNameByMasterId(long objId, String originTableName) {
|
||||
List<Obj> detailForms = remoteEBObjService.getAllTablesByMasterId(objId, RecruitModuleUtils.getCurrentTenantKey());
|
||||
log.info("getDetailTableNameByMasterId.detailForms:{}",detailForms);
|
||||
if (CollectionUtils.isEmpty(detailForms)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String tableName = null;
|
||||
for (Obj obj : detailForms) {
|
||||
//DataKey不为空的才是明细表
|
||||
if (StringUtils.isEmpty(obj.getDataKey())) {
|
||||
continue;
|
||||
}
|
||||
if (obj.getTableName().startsWith(originTableName)) {
|
||||
tableName = obj.getTableName();
|
||||
}
|
||||
}
|
||||
log.info("getDetailTableNameByMasterId.tableName:{}",tableName);
|
||||
return tableName;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue