Bladeren bron

Merge remote-tracking branch 'origin/dev' into dev

cr 3 dagen geleden
bovenliggende
commit
a1f679a396

+ 232 - 162
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
+import org.springblade.business.entity.WbsTreeContractStatistics;
 import org.springblade.business.feign.InformationQueryClient;
 import org.springblade.common.utils.BaiduApiUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
@@ -372,7 +373,11 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                 if (contractInfo.getContractType().equals(1)) {
                     LambdaQueryWrapper<WbsTreeContract> queryWrapper = new LambdaQueryWrapper<>();
                     queryWrapper.select(WbsTreeContract::getParentId, WbsTreeContract::getId, WbsTreeContract::getPKeyId);
-                    queryWrapper.like(WbsTreeContract::getFullName, queryValue);
+                    if (queryValue.startsWith(contractInfo.getContractName() + "\\") && queryValue.lastIndexOf("\\") + 1 < queryValue.length()) {
+                        queryWrapper.like(WbsTreeContract::getFullName, queryValue.substring(queryValue.lastIndexOf("\\") + 1));
+                    } else {
+                        queryWrapper.like(WbsTreeContract::getFullName, queryValue);
+                    }
                     queryWrapper.eq(WbsTreeContract::getContractId, contractId);
                     queryWrapper.eq(WbsTreeContract::getType, 1);
                     List<WbsTreeContract> nodes = wbsTreeContractMapper.selectList(queryWrapper);
@@ -401,15 +406,15 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                             }
                         }
 
-                        List<WbsTreeContractLazyVO> distinctNodesAll = nodesAllTemp.stream()
-                                .collect(Collectors.collectingAndThen(
-                                        Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
-                                        ArrayList::new
-                                ));
-                        List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
-                                Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
-                                ArrayList::new
-                        ));
+//                        List<WbsTreeContractLazyVO> distinctNodesAll = nodesAllTemp.stream()
+//                                .collect(Collectors.collectingAndThen(
+//                                        Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+//                                        ArrayList::new
+//                                ));
+//                        List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
+//                                Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+//                                ArrayList::new
+//                        ));
 
                         List<Long> parentIds = nodes.stream().map(WbsTreeContract::getParentId).collect(Collectors.toList());
                         List<Long> ids = nodes.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
@@ -420,68 +425,72 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                         resultNodesPKeyIds.addAll(nodes.stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList()));
                         List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, resultNodesPKeyIds));
 
