【7.6.0】【sys】解决组织机构树去重问题

pull/57/head
fengshuonan 2023-06-27 00:35:58 +08:00
parent 2090bf30b0
commit c3e13291b5
1 changed files with 8 additions and 5 deletions

View File

@ -36,14 +36,12 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import static cn.stylefeng.roses.kernel.rule.constants.SymbolConstant.LEFT_SQUARE_BRACKETS;
import static cn.stylefeng.roses.kernel.rule.constants.SymbolConstant.RIGHT_SQUARE_BRACKETS;
import static java.util.stream.Collectors.toCollection;
/**
*
@ -164,8 +162,13 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
// 合并两个集合
hrOrganizationList.addAll(parentOrgList);
// 去重
List<HrOrganization> newNotRepeatList = hrOrganizationList.stream().collect(
Collectors.collectingAndThen(toCollection(() -> new TreeSet<>(Comparator.comparing(HrOrganization::getOrgId))),
ArrayList::new));
// 构建树形结构
return new DefaultTreeBuildFactory<HrOrganization>().doTreeBuild(hrOrganizationList);
return new DefaultTreeBuildFactory<HrOrganization>().doTreeBuild(newNotRepeatList);
}
@Override