|
@@ -8,6 +8,7 @@ import com.bowintek.smartsearch.vo.cd.CdOrganizationTreeVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -18,8 +19,9 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
private CdOrganizationCQuery cdOrganizationCQuery;
|
|
|
|
|
|
@Override
|
|
|
+ @SwitchDataSource(DBTypeEnum.POSTGRE)
|
|
|
public List<CdOrganizationTreeVo> getListTree(){
|
|
|
- List<CdOrganizationTreeVo> sources = cdOrganizationCQuery.getListToTree();
|
|
|
+ List<CdOrganizationTreeVo> sources = cdOrganizationCQuery.getListToTree2();
|
|
|
return recursionListTree(sources, null);
|
|
|
}
|
|
|
|
|
@@ -27,13 +29,21 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
@Override
|
|
|
@SwitchDataSource(DBTypeEnum.POSTGRE)
|
|
|
public List<CdOrganizationTreeVo> getListTree(String parentValue){
|
|
|
- List<CdOrganizationTreeVo> sources = cdOrganizationCQuery.getListToTree();
|
|
|
+ List<CdOrganizationTreeVo> sources = cdOrganizationCQuery.getListToTree2();
|
|
|
return recursionListTree(sources, parentValue);
|
|
|
}
|
|
|
public List<CdOrganizationTreeVo> recursionListTree(List<CdOrganizationTreeVo> sources, String parentValue){
|
|
|
List<CdOrganizationTreeVo> rtnList = findTreeByParent(sources, parentValue);
|
|
|
for(int i=0;i<rtnList.size();i++){
|
|
|
CdOrganizationTreeVo vo = rtnList.get(i);
|
|
|
+ if(vo.getValue()==null){
|
|
|
+ vo.setChildren(new ArrayList<>());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(vo.getParentValue() != null && vo.getValue().equals(vo.getParentValue())){
|
|
|
+ vo.setChildren(new ArrayList<>());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
List<CdOrganizationTreeVo> childs = recursionListTree(sources, vo.getValue());
|
|
|
vo.setChildren(childs);
|
|
|
}
|