浏览代码

试验bug

liuyc 2 年之前
父节点
当前提交
5e90f60efd

+ 8 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreePrivateVO4.java

@@ -23,10 +23,14 @@ public class WbsTreePrivateVO4 implements Serializable {
 
     private String nodeName;
 
+    private String fullName;
+
     private Integer nodeType;
 
     private Integer type;
 
+    private Long parentId;
+
     private Integer tableType;
 
     private String tableOwner;
@@ -51,6 +55,10 @@ public class WbsTreePrivateVO4 implements Serializable {
 
     private Integer isLinkTable;
 
+    private String ancestors;
+
+    private Integer sort;
+
     //是否是复制的表 0=否 1=是 (复制表可以删除)
     private Integer isCopyTab;
 

+ 3 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java

@@ -113,10 +113,11 @@ public class ExcelTabClientImpl implements ExcelTabClient {
         } catch (Exception e) {
             if (e.getMessage().contains("字段过长")) {
                 //字段过长,新增失败的异常处理
-                throw new RuntimeException("字段过长,新增失败");
+                throw new RuntimeException("字段过长,操作失败");
             } else {
                 //其他类型的异常处理
-                throw new RuntimeException("保存数据出错");
+                e.printStackTrace();
+                throw new RuntimeException("公式执行异常,操作失败");
             }
         }
 

+ 3 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.xml

@@ -703,6 +703,7 @@
         SELECT
             p_key_id,
             node_name,
+            full_name,
             node_type,
             case when table_type in(1,9) then 1
                  when table_type in(2,10) then 2
@@ -718,6 +719,7 @@
             html_url,
             excel_id,
             project_id,
+            parent_id,
             type,
             init_table_name,
             init_table_id,
@@ -725,6 +727,7 @@
             pdf_url,
             sort,
             create_time,
+            ancestors,
             (CASE WHEN locate('__',node_name) > 0 THEN 1 ELSE 0 END) AS isCopyTab
         FROM
             m_wbs_tree_private

+ 57 - 54
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -339,7 +339,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 List<NodeTable> tableAll = createNodeTables(nodeId, tableInfoList.get(0).getContractId(), tableInfoList.get(0).getProjectId(), type);
                 StopWatch stopWatch = new StopWatch();
                 List<KeyMapper> keyMappers = this.formulaService.getKeyMapperList(tableInfoList.stream().map(TableInfo::getPkeyId).filter(Func::isNotEmpty).map(Long::parseLong).collect(Collectors.toList()), tableInfoList.get(0).getProjectId(), String.valueOf(nodeId), type);
-                if (Func.isNotEmpty(keyMappers)) {
+                if (Func.isNotEmpty(keyMappers) && Func.isNotEmpty(tableAll)) {
                     Map<String, Map<String, String>> coordinateMap = createCoordinateMap(keyMappers, type);
                     stopWatch.start("公式处理");
                     List<Formula> formulas = this.formulaService.getFormulaList(keyMappers);
@@ -702,9 +702,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     }
 
     @Override
-    public void gsColor(Long pKeyId,String nodeId,String projectId,Document doc) {
-        try{
-            List<KeyMapper> keyMappers=this.formulaService.getKeyMapperList(Collections.singletonList(pKeyId),projectId,nodeId,ExecuteType.INSPECTION);
+    public void gsColor(Long pKeyId, String nodeId, String projectId, Document doc) {
+        try {
+            List<KeyMapper> keyMappers = this.formulaService.getKeyMapperList(Collections.singletonList(pKeyId), projectId, nodeId, ExecuteType.INSPECTION);
             if (!keyMappers.isEmpty()) {
                 keyMappers.stream()
                         .filter(e -> e.getFormulaId() != null)
@@ -714,10 +714,11 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                             processElements(doc.select("el-date-picker[keyname^=" + key + "]"));
                         });
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
+
     private void processElements(Elements elements) {
         elements.forEach(element -> element.parent().attr("gscolor", "11"));
     }
@@ -2372,63 +2373,65 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         FileUtils.setExcelScaleToPdf(excelPath, pdfPath);
         BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
 
-        //附件
-        TableFile tableFile1 = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getType, 1)).stream().findAny().orElse(null);
-        if (tableFile1 != null) {
+        if (bladeFile != null) {
+            //附件
+            TableFile tableFile1 = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getType, 1)).stream().findAny().orElse(null);
+            if (tableFile1 != null) {
             /*tableFile1.setDomainPdfUrl(bladeFile.getLink());
             tableFileService.saveOrUpdate(tableFile1);*/
-            tableFileService.update(Wrappers.<TableFile>lambdaUpdate().set(TableFile::getDomainPdfUrl, bladeFile.getLink()).eq(TableFile::getId, tableFile1.getId()));
-        } else {
-            TableFile tableFile = new TableFile();
-            String fileExtension = FileUtil.getFileExtension(wbsTreePrivate.getFullName() + ".pdf");
-            tableFile.setTabId(pkeyId + "");
-            tableFile.setName(wbsTreePrivate.getFullName() + ".pdf");
-            tableFile.setType(1);
-            tableFile.setDomainUrl(bladeFile.getLink());
-            tableFile.setIsDeleted(0);
-            tableFile.setExtension(fileExtension);
-            tableFile.setDomainPdfUrl(bladeFile.getLink());
-            tableFile.setTrialRecordId(id);
-            tableFileService.saveOrUpdate(tableFile);
-        }
+                tableFileService.update(Wrappers.<TableFile>lambdaUpdate().set(TableFile::getDomainPdfUrl, bladeFile.getLink()).eq(TableFile::getId, tableFile1.getId()));
+            } else {
+                TableFile tableFile = new TableFile();
+                String fileExtension = FileUtil.getFileExtension(wbsTreePrivate.getFullName() + ".pdf");
+                tableFile.setTabId(pkeyId + "");
+                tableFile.setName(wbsTreePrivate.getFullName() + ".pdf");
+                tableFile.setType(1);
+                tableFile.setDomainUrl(bladeFile.getLink());
+                tableFile.setIsDeleted(0);
+                tableFile.setExtension(fileExtension);
+                tableFile.setDomainPdfUrl(bladeFile.getLink());
+                tableFile.setTrialRecordId(id);
+                tableFileService.saveOrUpdate(tableFile);
+            }
 
-        //获取当前试验记录的中的元素表的附件文件
-        List<TableFile> tableFileList = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getTrialRecordId, id));
+            //获取当前试验记录的中的元素表的附件文件
+            List<TableFile> tableFileList = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getTrialRecordId, id));
 
