|
@@ -38,6 +38,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.File;
|
|
|
import java.io.OutputStream;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -153,18 +154,39 @@ public class AttachmentController {
|
|
|
//将编码加到http头信息中
|
|
|
headers.setContentDispositionFormData("attachment", downloadFileName);
|
|
|
|
|
|
- String folder=System.getProperty("java.io.tmpdir");
|
|
|
+ String folderPath = pdfConfig.getOutputPath();
|
|
|
|
|
|
- String filePath = folder + File.separator + DateTime.now().toString("yyyyMMddHHmmssSSS") + ".pdf";
|
|
|
+ File folder = new File(folderPath);
|
|
|
+
|
|
|
+ if (!folder.exists()){
|
|
|
+ folder.mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
+ String filePath = folderPath + File.separator + DateTime.now().toString("yyyyMMddHHmmssSSS") + ".pdf";
|
|
|
+
|
|
|
+ log.warn("生成PDF文档:" + filePath);
|
|
|
|
|
|
ItextPDFUtil.createPdf(insuranceApplication, mapList, list, logoUrl,filePath);
|
|
|
|
|
|
- String outputPath = folder + File.separator + DateTime.now().toString("yyyyMMddHHmmssSSS") + "-watermark.pdf";
|
|
|
+ String watermarkFilePath = folderPath + File.separator + DateTime.now().toString("yyyyMMddHHmmssSSS") + "-watermark.pdf";
|
|
|
|
|
|
//pdf文档添加图片水印
|
|
|
if (StringUtils.isNotEmpty(company.getCompanyStampFile())) {
|
|
|
- Watermark.imageWatermark(filePath, outputPath, company.getCompanyStampFile());
|
|
|
- filePath = outputPath;
|
|
|
+ String ext = company.getCompanyStampFile().substring(company.getCompanyStampFile().lastIndexOf("."));
|
|
|
+ String watermarkLogoPath = folderPath + File.separator + DateTime.now().toString("yyyyMMddHHmmssSSS") + ext;
|
|
|
+
|
|
|
+ //下载水印图片
|
|
|
+ boolean success = OSSUtil.download(company.getCompanyStampFile(),watermarkLogoPath);
|
|
|
+
|
|
|
+ if(success) {
|
|
|
+ try {
|
|
|
+ Watermark.imageWatermark(filePath, watermarkFilePath, watermarkLogoPath);
|
|
|
+ filePath = watermarkFilePath;
|
|
|
+ }
|
|
|
+ catch (Exception e){
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
byte[] buffer = FileUtil.readBytes(filePath);
|