Ver Fonte

质检、试验保存优化

yangyj há 1 ano atrás
pai
commit
056b41ec44

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -1921,13 +1921,13 @@ public class ExcelTabController extends BladeController {
         /*全加载,或者可以优化成依赖加载*/
         List<AppWbsTreeContractVO> tableAll = new ArrayList<>();
         List<TableInfo> tableInfoList = this.excelTabService.getTableInfoList(dataArray);
-        long start = System.currentTimeMillis();
+/*        long start = System.currentTimeMillis();
         if (tableInfoList != null) {
             tableInfoList.forEach(e->{e.setToBeUpdated(true);});
             tableAll = wbsTreeContractService.searchNodeAllTable(nodeId, "1", contractId, projectId, null);
             doForTableIst(tableAll,tableInfoList);
         }
-        System.out.println("加载所有表单数据耗时:"+(System.currentTimeMillis()-start));
+        System.out.println("加载所有表单数据耗时:"+(System.currentTimeMillis()-start));*/
         //公式填充
         this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId), ExecuteType.INSPECTION);
         assert tableInfoList != null;

+ 37 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -256,6 +256,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             List<TableInfo> result = new ArrayList<>();
             for (int m = 0; m < dataArray.size(); m++) {
                 TableInfo tableInfo = new TableInfo();
+                tableInfo.setToBeUpdated(true);
                 JSONObject dataInfo2 = dataArray.getJSONObject(m);
                 //
                 tableInfo.setContractId(dataInfo2.getString("contractId"));
@@ -351,6 +352,42 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 FormulaLog log = new FormulaLog();
                 /*每次都是部分表单提交,保证跨节点跨表取数正常,其次是反向依赖的被动刷新*/
                 List<NodeTable> tableAll = createNodeTables(nodeId, tableInfoList.get(0).getContractId(), tableInfoList.get(0).getProjectId(), type);
+                if(tableAll.size()>tableInfoList.size()){
+                    TableInfo example = tableInfoList.get(0);
+                    /*补充缺失的数据*/
+                    List<Long> cp= tableInfoList.stream().map(TableInfo::getPkeyId).map(Long::parseLong).collect(Collectors.toList());
+                    List<Long> load=tableAll.stream().map(NodeTable::getPKeyId).filter(pk->!cp.contains(pk)).collect(Collectors.toList());
+                    Map<Long,String> keyMap=tableAll.stream().collect(Collectors.toMap(NodeTable::getPKeyId,NodeTable::getInitTableName));
+                    Map<String,List<Long>> loadMap=load.stream().collect(Collectors.groupingBy(keyMap::get,Collectors.toList()));
+                    loadMap.entrySet().parallelStream().forEach(entry->{
+                        /*init_table_name*/
+                        String k=entry.getKey();
+                        /*pkeyId集合*/
+                        List<Long> v= entry.getValue();
+                      List<Map<String,Object>> dataMap=  this.jdbcTemplate.queryForList("select * from "+k+" where p_key_id in ("+v.stream().map(Objects::toString).collect(Collectors.joining(","))+")");
+                      if(dataMap.size()>0){
+                           dataMap.forEach(map->{
+                               TableInfo e = new TableInfo();
+                               e.setPkeyId(map.get("p_key_id").toString());
+                               e.setDataMap(new LinkedHashMap<>());
+                               e.setToBeUpdated(false);
+                               e.setBusinessId(null);
+                               e.setContractId(example.getContractId());
+                               e.setClassify(example.getClassify());
+                               e.setProjectId(example.getProjectId());
+                               e.setGroupId(example.getGroupId());
+                               map.forEach((key,value)->{
+                                   if(key.startsWith("key_")){
+                                       e.getDataMap().put(key,Func.toStr(value));
+                                   }
+                               });
+                               tableInfoList.add(e);
+                           });
+                      }
+                    });
+                    List<Long> tableAllIds=tableAll.stream().map(NodeTable::getPKeyId).collect(Collectors.toList());
+                    tableInfoList.sort(Comparator.comparingInt(a -> tableAllIds.indexOf(Long.parseLong(a.getPkeyId()))));
+                }
                 StopWatch stopWatch = new StopWatch();
                 List<KeyMapper> keyMappers = this.formulaService.getKeyMapperList(tableAll.stream().map(NodeTable::getPKeyId).filter(Func::isNotEmpty).collect(Collectors.toList()), tableInfoList.get(0).getProjectId(), String.valueOf(nodeId), type);
                 if (Func.isNotEmpty(keyMappers) && Func.isNotEmpty(tableAll)) {