diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java index 9293b3018..b9b300176 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java @@ -293,20 +293,17 @@ public class CommonController { InputStream inputStream = null; OutputStream outputStream = null; try { - String fileName = ""; //本地下载 String filePath = ossFile.getUrl(); File file = new File(filePath); - if(!file.exists()){ + if(!CosBootUtil.doesObjectExist(filePath)){ response.setStatus(404); throw new RuntimeException("文件不存在.."); } // 文件名称 - fileName = file.getName(); - inputStream = new BufferedInputStream(new FileInputStream(filePath)); response.setContentType("application/force-download");// 设置强制下载不打开 response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1")); - inputStream = new BufferedInputStream(new FileInputStream(filePath)); + inputStream = CosBootUtil.download(filePath); outputStream = response.getOutputStream(); byte[] buf = new byte[1024]; int len; @@ -481,24 +478,23 @@ public class CommonController { } InputStream inputStream = null; OutputStream outputStream = null; + String fileName = ""; try { - String fileName = ""; //本地下载 String filePath = ossFile.getUrl(); - File file = new File(filePath); - //水印内容 - String waterContent = "water mark";//临时定义(水印信息通过传过来) - File newFile = PDFUtils.PDFWatermark(file,waterContent); - String path = newFile.getPath(); -// String substring = path.substring(filePath.length(), path.length()); - - if(!file.exists()){ + boolean b = CosBootUtil.doesObjectExist(filePath); + if (!b) { response.setStatus(404); throw new RuntimeException("文件不存在.."); } + InputStream download = CosBootUtil.download(filePath); + File file = new File(filePath); + //水印内容 + String waterContent = "water mark";//临时定义(水印信息通过传过来) + File newFile = PDFUtils.PDFWatermark(download,uploadpath,file.getName(),waterContent); // 文件名称 fileName = file.getName(); - inputStream = new BufferedInputStream(new FileInputStream(path)); + inputStream = new BufferedInputStream(new FileInputStream(newFile)); response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); response.setContentType("application/force-download");// 设置强制下载不打开 outputStream = response.getOutputStream(); @@ -527,9 +523,78 @@ public class CommonController { log.error(e.getMessage(), e); } } + File fileTemp = new File(uploadpath + File.separator +fileName); + fileTemp.delete(); } } +// /** +// * 文件预览PDF +// * +// * @param id 传入文件id +// * @param request +// * @param response +// */ +// @GetMapping(value = "/pdf/viewFile") +// public void viewFile(String id,HttpServletRequest request, HttpServletResponse response) { +// // 查询数据表数据是否存在 +// LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.eq(OSSFile::getId,id); +// OSSFile ossFile = ossFileService.getOne(queryWrapper); +// if( null == ossFile){ +// throw new JeroBootException("文件不存在.."); +// } +// InputStream inputStream = null; +// OutputStream outputStream = null; +// try { +// String fileName = ""; +// //本地下载 +// String filePath = ossFile.getUrl(); +// File file = new File(filePath); +// //水印内容 +// String waterContent = "water mark";//临时定义(水印信息通过传过来) +// File newFile = PDFUtils.PDFWatermark(file,waterContent); +// String path = newFile.getPath(); +//// String substring = path.substring(filePath.length(), path.length()); +// +// if(!file.exists()){ +// response.setStatus(404); +// throw new RuntimeException("文件不存在.."); +// } +// // 文件名称 +// fileName = file.getName(); +// inputStream = new BufferedInputStream(new FileInputStream(path)); +// response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); +// response.setContentType("application/force-download");// 设置强制下载不打开 +// outputStream = response.getOutputStream(); +// byte[] buf = new byte[1024]; +// int len; +// while ((len = inputStream.read(buf)) > 0) { +// outputStream.write(buf, 0, len); +// } +// response.flushBuffer(); +// } catch (IOException e) { +// log.error("文件下载失败" + e.getMessage()); +// response.setStatus(404); +// e.printStackTrace(); +// } finally { +// if (inputStream != null) { +// try { +// inputStream.close(); +// } catch (IOException e) { +// log.error(e.getMessage(), e); +// } +// } +// if (outputStream != null) { +// try { +// outputStream.close(); +// } catch (IOException e) { +// log.error(e.getMessage(), e); +// } +// } +// } +// +// } /** * @功能:pdf预览Iframe diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/util/PDFUtils.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/util/PDFUtils.java index 8b974fb56..223724870 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/util/PDFUtils.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/util/PDFUtils.java @@ -1,10 +1,25 @@ package com.jero.modules.system.util; -import com.spire.pdf.*; -import com.spire.pdf.graphics.*; +import com.spire.pdf.PdfDocument; +import com.spire.pdf.PdfPageBase; +import com.spire.pdf.graphics.PdfBrushes; +import com.spire.pdf.graphics.PdfFont; +import com.spire.pdf.graphics.PdfFontFamily; +import com.spire.pdf.graphics.PdfStringFormat; +import com.spire.pdf.graphics.PdfTextAlignment; +import com.spire.pdf.graphics.PdfTilingBrush; + import java.awt.*; -import java.awt.geom.*; -import java.io.*; +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; public class PDFUtils { public static void main(String[] args) throws IOException { @@ -69,43 +84,64 @@ public class PDFUtils { page.getCanvas().drawRectangle(brush, loRect); } - public static File PDFWatermark(File file,String waterMark) throws FileNotFoundException { - InputStream in = new FileInputStream(file) ; -// byte[] byteArray=File2byte(new File("f:ceshi/1.pdf")); + public static File PDFWatermark(InputStream in,String uploadpath, String fileName,String waterMark) throws FileNotFoundException { //创建PdfDocument类的对象 PdfDocument pdf = new PdfDocument(); //加载测试文档 pdf.loadFromStream(in); -// pdf.loadFromFile(file.getPath()); //为了去掉在第一页多余的水印,加一页,后边删除 pdf.getPages().add(); - //获取测试文档中的第一页 for(int i=0; i { Vue.ls.set(USER_NAME, res.result.userInfo.username, 7 * 24 * 60 * 60 * 1000) Vue.ls.set(USER_INFO, res.result.userInfo, 7 * 24 * 60 * 60 * 1000) Vue.ls.set(UI_CACHE_DB_DICT_DATA, res.result.sysAllDictItems, 7 * 24 * 60 * 60 * 1000) + Vue.ls.set('domianWebSocketURL', res.result.domianWebSocketURL) + Vue.ls.set('onlinePreviewDomainURL', res.result.onlinePreviewDomainURL) store.commit('SET_TOKEN', res.result.token) store.commit('SET_INFO', res.result.userInfo) store.commit('SET_NAME', { diff --git a/jero-web/src/views/documentManage/tags/dialog/TagForm.vue b/jero-web/src/views/documentManage/tags/dialog/TagForm.vue index 500bd41c1..09cfdc7ef 100644 --- a/jero-web/src/views/documentManage/tags/dialog/TagForm.vue +++ b/jero-web/src/views/documentManage/tags/dialog/TagForm.vue @@ -36,13 +36,13 @@ - + - + @@ -414,6 +414,9 @@ export default { submitForm () { // const that = this; // 触发表单验证 + this.form.dbFieldTxt = this.form.dbFieldTxt.trim() + this.form.dbFieldEnName = this.form.dbFieldEnName.trim() + this.form.dbFieldTxt = this.form.dbFieldTxt.trim() // console.log(this.$refs.tagform) this.$refs.tagEditForm.validate((valid)=>{ // console.log('valid',valid) diff --git a/jero-web/src/views/documentManage/tags/tabs/TagContent.vue b/jero-web/src/views/documentManage/tags/tabs/TagContent.vue index eeeea12c2..5c5a512da 100644 --- a/jero-web/src/views/documentManage/tags/tabs/TagContent.vue +++ b/jero-web/src/views/documentManage/tags/tabs/TagContent.vue @@ -44,7 +44,7 @@ > @@ -57,7 +57,7 @@ @@ -247,6 +247,8 @@ this.form = {} }, hideModal() { + this.form.dictName = this.form.dictName.trim() + this.form.description = this.form.description.trim() let params = { ...this.form }