-                        List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
-                        Object dataInformationQuery;
-                        if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
-                            dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1");
-                        } else {
-                            dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner);
-                        }
-                        if (dataInformationQuery != null) {
-                            queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
-                        } else {
-                            if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
-                                queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? GROUP BY wbs_id ) as a)"
-                                        , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractId);
-                                if (queryInfoList.size() > 0) {
-                                    JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
-                                    redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1", JSON.toJSON(array).toString());
-                                }
-                            } else {
-                                queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? AND classify = ? GROUP BY wbs_id) as a)"
-                                        , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractId,tableOwner);
-                                if (queryInfoList.size() > 0) {
-                                    JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
-                                    redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner, JSON.toJSON(array).toString());
-                                }
-                            }
-                        }
-                        Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getWbsId()))
-                                .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
-                        List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
-
-                        List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId()) && resultNodesPKeyIds.contains(f.getPKeyId())).collect(Collectors.toList());
-                        List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
-                        List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
-                        wbsTreeContractServiceImpl.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAllTemp);
-
-                        Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
-                                .peek(vo -> {
-                                    Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
-                                    if (colorStatus != null) {
-                                        vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
-                                    } else {
-                                        vo.setColorStatus(1);
-                                    }
-                                }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
-
-                        List<NodeVO> nodeVOList = distinctNodesAll.stream().map(wbsTreeContractServiceImpl::convertToNodeVO).collect(Collectors.toList());
-                        Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
-                        List<NodeVO> treeNodeVOList = wbsTreeContractServiceImpl.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
-                        NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
-                        List<NodeVO> nodeVOS = wbsTreeContractServiceImpl.flattenTree(treeNodeVOList);
-                        Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
+//                        List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
+//                        Object dataInformationQuery;
+//                        if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
+//                            dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1");
+//                        } else {
+//                            dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner);
+//                        }
+//                        if (dataInformationQuery != null) {
+//                            queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
+//                        } else {
+//                            if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
+//                                queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? GROUP BY wbs_id ) as a)"
+//                                        , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractId);
+//                                if (queryInfoList.size() > 0) {
+//                                    JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+//                                    redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1", JSON.toJSON(array).toString());
+//                                }
+//                            } else {
+//                                queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? AND classify = ? GROUP BY wbs_id) as a)"
+//                                        , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractId,tableOwner);
+//                                if (queryInfoList.size() > 0) {
+//                                    JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+//                                    redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner, JSON.toJSON(array).toString());
+//                                }
+//                            }
+//                        }
+//                        Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getWbsId()))
+//                                .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
+//                        List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
+
+//                        List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId()) && resultNodesPKeyIds.contains(f.getPKeyId())).collect(Collectors.toList());
+//                        List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
+//                        List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
+//                        wbsTreeContractServiceImpl.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAllTemp);
+//
+//                        Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
+//                                .peek(vo -> {
+//                                    Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
+//                                    if (colorStatus != null) {
+//                                        vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
+//                                    } else {
+//                                        vo.setColorStatus(1);
+//                                    }
+//                                }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
+//
+//                        List<NodeVO> nodeVOList = distinctNodesAll.stream().map(wbsTreeContractServiceImpl::convertToNodeVO).collect(Collectors.toList());
+//                        Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
+//                        List<NodeVO> treeNodeVOList = wbsTreeContractServiceImpl.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
+//                        NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
+//                        List<NodeVO> nodeVOS = wbsTreeContractServiceImpl.flattenTree(treeNodeVOList);
+//                        Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
 
                         if (wbsTreeContractList.size() > 0) {
-                            Map<Long, Long> countMap = new HashMap<>();
-                            for (WbsTreeContractLazyVO node : resultParentNodesTB) {
-                                Long key = node.getPKeyId();
-                                if (countMap.containsKey(key)) {
-                                    countMap.put(key, countMap.get(key) + 1L);
-                                } else {
-                                    countMap.put(key, 1L);
-                                }
-                            }
+//                            Map<Long, Long> countMap = new HashMap<>();
+//                            for (WbsTreeContractLazyVO node : resultParentNodesTB) {
+//                                Long key = node.getPKeyId();
+//                                if (countMap.containsKey(key)) {
+//                                    countMap.put(key, countMap.get(key) + 1L);
+//                                } else {
+//                                    countMap.put(key, 1L);
+//                                }
+//                            }
+                            String pKeyIds = 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 (" + pKeyIds + ")",
+                                    new BeanPropertyRowMapper<>(WbsTreeContractStatistics.class));
+                            Map<Long, WbsTreeContractStatistics> wbsTreeContractStatisticsMap = wbsTreeContractStatisticsList.stream().collect(Collectors.toMap(WbsTreeContractStatistics::getId, item -> item));
                             List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = wbsTreeContractList.stream()
                                     .map(node -> {
                                         WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
@@ -490,22 +499,30 @@ 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.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
-
-                                            Integer parentColorStatus = nodeColorStatusMap.get(vo.getPrimaryKeyId());
-                                            if (parentColorStatus != null) {
-                                                vo.setColorStatus(parentColorStatus);
+                                            WbsTreeContractStatistics statistics = wbsTreeContractStatisticsMap.get(node.getPKeyId());
+                                            if (statistics != null) {
+                                                Integer nums = statistics.calculateSubmitNums(tableOwner);
+                                                vo.setSubmitCounts(nums == null ? 0 : nums.longValue());
+                                                vo.setColorStatus(statistics.calculateColorStatus(tableOwner));
                                             } else {
-                                                WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(vo.getPrimaryKeyId());
-                                                if (lowestNode != null) {
-                                                    vo.setColorStatus(lowestNode.getColorStatus());
-                                                }
+                                                vo.setSubmitCounts(0L);
+                                                vo.setColorStatus(1);
                                             }
+//                                            vo.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
+//
+//                                            Integer parentColorStatus = nodeColorStatusMap.get(vo.getPrimaryKeyId());
+//                                            if (parentColorStatus != null) {
+//                                                vo.setColorStatus(parentColorStatus);
+//                                            } else {
+//                                                WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(vo.getPrimaryKeyId());
+//                                                if (lowestNode != null) {
+//                                                    vo.setColorStatus(lowestNode.getColorStatus());
+//                                                }
+//                                            }
                                         }
                                         return vo;
                                     }).collect(Collectors.toList());
-                            return R.data(this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS));
+                            return R.data(this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS, queryValue));
                         }
                     }
 
