ludc
2024-01-24 c327574106f470c72638e9f34c7f8cd26d78a2bf
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,7 @@
   @Resource
   private CodeBasicSecMapper codeBasicSecMapper;
   /**
    * 上级节点的属性名称
    */
@@ -510,7 +512,7 @@
    * @return 主题库分类显示树
    */
   @Override
   public List<Tree> referTree(TreeQueryObject treeQueryObject) {
   public List<Tree> referTree(TreeQueryObject treeQueryObject) throws ServiceException{
      if(treeQueryObject == null){
         treeQueryObject = new TreeQueryObject();
      }
@@ -520,7 +522,7 @@
      if(treeQueryObject.getConditionMap().containsKey(LC_STATUS)) {
         treeQueryObject.getConditionMap().remove(LC_STATUS);
      }
      if(treeQueryObject.getExtandParamsMap() ==null || !treeQueryObject.getExtandParamsMap().containsKey(REFER_SHOW_DISABLED_QUERY_KEY)) {
      if(treeQueryObject.getExtandParamsMap() == null || !treeQueryObject.getExtandParamsMap().containsKey(REFER_SHOW_DISABLED_QUERY_KEY)) {
      }
      treeQueryObject.getConditionMap().put(LC_STATUS, FRAMEWORK_DATA_ENABLED);
      return treeCodeClassify(treeQueryObject);
@@ -550,7 +552,7 @@
    * @return 主题库分类 显示树
    */
   @Override
   public List<Tree> treeCodeClassify(TreeQueryObject treeQueryObject) {
   public List<Tree> treeCodeClassify(TreeQueryObject treeQueryObject) throws ServiceException{
      List<CodeClassify> doList = null;
      String id = null;
      String lcStatus = null;
@@ -560,6 +562,7 @@
      }
      if(StringUtils.isNotBlank(id) || StringUtils.isNotBlank(lcStatus) ){
         //String tableName = this.getTableName(treeQueryObject.getConditionMap().get("btmTypeId"),treeQueryObject.getConditionMap().get("id"), treeQueryObject.getConditionMap().get("lcStatus"));
         // TODO: 2024-1-24 23:25我去掉了懒加载,因为会影响数据授权过滤,而且这儿感觉没必要做懒加载
         doList = codeClassifyMapper
            .selectCodeClassifyDOByTree(
               treeQueryObject.getConditionMap().get("id"),
@@ -578,33 +581,32 @@
      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(",")));
         R<List<String>> viewClassByRoleIds = sysClient.getViewClassByRoleIds(
            Arrays.asList(AuthUtil.getUser().getRoleId().split(",")),
            treeQueryObject.getConditionMap().getOrDefault("authType","classify_auth"),
            treeQueryObject.getConditionMap().getOrDefault("buttonCode","classify_view"),
            treeQueryObject.getConditionMap().getOrDefault("menuCode","classifyTree")
         );
         // 请求失败或者请求得到的具备查看权限的分类id集合为空
         if(!viewClassByRoleIds.isSuccess() && !viewClassByRoleIds.getData().isEmpty()){
            return new ArrayList<>();
         if(!viewClassByRoleIds.isSuccess() && viewClassByRoleIds.getData().isEmpty()){
            throw new ServiceException("主数据查看权限未配置,或配置有误!");
         }
         // 过滤
         filterTreeNodes(tree,viewClassByRoleIds.getData());
      }
      // 加载分类是否具有子分类
      tree.parallelStream().forEach(item -> {
         boolean checkHasChild = checkHasChild(item.getOid());
         item.setLeaf(!checkHasChild);
      });
      return tree;
   }
@@ -617,10 +619,10 @@
      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 中,直接保留其子节点集合
            // 如果顶层节点存在 classifyIds ,直接保留其子节点集合
            continue;
         }
         if (tree.getChildren() != null && !tree.getChildren().isEmpty()) {