【7.6.0】【sys】【org】更新获取子一级机构信息集合

pull/57/head
fengshuonan 2023-06-27 14:34:51 +08:00
parent 58fed480d7
commit 3f1a101fca
2 changed files with 29 additions and 3 deletions

View File

@ -121,4 +121,13 @@ public interface HrOrganizationService extends IService<HrOrganization> {
*/
HomeCompanyInfo orgStatInfo();
/**
* id
*
* @return orgId
* @author fengshuonan
* @since 2023/6/27 14:33
*/
List<Long> getSubOrgIdListOneLevel(Long orgId);
}

View File

@ -1,6 +1,7 @@
package cn.stylefeng.roses.kernel.sys.modular.org.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
@ -270,6 +271,23 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
return homeCompanyInfo;
}
@Override
public List<Long> getSubOrgIdListOneLevel(Long orgId) {
LambdaQueryWrapper<HrOrganization> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(HrOrganization::getOrgParentId, orgId);
wrapper.select(HrOrganization::getOrgId);
List<HrOrganization> subOrgList = this.list(wrapper);
if (ObjectUtil.isEmpty(subOrgList)) {
return ListUtil.list(false, orgId);
}
List<Long> subOrgIdList = subOrgList.stream().map(HrOrganization::getOrgId).collect(Collectors.toList());
subOrgIdList.add(orgId);
return subOrgIdList;
}
/**
*
*
@ -311,9 +329,8 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
Long orgId = hrOrganizationRequest.getOrgId();
if (orgId != null) {
// 查询orgId对应的所有子机构包含本orgId
Set<Long> subOrgIdList = dbOperatorApi.findSubListByParentId("hr_organization", "org_pids", "org_id", orgId);
subOrgIdList.add(orgId);
queryWrapper.nested(i -> i.in(HrOrganization::getOrgId, subOrgIdList));
List<Long> subOrgIdListOneLevel = this.getSubOrgIdListOneLevel(orgId);
queryWrapper.nested(i -> i.in(HrOrganization::getOrgId, subOrgIdListOneLevel));
}
// 根据排序正序查询