【8.3.3】【org】增加获取组织机构全路径方法

pull/62/head
stylefeng 2025-01-11 00:36:03 +08:00
parent a03d64b2ca
commit 4e5d913d89
4 changed files with 86 additions and 0 deletions

View File

@ -74,4 +74,12 @@ public interface OrganizationServiceApi {
*/
List<HrOrganizationDTO> getOrgNameList(Collection<Long> orgIdList);
/**
* /
*
* @author fengshuonan
* @since 2025/1/10 23:55
*/
String getOrgTotalPathName(Long orgId);
}

View File

@ -0,0 +1,37 @@
package cn.stylefeng.roses.kernel.sys.api.format;
import cn.hutool.core.convert.Convert;
import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.roses.kernel.rule.format.BaseSimpleFieldFormatProcess;
import cn.stylefeng.roses.kernel.sys.api.OrganizationServiceApi;
/**
*
* <p>
*
*
* @author fengshuonan
* @since 2025/1/11 0:11
*/
public class OrgFullPathNameFormatProcess extends BaseSimpleFieldFormatProcess {
@Override
public Class<?> getItemClass() {
return Long.class;
}
@Override
public Object simpleItemFormat(Object businessId) {
if (businessId == null) {
return null;
}
Long orgId = Convert.toLong(businessId);
OrganizationServiceApi organizationServiceApi = SpringUtil.getBean(OrganizationServiceApi.class);
return organizationServiceApi.getOrgTotalPathName(orgId);
}
}

View File

@ -17,6 +17,13 @@
<dependencies>
<!--树操作的sdk-->
<dependency>
<groupId>com.javaguns.roses</groupId>
<artifactId>kernel-d-tree</artifactId>
<version>${roses.version}</version>
</dependency>
<!-- 多数据源模块,获取数据源上下文 -->
<dependency>
<groupId>com.javaguns.roses</groupId>

View File

@ -21,6 +21,7 @@ import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.rule.pidset.ParentIdParseUtil;
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory;
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveOrgCallbackApi;
@ -416,6 +417,39 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
}
}
@Override
public String getOrgTotalPathName(Long orgId) {
// 获取机构的详情
HrOrganizationDTO orgInfo = this.getOrgInfo(orgId);
if (orgInfo == null || orgInfo.getOrgId() == null) {
return "";
}
// 解析pids
List<Long> orgIdList = ParentIdParseUtil.parseToPidList(orgInfo.getOrgPids());
// 去掉-1根节点
orgIdList.remove(TreeConstants.DEFAULT_PARENT_ID);
// 用于存储组织名称的列表
List<String> orgNameList = new ArrayList<>();
// 遍历每个父节点ID获取组织名称
for (Long parentId : orgIdList) {
HrOrganizationDTO parentOrgInfo = this.getOrgInfo(parentId);
if (parentOrgInfo != null && parentOrgInfo.getOrgName() != null) {
orgNameList.add(parentOrgInfo.getOrgName());
}
}
// 添加当前组织的名称
orgNameList.add(orgInfo.getOrgName());
// 用斜杠连接所有名称
return String.join("/", orgNameList);
}
@Override
public HomeCompanyInfo orgStatInfo() {