-        if (tableFileList.size() > 0) {
-            tableFileList.sort(Comparator.comparing(TableFile::getType));
-            List<String> dataListPdf = tableFileList.stream().filter(tableFile ->
-                    tableFile.getDomainPdfUrl() != null
-                            && (tableFile.getType() == 1 || tableFile.getType() == 2)
-            ).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
+            if (tableFileList.size() > 0) {
+                tableFileList.sort(Comparator.comparing(TableFile::getType));
+                List<String> dataListPdf = tableFileList.stream().filter(tableFile ->
+                        tableFile.getDomainPdfUrl() != null
+                                && (tableFile.getType() == 1 || tableFile.getType() == 2)
+                ).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
 
-            String pdfPath2 = file_path + "/pdf//" + pkeyId + "_2.pdf";
+                String pdfPath2 = file_path + "/pdf//" + pkeyId + "_2.pdf";
 
-            File tabPdf2 = ResourceUtil.getFile(pdfPath2);
-            if (tabPdf2.exists()) {
-                tabPdf2.delete();
-            }
-            FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
-
-            BladeFile bladeFile2 = newIOSSClient.uploadFile(pkeyId + "2.pdf", pdfPath2);
-
-            //查询是否存在关系
-            String sqlQuery = "select id from u_trial_self_data_record where record_id = " + id + " and tab_id = " + pkeyId;
-            List<TrialSelfDataRecord> query = jdbcTemplate.query(sqlQuery, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
-            String sql;
-            if (query.size() == 0) {
-                //新增关系
-                sql = "insert into u_trial_self_data_record(id,record_id,tab_id,is_buss_show,is_tab_pdf,is_tab_file_type,pdf_url) values" +
-                        "(" + SnowFlakeUtil.getId() + "," + id + "," + pkeyId + "," + 1 + "," + 2 + "," + 1 + ",'" + bladeFile2.getLink() + "')";
-            } else {
-                //修改pdfUrl
-                sql = "update u_trial_self_data_record set pdf_url ='" + bladeFile2.getLink() + "' where record_id = " + id + " and tab_id = " + pkeyId;
-            }
-            jdbcTemplate.execute(sql);
+                File tabPdf2 = ResourceUtil.getFile(pdfPath2);
+                if (tabPdf2.exists()) {
+                    tabPdf2.delete();
+                }
+                FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
+
+                BladeFile bladeFile2 = newIOSSClient.uploadFile(pkeyId + "2.pdf", pdfPath2);
+
+                //查询是否存在关系
+                String sqlQuery = "select id from u_trial_self_data_record where record_id = " + id + " and tab_id = " + pkeyId;
+                List<TrialSelfDataRecord> query = jdbcTemplate.query(sqlQuery, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
+                String sql;
+                if (query.size() == 0) {
+                    //新增关系
+                    sql = "insert into u_trial_self_data_record(id,record_id,tab_id,is_buss_show,is_tab_pdf,is_tab_file_type,pdf_url) values" +
+                            "(" + SnowFlakeUtil.getId() + "," + id + "," + pkeyId + "," + 1 + "," + 2 + "," + 1 + ",'" + bladeFile2.getLink() + "')";
+                } else {
+                    //修改pdfUrl
+                    sql = "update u_trial_self_data_record set pdf_url ='" + bladeFile2.getLink() + "' where record_id = " + id + " and tab_id = " + pkeyId;
+                }
+                jdbcTemplate.execute(sql);
 
-            return bladeFile2.getLink();
+                return bladeFile2.getLink();
+            }
+            return bladeFile.getLink();
         }
-
         return "";
     }