Browse Source

资料查询page接口限制

liuyc 1 year ago
parent
commit
b307a3bcd9

+ 75 - 62
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -1830,7 +1830,7 @@ public class InformationWriteQueryController extends BladeController {
         if (wtc != null) {
             try {
                 String tableName = wtc.getInitTableName();
-                if(!ekvMap.containsKey(tableName)) {
+                if (!ekvMap.containsKey(tableName)) {
                     Map<String, String> map = ekvMap.computeIfAbsent(wtc.getInitTableName(), K -> new HashMap<>());
                     if (parent == null) {
                         parent = this.wbsTreeContractClient.getContractWbsTreeByContractIdAndId(wtc.getParentId(), Long.parseLong(wtc.getContractId()));
@@ -2954,7 +2954,7 @@ public class InformationWriteQueryController extends BladeController {
     @PostMapping("/saveContractTreeNode")
     @ApiOperationSupport(order = 10)
     @ApiOperation(value = "新增节点及其子节点")
-    @TreeCodeUpdate(name="contractId_${vo.contractId}")
+    @TreeCodeUpdate(name = "contractId_${vo.contractId}")
     public R<Boolean> saveContractTreeNode(@RequestBody AddContractTreeNodeVO vo) {
         //先获取当前节点的信息
         WbsTreeContract treeContract = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.parseLong(vo.getCurrentNodePrimaryKeyId()));
@@ -3134,7 +3134,7 @@ public class InformationWriteQueryController extends BladeController {
                 newData.setContractIdRelation(treeContract.getContractIdRelation());
                 newData.setContractType(treeContract.getContractType());
                 newData.setCreateTime(new Date());
-                if(Optional.ofNullable(half.getNodeType()).orElse(7)<=6){
+                if (Optional.ofNullable(half.getNodeType()).orElse(7) <= 6) {
                     newData.setIsTypePrivatePid(half.getPKeyId());
                 }
                 if (half.getType() != null && new Integer("2").equals(half.getType())) {
@@ -3566,76 +3566,89 @@ public class InformationWriteQueryController extends BladeController {
             //这一步主要是为了兼容监理合同段
             node = this.wbsTreeContractClient.getContractWbsTreeByContractIdAndId(vo.getWbsId(), Long.parseLong(vo.getContractIdRelation()));
         }
-        List<QueryProcessDataVO> queryDataResult = new ArrayList<>();
-        List<WbsTreeContractVO8> lowestNodes = new ArrayList<>();
-        if (!new Integer("6").equals(node.getNodeType()) && !Arrays.asList("1,2,3,4".split(",")).contains(node.getMajorDataType() + "")) {
-            /**
-             * 更改逻辑
-             * 使用queryProcessDataByParentIdAndContractId_3中,通过pKeyId查询;
-             * 放弃使用queryProcessDataByParentIdAndContractIdTwo中,通过ancestors字段查询,ancestors有问题
-             * @author liuyc
-             * @date 2023年9月8日11:26:46
-             */
-            //不是工序,则查询当前节点下的所有填报节点
-            if (node.getParentId() == 0) {
-                //当前合同段最底层节点pKeyIds
-                List<WbsTreeContract> lowestNodesAll = jdbcTemplate.query("select a.p_key_id,a.id,(SELECT CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.contract_id = " + node.getContractId() + " AND b.status = 1 AND b.type = 1 AND b.is_deleted = 0) AS hasChildren from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + node.getContractId() + " HAVING hasChildren = 0", new BeanPropertyRowMapper<>(WbsTreeContract.class));
-                List<String> pKeyIds = lowestNodesAll.stream().map(WbsTreeContract::getPKeyId).map(String::valueOf).collect(Collectors.toList());
-                List<List<String>> partition = Lists.partition(pKeyIds, 1000);
-                for (List<String> items : partition) {
-                    //获取填报节点信息
-                    List<QueryProcessDataVO> result = this.informationQueryMapper.queryProcessDataByParentIdAndContractId_3(contract.getContractType(), items);
-                    if (result.size() > 0) {
-                        queryDataResult.addAll(result);
+
+        if (node != null) {
+            List<QueryProcessDataVO> queryDataResult = new ArrayList<>();
+            List<WbsTreeContractVO8> lowestNodes = new ArrayList<>();
+            if (!new Integer("6").equals(node.getNodeType()) && !Arrays.asList("1,2,3,4".split(",")).contains(node.getMajorDataType() + "")) {
+                /**
+                 * 更改逻辑
+                 * 使用queryProcessDataByParentIdAndContractId_3中,通过pKeyId查询;
+                 * 放弃使用queryProcessDataByParentIdAndContractIdTwo中,通过ancestors字段查询,ancestors有问题
+                 * @author liuyc
+                 * @date 2023年9月8日11:26:46
+                 */
+                //不是工序,则查询当前节点下的所有填报节点
+                if (node.getParentId() == 0) {
+                    //当前合同段最底层节点pKeyIds
+                    List<WbsTreeContract> lowestNodesAll = jdbcTemplate.query("select a.p_key_id,a.id,(SELECT CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.contract_id = " + node.getContractId() + " AND b.status = 1 AND b.type = 1 AND b.is_deleted = 0) AS hasChildren from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + node.getContractId() + " HAVING hasChildren = 0", new BeanPropertyRowMapper<>(WbsTreeContract.class));
+                    List<String> pKeyIds = lowestNodesAll.stream().map(WbsTreeContract::getPKeyId).map(String::valueOf).collect(Collectors.toList());
+
+                    /*TODO 暂时解决page数量过多导致响应超时问题*/
+                    if (pKeyIds.size() > 1000) {
+                        return R.fail("当前节点下子节点过多,请减少节点层级进行检索!");
+                    }
+
+                    List<List<String>> partition = Lists.partition(pKeyIds, 1000);
+                    for (List<String> items : partition) {
+                        //获取填报节点信息
+                        List<QueryProcessDataVO> result = this.informationQueryMapper.queryProcessDataByParentIdAndContractId_3(contract.getContractType(), items);
+                        if (result.size() > 0) {
+                            queryDataResult.addAll(result);
+                        }
                     }
-                }
 
-                //queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractIdTwo("", contract.getContractType(), StringUtils.isNotEmpty(vo.getContractIdRelation()) ? vo.getContractIdRelation() : vo.getContractId().toString());
-            } else {
-                //获取当前选择的节点下的所有最底层节点
-                WbsTreeContractVO8 vo8 = BeanUtil.copyProperties(node, WbsTreeContractVO8.class);
-                this.lowestNodesRecursively(lowestNodes, Collections.singleton(vo8), node.getContractId());
-                List<String> pKeyIds = lowestNodes.stream().map(WbsTreeContractVO8::getPKeyId).map(String::valueOf).collect(Collectors.toList());
-                List<List<String>> partition = Lists.partition(pKeyIds, 1000);
-                for (List<String> items : partition) {
-                    //获取填报节点信息
-                    List<QueryProcessDataVO> result = this.informationQueryMapper.queryProcessDataByParentIdAndContractId_3(contract.getContractType(), items);
-                    if (result.size() > 0) {
-                        queryDataResult.addAll(result);
+                    //queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractIdTwo("", contract.getContractType(), StringUtils.isNotEmpty(vo.getContractIdRelation()) ? vo.getContractIdRelation() : vo.getContractId().toString());
+                } else {
+                    //获取当前选择的节点下的所有最底层节点
+                    WbsTreeContractVO8 vo8 = BeanUtil.copyProperties(node, WbsTreeContractVO8.class);
+                    this.lowestNodesRecursively(lowestNodes, Collections.singleton(vo8), node.getContractId());
+                    List<String> pKeyIds = lowestNodes.stream().map(WbsTreeContractVO8::getPKeyId).map(String::valueOf).collect(Collectors.toList());
+
+                    /*TODO 暂时解决page数量过多导致响应超时问题*/
+                    if (pKeyIds.size() > 1000) {
+                        return R.fail("当前节点下子节点过多,请减少节点层级进行检索!");
+                    }
+
+                    List<List<String>> partition = Lists.partition(pKeyIds, 1000);
+                    for (List<String> items : partition) {
+                        //获取填报节点信息
+                        List<QueryProcessDataVO> result = this.informationQueryMapper.queryProcessDataByParentIdAndContractId_3(contract.getContractType(), items);
+                        if (result.size() > 0) {
+                            queryDataResult.addAll(result);
+                        }
                     }
-                }
 
-                //queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractIdTwo(node.getId().toString(), contract.getContractType(), StringUtils.isNotEmpty(vo.getContractIdRelation()) ? vo.getContractIdRelation() : vo.getContractId().toString());
-            }
+                    //queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractIdTwo(node.getId().toString(), contract.getContractType(), StringUtils.isNotEmpty(vo.getContractIdRelation()) ? vo.getContractIdRelation() : vo.getContractId().toString());
+                }
 
-            //如果是首件列表请求,则删掉没有标记为首件的数据
-            if (queryDataResult.size() > 0) {
-                if (StringUtils.isNotEmpty(vo.getIsFirst())) {
-                    if (StringUtils.isNotEmpty(vo.getFirstTitle())) {
-                        queryDataResult = queryDataResult.stream().filter(qdr -> "3".equals(qdr.getQueryType())).collect(Collectors.toList());
-                    } else {
-                        //节点主键集合
-                        List<String> treeIds = queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList());
-                        //通过合同段主键在首件关联表中查询出所有数据
-                        List<TreeContractFirst> firstList = treeContractFirstService.list(new LambdaQueryWrapper<TreeContractFirst>().in(TreeContractFirst::getWbsNodeId, treeIds));
-                        List<String> list = firstList.stream().map(fl -> (fl.getWbsNodeId() + "")).collect(Collectors.toList());
-                        queryDataResult = queryDataResult.stream().filter(qdr -> list.contains(qdr.getPrimaryKeyId())).collect(Collectors.toList());
+                //如果是首件列表请求,则删掉没有标记为首件的数据
+                if (queryDataResult.size() > 0) {
+                    if (StringUtils.isNotEmpty(vo.getIsFirst())) {
+                        if (StringUtils.isNotEmpty(vo.getFirstTitle())) {
+                            queryDataResult = queryDataResult.stream().filter(qdr -> "3".equals(qdr.getQueryType())).collect(Collectors.toList());
+                        } else {
+                            //节点主键集合
+                            List<String> treeIds = queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList());
+                            //通过合同段主键在首件关联表中查询出所有数据
+                            List<TreeContractFirst> firstList = treeContractFirstService.list(new LambdaQueryWrapper<TreeContractFirst>().in(TreeContractFirst::getWbsNodeId, treeIds));
+                            List<String> list = firstList.stream().map(fl -> (fl.getWbsNodeId() + "")).collect(Collectors.toList());
+                            queryDataResult = queryDataResult.stream().filter(qdr -> list.contains(qdr.getPrimaryKeyId())).collect(Collectors.toList());
+                        }
                     }
+                    submitNodeKeyIds.addAll(queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList()));
                 }
-                submitNodeKeyIds.addAll(queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList()));
             }
-        }
 
-        //设置进集合中
-        vo.setWbsIds(submitNodeKeyIds);
-        if (StringUtils.isNotEmpty(vo.getContractIdRelation())) {
-            vo.setContractId(Long.valueOf(vo.getContractIdRelation()));
+            //设置进集合中
+            vo.setWbsIds(submitNodeKeyIds);
+            if (StringUtils.isNotEmpty(vo.getContractIdRelation())) {
+                vo.setContractId(Long.valueOf(vo.getContractIdRelation()));
+            }
         }
-
         return R.data(this.informationQueryService.selectInformationQueryPage(Condition.getPage(query), vo, node));
     }
 
-
     /**
      * 获取一个节点下的所有最底层节点
      *
@@ -3782,9 +3795,9 @@ public class InformationWriteQueryController extends BladeController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "ids", value = "ids", required = true)
     })
-    public R<String> getQueryInfoIds(String  ids) {
+    public R<String> getQueryInfoIds(String ids) {
         List<String> strList = Func.toStrList(ids);
-        for(String da : strList) {
+        for (String da : strList) {
             InformationQueryVO vo = new InformationQueryVO();
             vo.setWbsId(Long.parseLong(da));
             vo.setClassifyType("1");