mirror of https://gitee.com/stylefeng/roses
【8.3.3】【org】增加获取组织机构全路径方法
parent
a03d64b2ca
commit
4e5d913d89
|
@ -74,4 +74,12 @@ public interface OrganizationServiceApi {
|
||||||
*/
|
*/
|
||||||
List<HrOrganizationDTO> getOrgNameList(Collection<Long> orgIdList);
|
List<HrOrganizationDTO> getOrgNameList(Collection<Long> orgIdList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取组织机构的全路径名称,例如:北京公司/信息部门
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2025/1/10 23:55
|
||||||
|
*/
|
||||||
|
String getOrgTotalPathName(Long orgId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,6 +17,13 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!--树操作的sdk-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.javaguns.roses</groupId>
|
||||||
|
<artifactId>kernel-d-tree</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 多数据源模块,获取数据源上下文 -->
|
<!-- 多数据源模块,获取数据源上下文 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.javaguns.roses</groupId>
|
<groupId>com.javaguns.roses</groupId>
|
||||||
|
|
|
@ -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.DbTypeEnum;
|
||||||
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
|
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
|
||||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
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.pojo.dict.SimpleDict;
|
||||||
import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory;
|
import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory;
|
||||||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveOrgCallbackApi;
|
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
|
@Override
|
||||||
public HomeCompanyInfo orgStatInfo() {
|
public HomeCompanyInfo orgStatInfo() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue