Merge branch 'master' into dev
This commit is contained in:
commit
692b678d8e
@ -191,7 +191,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.thoughtworks.xstream</groupId>
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
<artifactId>xstream</artifactId>
|
<artifactId>xstream</artifactId>
|
||||||
<version>1.4.18</version>
|
<version>1.4.20</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.googlecode.concurrentlinkedhashmap</groupId>
|
<groupId>com.googlecode.concurrentlinkedhashmap</groupId>
|
||||||
|
@ -237,7 +237,7 @@ public class ContractService {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public File download(String templateName, Map<String, Object> dataMap) throws Exception {
|
public File download(String templateName, Map<String, Object> dataMap,String type) throws Exception {
|
||||||
OutputStream os = null;
|
OutputStream os = null;
|
||||||
try {
|
try {
|
||||||
File outFile = new File(Consts.uploadAbsDir());
|
File outFile = new File(Consts.uploadAbsDir());
|
||||||
@ -266,10 +266,12 @@ public class ContractService {
|
|||||||
xwpfDocument.write(os);
|
xwpfDocument.write(os);
|
||||||
String outFilePath = Consts.uploadAbsDir()+ File.separator+ pdfName;
|
String outFilePath = Consts.uploadAbsDir()+ File.separator+ pdfName;
|
||||||
officeToPdfService.openOfficeToPDF(pathFile, outFilePath);
|
officeToPdfService.openOfficeToPDF(pathFile, outFilePath);
|
||||||
//返回pdf
|
if("pdf".equals(type)){
|
||||||
return new File(outFilePath);
|
//返回pdf
|
||||||
|
return new File(outFilePath);
|
||||||
|
}
|
||||||
//返回word
|
//返回word
|
||||||
//return new File(pathFile);
|
return new File(pathFile);
|
||||||
} finally {
|
} finally {
|
||||||
if (os != null) {
|
if (os != null) {
|
||||||
os.close();
|
os.close();
|
||||||
|
@ -5,6 +5,7 @@ import cn.keking.service.ContractService;
|
|||||||
import cn.keking.utils.Consts;
|
import cn.keking.utils.Consts;
|
||||||
import cn.keking.utils.ServiceResponse;
|
import cn.keking.utils.ServiceResponse;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.github.xiaoymin.knife4j.core.util.StrUtil;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -119,17 +120,21 @@ public class ContractController {
|
|||||||
@ApiParam(value = "模板名称: 销售合同: sellContract ; 销售框架合同: frameContract", required = true) @PathVariable String templateName,
|
@ApiParam(value = "模板名称: 销售合同: sellContract ; 销售框架合同: frameContract", required = true) @PathVariable String templateName,
|
||||||
@io.swagger.v3.oas.annotations.parameters.RequestBody()
|
@io.swagger.v3.oas.annotations.parameters.RequestBody()
|
||||||
@RequestBody Map<String, Object> dataMap,
|
@RequestBody Map<String, Object> dataMap,
|
||||||
HttpServletResponse response
|
HttpServletResponse response,
|
||||||
|
@RequestParam(value = "type", required = false) String type
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
log.error(JSON.toJSONString(dataMap));
|
log.error(JSON.toJSONString(dataMap));
|
||||||
OutputStream outstream = null;
|
OutputStream outstream = null;
|
||||||
|
if (type == null) {
|
||||||
|
type="pdf";
|
||||||
|
}
|
||||||
|
|
||||||
File file = contractService.download(templateName, dataMap);
|
File file = contractService.download(templateName, dataMap,type);
|
||||||
outstream = response.getOutputStream();
|
outstream = response.getOutputStream();
|
||||||
response.setCharacterEncoding("utf-8");
|
response.setCharacterEncoding("utf-8");
|
||||||
response.setContentType("application/octet-stream");
|
response.setContentType("application/octet-stream");
|
||||||
String filename = dataMap.get("conCode") + ".pdf";
|
String filename = dataMap.get("conCode") + "."+type;
|
||||||
response.reset();
|
response.reset();
|
||||||
// 设置response的Header
|
// 设置response的Header
|
||||||
response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes()));
|
response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user