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.
weaver-hrm-organization/src/com/engine/organization/util/detach/DetachUtil.java

85 lines
2.6 KiB
Java

3 years ago
package com.engine.organization.util.detach;
import com.engine.organization.entity.company.po.CompPO;
3 years ago
import com.engine.organization.entity.department.po.DepartmentPO;
import com.engine.organization.entity.job.dto.JobListDTO;
3 years ago
import com.engine.organization.entity.job.po.JobPO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.hrm.User;
import weaver.hrm.moduledetach.ManageDetachComInfo;
3 years ago
import java.util.ArrayList;
3 years ago
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
3 years ago
/**
* @author:dxfeng
* @createTime: 2022/10/28
* @version: 1.0
*/
public class DetachUtil {
private boolean DETACH;
3 years ago
private List<Integer> jclRoleLevels = new ArrayList<>();
3 years ago
public DetachUtil(User user) {
ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
DETACH = manageDetachComInfo.isUseManageDetach();
if (1 == user.getUID()) {
DETACH = false;
}
if (DETACH) {
String detachableSubCompanyIds = manageDetachComInfo.getDetachableSubcompanyIds(user);
if (StringUtils.isNotBlank(detachableSubCompanyIds)) {
jclRoleLevels = Stream.of(detachableSubCompanyIds.split(",")).map(Integer::parseInt).collect(Collectors.toList());
}
}
3 years ago
}
/**
*
*/
public void filterCompanyList(List<CompPO> companyList) {
if (DETACH && CollectionUtils.isNotEmpty(companyList)) {
companyList.removeIf(item -> !jclRoleLevels.contains(item.getId()));
3 years ago
}
}
/**
*
*/
public void filterDepartmentList(List<DepartmentPO> departmentList) {
if (DETACH && CollectionUtils.isNotEmpty(departmentList)) {
departmentList.removeIf(item -> !jclRoleLevels.contains(item.getSubCompanyId1()));
}
}
/**
*
*/
public void filterJobDTOList(List<JobListDTO> jobList) {
if (DETACH && CollectionUtils.isNotEmpty(jobList)) {
jobList.removeIf(item -> !jclRoleLevels.contains(item.getEcCompany()));
3 years ago
}
}
/**
*
*/
public void filterJobList(List<JobPO> jobList) {
if (DETACH && CollectionUtils.isNotEmpty(jobList)) {
jobList.removeIf(item -> !jclRoleLevels.contains(item.getEcCompany()));
3 years ago
}
}
public String getJclRoleLevels() {
return StringUtils.join(jclRoleLevels, ",");
}
public boolean isDETACH() {
return DETACH;
}
3 years ago
}