Merge remote-tracking branch 'origin/master'
This commit is contained in:
+80
-15
@@ -293,20 +293,17 @@ public class CommonController {
|
|||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
OutputStream outputStream = null;
|
OutputStream outputStream = null;
|
||||||
try {
|
try {
|
||||||
String fileName = "";
|
|
||||||
//本地下载
|
//本地下载
|
||||||
String filePath = ossFile.getUrl();
|
String filePath = ossFile.getUrl();
|
||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
if(!file.exists()){
|
if(!CosBootUtil.doesObjectExist(filePath)){
|
||||||
response.setStatus(404);
|
response.setStatus(404);
|
||||||
throw new RuntimeException("文件不存在..");
|
throw new RuntimeException("文件不存在..");
|
||||||
}
|
}
|
||||||
// 文件名称
|
// 文件名称
|
||||||
fileName = file.getName();
|
|
||||||
inputStream = new BufferedInputStream(new FileInputStream(filePath));
|
|
||||||
response.setContentType("application/force-download");// 设置强制下载不打开
|
response.setContentType("application/force-download");// 设置强制下载不打开
|
||||||
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
|
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();
|
outputStream = response.getOutputStream();
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
int len;
|
int len;
|
||||||
@@ -481,24 +478,23 @@ public class CommonController {
|
|||||||
}
|
}
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
OutputStream outputStream = null;
|
OutputStream outputStream = null;
|
||||||
|
String fileName = "";
|
||||||
try {
|
try {
|
||||||
String fileName = "";
|
|
||||||
//本地下载
|
//本地下载
|
||||||
String filePath = ossFile.getUrl();
|
String filePath = ossFile.getUrl();
|
||||||
File file = new File(filePath);
|
boolean b = CosBootUtil.doesObjectExist(filePath);
|
||||||
//水印内容
|
if (!b) {
|
||||||
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);
|
response.setStatus(404);
|
||||||
throw new RuntimeException("文件不存在..");
|
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();
|
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.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1"));
|
||||||
response.setContentType("application/force-download");// 设置强制下载不打开
|
response.setContentType("application/force-download");// 设置强制下载不打开
|
||||||
outputStream = response.getOutputStream();
|
outputStream = response.getOutputStream();
|
||||||
@@ -527,9 +523,78 @@ public class CommonController {
|
|||||||
log.error(e.getMessage(), e);
|
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<OSSFile> 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
|
* @功能:pdf预览Iframe
|
||||||
|
|||||||
+59
-23
@@ -1,10 +1,25 @@
|
|||||||
package com.jero.modules.system.util;
|
package com.jero.modules.system.util;
|
||||||
|
|
||||||
import com.spire.pdf.*;
|
import com.spire.pdf.PdfDocument;
|
||||||
import com.spire.pdf.graphics.*;
|
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.*;
|
||||||
import java.awt.geom.*;
|
import java.awt.geom.Dimension2D;
|
||||||
import java.io.*;
|
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 class PDFUtils {
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
@@ -69,43 +84,64 @@ public class PDFUtils {
|
|||||||
page.getCanvas().drawRectangle(brush, loRect);
|
page.getCanvas().drawRectangle(brush, loRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File PDFWatermark(File file,String waterMark) throws FileNotFoundException {
|
public static File PDFWatermark(InputStream in,String uploadpath, String fileName,String waterMark) throws FileNotFoundException {
|
||||||
InputStream in = new FileInputStream(file) ;
|
|
||||||
// byte[] byteArray=File2byte(new File("f:ceshi/1.pdf"));
|
|
||||||
//创建PdfDocument类的对象
|
//创建PdfDocument类的对象
|
||||||
PdfDocument pdf = new PdfDocument();
|
PdfDocument pdf = new PdfDocument();
|
||||||
//加载测试文档
|
//加载测试文档
|
||||||
pdf.loadFromStream(in);
|
pdf.loadFromStream(in);
|
||||||
// pdf.loadFromFile(file.getPath());
|
|
||||||
//为了去掉在第一页多余的水印,加一页,后边删除
|
//为了去掉在第一页多余的水印,加一页,后边删除
|
||||||
pdf.getPages().add();
|
pdf.getPages().add();
|
||||||
|
|
||||||
//获取测试文档中的第一页
|
//获取测试文档中的第一页
|
||||||
for(int i=0; i<pdf.getPages().getCount();i++){
|
for(int i=0; i<pdf.getPages().getCount();i++){
|
||||||
|
|
||||||
PdfPageBase page = pdf.getPages().get(i);
|
PdfPageBase page = pdf.getPages().get(i);
|
||||||
//调用insertWatermark()方法添加文本水印
|
//调用insertWatermark()方法添加文本水印
|
||||||
insertWatermark(page, waterMark);
|
insertWatermark(page, waterMark);
|
||||||
}
|
}
|
||||||
// 删除加的第一页
|
// 删除加的第一页
|
||||||
|
|
||||||
pdf.getPages().remove(pdf.getPages().get(pdf.getPages().getCount()-1));
|
pdf.getPages().remove(pdf.getPages().get(pdf.getPages().getCount()-1));
|
||||||
String newFilePath = file.getPath().replace(file.getName(),"transformation"+file.getName());
|
String path = uploadpath + File.separator +fileName;
|
||||||
|
String newFilePath = path.replace(fileName,"transformation"+fileName);
|
||||||
//保存文档
|
//保存文档
|
||||||
pdf.saveToFile(newFilePath);
|
pdf.saveToFile(newFilePath);
|
||||||
// File newFile =
|
|
||||||
// File file2 = new File("f:ceshi/4.pdf");
|
|
||||||
// InputStream in1 = new FileInputStream(file1);
|
|
||||||
//
|
|
||||||
// OutputStream out2 = new FileOutputStream(file2);
|
|
||||||
// byte[] buffer = new byte[4096];
|
|
||||||
// int n = 0;
|
|
||||||
// while (-1 != (n = in1.read(buffer))) {
|
|
||||||
// out2.write(buffer, 0, n);
|
|
||||||
// }
|
|
||||||
// file1.delete();
|
|
||||||
return new File(newFilePath);
|
return new File(newFilePath);
|
||||||
}
|
}
|
||||||
|
// public static File PDFWatermark(File file,String waterMark) throws FileNotFoundException {
|
||||||
|
// InputStream in = new FileInputStream(file) ;
|
||||||
|
//// byte[] byteArray=File2byte(new File("f:ceshi/1.pdf"));
|
||||||
|
// //创建PdfDocument类的对象
|
||||||
|
// PdfDocument pdf = new PdfDocument();
|
||||||
|
// //加载测试文档
|
||||||
|
// pdf.loadFromStream(in);
|
||||||
|
//// pdf.loadFromFile(file.getPath());
|
||||||
|
// //为了去掉在第一页多余的水印,加一页,后边删除
|
||||||
|
// pdf.getPages().add();
|
||||||
|
//
|
||||||
|
// //获取测试文档中的第一页
|
||||||
|
// for(int i=0; i<pdf.getPages().getCount();i++){
|
||||||
|
//
|
||||||
|
// PdfPageBase page = pdf.getPages().get(i);
|
||||||
|
// //调用insertWatermark()方法添加文本水印
|
||||||
|
// insertWatermark(page, waterMark);
|
||||||
|
// }
|
||||||
|
//// 删除加的第一页
|
||||||
|
//
|
||||||
|
// pdf.getPages().remove(pdf.getPages().get(pdf.getPages().getCount()-1));
|
||||||
|
// String newFilePath = file.getPath().replace(file.getName(),"transformation"+file.getName());
|
||||||
|
// //保存文档
|
||||||
|
// pdf.saveToFile(newFilePath);
|
||||||
|
//// File newFile =
|
||||||
|
//// File file2 = new File("f:ceshi/4.pdf");
|
||||||
|
//// InputStream in1 = new FileInputStream(file1);
|
||||||
|
////
|
||||||
|
//// OutputStream out2 = new FileOutputStream(file2);
|
||||||
|
//// byte[] buffer = new byte[4096];
|
||||||
|
//// int n = 0;
|
||||||
|
//// while (-1 != (n = in1.read(buffer))) {
|
||||||
|
//// out2.write(buffer, 0, n);
|
||||||
|
//// }
|
||||||
|
//// file1.delete();
|
||||||
|
// return new File(newFilePath);
|
||||||
|
// }
|
||||||
public static File PDFWatermark(String newFilePath,InputStream in,String waterMark) throws FileNotFoundException {
|
public static File PDFWatermark(String newFilePath,InputStream in,String waterMark) throws FileNotFoundException {
|
||||||
// InputStream in = new FileInputStream(file) ;
|
// InputStream in = new FileInputStream(file) ;
|
||||||
// byte[] byteArray=File2byte(new File("f:ceshi/1.pdf"));
|
// byte[] byteArray=File2byte(new File("f:ceshi/1.pdf"));
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ router.beforeEach((to, from, next) => {
|
|||||||
Vue.ls.set(USER_NAME, res.result.userInfo.username, 7 * 24 * 60 * 60 * 1000)
|
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(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(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_TOKEN', res.result.token)
|
||||||
store.commit('SET_INFO', res.result.userInfo)
|
store.commit('SET_INFO', res.result.userInfo)
|
||||||
store.commit('SET_NAME', {
|
store.commit('SET_NAME', {
|
||||||
|
|||||||
@@ -36,13 +36,13 @@
|
|||||||
<!-- 属性名称-->
|
<!-- 属性名称-->
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-model-item :label="$t('AttributeName')" prop="dbFieldTxt">
|
<a-form-model-item :label="$t('AttributeName')" prop="dbFieldTxt">
|
||||||
<a-input v-model.trim="form.dbFieldTxt" :placeholder="$t('PleaseEnterPropertyName')" :maxLength="120" ></a-input>
|
<a-input v-model="form.dbFieldTxt" :placeholder="$t('PleaseEnterPropertyName')" :maxLength="120" ></a-input>
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<!-- 英文名称-->
|
<!-- 英文名称-->
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-model-item :label="$t('enName')" prop="dbFieldEnName">
|
<a-form-model-item :label="$t('enName')" prop="dbFieldEnName">
|
||||||
<a-input v-model.trim="form.dbFieldEnName" :placeholder="$t('PleaseEnterYourEnglishName')" :maxLength="120" ></a-input>
|
<a-input v-model="form.dbFieldEnName" :placeholder="$t('PleaseEnterYourEnglishName')" :maxLength="120" ></a-input>
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<!-- 属性类型-->
|
<!-- 属性类型-->
|
||||||
@@ -414,6 +414,9 @@ export default {
|
|||||||
submitForm () {
|
submitForm () {
|
||||||
// const that = this;
|
// 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)
|
// console.log(this.$refs.tagform)
|
||||||
this.$refs.tagEditForm.validate((valid)=>{
|
this.$refs.tagEditForm.validate((valid)=>{
|
||||||
// console.log('valid',valid)
|
// console.log('valid',valid)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
>
|
>
|
||||||
<a-form-model-item ref="tagName" :label="$t('LabeItemName')" prop="dictName" class="tag-item">
|
<a-form-model-item ref="tagName" :label="$t('LabeItemName')" prop="dictName" class="tag-item">
|
||||||
<a-input
|
<a-input
|
||||||
v-model.trim="form.dictName"
|
v-model="form.dictName"
|
||||||
:placeholder="$t('PleaseEnterLabelName')"
|
:placeholder="$t('PleaseEnterLabelName')"
|
||||||
/>
|
/>
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
<a-form-model-item ref="describe" :label="$t('describe')" prop="description" class="tag-item">
|
<a-form-model-item ref="describe" :label="$t('describe')" prop="description" class="tag-item">
|
||||||
<a-input
|
<a-input
|
||||||
v-model.trim="form.description"
|
v-model="form.description"
|
||||||
:placeholder="$t('PleaseEnterDescription')"
|
:placeholder="$t('PleaseEnterDescription')"
|
||||||
/>
|
/>
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
@@ -247,6 +247,8 @@
|
|||||||
this.form = {}
|
this.form = {}
|
||||||
},
|
},
|
||||||
hideModal() {
|
hideModal() {
|
||||||
|
this.form.dictName = this.form.dictName.trim()
|
||||||
|
this.form.description = this.form.description.trim()
|
||||||
let params = {
|
let params = {
|
||||||
...this.form
|
...this.form
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user