@@ -517,9 +534,14 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                         return null;
                     }
                     for (ContractRelationJlyz contractRelationJlyz : relationJLYZList) {
+                        ContractInfo contractInfoJlYz = this.getBaseMapper().selectById(contractRelationJlyz.getContractIdSg());
                         LambdaQueryWrapper<WbsTreeContract> queryWrapper = new LambdaQueryWrapper<>();
                         queryWrapper.select(WbsTreeContract::getParentId, WbsTreeContract::getId, WbsTreeContract::getPKeyId);
-                        queryWrapper.like(WbsTreeContract::getFullName, queryValue);
+                        if (queryValue.startsWith(contractInfoJlYz.getContractName() + "\\") && queryValue.lastIndexOf("\\") + 1 < queryValue.length()) {
+                            queryWrapper.like(WbsTreeContract::getFullName, queryValue.substring(queryValue.lastIndexOf("\\") + 1));
+                        } else {
+                            queryWrapper.like(WbsTreeContract::getFullName, queryValue);
+                        }
                         queryWrapper.eq(WbsTreeContract::getContractId, contractRelationJlyz.getContractIdSg());
                         queryWrapper.eq(WbsTreeContract::getType, 1);
                         List<WbsTreeContract> nodes = wbsTreeContractMapper.selectList(queryWrapper);
@@ -549,15 +571,15 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                                 }
                             }
 
-                            List<WbsTreeContractLazyVO> distinctNodesAll = nodesAllTemp.stream()
-                                    .collect(Collectors.collectingAndThen(
-                                            Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
-                                            ArrayList::new
-                                    ));
-                            List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
-                                    Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
-                                    ArrayList::new
-                            ));
+//                            List<WbsTreeContractLazyVO> distinctNodesAll = nodesAllTemp.stream()
+//                                    .collect(Collectors.collectingAndThen(
+//                                            Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+//                                            ArrayList::new
+//                                    ));
+//                            List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
+//                                    Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+//                                    ArrayList::new
+//                            ));
 
                             List<Long> parentIds = nodes.stream().map(WbsTreeContract::getParentId).collect(Collectors.toList());
                             List<Long> ids = nodes.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
@@ -567,69 +589,73 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                             resultNodesPKeyIds.addAll(nodes.stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList()));
                             List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, resultNodesPKeyIds));
 
