Ver código fonte

资料查询根节点查不出数据

qianxb 2 anos atrás
pai
commit
90b4152bc9

+ 31 - 15
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -3,6 +3,7 @@ package org.springblade.business.controller;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
@@ -21,9 +22,7 @@ import org.springblade.business.feign.MessageWarningClient;
 import org.springblade.business.feign.OperationLogClient;
 import org.springblade.business.feign.RecycleBinClient;
 import org.springblade.business.feign.TaskClient;
-import org.springblade.business.service.IConstructionLedgerService;
-import org.springblade.business.service.IInformationQueryFileService;
-import org.springblade.business.service.ITaskService;
+import org.springblade.business.service.*;
 import org.springblade.business.socket.WebSocket;
 import org.springblade.business.utils.FileUtils;
 import org.springblade.business.vo.*;
@@ -53,7 +52,6 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
-import org.springblade.business.service.IInformationQueryService;
 import org.springblade.core.boot.ctrl.BladeController;
 
 import java.io.IOException;
@@ -108,6 +106,8 @@ public class InformationWriteQueryController extends BladeController {
 
     private final TableFileClient tableFileClient;
 
+    private final ITreeContractFirstService treeContractFirstService;
+
     /**
      * 获取文件题名
      */
@@ -2094,28 +2094,44 @@ public class InformationWriteQueryController extends BladeController {
             //这一步主要是为了兼容监理合同段
             node = this.wbsTreeContractClient.getContractWbsTreeByContractIdAndId(vo.getWbsId(), Long.parseLong(vo.getContractIdRelation()));
         }
-
+        List<QueryProcessDataVO> queryDataResult = new ArrayList<>();
         if (!new Integer("6").equals(node.getNodeType()) && !Arrays.asList("1,2,3,4".split(",")).contains(node.getMajorDataType().toString())) {
             //不是工序,则查询当前节点下的所有填报节点
             if (node.getParentId() == 0) {
                 String contractId = node.getContractId();
                 List<WbsTreeContract> treeS = wbsTreeContractClient.getContractWbsTreeByParentId(node.getId().toString(), contractId);
                 for (WbsTreeContract tree : treeS) {
-                    List<QueryProcessDataVO> queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(tree.getId().toString(), contract.getContractType(), StringUtils.isNotEmpty(vo.getContractIdRelation()) ? vo.getContractIdRelation() : vo.getContractId().toString());
-                    if (queryDataResult != null && queryDataResult.size() > 0) {
-                        submitNodeKeyIds.addAll(queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList()));
-                        queryDataResult.clear();
+                    List<QueryProcessDataVO> Result = this.informationQueryService.queryProcessDataByParentIdAndContractIdTwo(tree.getId().toString(), contract.getContractType(), StringUtils.isNotEmpty(vo.getContractIdRelation()) ? vo.getContractIdRelation() : vo.getContractId().toString());
+                    if (Result != null && Result.size() > 0) {
+                        queryDataResult.addAll(Result);
+                        Result.clear();
                     }
                 }
             } else {
-                List<QueryProcessDataVO> queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(node.getId().toString(), contract.getContractType(), StringUtils.isNotEmpty(vo.getContractIdRelation()) ? vo.getContractIdRelation() : vo.getContractId().toString());
-                if (StringUtils.isNotEmpty(vo.getIsFirst())) {
-                    //如果是首件列表请求,则删掉没有标记为首件的数据
-                    queryDataResult.removeIf(data -> StringUtils.isEmpty(data.getFirstId()));
+                List<QueryProcessDataVO> Result = this.informationQueryService.queryProcessDataByParentIdAndContractIdTwo(node.getId().toString(), contract.getContractType(), StringUtils.isNotEmpty(vo.getContractIdRelation()) ? vo.getContractIdRelation() : vo.getContractId().toString());
+                if (Result != null && Result.size() > 0) {
+                    queryDataResult.addAll(Result);
+                    Result.clear();
                 }
-                if (queryDataResult != null && queryDataResult.size() > 0) {
-                    submitNodeKeyIds.addAll(queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList()));
+            }
+            //如果是首件列表请求,则删掉没有标记为首件的数据
+            if (queryDataResult != null && queryDataResult.size() > 0) {
+                if (StringUtils.isNotEmpty(vo.getIsFirst())) {
+                    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());
+//                    for (QueryProcessDataVO queryProcessDataVO : queryDataResult) {
+//                        TreeContractFirst first = treeContractFirstService.getOne(new LambdaQueryWrapper<TreeContractFirst>()
+//                                .eq(TreeContractFirst::getWbsNodeId, queryProcessDataVO.getPrimaryKeyId()));
+//                        if (first != null){
+//                            queryProcessDataVO.setFirstId(first.getId()+"");
+//                        }
+//                    }
+//                    queryDataResult.removeIf(data -> StringUtils.isEmpty(data.getFirstId()));
                 }
+                submitNodeKeyIds.addAll(queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList()));
             }
         }
         //设置进集合中