Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/test-merge' into test-merge

cr 3 dienas atpakaļ
vecāks
revīzija
b80be6b127

+ 21 - 12
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchivesAutoController.java

@@ -44,6 +44,7 @@ import org.springblade.archive.utils.CallBgrsjk;
 import org.springblade.archive.vo.*;
 import org.springblade.business.entity.ArchiveFile;
 import org.springblade.business.feign.ArchiveFileClient;
+import org.springblade.business.vo.ArchiveFileVO;
 import org.springblade.business.vo.NeiYeLedgerVO1;
 //import org.springblade.common.utils.DeepSeekClient;
 import org.springblade.common.utils.SnowFlakeUtil;
@@ -1256,29 +1257,37 @@ public class ArchivesAutoController extends BladeController {
 		if ((vo.getSortFileList() ==  null || !vo.getSortFileList().contains(","))) {
 			return R.fail("参数错误");
 		}
-		List<ArchiveFile> updateArchiveFileList = new ArrayList<>();
-		int sort = 0;
+		List<ArchiveFileVO> updateArchiveFileList = new ArrayList<>();
 		String[] split1 = vo.getSortFileList().split(",");
-		Map<Long, Integer> map = sourceArchiveFileList.stream().collect(Collectors.toMap(ArchiveFile::getId, ArchiveFile::getSort));
+		List<ArchiveFile> targetArchiveFileList = archiveFileClient.getArchiveFileByArchiveIds(target.getId() + "");
+		targetArchiveFileList.addAll(sourceArchiveFileList);
+		Map<Long, ArchiveFile> targetMap = targetArchiveFileList.stream().collect(Collectors.toMap(ArchiveFile::getId, item -> item, (k1, k2) -> k1));
+		Map<Long, ArchiveFile> map = sourceArchiveFileList.stream().collect(Collectors.toMap(ArchiveFile::getId, item -> item));
 		for (String s : split1) {
 			if (StringUtils.isNumeric(s)) {
-				ArchiveFile file = new ArchiveFile();
-				file.setId(Long.parseLong(s));
-				updateArchiveFileList.add(file);
-				file.setSort(sort);
-				if (map.containsKey(file.getId())) {
-					file.setPageNum("");
-					file.setArchiveId(target.getId());
+				ArchiveFile tempFile = targetMap.get(Long.parseLong(s));
+				if (tempFile != null) {
+					ArchiveFileVO file = new ArchiveFileVO();
+					file.setId(tempFile.getId());
+					file.setSort(tempFile.getSort());
+					file.setArchiveSort(tempFile.getArchiveSort());
+					file.setNodeId(tempFile.getNodeId());
+					updateArchiveFileList.add(file);
+					if (map.containsKey(file.getId())) {
+						file.setPageNum("");
+						file.setArchiveId(target.getId());
+					}
 				}
-				sort++;
 			}
 		}
 		// 修改标识
-		archiveFileClient.updateArchiveFile(updateArchiveFileList);
 		boolean update = archivesAutoService.update(Wrappers.<ArchivesAuto>lambdaUpdate().in(ArchivesAuto::getId, vo.getTargetId(), vo.getSourceId()).set(ArchivesAuto::getActionType, 3).last("and (action_type is null or action_type in (0,3))"));
 		if (!update) {
 			return R.fail("案卷【" + target.getName() + "】或【" + source.getName() + "】正在被其他用户操作,请稍后再试");
 		}
+		ArchiveFileVO fileVO = new ArchiveFileVO();
+		fileVO.setList(updateArchiveFileList);
+		archiveFileClient.updateArchiveFileSort(fileVO);
 		return R.status(true);
 	}
 

+ 2 - 2
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.xml

@@ -375,12 +375,12 @@
                 ORDER BY
                     m.tree_sort,
                     CASE WHEN u.file_number IS NULL THEN 1 ELSE 0 END,
-                    trailing_number
+                    trailing_number,u.create_time
             </when>
             <when test="vo.sortRuleType != null and vo.sortRuleType == 2 and vo.isArchive != null and vo.isArchive != ''">
                 order by
                     CASE WHEN u.file_number IS NULL THEN 1 ELSE 0 END,
-                    trailing_number
+                    trailing_number,u.create_time
             </when>
             <otherwise>
                 order by m.tree_sort,u.auto_file_sort is null ,u.auto_file_sort,u.file_number is null,

+ 18 - 19
blade-service/blade-business/src/main/java/org/springblade/business/controller/FixedFlowController.java

@@ -383,7 +383,6 @@ public class FixedFlowController extends BladeController {
             fixedFlow.setCreateDept(fixedFlow.getId());
             fixedFlow.setUpdateTime(new Date());
             fixedFlow.setCreateUser(AuthUtil.getUserId());
-            fixedFlow.setSort(null);
         });
         boolean flow = this.fixedFlowService.saveBatch(fixedFlowList);
         if (flow && !newFixedFolwLinkList.isEmpty()) {
@@ -515,7 +514,7 @@ public class FixedFlowController extends BladeController {
         IPage<FixedFlow> fixedFlowsPage = fixedFlowService.getBaseMapper().selectPage(page,
                 Wrappers.<FixedFlow>lambdaQuery()
                         .eq(FixedFlow::getContractId, dto.getContractId())
-                        .eq(FixedFlow::getProjectId, dto.getProjectId()).last(" and (is_meter is null or is_meter != 1) order by sort"));
+                        .eq(FixedFlow::getProjectId, dto.getProjectId()).last(" and (is_meter is null or is_meter != 1) order by sort, fixed_flow_name, create_time desc"));
         List<FixedFlow> fixedFlows = fixedFlowsPage.getRecords();
         List<Long> collect = fixedFlows.stream().map(FixedFlow::getId).collect(Collectors.toList());
         if (!collect.isEmpty()) {
@@ -569,23 +568,23 @@ public class FixedFlowController extends BladeController {
             resultMap.setSize(fixedFlowsPage.getSize());
             resultMap.setTotal(fixedFlowsPage.getTotal());
             resultMap.setRecords(fixedFlowVOList);
-            Map<Boolean, List<FixedFlowVO>> groupMap = fixedFlowVOList.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName() != null && record.getFixedFlowName().contains("_") && record.getSort() == null));
-            List<FixedFlowVO> copyFixedFlowVOS = groupMap.get(true);
-            List<FixedFlowVO> fixedFlowVOS = groupMap.get(false);
-            if (copyFixedFlowVOS ==  null || copyFixedFlowVOS.isEmpty() || fixedFlowVOS ==  null || fixedFlowVOS.isEmpty()) {
-                return R.data(resultMap);
-            }
-            Map<String, List<FixedFlowVO>> nameMap = copyFixedFlowVOS.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName().split("_")[0]));
-            List<FixedFlowVO> newData = new ArrayList<>(fixedFlowVOList);
-            for (FixedFlowVO flowVO : fixedFlowVOS) {
-//                newData.add(flowVO);
-                List<FixedFlowVO> flowVOS = nameMap.get(flowVO.getFixedFlowName());
-                if (flowVOS != null && !flowVOS.isEmpty()) {
-                    flowVOS.sort(Comparator.comparing(FixedFlow::getFixedFlowName));
-                    newData.addAll(flowVOS);
-                }
-            }
-            resultMap.setRecords(newData);
+//            Map<Boolean, List<FixedFlowVO>> groupMap = fixedFlowVOList.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName() != null && record.getFixedFlowName().contains("_") && record.getSort() == null));
+//            List<FixedFlowVO> copyFixedFlowVOS = groupMap.get(true);
+//            List<FixedFlowVO> fixedFlowVOS = groupMap.get(false);
+//            if (copyFixedFlowVOS ==  null || copyFixedFlowVOS.isEmpty() || fixedFlowVOS ==  null || fixedFlowVOS.isEmpty()) {
+//                return R.data(resultMap);
+//            }
+//            Map<String, List<FixedFlowVO>> nameMap = copyFixedFlowVOS.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName().split("_")[0]));
+//            List<FixedFlowVO> newData = new ArrayList<>(fixedFlowVOList);
+//            for (FixedFlowVO flowVO : fixedFlowVOS) {
+////                newData.add(flowVO);
+//                List<FixedFlowVO> flowVOS = nameMap.get(flowVO.getFixedFlowName());
+//                if (flowVOS != null && !flowVOS.isEmpty()) {
+//                    flowVOS.sort(Comparator.comparing(FixedFlow::getFixedFlowName));
+//                    newData.addAll(flowVOS);
+//                }
+//            }
+//            resultMap.setRecords(newData);
             return R.data(resultMap);
         }
         return R.fail("暂无数据");

