mirror of https://gitee.com/stylefeng/roses
【8.3.3】【org】从新整理通用树形的接口
parent
179f0930f7
commit
8cb191fc0c
|
@ -0,0 +1,139 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.org.factory;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.stylefeng.roses.kernel.db.mp.datascope.config.DataScopeConfig;
|
||||||
|
import cn.stylefeng.roses.kernel.db.mp.datascope.holder.DataScopeHolder;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.enums.org.OrgTypeEnum;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.CommonOrgTreeRequest;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.HrOrganizationRequest;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.org.service.HrOrganizationService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织机构查询相关的条件组装
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2025/1/26 20:00
|
||||||
|
*/
|
||||||
|
public class OrgConditionFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 针对通用组织机构树查询,组装一些通用的查询条件
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2025/1/26 20:00
|
||||||
|
*/
|
||||||
|
public static void prepareRequest(CommonOrgTreeRequest commonOrgTreeRequest) {
|
||||||
|
|
||||||
|
// 获取数据范围的信息,如果数据范围是包含全部数据,则将parentId设置为-1
|
||||||
|
DataScopeConfig dataScopeConfig = DataScopeHolder.get();
|
||||||
|
if (dataScopeConfig == null || dataScopeConfig.isTotalDataScope()) {
|
||||||
|
if (commonOrgTreeRequest.getOrgParentId() == null) {
|
||||||
|
commonOrgTreeRequest.setOrgParentId(TreeConstants.DEFAULT_PARENT_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果查询带组织机构名称的搜索,则清空其他条件
|
||||||
|
if (ObjectUtil.isNotEmpty(commonOrgTreeRequest.getSearchText())) {
|
||||||
|
commonOrgTreeRequest.setOrgParentId(null);
|
||||||
|
commonOrgTreeRequest.setIndexOrgIdList(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果查询待组织机构的状态信息,则清空parentId
|
||||||
|
if (ObjectUtil.isNotEmpty(commonOrgTreeRequest.getIndexOrgIdList())) {
|
||||||
|
commonOrgTreeRequest.setOrgParentId(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建查询组织机构树的Wrapper
|
||||||
|
* <p>
|
||||||
|
* 根据父级id、定位id、公司筛选标识等查询条件进行查询
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2025/1/26 20:13
|
||||||
|
*/
|
||||||
|
public static LambdaQueryWrapper<HrOrganization> createCommonTreeWrapper(CommonOrgTreeRequest commonOrgTreeRequest, HrOrganizationService hrOrganizationService) {
|
||||||
|
|
||||||
|
// 创建基本的wrapper
|
||||||
|
HrOrganizationRequest hrOrganizationRequest = new HrOrganizationRequest();
|
||||||
|
hrOrganizationRequest.setSearchText(commonOrgTreeRequest.getSearchText());
|
||||||
|
LambdaQueryWrapper<HrOrganization> queryWrapper = OrgConditionFactory.createWrapper(hrOrganizationRequest);
|
||||||
|
|
||||||
|
// 如果查询条件有orgId,则查询指定机构下的子机构
|
||||||
|
Long parentId = commonOrgTreeRequest.getOrgParentId();
|
||||||
|
if (parentId != null) {
|
||||||
|
queryWrapper.eq(HrOrganization::getOrgParentId, parentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果有定位状态的组织机构,则需要查询到定位的组织机构的所有子一级
|
||||||
|
Set<Long> indexOrgIdList = commonOrgTreeRequest.getIndexOrgIdList();
|
||||||
|
if (ObjectUtil.isNotEmpty(indexOrgIdList)) {
|
||||||
|
Set<Long> parentIdListTotal = hrOrganizationService.queryOrgIdParentIdList(indexOrgIdList);
|
||||||
|
if (ObjectUtil.isNotEmpty(parentIdListTotal)) {
|
||||||
|
queryWrapper.in(HrOrganization::getOrgParentId, parentIdListTotal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果有筛选公司的标识,则只查询公司列表
|
||||||
|
Boolean companySearchFlag = commonOrgTreeRequest.getCompanySearchFlag();
|
||||||
|
if (ObjectUtil.isNotEmpty(companySearchFlag) && companySearchFlag) {
|
||||||
|
queryWrapper.eq(HrOrganization::getOrgType, OrgTypeEnum.COMPANY.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 只查询启用状态的机构
|
||||||
|
queryWrapper.eq(HrOrganization::getStatusFlag, StatusEnum.ENABLE.getCode());
|
||||||
|
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建通用查询Wrapper
|
||||||
|
* <p>
|
||||||
|
* 根据名称、状态、指定机构id等参数
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2025/1/26 20:20
|
||||||
|
*/
|
||||||
|
public static LambdaQueryWrapper<HrOrganization> createWrapper(HrOrganizationRequest hrOrganizationRequest) {
|
||||||
|
LambdaQueryWrapper<HrOrganization> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
// 如果按文本查询条件不为空,则判断组织机构名称、简称、税号、备注是否有匹配
|
||||||
|
String searchText = hrOrganizationRequest.getSearchText();
|
||||||
|
if (StrUtil.isNotEmpty(searchText)) {
|
||||||
|
queryWrapper.nested(wrap -> {
|
||||||
|
wrap.like(HrOrganization::getOrgName, searchText);
|
||||||
|
wrap.or().like(HrOrganization::getOrgShortName, searchText);
|
||||||
|
wrap.or().like(HrOrganization::getTaxNo, searchText);
|
||||||
|
wrap.or().like(HrOrganization::getOrgCode, searchText);
|
||||||
|
wrap.or().like(HrOrganization::getRemark, searchText);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据机构状态查询
|
||||||
|
Integer statusFlag = hrOrganizationRequest.getStatusFlag();
|
||||||
|
queryWrapper.eq(ObjectUtil.isNotNull(statusFlag), HrOrganization::getStatusFlag, statusFlag);
|
||||||
|
|
||||||
|
// 如果查询条件有orgId,则查询指定机构下的子机构
|
||||||
|
Long orgId = hrOrganizationRequest.getOrgId();
|
||||||
|
if (orgId != null) {
|
||||||
|
// 查询orgId对应的所有子机构,包含本orgId
|
||||||
|
queryWrapper.nested(wrap -> {
|
||||||
|
wrap.eq(HrOrganization::getOrgParentId, orgId).or().eq(HrOrganization::getOrgId, orgId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据排序正序查询
|
||||||
|
queryWrapper.orderByAsc(HrOrganization::getOrgSort);
|
||||||
|
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package cn.stylefeng.roses.kernel.sys.modular.org.pojo.request;
|
package cn.stylefeng.roses.kernel.sys.modular.org.pojo.request;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||||
import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
|
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -26,7 +25,7 @@ public class CommonOrgTreeRequest extends BaseRequest {
|
||||||
* 不传此参数,则默认查询所有一级的结构
|
* 不传此参数,则默认查询所有一级的结构
|
||||||
*/
|
*/
|
||||||
@ChineseDescription("父级id,一级节点父id是-1")
|
@ChineseDescription("父级id,一级节点父id是-1")
|
||||||
private Long orgParentId = TreeConstants.DEFAULT_PARENT_ID;
|
private Long orgParentId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定位组织机构状态的组织机构id集合
|
* 定位组织机构状态的组织机构id集合
|
||||||
|
|
|
@ -38,6 +38,7 @@ import cn.stylefeng.roses.kernel.sys.api.pojo.org.HrOrganizationDTO;
|
||||||
import cn.stylefeng.roses.kernel.sys.api.pojo.org.OrganizationLevelRequest;
|
import cn.stylefeng.roses.kernel.sys.api.pojo.org.OrganizationLevelRequest;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.org.constants.OrgConstants;
|
import cn.stylefeng.roses.kernel.sys.modular.org.constants.OrgConstants;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization;
|
import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.org.factory.OrgConditionFactory;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.org.factory.OrganizationFactory;
|
import cn.stylefeng.roses.kernel.sys.modular.org.factory.OrganizationFactory;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.org.mapper.HrOrganizationMapper;
|
import cn.stylefeng.roses.kernel.sys.modular.org.mapper.HrOrganizationMapper;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.CommonOrgTreeRequest;
|
import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.CommonOrgTreeRequest;
|
||||||
|
@ -63,7 +64,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.stylefeng.roses.kernel.rule.constants.SymbolConstant.LEFT_SQUARE_BRACKETS;
|
import static cn.stylefeng.roses.kernel.rule.constants.SymbolConstant.LEFT_SQUARE_BRACKETS;
|
||||||
import static cn.stylefeng.roses.kernel.rule.constants.SymbolConstant.RIGHT_SQUARE_BRACKETS;
|
import static cn.stylefeng.roses.kernel.rule.constants.SymbolConstant.RIGHT_SQUARE_BRACKETS;
|
||||||
import static java.util.stream.Collectors.toCollection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织机构信息业务实现层
|
* 组织机构信息业务实现层
|
||||||
|
@ -200,14 +200,14 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HrOrganization> findList(HrOrganizationRequest hrOrganizationRequest) {
|
public List<HrOrganization> findList(HrOrganizationRequest hrOrganizationRequest) {
|
||||||
LambdaQueryWrapper<HrOrganization> wrapper = this.createWrapper(hrOrganizationRequest);
|
LambdaQueryWrapper<HrOrganization> wrapper = OrgConditionFactory.createWrapper(hrOrganizationRequest);
|
||||||
return this.list(wrapper);
|
return this.list(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DataScope(userIdFieldName = "create_user")
|
@DataScope(userIdFieldName = "create_user")
|
||||||
public PageResult<HrOrganization> findPage(HrOrganizationRequest hrOrganizationRequest) {
|
public PageResult<HrOrganization> findPage(HrOrganizationRequest hrOrganizationRequest) {
|
||||||
LambdaQueryWrapper<HrOrganization> wrapper = createWrapper(hrOrganizationRequest);
|
LambdaQueryWrapper<HrOrganization> wrapper = OrgConditionFactory.createWrapper(hrOrganizationRequest);
|
||||||
|
|
||||||
// 只查询需要的字段
|
// 只查询需要的字段
|
||||||
wrapper.select(HrOrganization::getOrgId, HrOrganization::getOrgName, HrOrganization::getOrgCode, HrOrganization::getStatusFlag,
|
wrapper.select(HrOrganization::getOrgId, HrOrganization::getOrgName, HrOrganization::getOrgCode, HrOrganization::getStatusFlag,
|
||||||
|
@ -238,7 +238,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
|
|
||||||
// 只查询未禁用的组织机构
|
// 只查询未禁用的组织机构
|
||||||
hrOrganizationRequest.setStatusFlag(StatusEnum.ENABLE.getCode());
|
hrOrganizationRequest.setStatusFlag(StatusEnum.ENABLE.getCode());
|
||||||
LambdaQueryWrapper<HrOrganization> wrapper = createWrapper(hrOrganizationRequest);
|
LambdaQueryWrapper<HrOrganization> wrapper = OrgConditionFactory.createWrapper(hrOrganizationRequest);
|
||||||
|
|
||||||
// 只查询需要的字段
|
// 只查询需要的字段
|
||||||
wrapper.select(HrOrganization::getOrgId, HrOrganization::getOrgName, HrOrganization::getOrgCode, HrOrganization::getOrgType,
|
wrapper.select(HrOrganization::getOrgId, HrOrganization::getOrgName, HrOrganization::getOrgCode, HrOrganization::getOrgType,
|
||||||
|
@ -262,62 +262,29 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
@DataScope(userIdFieldName = "create_user")
|
@DataScope(userIdFieldName = "create_user")
|
||||||
public CommonOrgTreeResponse commonOrgTree(CommonOrgTreeRequest commonOrgTreeRequest) {
|
public CommonOrgTreeResponse commonOrgTree(CommonOrgTreeRequest commonOrgTreeRequest) {
|
||||||
|
|
||||||
// 如果查询带组织机构名称的搜索,则清空其他条件
|
// 预填充一些查询参数
|
||||||
if (ObjectUtil.isNotEmpty(commonOrgTreeRequest.getSearchText())) {
|
OrgConditionFactory.prepareRequest(commonOrgTreeRequest);
|
||||||
commonOrgTreeRequest.setOrgParentId(null);
|
|
||||||
commonOrgTreeRequest.setIndexOrgIdList(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果查询待组织机构的状态信息,则清空parentId
|
|
||||||
if (ObjectUtil.isNotEmpty(commonOrgTreeRequest.getIndexOrgIdList())) {
|
|
||||||
commonOrgTreeRequest.setOrgParentId(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据条件查询组织机构列表
|
// 根据条件查询组织机构列表
|
||||||
LambdaQueryWrapper<HrOrganization> wrapper = this.createCommonTreeWrapper(commonOrgTreeRequest);
|
LambdaQueryWrapper<HrOrganization> wrapper = OrgConditionFactory.createCommonTreeWrapper(commonOrgTreeRequest, this);
|
||||||
wrapper.select(HrOrganization::getOrgId, HrOrganization::getOrgPids, HrOrganization::getOrgParentId, HrOrganization::getOrgName,
|
wrapper.select(HrOrganization::getOrgId, HrOrganization::getOrgPids, HrOrganization::getOrgParentId, HrOrganization::getOrgName,
|
||||||
HrOrganization::getOrgSort, HrOrganization::getOrgType);
|
HrOrganization::getOrgSort, HrOrganization::getOrgType);
|
||||||
List<HrOrganization> hrOrganizationList = this.list(wrapper);
|
List<HrOrganization> hrOrganizationList = this.list(wrapper);
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(hrOrganizationList)) {
|
if (ObjectUtil.isEmpty(hrOrganizationList)) {
|
||||||
return new CommonOrgTreeResponse(hrOrganizationList, new ArrayList<>());
|
return new CommonOrgTreeResponse(hrOrganizationList, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果查询条件不为空,则把相关的查询结果的父级也查询出来,组成一颗完整树
|
|
||||||
String searchText = commonOrgTreeRequest.getSearchText();
|
|
||||||
List<HrOrganization> parentOrgList = new ArrayList<>();
|
|
||||||
if (ObjectUtil.isNotEmpty(searchText)) {
|
|
||||||
Set<Long> orgParentIdList = OrganizationFactory.getOrgParentIdList(hrOrganizationList);
|
|
||||||
LambdaQueryWrapper<HrOrganization> parentWrapper = new LambdaQueryWrapper<>();
|
|
||||||
parentWrapper.in(HrOrganization::getOrgId, orgParentIdList);
|
|
||||||
parentOrgList = this.list(parentWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 合并两个集合
|
|
||||||
hrOrganizationList.addAll(parentOrgList);
|
|
||||||
|
|
||||||
// 去重
|
|
||||||
List<HrOrganization> newNotRepeatList = hrOrganizationList.stream().collect(
|
|
||||||
Collectors.collectingAndThen(toCollection(() -> new TreeSet<>(Comparator.comparing(HrOrganization::getOrgId))),
|
|
||||||
LinkedList::new));
|
|
||||||
|
|
||||||
// 从新排序,根据sort字段排序
|
|
||||||
newNotRepeatList.sort(Comparator.comparing(HrOrganization::getOrgSort));
|
|
||||||
|
|
||||||
// 构建树形结构
|
// 构建树形结构
|
||||||
if (ObjectUtil.isNotEmpty(commonOrgTreeRequest.getSearchText()) || ObjectUtil.isNotEmpty(
|
hrOrganizationList = new SortedTreeBuildFactory<HrOrganization>().doTreeBuild(hrOrganizationList);
|
||||||
commonOrgTreeRequest.getIndexOrgIdList())) {
|
|
||||||
newNotRepeatList = new SortedTreeBuildFactory<HrOrganization>().doTreeBuild(newNotRepeatList);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 遍历所有节点,查询这些节点有没有子级,填充haveSubOrgFlag
|
// 遍历所有节点,查询这些节点有没有子级,填充haveSubOrgFlag
|
||||||
this.fillHaveSubFlag(newNotRepeatList);
|
this.fillHaveSubFlag(hrOrganizationList);
|
||||||
|
|
||||||
// 遍历这些节点,如果有children的,都展开,并搜集到数组里
|
// 遍历这些节点,如果有children的,都展开,并搜集到数组里
|
||||||
List<Long> expandOrgIds = new ArrayList<>();
|
List<Long> expandOrgIds = new ArrayList<>();
|
||||||
this.fillExpandFlag(newNotRepeatList, expandOrgIds);
|
this.fillExpandFlag(hrOrganizationList, expandOrgIds);
|
||||||
|
|
||||||
return new CommonOrgTreeResponse(newNotRepeatList, expandOrgIds);
|
return new CommonOrgTreeResponse(hrOrganizationList, expandOrgIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -711,46 +678,6 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
return hrOrganization;
|
return hrOrganization;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建查询wrapper
|
|
||||||
*
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2023/06/10 21:23
|
|
||||||
*/
|
|
||||||
private LambdaQueryWrapper<HrOrganization> createWrapper(HrOrganizationRequest hrOrganizationRequest) {
|
|
||||||
LambdaQueryWrapper<HrOrganization> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
|
|
||||||
// 如果按文本查询条件不为空,则判断组织机构名称、简称、税号、备注是否有匹配
|
|
||||||
String searchText = hrOrganizationRequest.getSearchText();
|
|
||||||
if (StrUtil.isNotEmpty(searchText)) {
|
|
||||||
queryWrapper.nested(wrap -> {
|
|
||||||
wrap.like(HrOrganization::getOrgName, searchText);
|
|
||||||
wrap.or().like(HrOrganization::getOrgShortName, searchText);
|
|
||||||
wrap.or().like(HrOrganization::getTaxNo, searchText);
|
|
||||||
wrap.or().like(HrOrganization::getOrgCode, searchText);
|
|
||||||
wrap.or().like(HrOrganization::getRemark, searchText);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据机构状态查询
|
|
||||||
Integer statusFlag = hrOrganizationRequest.getStatusFlag();
|
|
||||||
queryWrapper.eq(ObjectUtil.isNotNull(statusFlag), HrOrganization::getStatusFlag, statusFlag);
|
|
||||||
|
|
||||||
// 如果查询条件有orgId,则查询指定机构下的子机构
|
|
||||||
Long orgId = hrOrganizationRequest.getOrgId();
|
|
||||||
if (orgId != null) {
|
|
||||||
// 查询orgId对应的所有子机构,包含本orgId
|
|
||||||
queryWrapper.nested(wrap -> {
|
|
||||||
wrap.eq(HrOrganization::getOrgParentId, orgId).or().eq(HrOrganization::getOrgId, orgId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据排序正序查询
|
|
||||||
queryWrapper.orderByAsc(HrOrganization::getOrgSort);
|
|
||||||
|
|
||||||
return queryWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除组织机构
|
* 批量删除组织机构
|
||||||
*
|
*
|
||||||
|
@ -773,46 +700,6 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
this.removeBatchByIds(totalOrgIdSet);
|
this.removeBatchByIds(totalOrgIdSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建查询wrapper
|
|
||||||
*
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2023/06/10 21:23
|
|
||||||
*/
|
|
||||||
private LambdaQueryWrapper<HrOrganization> createCommonTreeWrapper(CommonOrgTreeRequest commonOrgTreeRequest) {
|
|
||||||
|
|
||||||
// 创建基本的wrapper
|
|
||||||
HrOrganizationRequest hrOrganizationRequest = new HrOrganizationRequest();
|
|
||||||
hrOrganizationRequest.setSearchText(commonOrgTreeRequest.getSearchText());
|
|
||||||
LambdaQueryWrapper<HrOrganization> queryWrapper = this.createWrapper(hrOrganizationRequest);
|
|
||||||
|
|
||||||
// 如果查询条件有orgId,则查询指定机构下的子机构
|
|
||||||
Long parentId = commonOrgTreeRequest.getOrgParentId();
|
|
||||||
if (parentId != null) {
|
|
||||||
queryWrapper.eq(HrOrganization::getOrgParentId, parentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果有定位状态的组织机构,则需要查询到定位的组织机构的所有子一级
|
|
||||||
Set<Long> indexOrgIdList = commonOrgTreeRequest.getIndexOrgIdList();
|
|
||||||
if (ObjectUtil.isNotEmpty(indexOrgIdList)) {
|
|
||||||
Set<Long> parentIdListTotal = this.queryOrgIdParentIdList(indexOrgIdList);
|
|
||||||
if (ObjectUtil.isNotEmpty(parentIdListTotal)) {
|
|
||||||
queryWrapper.in(HrOrganization::getOrgParentId, parentIdListTotal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果有筛选公司的标识,则只查询公司列表
|
|
||||||
Boolean companySearchFlag = commonOrgTreeRequest.getCompanySearchFlag();
|
|
||||||
if (ObjectUtil.isNotEmpty(companySearchFlag) && companySearchFlag) {
|
|
||||||
queryWrapper.eq(HrOrganization::getOrgType, OrgTypeEnum.COMPANY.getCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 只查询启用状态的机构
|
|
||||||
queryWrapper.eq(HrOrganization::getStatusFlag, StatusEnum.ENABLE.getCode());
|
|
||||||
|
|
||||||
return queryWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 填充是否含有下级的标识
|
* 填充是否含有下级的标识
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue