ソースを参照

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

yangyj 2 年 前
コミット
0a8ae3d23d

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

@@ -681,7 +681,7 @@ public class ExcelTabController extends BladeController {
 
 
     /**
-     * 清表生成html
+     * 客户端清表生成html
      */
     @GetMapping("/get-excel-html")
     @ApiOperationSupport(order = 15)
@@ -700,6 +700,59 @@ public class ExcelTabController extends BladeController {
             return R.fail("请上传清表!");
         }
 
+        File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
+//        File file1 = ResourceUtil.getFile("D:\\develop\\1625742323381960704.html");
+        FileInputStream fileInputStream = new FileInputStream(file1);
+        String htmlString = IoUtil.readToString(fileInputStream);
+
+        // 远程搜索配置
+        Document doc = Jsoup.parse(htmlString);
+        Element table = doc.select("table").first();
+        Elements col = doc.select("Col");
+        doc.select("Col").remove();
+        ProjectInfo projectInfo = projectInfoService.getById(wbsTreePrivate.getProjectId());
+        // 添加标题显示
+        Elements trs = table.select("tr");
+        for (int i = 1; i < 6; i++) {
+            Element tr = trs.get(i);
+            Elements tds = tr.select("td");
+            for (int j = 0; j < tds.size(); j++) {
+                Element data = tds.get(j);
+                int colspan = data.attr("COLSPAN").equals("") ? 0 : Integer.parseInt(data.attr("COLSPAN"));
+                String style = data.attr("style");
+                if (style.indexOf("font-size") >= 0) {
+                    int fontsize = Integer.parseInt(style.substring(style.indexOf("font-size:") + 10, style.indexOf(".0pt")));
+                    if (StringUtils.isNotEmpty(data.text()) && fontsize >= 12) {
+                        trs.get(i - 1).select("td").get(0).text(projectInfo.getProjectName());
+                        break;
+                    }
+                }
+            }
+        }
+        fileInputStream.close();
+        return R.data(table + "");
+    }
+
+    /**
+     * 后管清表生成html
+     */
+    @GetMapping("/get-excel-html-two")
+    @ApiOperationSupport(order = 15)
+    @ApiOperation(value = "清表生成html", notes = "清表生成html")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
+    })
+    public R getExcelHtmlTwo(Long pkeyId) throws IOException, InterruptedException {
+
+        Thread.sleep(200);
+        WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(pkeyId);
+        if (wbsTreePrivate == null) {
+            return R.fail("该数据下无此节点!");
+        }
+        if (wbsTreePrivate.getHtmlUrl() == null) {
+            return R.fail("请上传清表!");
+        }
+
         File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
 //        File file1 = ResourceUtil.getFile("D:\\develop\\1613737889349238784.html");
         FileInputStream fileInputStream = new FileInputStream(file1);
@@ -711,13 +764,10 @@ public class ExcelTabController extends BladeController {
         // 远程搜索配置
         Document doc = Jsoup.parse(htmlString);
         Element table = doc.select("table").first();
-
-
         Elements col = doc.select("Col");
         doc.select("Col").remove();
         ProjectInfo projectInfo = projectInfoService.getById(wbsTreePrivate.getProjectId());
         // 添加标题显示
-
         Elements trs = table.select("tr");
         for (int i = 1; i < 6; i++) {
             Element tr = trs.get(i);
@@ -735,8 +785,6 @@ public class ExcelTabController extends BladeController {
                 }
             }
         }
-
-
         fileInputStream.close();
         return R.data(table + "");
     }