|
@@ -9,10 +9,12 @@ import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.ribbon.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.IoUtil;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.core.tool.utils.ResourceUtil;
|
|
|
import org.springblade.manager.entity.SignPfxFilePre;
|
|
|
import org.springblade.manager.entity.TextdictInfo;
|
|
@@ -29,7 +31,10 @@ import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class SignPfxFilePreServiceImpl implements ISignPfxFilePreService {
|
|
@@ -47,7 +52,7 @@ public class SignPfxFilePreServiceImpl implements ISignPfxFilePreService {
|
|
|
MultipartFile file1 = vo.getFile();
|
|
|
//图片保存到本地
|
|
|
String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
- String localImgPath = file_path + "print//" + UUID.randomUUID() + ".png";
|
|
|
+ String localImgPath = file_path + "print//" + SnowFlakeUtil.getId() + ".png";
|
|
|
// 检查文件是否存在
|
|
|
File file = new File(localImgPath);
|
|
|
if (!file.exists()) {
|
|
@@ -68,22 +73,33 @@ public class SignPfxFilePreServiceImpl implements ISignPfxFilePreService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R prePicture(SignPfxFilePre signPfxFilePre) throws Exception {
|
|
|
- SignPfxFilePre spr = signPfxFilePreMapper.selectByPrimaryKey(signPfxFilePre.getId());
|
|
|
+ public R prePicture(SignPfxFilePreVo vo) throws Exception {
|
|
|
+// SignPfxFilePre spr = signPfxFilePreMapper.selectByPrimaryKey(vo.getId());
|
|
|
+ InputStream inputStreamByUrl1 = FileUtils.getInputStreamByUrl(vo.getFileStr());
|
|
|
+ MultipartFile file1 = vo.getFile();
|
|
|
//宽度
|
|
|
- Double wide = spr.getWide();
|
|
|
+ Double wide = vo.getWide();
|
|
|
//高度
|
|
|
- Double hight = spr.getHigh();
|
|
|
+ Double high = vo.getHigh();
|
|
|
+ if(ObjectUtil.isEmpty(wide) && ObjectUtil.isEmpty(high)){
|
|
|
+ if(ObjectUtil.isEmpty(file1)){
|
|
|
+ Map imageSize = FileUtils.getImageSize(inputStreamByUrl1);
|
|
|
+ Integer width = (Integer) imageSize.get("width");
|
|
|
+ Integer height = (Integer) imageSize.get("height");
|
|
|
+ wide = width.doubleValue();
|
|
|
+ high = height.doubleValue();
|
|
|
+ }else {
|
|
|
+ wide = FileUtils.getImageWidth(file1).doubleValue();
|
|
|
+ high = FileUtils.getImageHeight(file1).doubleValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
//图片地址
|
|
|
- String localImgPath = spr.getSignaturePngUrl();
|
|
|
String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ String compressImgPath = file_path + "/pdf//" + id + ".png";
|
|
|
|
|
|
- //图片压缩后的地址
|
|
|
- UUID uuid = UUID.randomUUID();
|
|
|
- String compressImgPath = file_path + "/print//" + uuid + ".png";
|
|
|
-
|
|
|
- String pdfPath = file_path + "/pdf//" + "1751795857679712265" + ".pdf";
|
|
|
- String excelPath = file_path + "/pdf//" + uuid + ".xlsx";
|
|
|
+ String pdfPath = file_path + "/print//" + "1751795857679712265" + ".pdf";
|
|
|
+ String excelPath = file_path + "/pdf//" + id + ".xlsx";
|
|
|
|
|
|
File tabPdf = ResourceUtil.getFile(pdfPath);
|
|
|
if (tabPdf.exists()) {
|
|
@@ -155,9 +171,18 @@ public class SignPfxFilePreServiceImpl implements ISignPfxFilePreService {
|
|
|
FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
|
workbook.write(outputStream);
|
|
|
FileUtils.excelToPdf(excelPath, pdfPath);
|
|
|
- FileUtils.compressImage(localImgPath,compressImgPath, spr.getWide(),spr.getHigh());
|
|
|
+ if(ObjectUtil.isEmpty(file1)){
|
|
|
+ InputStream inputStreamByUrl2 = FileUtils.getInputStreamByUrl(vo.getFileStr());
|
|
|
+ FileUtils.compressImage(inputStreamByUrl2,compressImgPath, wide,high);
|
|
|
+ }else {
|
|
|
+ FileUtils.compressImage(file1.getInputStream(),compressImgPath, wide,high);
|
|
|
+ }
|
|
|
PdfAddimgUtil.pdfAddImgInfoNew(pdfPath, String.join(",", sign),textMap,compressImgPath);
|
|
|
//压缩后的图片上传oss
|
|
|
- return R.data(FileUtils.getNetUrl(pdfPath));
|
|
|
+ SignPfxFilePreVo signPfxFilePreVo = new SignPfxFilePreVo();
|
|
|
+ signPfxFilePreVo.setWide(wide);
|
|
|
+ signPfxFilePreVo.setHigh(high);
|
|
|
+ signPfxFilePreVo.setPreUrl(FileUtils.getNetUrl(pdfPath));
|
|
|
+ return R.data(signPfxFilePreVo);
|
|
|
}
|
|
|
}
|