From 00e4715a062585ad8e4f9dbaea8910b06e8ff228 Mon Sep 17 00:00:00 2001 From: whycxzp <perryhsu@163.com> Date: 星期三, 07 十二月 2022 12:01:45 +0800 Subject: [PATCH] 流程卡和SOP更新 --- src/main/java/com/whyc/service/ProcedureDocService.java | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/whyc/service/ProcedureDocService.java b/src/main/java/com/whyc/service/ProcedureDocService.java index 36971b7..7a7c583 100644 --- a/src/main/java/com/whyc/service/ProcedureDocService.java +++ b/src/main/java/com/whyc/service/ProcedureDocService.java @@ -1,10 +1,16 @@ package com.whyc.service; +import com.whyc.dto.Response; import com.whyc.mapper.ProcedureDocMapper; import com.whyc.pojo.ProcedureDoc; +import com.whyc.util.CommonUtil; +import com.whyc.util.FileUtil; +import com.whyc.util.Word2PdfAsposeUtil; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.File; @Service public class ProcedureDocService { @@ -15,4 +21,25 @@ public void insert(ProcedureDoc procedureDoc) { mapper.insert(procedureDoc); } + + public Response preview(String filePath) { + String fileSuffix = filePath.substring(filePath.lastIndexOf(".")+1); + String suffixOutFilePath; + if(fileSuffix.equals("doc")){ + suffixOutFilePath = filePath.replace(".doc","-doc.pdf"); + }else{ + suffixOutFilePath = filePath.replace(".docx","-docx.pdf"); + } + String projectDir = CommonUtil.getProjectDir(); + Word2PdfAsposeUtil.doc2pdf(projectDir + File.separator + filePath, + projectDir + File.separator + suffixOutFilePath); + return new Response().setII(1,suffixOutFilePath); + } + + public void download(String filePath, HttpServletResponse response) { + String projectDir = CommonUtil.getProjectDir(); + String absolutePath = projectDir + File.separator + filePath; + String filename = filePath.substring(filePath.lastIndexOf(File.separator)+1); + FileUtil.download(response,absolutePath,filename); + } } -- Gitblit v1.9.1