|
@@ -25,6 +25,7 @@ import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.common.vo.DataVO;
|
|
import org.springblade.common.vo.DataVO;
|
|
import org.springblade.common.vo.FileSize;
|
|
import org.springblade.common.vo.FileSize;
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
import org.springblade.core.tool.utils.ResourceUtil;
|
|
import org.springblade.core.tool.utils.ResourceUtil;
|
|
import org.springblade.core.tool.utils.StringUtil;
|
|
import org.springblade.core.tool.utils.StringUtil;
|
|
@@ -93,7 +94,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
String key1 = "2__"+ dataVO1.getY() + "_" + dataVO1.getX();
|
|
String key1 = "2__"+ dataVO1.getY() + "_" + dataVO1.getX();
|
|
DataInfo.put(key1,"hahahahaa");
|
|
DataInfo.put(key1,"hahahahaa");
|
|
try {
|
|
try {
|
|
- String url = getBussPdfInfo(pkeyId.toString(),DataInfo,excelUrl,file_path);
|
|
|
|
|
|
+ String url = getBussPdfInfo(pkeyId.toString(),DataInfo,excelUrl,file_path,null,null);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -312,11 +313,11 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
if (multiLineconfig != null) {
|
|
if (multiLineconfig != null) {
|
|
String coords = multiLineconfig.getCoords();
|
|
String coords = multiLineconfig.getCoords();
|
|
String formula = multiLineconfig.getFormula();
|
|
String formula = multiLineconfig.getFormula();
|
|
- handleArchiveFile(coords, formula, variables, file_path, excelUrl, dataInfo,urls,fileName);
|
|
|
|
|
|
+ handleArchiveFile(coords, formula, variables, file_path, excelUrl, dataInfo,urls,fileName, archivesAuto.getProjectId());
|
|
|
|
|
|
}else {
|
|
}else {
|
|
try {
|
|
try {
|
|
- String url = getBussPdfInfo(fileName, dataInfo, excelUrl, file_path);
|
|
|
|
|
|
+ String url = getBussPdfInfo(fileName, dataInfo, excelUrl, file_path,OssConstant.ARCHIVE_DIRECTORY,archivesAuto.getProjectId());
|
|
urls.add(url);
|
|
urls.add(url);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -337,7 +338,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
*/
|
|
*/
|
|
private void handleArchiveFile(String coords, String formula,
|
|
private void handleArchiveFile(String coords, String formula,
|
|
Map<String,Object> variables,String file_path,
|
|
Map<String,Object> variables,String file_path,
|
|
- String excelUrl, Map<String, Object> dataInfo,List<String> urls,String fileName){
|
|
|
|
|
|
+ String excelUrl, Map<String, Object> dataInfo,List<String> urls,String fileName,Long projectId){
|
|
//todo 目录多页合并一页,文件名带上
|
|
//todo 目录多页合并一页,文件名带上
|
|
|
|
|
|
|
|
|
|
@@ -380,7 +381,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
subIndex++;
|
|
subIndex++;
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
- String url = getBussPdfInfo(fileName + subIndex, pageMap, excelUrl, file_path);
|
|
|
|
|
|
+ String url = getBussPdfInfo(fileName + subIndex, pageMap, excelUrl, file_path,OssConstant.ARCHIVE_DIRECTORY,projectId);
|
|
localUrls.add(url);
|
|
localUrls.add(url);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -398,11 +399,11 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
//合并成一个
|
|
//合并成一个
|
|
if (localUrls.size() > 1) {
|
|
if (localUrls.size() > 1) {
|
|
Long id = SnowFlakeUtil.getId();
|
|
Long id = SnowFlakeUtil.getId();
|
|
- String trialPdf = file_path + "/pdf/" + id + ".pdf";
|
|
|
|
|
|
+ String localPdf = file_path + "/pdf/" + id + ".pdf";
|
|
|
|
|
|
//合并当前所有选择的试验pdf
|
|
//合并当前所有选择的试验pdf
|
|
- FileUtils.mergePdfPublicMethods(localUrls, trialPdf);
|
|
|
|
- BladeFile bladeFile = this.newIOSSClient.uploadFile(fileName + ".pdf", trialPdf);
|
|
|
|
|
|
+ FileUtils.mergePdfPublicMethods(localUrls, localPdf);
|
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(fileName + ".pdf", localPdf, OssConstant.ARCHIVE_DIRECTORY,projectId);
|
|
|
|
|
|
|
|
|
|
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
@@ -455,19 +456,23 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
* @param fileName 文件名
|
|
* @param fileName 文件名
|
|
* @param DataInfo excel和数据
|
|
* @param DataInfo excel和数据
|
|
* @param excelUrl excel模板
|
|
* @param excelUrl excel模板
|
|
- * @param filePath 本地路径
|
|
|
|
|
|
+ * @param localPath 本地路径
|
|
|
|
+ * @param ossPath oss上的路径
|
|
|
|
+ * @param projectId 项目ID
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
- public String getBussPdfInfo(String fileName,Map<String, Object> DataInfo,String excelUrl,String filePath) throws Exception{
|
|
|
|
|
|
+ public String getBussPdfInfo(String fileName,Map<String, Object> DataInfo,String excelUrl,String localPath,
|
|
|
|
+ String ossPath, Long projectId) throws Exception{
|
|
|
|
|
|
if (fileName == null) {
|
|
if (fileName == null) {
|
|
fileName = SnowFlakeUtil.getId().toString();
|
|
fileName = SnowFlakeUtil.getId().toString();
|
|
}
|
|
}
|
|
|
|
|
|
- String pdfPath = filePath + "/pdf//" + fileName + ".pdf";
|
|
|
|
- String excelPath = filePath + "/pdf//" + fileName + ".xlsx";
|
|
|
|
- File tabPdf = ResourceUtil.getFile(pdfPath);
|
|
|
|
|
|
+ //本地文件路径
|
|
|
|
+ String localPdfPath = localPath + "/pdf//" + fileName + ".pdf";
|
|
|
|
+ String excelPath = localPath + "/pdf//" + fileName + ".xlsx";
|
|
|
|
+ File tabPdf = ResourceUtil.getFile(localPdfPath);
|
|
if (tabPdf.exists()) {
|
|
if (tabPdf.exists()) {
|
|
tabPdf.delete();
|
|
tabPdf.delete();
|
|
}
|
|
}
|
|
@@ -549,8 +554,8 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
|
|
|
|
FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
workbook.write(outputStream);
|
|
workbook.write(outputStream);
|
|
- FileUtils.setExcelScaleToPdf(excelPath, pdfPath);
|
|
|
|
- BladeFile bladeFile = newIOSSClient.uploadFile(fileName + ".pdf", OssConstant.TEMP_DIRECTORY, pdfPath);
|
|
|
|
|
|
+ FileUtils.setExcelScaleToPdf(excelPath, localPdfPath);
|
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(fileName + ".pdf", localPdfPath,ossPath, projectId);
|
|
|
|
|
|
String pdfLink = "";
|
|
String pdfLink = "";
|
|
if (bladeFile!= null ){
|
|
if (bladeFile!= null ){
|
|
@@ -743,14 +748,14 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
* @param fileName
|
|
* @param fileName
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public String MergePdfAndUpload(List<String> urlList,String fileName,String filePath) {
|
|
|
|
|
|
+ public String MergePdfAndUpload(List<String> urlList,String fileName,String filePath,Long pojectId) {
|
|
String url = "";
|
|
String url = "";
|
|
Long id = SnowFlakeUtil.getId();
|
|
Long id = SnowFlakeUtil.getId();
|
|
- String trialPdf = FileUtils.LocalPath + "/pdf/" + id + ".pdf";
|
|
|
|
|
|
+ String localPdf = FileUtils.LocalPath + "/pdf/" + id + ".pdf";
|
|
|
|
|
|
try {
|
|
try {
|
|
//合并pdf
|
|
//合并pdf
|
|
- FileUtils.mergePdfPublicMethods(urlList,trialPdf);
|
|
|
|
|
|
+ FileUtils.mergePdfPublicMethods(urlList,localPdf);
|
|
|
|
|
|
if (StringUtils.isEmpty(filePath)) {
|
|
if (StringUtils.isEmpty(filePath)) {
|
|
filePath = OssConstant.TEMP_DIRECTORY;
|
|
filePath = OssConstant.TEMP_DIRECTORY;
|
|
@@ -759,7 +764,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
fileName += (OssConstant.SEPARATOR + id);
|
|
fileName += (OssConstant.SEPARATOR + id);
|
|
|
|
|
|
//上传到oss
|
|
//上传到oss
|
|
- BladeFile file = newIOSSClient.uploadFile(fileName+ ".pdf", filePath,trialPdf);
|
|
|
|
|
|
+ BladeFile file = newIOSSClient.uploadFile(fileName+ ".pdf", localPdf,filePath,pojectId);
|
|
url = file.getLink();
|
|
url = file.getLink();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|