-                            List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
-                            Object dataInformationQuery;
-                            if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
-                                dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_1");
-                            } else {
-                                dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_" + tableOwner);
-                            }
-                            if (dataInformationQuery != null) {
-                                queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
-                            } else {
-                                if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
-                                    queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? GROUP BY wbs_id) as a)"
-                                            , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractRelationJlyz.getContractIdSg());
-                                    if (queryInfoList.size() > 0) {
-                                        JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
-                                        redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_1", JSON.toJSON(array).toString());
-                                    }
-                                } else {
-                                    queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? AND classify = ? GROUP BY wbs_id) as a)"
-                                            , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractRelationJlyz.getContractIdSg(), tableOwner);
-                                    if (queryInfoList.size() > 0) {
-                                        JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
-                                        redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_" + tableOwner, JSON.toJSON(array).toString());
-                                    }
-                                }
-                            }
-                            Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getWbsId()))
-                                    .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
-                            List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
-
-                            //数量
-                            List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId()) && resultNodesPKeyIds.contains(f.getPKeyId())).collect(Collectors.toList());
-                            List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
-                            List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
-                            wbsTreeContractServiceImpl.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAllTemp);
-
-                            Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
-                                    .peek(vo -> {
-                                        Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
-                                        if (colorStatus != null) {
-                                            vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
-                                        } else {
-                                            vo.setColorStatus(1);
-                                        }
-                                    }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
-
-                            List<NodeVO> nodeVOList = distinctNodesAll.stream().map(wbsTreeContractServiceImpl::convertToNodeVO).collect(Collectors.toList());
-                            Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
-                            List<NodeVO> treeNodeVOList = wbsTreeContractServiceImpl.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
-                            NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
-                            List<NodeVO> nodeVOS = wbsTreeContractServiceImpl.flattenTree(treeNodeVOList);
-                            Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
+//                            List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
+//                            Object dataInformationQuery;
+//                            if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
+//                                dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_1");
+//                            } else {
+//                                dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_" + tableOwner);
+//                            }
+//                            if (dataInformationQuery != null) {
+//                                queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
+//                            } else {
+//                                if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
+//                                    queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? GROUP BY wbs_id) as a)"
+//                                            , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractRelationJlyz.getContractIdSg());
+//                                    if (queryInfoList.size() > 0) {
+//                                        JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+//                                        redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_1", JSON.toJSON(array).toString());
+//                                    }
+//                                } else {
+//                                    queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? AND classify = ? GROUP BY wbs_id) as a)"
+//                                            , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractRelationJlyz.getContractIdSg(), tableOwner);
+//                                    if (queryInfoList.size() > 0) {
+//                                        JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+//                                        redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_" + tableOwner, JSON.toJSON(array).toString());
+//                                    }
+//                                }
+//                            }
+//                            Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getWbsId()))
+//                                    .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
+//                            List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
+//
+//                            //数量
+//                            List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId()) && resultNodesPKeyIds.contains(f.getPKeyId())).collect(Collectors.toList());
+//                            List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
+//                            List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
+//                            wbsTreeContractServiceImpl.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAllTemp);
+//
+//                            Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
+//                                    .peek(vo -> {
+//                                        Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
+//                                        if (colorStatus != null) {
+//                                            vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
+//                                        } else {
+//                                            vo.setColorStatus(1);
+//                                        }
+//                                    }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
+//
+//                            List<NodeVO> nodeVOList = distinctNodesAll.stream().map(wbsTreeContractServiceImpl::convertToNodeVO).collect(Collectors.toList());
+//                            Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
+//                            List<NodeVO> treeNodeVOList = wbsTreeContractServiceImpl.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
+//                            NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
+//                            List<NodeVO> nodeVOS = wbsTreeContractServiceImpl.flattenTree(treeNodeVOList);
+//                            Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
 
                             if (wbsTreeContractList.size() > 0) {
-                                Map<Long, Long> countMap = new HashMap<>();
-                                for (WbsTreeContractLazyVO node : resultParentNodesTB) {
-                                    Long key = node.getPKeyId();
-                                    if (countMap.containsKey(key)) {
-                                        countMap.put(key, countMap.get(key) + 1L);
-                                    } else {
-                                        countMap.put(key, 1L);
-                                    }
-                                }
+//                                Map<Long, Long> countMap = new HashMap<>();
+//                                for (WbsTreeContractLazyVO node : resultParentNodesTB) {
+//                                    Long key = node.getPKeyId();
+//                                    if (countMap.containsKey(key)) {
+//                                        countMap.put(key, countMap.get(key) + 1L);
+//                                    } else {
+//                                        countMap.put(key, 1L);
+//                                    }
+//                                }
+                                String pKeyIds = 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 (" + pKeyIds + ")",
+                                        new BeanPropertyRowMapper<>(WbsTreeContractStatistics.class));
+                                Map<Long, WbsTreeContractStatistics> wbsTreeContractStatisticsMap = wbsTreeContractStatisticsList.stream().collect(Collectors.toMap(WbsTreeContractStatistics::getId, item -> item));
                                 List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = wbsTreeContractList.stream()
                                         .map(node -> {
                                             WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
@@ -638,21 +664,30 @@ 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.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
-
-                                                Integer parentColorStatus = nodeColorStatusMap.get(vo.getPrimaryKeyId());
-                                                if (parentColorStatus != null) {
-                                                    vo.setColorStatus(parentColorStatus);
+                                                WbsTreeContractStatistics statistics = wbsTreeContractStatisticsMap.get(node.getPKeyId());
+                                                if (statistics != null) {
+                                                    Integer nums = statistics.calculateSubmitNums(tableOwner);
+                                                    vo.setSubmitCounts(nums == null ? 0 : nums.longValue());
+                                                    vo.setColorStatus(statistics.calculateColorStatus(tableOwner));
                                                 } else {
-                                                    WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(vo.getPrimaryKeyId());
-                                                    if (lowestNode != null) {
-                                                        vo.setColorStatus(lowestNode.getColorStatus());
-                                                    }
+                                                    vo.setSubmitCounts(0L);
+                                                    vo.setColorStatus(1);
                                                 }
+//                                                vo.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
+//
+//                                                Integer parentColorStatus = nodeColorStatusMap.get(vo.getPrimaryKeyId());
+//                                                if (parentColorStatus != null) {
+//                                                    vo.setColorStatus(parentColorStatus);
+//                                                } else {
+//                                                    WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(vo.getPrimaryKeyId());
+//                                                    if (lowestNode != null) {
+//                                                        vo.setColorStatus(lowestNode.getColorStatus());
+//                                                    }
+//                                                }
                                             }
                                             return vo;
                                         }).collect(Collectors.toList());
-                                resultMaps.put(contractRelationJlyz.getContractIdSg(), this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS));
+                                resultMaps.put(contractRelationJlyz.getContractIdSg(), this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS, queryValue));
                             }
                         }
                     }
