Przeglądaj źródła

添加预览报告接口

gushoubang 7 miesięcy temu
rodzic
commit
f4117f2309

+ 15 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/controller/FzssController.java

@@ -106,7 +106,8 @@ public class FzssController extends BaseController {
     public RequestResult SaveWordFile(@RequestBody DkReportVo dkReportVo) {
         FzxzReport fzxzReport = iReportService.createReport(dkReportVo.getBsm(), dkReportVo.getDkIds());
         Map<String, String> resMap = new HashMap<>();
-        resMap.put("fxbg", fzxzReport.getReportfile());
+        resMap.put("fxbg", fzxzReport.getReportFile());
+        resMap.put("fxbgPdf", fzxzReport.getReportPdfFile());
         return RequestResult.success("查询成功!", resMap);
     }
 
@@ -129,4 +130,17 @@ public class FzssController extends BaseController {
             FileUtils.writeBytes(realFileName, response.getOutputStream());
         }
     }
+
+    @GetMapping("/ShowReport")
+    public void fileShow(String filePath, HttpServletResponse response) throws IOException {
+        String realFileName = temp + filePath;
+        File file = new File(realFileName);
+        // 取得文件名。
+        String downloadName = file.getName();
+
+        response.setCharacterEncoding("utf-8");
+        response.setContentType("application/pdf");
+        response.setHeader("Content-Disposition", "inline;fileName=" + URLEncoder.encode(downloadName, "UTF-8"));
+        FileUtils.writeBytes(realFileName, response.getOutputStream());
+    }
 }

+ 2 - 2
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/domain/FzxzReport.java

@@ -7,8 +7,8 @@ import java.util.List;
 @Data
 public class FzxzReport {
     private String message = "检查完成";/// 消息内容
-    private String reportfile;/// 选址报告文件
-    // private String rootPath;/// 根目录
+    private String reportFile;/// 选址报告文件
+    private String reportPdfFile;/// 根目录
 
     private String bsm;
     // private String fxbg;

+ 3 - 3
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/ReportServiceImpl.java

@@ -27,7 +27,6 @@ import com.onemap.system.api.SpatialService;
 import com.onemap.system.api.domain.PolygonDataVo;
 import com.onemap.system.api.domain.WktsVo;
 import org.apache.commons.io.FileUtils;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.util.Units;
 import org.apache.poi.xwpf.usermodel.*;
 import org.springframework.beans.factory.annotation.Value;
@@ -98,7 +97,8 @@ public class ReportServiceImpl implements IReportService {
             String reportPath = "选址报告_" + timeStamp + ".docx";
             createReport(res, allPath + "/" + reportPath, dkIds);
             // 生成返回结果
-            fzxzReport.setReportfile(filePath + "/" + reportPath);
+            fzxzReport.setReportFile(filePath + "/" + reportPath);
+            fzxzReport.setReportPdfFile(filePath + "/" + reportPath.replace(".docx", ".pdf"));
             fzxzReport.setBsm(bsm);
             // fzxzReport.setFxbg(fzxzReport.getReportfile());
             fzxzReport.setJsdw(res.getJsdw());
@@ -453,7 +453,7 @@ public class ReportServiceImpl implements IReportService {
         }
         // 转PDF
         String outfilepath = reportPath.replace(".docx", ".pdf");
-        // NpoiHelper.doc2pdf(reportPath, outfilepath);
+        NpoiHelper.doc2pdf(reportPath, outfilepath);
         System.out.println(outfilepath);
     }