|
|
@@ -1,18 +1,24 @@ |
|
|
|
package com.ningdatech.pmapi.organization.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.pmapi.common.config.DingOrganizationProperties; |
|
|
|
import com.ningdatech.pmapi.common.util.StrUtils; |
|
|
|
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; |
|
|
|
import com.ningdatech.pmapi.organization.model.po.ReqOrganizationListPO; |
|
|
|
import com.ningdatech.pmapi.organization.model.vo.OrganizationTreeVO; |
|
|
|
import com.ningdatech.pmapi.organization.model.vo.ResOrganizationListVO; |
|
|
|
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@@ -26,6 +32,8 @@ public class OrganizationManage { |
|
|
|
|
|
|
|
private final IDingOrganizationService iDingOrganizationService; |
|
|
|
|
|
|
|
private final DingOrganizationProperties dingOrganizationProperties; |
|
|
|
|
|
|
|
public PageVo<ResOrganizationListVO> organizationList(ReqOrganizationListPO reqOrganizationListPO) { |
|
|
|
String orgName = reqOrganizationListPO.getOrgName(); |
|
|
|
|
|
|
@@ -54,4 +62,43 @@ public class OrganizationManage { |
|
|
|
return pageVo; |
|
|
|
} |
|
|
|
|
|
|
|
public List<OrganizationTreeVO> getChildOrganizationList(String parentCode) { |
|
|
|
List<String> parentCodeList = new ArrayList<>(); |
|
|
|
List<DingOrganization> dingOrganizationList = new ArrayList<>(); |
|
|
|
if (StrUtils.isBlank(parentCode)) { |
|
|
|
parentCodeList = dingOrganizationProperties.getDeptVisibleScopes(); |
|
|
|
dingOrganizationList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) |
|
|
|
.in(DingOrganization::getOrganizationCode, parentCodeList)); |
|
|
|
} else { |
|
|
|
parentCodeList = CollectionUtil.toList(parentCode); |
|
|
|
dingOrganizationList = iDingOrganizationService |
|
|
|
.list(Wrappers.lambdaQuery(DingOrganization.class).in(DingOrganization::getParentCode, parentCodeList)); |
|
|
|
} |
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(dingOrganizationList)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
dingOrganizationList.sort(Comparator.comparing(DingOrganization::getDisplayOrder)); |
|
|
|
return dingOrganizationList.stream().map(r -> { |
|
|
|
OrganizationTreeVO treeVO = new OrganizationTreeVO(); |
|
|
|
treeVO.setId(r.getId()); |
|
|
|
treeVO.setName(r.getOrganizationName()); |
|
|
|
// Boolean enabled = "1".equals(r.get()); |
|
|
|
// treeVO.setEnabled(enabled); |
|
|
|
treeVO.setOrganizationCode(r.getOrganizationCode()); |
|
|
|
treeVO.setParentCode(r.getParentCode()); |
|
|
|
// treeVO.setSubCount(r.get()); |
|
|
|
// Boolean isLeaf = true; |
|
|
|
// Long subCount = r.getSubCount(); |
|
|
|
// if (Objects.nonNull(subCount) && subCount > 0) { |
|
|
|
// isLeaf = false; |
|
|
|
// } |
|
|
|
// treeVO.setIsLeaf(isLeaf); |
|
|
|
// treeVO.setDeptSort(r.getDeptSort()); |
|
|
|
// treeVO.setUnionCode(r.getName() + "##" + r.getOrganizationCode()); |
|
|
|
return treeVO; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
} |