@@ -759,6 +794,41 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
         this.recursionFnTreeAll(list, map);
         return list;
     }
+    public List<WbsTreeContractTreeAllVO> buildWbsTreeByStreamByTreeAll(List<WbsTreeContractTreeAllVO> wbsTreeVO2s, String position) {
+        String[] split = position.split("\\\\");
+        if (split.length > 1 && split[1] != null && !split[1].isEmpty()) {
+            List<WbsTreeContractTreeAllVO> list = wbsTreeVO2s.stream().filter(f -> f.getParentId() == 0L).collect(Collectors.toList());
+            Map<Long, List<WbsTreeContractTreeAllVO>> map = wbsTreeVO2s.stream().collect(Collectors.groupingBy(WbsTreeContractTreeAllVO::getParentId));
+            this.recursionFnTreeAll(list, map, split, 0);
+            return list;
+        }
+        return buildWbsTreeByStreamByTreeAll(wbsTreeVO2s);
+    }
+    public void recursionFnTreeAll(List<WbsTreeContractTreeAllVO> list, Map<Long, List<WbsTreeContractTreeAllVO>> map, String[] positions, int i) {
+        for (WbsTreeContractTreeAllVO wbsTreeContractVO : list) {
+            String position;
+            if (i == 0 || i >= positions.length) {
+                position = null;
+            } else {
+                position = positions[i];
+            }
+            i++;
+            if (wbsTreeContractVO.getTitle() != null && (position == null || wbsTreeContractVO.getTitle().contains(position))) {
+                List<WbsTreeContractTreeAllVO> childrenList = map.get(wbsTreeContractVO.getId());
+                if (childrenList != null && !childrenList.isEmpty()) {
+                    if (i < positions.length) {
+                        String temp = positions[i];
+                        childrenList = childrenList.stream().filter(item -> item.getTitle().contains(temp)).collect(Collectors.toList());
+                    }
+                    wbsTreeContractVO.setChildren(childrenList);
+                    if (!childrenList.isEmpty()) {
+                        wbsTreeContractVO.setHasChildren(true);
+                        recursionFnTreeAll(childrenList, map, positions, i);
+                    }
+                }
+            }
+        }
+    }
 
     public void recursionFnTree(List<WbsTreeContractVO> list, Map<Long, List<WbsTreeContractVO>> map) {
         for (WbsTreeContractVO wbsTreeContractVO : list) {

+ 34 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/ExcelInfoUtils.java

@@ -1,5 +1,8 @@
 package org.springblade.manager.utils;
 
+import com.aspose.cells.Column;
+import com.aspose.cells.ColumnCollection;
+import com.aspose.cells.SaveFormat;
 import com.spire.xls.CellRange;
 import com.spire.xls.FileFormat;
 import com.spire.xls.Workbook;
@@ -18,9 +21,8 @@ import org.springblade.core.tool.utils.IoUtil;
 import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.manager.vo.DateFormat;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
+import java.awt.*;
+import java.io.*;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -37,7 +39,7 @@ public class ExcelInfoUtils {
 
             // 解析原始excel
             Workbook wb = new Workbook();
-            wb.loadFromMHtml(inputStream);
+            wb.loadFromMHtml(getInputStreamByUrl(inputStream));
             Worksheet sheet = wb.getWorksheets().get(0);
             HTMLOptions options = new HTMLOptions();
             options.setImageEmbedded(true);
@@ -207,6 +209,34 @@ public class ExcelInfoUtils {
             e.printStackTrace();
         }
     }
+
+
+    /**
+     * 解析excel 对隐藏的列设置初始列宽
+     * @param inputStream
+     * @return
+     * @throws Exception
+     */
+    public static InputStream getInputStreamByUrl(InputStream inputStream) throws Exception {
+        com.aspose.cells.Workbook workbook = new com.aspose.cells.Workbook(inputStream);
+        com.aspose.cells.Worksheet worksheet = workbook.getWorksheets().get(0);
+        // 获取工作表中所有列
+        ColumnCollection columns = worksheet.getCells().getColumns();
+        // 遍历所有列
+        for (int i = 0; i < columns.getCount(); i++) {
+            Column column = columns.get(i);
+            // 如果列是隐藏的(列宽为0)
+            if (column.isHidden()) {
+                // 解除隐藏并设置一个最小列宽(例如0.1)
+                column.setHidden(false);
+                column.setWidth(0.1);
+            }
+        }
+        // 将工作簿保存到ByteArrayOutputStream,然后转换为ByteArrayInputStream
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        workbook.save(outputStream, SaveFormat.XLSX);
+        return new ByteArrayInputStream(outputStream.toByteArray());
+    }
     /**
      * 在线编辑excel 操作
      *

+ 67 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/FileUtils.java

@@ -1,7 +1,6 @@
 package org.springblade.manager.utils;
 
-import com.aspose.cells.PdfSaveOptions;
-import com.aspose.cells.SaveFormat;
+import com.aspose.cells.*;
 import com.aspose.cells.Workbook;
 import com.drew.imaging.ImageMetadataReader;
 import com.drew.imaging.ImageProcessingException;
@@ -302,7 +301,70 @@ public class FileUtils {
         }
     }
 
+    /**
+     * Excel 转 PDF(完整缩放到 A4 纸张)
+     *
+     * @param excelPath  Excel 文件路径
+     * @param pdfPath    输出 PDF 路径
+     */
+    public static void excelToPdf(String excelPath, String pdfPath, Boolean a) {
+        // 显式指定中文字体
+        FontConfigs.setDefaultFontName("WenQuanYi Micro Hei"); // 文泉驿微米黑
+        FontConfigs.setFontSubstitutes("SimSun", new String[]{"WenQuanYi Micro Hei"}); // 宋体替代
+        Workbook workbook = null;
+        try {
+            // 1. 创建输出目录(如果需要)
+            File pdfFile = new File(pdfPath);
+            File parentDir = pdfFile.getParentFile();
+            if (parentDir != null && !parentDir.exists()) {
+                parentDir.mkdirs();
+            }
 
+            // 2. 直接加载 Excel 文件(无需 Apache POI 中转)
+            workbook = new Workbook(excelPath);
+
+            // 3. 配置 PDF 保存选项
+            PdfSaveOptions pdfOptions = new PdfSaveOptions();
+            pdfOptions.setOnePagePerSheet(true); // 每张表单独一页
+
+            // 4. 遍历所有工作表设置 A4 缩放
+            WorksheetCollection worksheets = workbook.getWorksheets();
+            for (int i = 0; i < worksheets.getCount(); i++) {
+                com.aspose.cells.Worksheet sheet = worksheets.get(i);
+                PageSetup pageSetup = sheet.getPageSetup();
+
+                // 核心缩放设置
+                pageSetup.setPaperSize(PaperSizeType.PAPER_A_4);
+                pageSetup.setFitToPagesWide(1);  // 宽度缩放到1页
+                pageSetup.setFitToPagesTall(1);  // 高度缩放到1页
+
+                // 可选优化设置
+//                pageSetup.setOrientation(PageOrientationType.LANDSCAPE); // 横向(宽表格适用)
+                pageSetup.setPrintGridlines(false); // 不打印网格线
+
+                // 调整边距(毫米单位)
+                pageSetup.setLeftMargin(1);
+                pageSetup.setRightMargin(1);
+                pageSetup.setTopMargin(1);
+                pageSetup.setBottomMargin(1);
+            }
+
+            // 5. 保存为 PDF
+            workbook.save(pdfPath, pdfOptions);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            // 6. 释放资源(新版 Aspose.Cells 支持自动关闭)
+            if (workbook != null) {
+                try {
+                    workbook.dispose();
+                } catch (Exception e) {
+                    // 忽略关闭异常
+                }
+            }
+        }
+    }
     /**
      * excel 转pdf
      *
@@ -310,6 +372,9 @@ public class FileUtils {
      * @param pdfUrl
      */
     public static void excelToPdf(String exUrl, String pdfUrl) {
+        // 显式指定中文字体
+        FontConfigs.setDefaultFontName("WenQuanYi Micro Hei"); // 文泉驿微米黑
+        FontConfigs.setFontSubstitutes("SimSun", new String[]{"WenQuanYi Micro Hei"}); // 宋体替代
 
         org.apache.poi.ss.usermodel.Workbook ss = null;
         ByteArrayInputStream byteArrayInputStream = null;