You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
3.7 KiB
Java
120 lines
3.7 KiB
Java
package com.engine.organization.util.relation;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.engine.organization.entity.company.po.CompPO;
|
|
import com.engine.organization.entity.department.po.DepartmentPO;
|
|
import com.engine.organization.entity.job.po.JobPO;
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
|
import com.engine.organization.mapper.hrmresource.SystemDataMapper;
|
|
import com.engine.organization.mapper.job.JobMapper;
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author:dxfeng
|
|
* @createTime: 2022/07/13
|
|
* @version: 1.0
|
|
*/
|
|
public class EcHrmRelationUtil {
|
|
|
|
private static final String HRM_COMPANY = "hrmsubcompany";
|
|
private static final String HRM_DEPARTMENT = "hrmdepartment";
|
|
|
|
|
|
private static SystemDataMapper getSystemDataMapper() {
|
|
return MapperProxyFactory.getProxy(SystemDataMapper.class);
|
|
}
|
|
|
|
private static CompMapper getCompMapper() {
|
|
return MapperProxyFactory.getProxy(CompMapper.class);
|
|
}
|
|
|
|
private static DepartmentMapper getDepartmentMapper() {
|
|
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
|
}
|
|
|
|
private static JobMapper getJobMapper() {
|
|
return MapperProxyFactory.getProxy(JobMapper.class);
|
|
}
|
|
|
|
/**
|
|
* 根据jcl_org_comp.id获取HrmSubCompany.id
|
|
*
|
|
* @param companyId
|
|
* @return
|
|
*/
|
|
public static String getEcCompanyId(String companyId) {
|
|
CompPO compPO = getCompMapper().listById(Long.parseLong(companyId));
|
|
JSONObject supSubCompany = getSystemDataMapper().getHrmObjectByUUID(HRM_COMPANY, compPO.getUuid());
|
|
return supSubCompany.getString("id");
|
|
}
|
|
|
|
/**
|
|
* 根据jcl_org_dept.id获取HrmDepartment.id
|
|
*
|
|
* @param departmentId
|
|
* @return
|
|
*/
|
|
public static String getEcDepartmentId(String departmentId) {
|
|
DepartmentPO departmentPO = getDepartmentMapper().getDeptById(Long.parseLong(departmentId));
|
|
JSONObject supDepartment = getSystemDataMapper().getHrmObjectByUUID(HRM_DEPARTMENT, departmentPO.getUuid());
|
|
return supDepartment.getString("id");
|
|
}
|
|
|
|
public static CompPO getJclCompanyId(String ecCompanyId) {
|
|
if (StringUtils.isBlank(ecCompanyId)) {
|
|
return null;
|
|
}
|
|
JSONObject ecCompany = getSystemDataMapper().getHrmObjectByID(HRM_COMPANY, ecCompanyId);
|
|
if (null == ecCompany) {
|
|
return null;
|
|
}
|
|
String uuid = ecCompany.getString("uuid");
|
|
return getCompMapper().getCompanyByUUID(uuid);
|
|
}
|
|
|
|
|
|
public static DepartmentPO getJclDepartmentId(String ecDepartmentId) {
|
|
if (StringUtils.isBlank(ecDepartmentId)) {
|
|
return null;
|
|
}
|
|
JSONObject ecDepartment = getSystemDataMapper().getHrmObjectByID(HRM_DEPARTMENT, ecDepartmentId);
|
|
if (null == ecDepartment) {
|
|
return null;
|
|
}
|
|
String uuid = ecDepartment.getString("uuid");
|
|
return getDepartmentMapper().getDepartmentByUUID(uuid);
|
|
}
|
|
|
|
|
|
/**
|
|
* 判断岗位名称是否共用
|
|
* <p>存在返回true</p>
|
|
*
|
|
* @param jobName
|
|
* @param id
|
|
* @return
|
|
*/
|
|
public static boolean isExistJob(String jobName, Long id) {
|
|
List<JobPO> jobPOS = getJobMapper().listByNameExceptId(jobName, id);
|
|
return CollectionUtils.isNotEmpty(jobPOS);
|
|
}
|
|
|
|
/**
|
|
* 判断岗位名称是否共用
|
|
* <p>不存在返回true</p>
|
|
*
|
|
* @param jobName
|
|
* @param id
|
|
* @return
|
|
*/
|
|
public static boolean isNotExistJob(String jobName, Long id) {
|
|
return !isExistJob(jobName, id);
|
|
}
|
|
|
|
}
|