mirror of https://gitee.com/stylefeng/roses
【8.3.3】【org】获取指定机构的指定层级编码的机构
parent
79da038b11
commit
ffcd70ab4b
|
@ -82,4 +82,17 @@ public interface OrganizationServiceApi {
|
|||
*/
|
||||
String getOrgTotalPathName(Long orgId);
|
||||
|
||||
/**
|
||||
* 获取指定机构的指定层级的机构id,从下往上直到找到指定的机构层级
|
||||
* <p>
|
||||
* 如果找不到指定层级,返回为空
|
||||
*
|
||||
* @param orgId 指定机构id
|
||||
* @param orgLevelCode 机构层级编码
|
||||
* @return 指定层级的机构的id
|
||||
* @author fengshuonan
|
||||
* @since 2025/1/26 14:45
|
||||
*/
|
||||
Long getParentOrgLevel(Long orgId, String orgLevelCode);
|
||||
|
||||
}
|
||||
|
|
|
@ -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.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
@ -463,6 +464,47 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
|||
return String.join("/", orgNameList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getParentOrgLevel(Long orgId, String orgLevelCode) {
|
||||
if (orgId == null || StrUtil.isEmpty(orgLevelCode)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取当前机构的父级id集合
|
||||
LambdaQueryWrapper<HrOrganization> hrOrganizationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
hrOrganizationLambdaQueryWrapper.eq(HrOrganization::getOrgId, orgId);
|
||||
hrOrganizationLambdaQueryWrapper.select(HrOrganization::getOrgPids);
|
||||
HrOrganization thisOrg = this.getOne(hrOrganizationLambdaQueryWrapper, false);
|
||||
if (thisOrg == null) {
|
||||
return null;
|
||||
}
|
||||
String orgPids = thisOrg.getOrgPids();
|
||||
if (ObjectUtil.isEmpty(orgPids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取父级id集合,移除掉为-1的id
|
||||
List<Long> parentIdList = ParentIdParseUtil.parseToPidList(orgPids);
|
||||
parentIdList.remove(TreeConstants.DEFAULT_PARENT_ID);
|
||||
|
||||
// 获取这些机构的详细信息
|
||||
List<HrOrganization> parentOrgList = this.listByIds(parentIdList);
|
||||
parentOrgList = CollectionUtil.reverse(parentOrgList);
|
||||
|
||||
// 开始遍历机构,找到指定参数层级的机构
|
||||
for (HrOrganization parentOrg : parentOrgList) {
|
||||
// 获取到当前机构的层级编码
|
||||
String orgLevelCodeTemp = parentOrg.getLevelCode();
|
||||
|
||||
// 如果层级编码和参数的层级编码相同,则返回当前机构的层级编码
|
||||
if (orgLevelCodeTemp.equals(orgLevelCode)) {
|
||||
return parentOrg.getOrgId();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HomeCompanyInfo orgStatInfo() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue