liuyc 1 年之前
父節點
當前提交
f24dce3f22

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

@@ -328,6 +328,7 @@ public class WbsTreeContractController extends BladeController {
     public void downloadExcel(@RequestParam String pKeyId, HttpServletResponse response) {
     public void downloadExcel(@RequestParam String pKeyId, HttpServletResponse response) {
         com.spire.xls.Workbook workbook = null;
         com.spire.xls.Workbook workbook = null;
         String htmlUrl = "";
         String htmlUrl = "";
+        String fileName = "";
         try {
         try {
             WbsTreeContract tab = iWbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, pKeyId));
             WbsTreeContract tab = iWbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, pKeyId));
             if (ObjectUtil.isEmpty(tab)) {
             if (ObjectUtil.isEmpty(tab)) {
@@ -335,9 +336,11 @@ public class WbsTreeContractController extends BladeController {
                 WbsTreePrivate treePrivateTab = jdbcTemplate.query("select * from m_wbs_tree_private where p_key_id = " + pKeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
                 WbsTreePrivate treePrivateTab = jdbcTemplate.query("select * from m_wbs_tree_private where p_key_id = " + pKeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
                 if (treePrivateTab != null && treePrivateTab.getHtmlUrl() != null) {
                 if (treePrivateTab != null && treePrivateTab.getHtmlUrl() != null) {
                     htmlUrl = treePrivateTab.getHtmlUrl();
                     htmlUrl = treePrivateTab.getHtmlUrl();
+                    fileName = ObjectUtil.isNotEmpty(treePrivateTab.getFullName()) ? treePrivateTab.getFullName() : treePrivateTab.getNodeName();
                 }
                 }
             } else {
             } else {
                 htmlUrl = tab.getHtmlUrl();
                 htmlUrl = tab.getHtmlUrl();
+                fileName = ObjectUtil.isNotEmpty(tab.getFullName()) ? tab.getFullName() : tab.getNodeName();
             }
             }
 
 
             if (ObjectUtil.isEmpty(htmlUrl)) {
             if (ObjectUtil.isEmpty(htmlUrl)) {
@@ -346,7 +349,7 @@ public class WbsTreeContractController extends BladeController {
 
 
             //将html转换为excel
             //将html转换为excel
             ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
             ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-            InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(tab.getHtmlUrl());
+            InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(htmlUrl);
             workbook = new com.spire.xls.Workbook();
             workbook = new com.spire.xls.Workbook();
             workbook.loadFromHtml(inputStreamByUrl);
             workbook.loadFromHtml(inputStreamByUrl);
             workbook.saveToStream(byteArrayOutputStream, FileFormat.Version2007);
             workbook.saveToStream(byteArrayOutputStream, FileFormat.Version2007);
@@ -407,7 +410,7 @@ public class WbsTreeContractController extends BladeController {
                 try (ServletOutputStream outputStream = response.getOutputStream();
                 try (ServletOutputStream outputStream = response.getOutputStream();
                      ByteArrayOutputStream byteArrayOutputStreamResult = new ByteArrayOutputStream()) {
                      ByteArrayOutputStream byteArrayOutputStreamResult = new ByteArrayOutputStream()) {
                     //设置响应头
                     //设置响应头
-                    response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(ObjectUtil.isNotEmpty(tab.getFullName()) ? tab.getFullName() : tab.getNodeName(), "UTF-8") + ".xlsx");
+                    response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
                     response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
                     response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
                     poiWorkbook.write(byteArrayOutputStreamResult);
                     poiWorkbook.write(byteArrayOutputStreamResult);
                     byte[] excelBytesResult = byteArrayOutputStreamResult.toByteArray();
                     byte[] excelBytesResult = byteArrayOutputStreamResult.toByteArray();