From 6546b269ef9950ffaaf2d38bd37b6094f4e2c7fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=B7=A1=E5=BF=98=E4=B8=80=E5=88=87?=
<7990497@qq.com>
Date: Thu, 21 Dec 2023 17:46:36 +0800
Subject: [PATCH] =?UTF-8?q?Finish=20Task=20#9031=20Cost:3h=20=E5=BC=80?=
=?UTF-8?q?=E5=8F=91=E5=AF=BC=E5=87=BAword?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crm-print.iml | 12 ---------
office-plugin/office-plugin.iml | 27 -------------------
.../cn/keking/service/ContractService.java | 10 ++++---
.../web/controller/ContractController.java | 11 +++++---
4 files changed, 14 insertions(+), 46 deletions(-)
delete mode 100644 crm-print.iml
delete mode 100644 office-plugin/office-plugin.iml
diff --git a/crm-print.iml b/crm-print.iml
deleted file mode 100644
index f409c0e..0000000
--- a/crm-print.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/office-plugin/office-plugin.iml b/office-plugin/office-plugin.iml
deleted file mode 100644
index 46b5623..0000000
--- a/office-plugin/office-plugin.iml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/server/src/main/java/cn/keking/service/ContractService.java b/server/src/main/java/cn/keking/service/ContractService.java
index 736a1bf..726a089 100644
--- a/server/src/main/java/cn/keking/service/ContractService.java
+++ b/server/src/main/java/cn/keking/service/ContractService.java
@@ -230,7 +230,7 @@ public class ContractService {
}
- public File download(String templateName, Map dataMap) throws Exception {
+ public File download(String templateName, Map dataMap,String type) throws Exception {
OutputStream os = null;
try {
File outFile = new File(Consts.uploadAbsDir());
@@ -259,10 +259,12 @@ public class ContractService {
xwpfDocument.write(os);
String outFilePath = Consts.uploadAbsDir()+ File.separator+ pdfName;
officeToPdfService.openOfficeToPDF(pathFile, outFilePath);
- //返回pdf
- return new File(outFilePath);
+ if("pdf".equals(type)){
+ //返回pdf
+ return new File(outFilePath);
+ }
//返回word
- //return new File(pathFile);
+ return new File(pathFile);
} finally {
if (os != null) {
os.close();
diff --git a/server/src/main/java/cn/keking/web/controller/ContractController.java b/server/src/main/java/cn/keking/web/controller/ContractController.java
index ee2b11e..1bbc7d9 100644
--- a/server/src/main/java/cn/keking/web/controller/ContractController.java
+++ b/server/src/main/java/cn/keking/web/controller/ContractController.java
@@ -5,6 +5,7 @@ import cn.keking.service.ContractService;
import cn.keking.utils.Consts;
import cn.keking.utils.ServiceResponse;
import com.alibaba.fastjson2.JSON;
+import com.github.xiaoymin.knife4j.core.util.StrUtil;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@@ -119,17 +120,21 @@ public class ContractController {
@ApiParam(value = "模板名称: 销售合同: sellContract ; 销售框架合同: frameContract", required = true) @PathVariable String templateName,
@io.swagger.v3.oas.annotations.parameters.RequestBody()
@RequestBody Map dataMap,
- HttpServletResponse response
+ HttpServletResponse response,
+ @RequestParam(value = "type", required = false) String type
) {
try {
log.error(JSON.toJSONString(dataMap));
OutputStream outstream = null;
+ if (type == null) {
+ type="pdf";
+ }
- File file = contractService.download(templateName, dataMap);
+ File file = contractService.download(templateName, dataMap,type);
outstream = response.getOutputStream();
response.setCharacterEncoding("utf-8");
response.setContentType("application/octet-stream");
- String filename = dataMap.get("conCode") + ".pdf";
+ String filename = dataMap.get("conCode") + "."+type;
response.reset();
// 设置response的Header
response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes()));