ludc
2024-01-18 735b8b4c7eea4a5a6d42f25f070944f85e9603d9
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java
@@ -71,6 +71,7 @@
import java.awt.event.ItemEvent;
import java.io.File;
import java.util.*;
import java.util.concurrent.ForkJoinPool;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -116,6 +117,12 @@
   @Resource
   private CodeBasicSecMapper codeBasicSecMapper;
   /**
    * 自定义并发ForkJoinPool
    */
   private static final ForkJoinPool customForkJoinPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors()-1);
   /**
    * 上级节点的属性名称
    */
@@ -578,33 +585,30 @@
      List<CodeClassifyVO> voList = codeClassifyDO2VOs(doList);
      TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(PARENT_FIELD_NAME);
      treeWrapperOptions.copyFromTreeQuery(treeQueryObject);
      List<Tree> tree= revisionModelUtil.doList2Trees(voList,treeWrapperOptions,(CodeClassifyVO s) ->{
      List<Tree> tree = revisionModelUtil.doList2Trees(voList,treeWrapperOptions,(CodeClassifyVO s) ->{
         //可以在这里处理树节点的显示
         return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s
            .getLcStatus()) ? (" 【停用】 ") : "");
      });
      //超管显示所有分类
      if(VciBaseUtil.checkAdminTenant()){
         Iterator var6 =  tree.listIterator();
         while(var6.hasNext()){
            Tree trees = (Tree) var6.next();
            boolean checkHasChild=codeClassifyMapper.checkHasChild(trees.getOid());
            if(checkHasChild){
               trees.setLeaf(false);
            }else{
               trees.setLeaf(true);
            }
         }
      }else {
      // 非超管过滤未授权的分类
      if(!VciBaseUtil.checkAdminTenant()){
         // 那些分类具备查看权限
         R<List<String>> viewClassByRoleIds = sysClient.getViewClassByRoleIds(Arrays.asList(AuthUtil.getUser().getRoleId().split(",")),treeQueryObject.getConditionMap().getOrDefault("authType","classify_auth"),treeQueryObject.getConditionMap().getOrDefault("menuCode","classify_view"));
         // 请求失败或者请求得到的具备查看权限的分类id集合为空
         if(!viewClassByRoleIds.isSuccess() && viewClassByRoleIds.getData().isEmpty()){
            throw new ServiceException("主数据查看权限未配置,或配置有误!");
         }
         long startTime = System.currentTimeMillis();
         // 过滤
         filterTreeNodes(tree,viewClassByRoleIds.getData());
         long endTime = System.currentTimeMillis();
         System.out.println(("执行时间:"+(endTime-startTime)/1000)+"s");
      }
      // 加载分类是否具有子分类
      tree.parallelStream().forEach(item -> {
         boolean checkHasChild = checkHasChild(item.getOid());
         item.setLeaf(!checkHasChild);
      });
      return tree;
   }
@@ -617,8 +621,8 @@
      Iterator<Tree> iterator = trees.iterator();
      while (iterator.hasNext()) {
         Tree tree = iterator.next();
         Boolean checkHasChild = codeClassifyMapper.checkHasChild(tree.getOid());
         tree.setLeaf(!checkHasChild);
         /*Boolean checkHasChild = checkHasChild(tree.getOid());
         tree.setLeaf(!checkHasChild);*/
         if (classifyIds.contains(tree.getOid())) {
            // 如果顶层节点存在于 classifyIds 中,直接保留其子节点集合
            continue;