+ 62 - 41
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -1809,7 +1809,7 @@ public class TaskController extends BladeController {
         if (CollectionUtil.isNotEmpty(processInstanceIds)) {
             String idsStr = processInstanceIds.stream().map(id -> "'" + id + "'").collect(Collectors.joining(","));
             taskParallelGroupMap = jdbcTemplate.query(
-                    "select process_instance_id,task_user,task_user_name,e_visa_status,e_visa_content,parallel_process_instance_id,status from u_task_parallel where process_instance_id in(" + idsStr + ") order by id",
+                    "select process_instance_id,task_user,task_user_name,e_visa_status,e_visa_content,parallel_process_instance_id,status,sort from u_task_parallel where process_instance_id in(" + idsStr + ") order by id",
                     new BeanPropertyRowMapper<>(TaskParallel.class)
             ).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
         }
@@ -1832,11 +1832,37 @@ public class TaskController extends BladeController {
         }
 
         // 6. 对原始数据执行业务过滤(核心:垂直签待办任务可见性判断)
+        //根据条件过滤出可审批的数据(流程审批-非自定义流程)   flowid为0的是自定义审批的流程
+        Map<Long, List<Task>> flowIdMaps = allResultList.stream().filter(task->!"0".equals(task.getFixedFlowId().toString())).collect(Collectors.groupingBy(Task::getFixedFlowId));
+        Map<Long, List<FixedFlowLink>> fixedsMap;
+        if(ObjectUtil.isNotEmpty(flowIdMaps)){
+            String join = StringUtils.join(flowIdMaps.keySet(), ",");
+            //结果集所有数据
+            String sql = "select fixed_flow_id ,fixed_flow_branch_sort,fixed_flow_link_type,fixed_flow_link_sort from u_fixed_flow_link where  is_deleted = 0  and  fixed_flow_id in ( "+join+")";
+            List<FixedFlowLink> fixedFlowLinks = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(FixedFlowLink.class));
+            fixedsMap = fixedFlowLinks.stream().collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId));
+        } else {
+            fixedsMap = new HashMap<>();
+        }
         Map<String, List<TaskParallel>> finalTaskParallelGroupMap = taskParallelGroupMap;
         List<Task> filteredList = allResultList.stream()
                 .filter(task -> {
+                    // 获取任务流程信息,判断是否是垂直签
+                    if (task.getFixedFlowId() != null && fixedsMap.containsKey(task.getFixedFlowId())) {
+                        // 预设流程
+                        List<FixedFlowLink> fixedFlowLinks = fixedsMap.get(task.getFixedFlowId());
+                        List<FixedFlowLink> linkList = fixedFlowLinks.stream().filter(link -> link.getFixedFlowLinkType() == null).collect(Collectors.toList());
+                        if (linkList.isEmpty()) {
+                            // 获取垂直流程
+                            List<FixedFlowLink> collect = fixedFlowLinks.stream().filter(link -> link.getFixedFlowLinkType() != null && link.getFixedFlowLinkType() == 1).collect(Collectors.toList());
+                            if (!collect.isEmpty()) {
+                                // 走垂直审批逻辑
+                                return handleTaskParallel(fixedFlowLinks, finalTaskParallelGroupMap.get(task.getProcessInstanceId()), SecureUtil.getUserId());
+                            }
+                        }
+                    }
                     // 仅处理垂直签+待办页面的过滤逻辑
-                    if (projectInfo != null && projectInfo.getApprovalType() == 1 && dto.getSelectedType() == 1) {
+                    if (((projectInfo != null && projectInfo.getApprovalType() == 1)) && dto.getSelectedType() == 1) {
                         List<TaskParallel> parallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
                         if (CollectionUtil.isEmpty(parallelList)) {
                             return false;
@@ -1982,11 +2008,18 @@ public class TaskController extends BladeController {
         return R.data(page);
     }
 
-    private void handleTaskParallel1(Task task, Map<Long, List<FixedFlowLink>> fixedsMap, Map<String, List<TaskParallel>> taskParallelMap, Long userId, List<Task> resultList) {
-        Long fixedFlowId = task.getFixedFlowId();
-        String processInstanceId = task.getProcessInstanceId();
+    private boolean handleTaskParallel(List<FixedFlowLink> fixedFlowLinks, List<TaskParallel> taskParallels, Long userId) {
+        taskParallels.sort(Comparator.comparing(TaskParallel::getSort, Comparator.nullsLast(Comparator.naturalOrder())));
+        for (int i = 0; i < taskParallels.size(); i++) {
+            TaskParallel parallel = taskParallels.get(i);
+            parallel.setSort(i);
+        }
+        fixedFlowLinks.sort(Comparator.comparing(FixedFlowLink::getFixedFlowBranchSort, Comparator.nullsLast(Comparator.naturalOrder())));
+        for (int i = 0; i < fixedFlowLinks.size(); i++) {
+            FixedFlowLink link = fixedFlowLinks.get(i);
+            link.setFixedFlowBranchSort(i);
+        }
         //查出当前电签到的节点sort
-        List<TaskParallel> taskParallels = taskParallelMap.get(processInstanceId);
         Optional<Integer> sortDq = taskParallels.stream()
                 .filter(t -> t.getStatus() == 1)
                 .min(Comparator.comparing(TaskParallel::getSort))
@@ -2001,54 +2034,42 @@ public class TaskController extends BladeController {
             List<Integer> list1 = userSort.stream().filter(a -> dqSort.compareTo(a) <= 0).collect(Collectors.toList());
             if(ObjectUtil.isEmpty(list1)){
                 //当前用户已经签字过
-                resultList.remove(task);
+                return false;
             }else {
                 //筛选出最近的一条没有电签的当前用户的sort
                 Integer userMinSort = Collections.min(list1);
                 if(userMinSort.toString().equals(dqSort.toString())){
                     //当前用户就是下一个电签用户 可审批 放行
-                    return;
+                    return true;
                 }
-                List<FixedFlowLink> fixedFlowLinks = fixedsMap.get(fixedFlowId);
-                Optional<FixedFlowLink> dqFlowLink = fixedFlowLinks.stream().filter(f -> f.getFixedFlowBranchSort().equals(dqSort)).findFirst();
-                Optional<FixedFlowLink> userFlowLink = fixedFlowLinks.stream().filter(f -> f.getFixedFlowBranchSort().equals(userMinSort)).findFirst();
-                if(dqFlowLink.get().getFixedFlowLinkSort() == userFlowLink.get().getFixedFlowLinkSort()){
-                    //在同一个小流程里面去判断是否垂直还是水平
-                    if(dqFlowLink.get().getFixedFlowLinkType() == 2){//平行
-                        //通过
-                        return;
-                    }else {
-                        resultList.remove(task);
+                FixedFlowLink dqFlowLink = null;
+                FixedFlowLink userFlowLink = null;
+                for (FixedFlowLink fixedFlowLink : fixedFlowLinks) {
+                    if (fixedFlowLink.getFixedFlowBranchSort() != null && fixedFlowLink.getFixedFlowBranchSort() >= dqSort && dqFlowLink == null) {
+                        dqFlowLink = fixedFlowLink;
                     }
+                    if (fixedFlowLink.getFixedFlowBranchSort() != null && fixedFlowLink.getFixedFlowBranchSort() >= userMinSort && userFlowLink == null) {
+                        userFlowLink = fixedFlowLink;
+                    }
+                    if (dqFlowLink != null && userFlowLink != null) {
+                        break;
+                    }
+                }
+                if (dqFlowLink == null || userFlowLink == null) {
+                    return false;
+                }
+                if(Objects.equals(dqFlowLink.getFixedFlowLinkSort(), userFlowLink.getFixedFlowLinkSort())){
+                    //在同一个小流程里面去判断是否垂直还是水平
+                    //平行 通过
+                    return dqFlowLink.getFixedFlowLinkType() == 2;
                 }else {
                     //不在一个小流程 不可审批
-                    resultList.remove(task);
+                    return  false;
                 }
             }
         }else {
             //全部签完了 肯定不是可审批
-            resultList.remove(task);
-        }
-    }
-    //判断当前任务当前用户是否可审批  如果不可审批则从resultList中删除
-    private void handleTaskParallel(Task task,Map<String, List<TaskParallel>> map, Long userId, List<Task> resultList) {
-        String processInstanceId = task.getProcessInstanceId();
-        List<TaskParallel> taskParallels = map.get(processInstanceId);
-        //按照sort升序排序
-        taskParallels.sort(Comparator.comparingInt(TaskParallel::getSort));
-        boolean isApprove = true;
-        for (TaskParallel taskParallel : taskParallels) {
-            if(taskParallel.getTaskUser().equals(userId.toString())){
-                break;
-            }else {
-                if(taskParallel.getStatus() != 2){//不为2说明 还未审批  流程未到当前用户 不可审批
-                    isApprove = false;
-                    break;
-                }
-            }
-        }
-        if(!isApprove){//不可审批的数据
-            resultList.remove(task);
+            return false;
         }
     }
 

+ 70 - 29
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -1615,31 +1615,22 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                     for (int i = 0; i < split.length; i++) {
                         String s = split[i];
                         if (StringUtil.isNumeric(s)) {
-//                            pKeyIds.add(Long.parseLong(s));
-                            if (s.equals(pKeyId + "") && i + 1 < split.length) {
-                                pKeyIds.add(Long.parseLong(split[i + 1]));
-                                break;
-                            }
+                            pKeyIds.add(Long.parseLong(s));
                         }
                     }
                 }
                 collectMap.put(node.getNodeId(), "");
-//                pKeyIds.add(node.getNodeId());
+                pKeyIds.add(node.getNodeId());
             }
             List<WbsTreeContract> wbsTreeContractList = new ArrayList<>();
             if (!pKeyIds.isEmpty()) {
                 LambdaQueryWrapper<WbsTreeContract> wrapper = Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, pKeyIds);
-                if (pKeyId == null || pKeyId == 0) {
-                    wrapper.and(wrapper1 -> wrapper1.isNull(WbsTreeContract::getPId).or().eq(WbsTreeContract::getPId, 0));
-                } else {
-                    wrapper.eq(WbsTreeContract::getPId, pKeyId);
-                }
                 wrapper.and(wrapper1 -> wrapper1.isNull(WbsTreeContract::getIsBussShow).or().ne(WbsTreeContract::getIsBussShow, 2));
                 wbsTreeContractList = wbsTreeContractMapper.selectList(wrapper);
             }
             if (!wbsTreeContractList.isEmpty()) {
                 String pKeyIdStr = wbsTreeContractList.stream().map(item -> item.getPKeyId() + "").collect(Collectors.joining(","));
-                List<WbsTreeContractStatistics> wbsTreeContractStatisticsList = jdbcTemplate.query("select id, leaf_num, fill_num, approve_num, complete_num,jl_fill_num, jl_approve_num, jl_complete_num from m_wbs_tree_contract_statistics where id in (" + pKeyIdStr + ")",
+                List<WbsTreeContractStatistics> wbsTreeContractStatisticsList = jdbcTemplate.query("select id, parent_id, leaf_num, fill_num, approve_num, complete_num,jl_fill_num, jl_approve_num, jl_complete_num from m_wbs_tree_contract_statistics where id in (" + pKeyIdStr + ")",
                         new BeanPropertyRowMapper<>(WbsTreeContractStatistics.class));
                 Map<Long, WbsTreeContractStatistics> wbsTreeContractStatisticsMap = wbsTreeContractStatisticsList.stream().collect(Collectors.toMap(WbsTreeContractStatistics::getId, item -> item));
                 Map<String, List<WbsTreeContract>> contractGroupMap = wbsTreeContractList.stream().collect(Collectors.groupingBy(WbsTreeContract::getContractId));
@@ -1653,6 +1644,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                                     vo.setType(ObjectUtils.isNotEmpty(node.getNodeType()) ? node.getNodeType() : 0);
                                     vo.setTitle(ObjectUtil.isNotEmpty(node.getFullName()) ? node.getFullName() : node.getNodeName());
                                     vo.setPrimaryKeyId(node.getPKeyId());
+                                    vo.setParentId(node.getPId());
                                     WbsTreeContractStatistics statistics = wbsTreeContractStatisticsMap.get(node.getPKeyId());
                                     if (statistics != null) {
                                         Integer nums = statistics.calculateSubmitNums(tableOwner);
@@ -1663,6 +1655,9 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                                         } else {
                                             vo.setHasChildren(false);
                                         }
+                                        if (vo.getParentId() == null) {
+                                            vo.setParentId(statistics.getParentId());
+                                        }
                                     } else {
                                         vo.setSubmitCounts(0L);
                                         vo.setColorStatus(1);
@@ -1681,20 +1676,8 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                                 }
                                 return vo;
                             }).collect(Collectors.toList());
-//                    List<WbsTreeContractTreeAllVO> resultList = this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS);
-                    Comparator<WbsTreeContractTreeAllVO> safeComparator = Comparator
-                            .comparing(WbsTreeContractTreeAllVO::getSort, Comparator.nullsFirst(Comparator.naturalOrder()))
-                            .thenComparing(new ComplexStringComparator<>(obj ->
-                                    obj.getTitle() != null ? obj.getTitle() : ""))
-                            .thenComparing(
-                                    WbsTreeContractTreeAllVO::getPrimaryKeyId,
-                                    Comparator.nullsLast(Comparator.reverseOrder()));
-                    wbsTreeContractTreeAllVOS.sort(safeComparator);
-                    if (StringUtil.hasText(queryValue)) {
-                        resultMaps.put(Long.parseLong(cId), this.queryTreeResult(wbsTreeContractTreeAllVOS, queryValue));
-                    } else {
-                        resultMaps.put(Long.parseLong(cId), wbsTreeContractTreeAllVOS);
-                    }
+                    List<WbsTreeContractTreeAllVO> resultList = this.buildWbsTreeByStreamByTreeAll1(wbsTreeContractTreeAllVOS, pKeyId);
+                    resultMaps.put(Long.parseLong(cId), resultList);
                 });
                 if (contractInfo.getContractType() != null && contractInfo.getContractType() == 1) {
                     return R.data(resultMaps.get(contractInfo.getId()));
@@ -1704,6 +1687,64 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
         }
         return null;
     }
+    public List<WbsTreeContractTreeAllVO> buildWbsTreeByStreamByTreeAll1(List<WbsTreeContractTreeAllVO> wbsTreeVO2s, Long pKeyId) {
+        List<WbsTreeContractTreeAllVO> list = wbsTreeVO2s.stream().filter(f -> f.getParentId() == 0L).collect(Collectors.toList());
+        // 修改比较器链,处理空值情况
+        Comparator<WbsTreeContractTreeAllVO> safeComparator = Comparator
+                .comparing(WbsTreeContractTreeAllVO::getSort, Comparator.nullsFirst(Comparator.naturalOrder()))
+                .thenComparing(new ComplexStringComparator<>(obj ->
+                        obj.getTitle() != null ? obj.getTitle() : ""))
+                .thenComparing(
+                        WbsTreeContractTreeAllVO::getId,
+                        Comparator.nullsLast(Comparator.reverseOrder()));
+        list.sort(safeComparator);
+        Map<Long, List<WbsTreeContractTreeAllVO>> map = wbsTreeVO2s.stream().collect(Collectors.groupingBy(WbsTreeContractTreeAllVO::getParentId,
+                Collectors.collectingAndThen(Collectors.toList(), items -> items.stream().sorted(safeComparator).collect(Collectors.toList()))));
+        List<WbsTreeContractTreeAllVO> list1 = map.get(pKeyId);
+        if (list1 == null || list1.isEmpty()) {
+            return list1;
+        }
+        List<WbsTreeContractTreeAllVO> resultList = new ArrayList<>();
+        for (WbsTreeContractTreeAllVO vo : list1) {
+            List<WbsTreeContractTreeAllVO> list2 = map.get(vo.getPrimaryKeyId());
+            if ((list2 == null || list2.isEmpty())) {
+                if (vo.getIsCollect() != null && vo.getIsCollect() == 1) {
+                    resultList.add(vo);
+                }
+                continue;
+            }
+            long count = list2.stream().filter(f -> f.getIsCollect() != null && f.getIsCollect() == 1).count();
+            if (count > 0) {
+                resultList.add(vo);
+            } else {
+                if (isShow(list2, map)) {
+                    resultList.add(vo);
+                }
+            }
+        }
+        return resultList;
+    }
+
+    public boolean isShow(List<WbsTreeContractTreeAllVO> list, Map<Long, List<WbsTreeContractTreeAllVO>> map){
+        for (WbsTreeContractTreeAllVO vo : list) {
+            List<WbsTreeContractTreeAllVO> list2 = map.get(vo.getPrimaryKeyId());
+            if ((list2 == null || list2.isEmpty())) {
+                if (vo.getIsCollect() != null && vo.getIsCollect() == 1) {
+                    return true;
+                }
+                continue;
+            }
+            long count = list2.stream().filter(f -> f.getIsCollect() != null && f.getIsCollect() == 1).count();
+            if (count > 0) {
+                return true;
+            } else {
+                if (isShow(list2, map)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
 
     @Override
     public R<Object> getCollectTreeNodeByQuery(String contractId, String tableOwner, Long folderId, String queryValue) {
@@ -1718,8 +1759,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
             return R.fail(200, "合同段不存在");
         }
         Set<String> syncPKeyIds = getSyncFlagIds(contractId, tableOwner);
-        List<ContractCollectFolder> contractCollectNodes = jdbcTemplate.query("select node_id, ifnull((select ancestors_p_id from m_wbs_tree_contract where p_key_id = a.node_id), (select ancestors from m_wbs_tree_contract_statistics where id = a.node_id)) as nodeAncestors from m_contract_collect_folder a where type = 1 and parent_id = " + folderId
-                        + " and EXISTS (SELECT 1 from m_wbs_tree_contract where p_key_id = a.node_id)",
+        List<ContractCollectFolder> contractCollectNodes = jdbcTemplate.query("select node_id, ifnull((select ancestors_p_id from m_wbs_tree_contract where p_key_id = a.node_id), (select ancestors from m_wbs_tree_contract_statistics where id = a.node_id)) as nodeAncestors from m_contract_collect_folder a where type = 1 and parent_id = " + folderId,
                 new BeanPropertyRowMapper<>(ContractCollectFolder.class));
         if (!contractCollectNodes.isEmpty()) {
             Set<Long> pKeyIds = new LinkedHashSet<>();
@@ -1737,7 +1777,8 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                 collectMap.put(node.getNodeId(), "");
                 pKeyIds.add(node.getNodeId());
             }
-            List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, pKeyIds));
+            List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, pKeyIds).
+                    and(wrapper1 -> wrapper1.isNull(WbsTreeContract::getIsBussShow).or().ne(WbsTreeContract::getIsBussShow, 2)));
             if (!wbsTreeContractList.isEmpty()) {
                 String pKeyIdStr = wbsTreeContractList.stream().map(item -> item.getPKeyId() + "").collect(Collectors.joining(","));
                 List<WbsTreeContractStatistics> wbsTreeContractStatisticsList = jdbcTemplate.query("select id, leaf_num, fill_num, approve_num, complete_num,jl_fill_num, jl_approve_num, jl_complete_num from m_wbs_tree_contract_statistics where id in (" + pKeyIdStr + ")",