feat: There is no way the Buss and Convert
This commit is contained in:
@@ -1,264 +0,0 @@
|
||||
package com.adc.da.convert.common;
|
||||
|
||||
import com.artofsolving.jodconverter.DocumentConverter;
|
||||
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
|
||||
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
|
||||
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @Author yangxuenan
|
||||
* @Description 文档转换
|
||||
* Date 2018/8/24 13:44
|
||||
* @Param
|
||||
* @return
|
||||
**/
|
||||
public class DocConverter {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DocConverter.class);
|
||||
// 环境 1:windows 2:linux
|
||||
private static final int ENVIRONMENT = 1;
|
||||
// (只涉及pdf2swf路径问题)
|
||||
private String fileString;
|
||||
// 输入路径 ,如果不设置就输出在默认的位置
|
||||
private String outputPath = "";
|
||||
//转化文件名称
|
||||
private String fileName;
|
||||
//转换pdf文件
|
||||
private File pdfFile;
|
||||
//转换成swf文件
|
||||
private File swfFile;
|
||||
//待转换doc文件
|
||||
private File docFile;
|
||||
//为文件加水印后文件路径
|
||||
String waterPdfPath;
|
||||
|
||||
@Value("${convert.host}")
|
||||
private String convertHost;
|
||||
|
||||
public DocConverter(String fileString,String fileType) {
|
||||
ini(fileString,fileType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author yangxuenan
|
||||
* @Description 重新设置file
|
||||
* Date 2018/8/24 13:50
|
||||
* @Param [fileString, fileType]
|
||||
* @return void
|
||||
**/
|
||||
public void setFile(String fileString,String fileType) {
|
||||
ini(fileString,fileType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author yangxuenan
|
||||
* @Description 初始化
|
||||
* Date 2018/8/24 13:50
|
||||
* @Param [fileString, fileType]
|
||||
* @return void
|
||||
**/
|
||||
private void ini(String fileString,String fileType) {
|
||||
this.fileString = fileString;
|
||||
fileName = fileString.substring(0, fileString.lastIndexOf("."));
|
||||
//判断文件类型,进行不同操作
|
||||
if(".doc".equals(fileType) || ".docx".equals(fileType)){
|
||||
docFile = new File(fileString);
|
||||
pdfFile = new File(fileName + ".pdf");
|
||||
swfFile = new File(fileName + ".swf");
|
||||
} else if (".pdf".equals(fileType)){
|
||||
pdfFile = new File(fileName + ".pdf");
|
||||
swfFile = new File(fileName + ".swf");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author yangxuenan
|
||||
* @Description 转为PDF
|
||||
* Date 2018/8/24 13:50
|
||||
* @Param []
|
||||
* @return void
|
||||
**/
|
||||
private void doc2pdf() throws Exception {
|
||||
if (docFile.exists()) {
|
||||
if (!pdfFile.exists()) {
|
||||
logger.info("转换服务地址接口:"+convertHost);
|
||||
//连接openOffice
|
||||
OpenOfficeConnection connection = new SocketOpenOfficeConnection(convertHost,8100);
|
||||
try {
|
||||
connection.connect();
|
||||
//使用openOffice将doc文件转换问pdf文件
|
||||
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
|
||||
converter.convert(docFile, pdfFile);
|
||||
// 关闭连接
|
||||
connection.disconnect();
|
||||
logger.info("****pdf转换成功,PDF输出:" + pdfFile.getPath()+ "****");
|
||||
} catch (java.net.ConnectException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
logger.info("****swf转换器异常,openoffice服务未启动!****");
|
||||
throw e;
|
||||
} catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
logger.info("****swf转换器异常,读取转换文件失败****");
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
logger.info("****已经转换为pdf,不需要再进行转化****");
|
||||
}
|
||||
} else {
|
||||
logger.info("****swf转换器异常,需要转换的文档不存在,无法转换****");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author yangxuenan
|
||||
* @Description 转换成 swf
|
||||
* Date 2018/8/24 13:51
|
||||
* @Param [fileType]
|
||||
* @return void
|
||||
**/
|
||||
/*private void pdf2swf(String fileType) throws Exception {
|
||||
Runtime r = Runtime.getRuntime();
|
||||
if (!swfFile.exists()) {
|
||||
if (pdfFile.exists()) {
|
||||
// windows环境处理
|
||||
if (ENVIRONMENT == 1) {
|
||||
try {
|
||||
//使用swfTools工具将pdf文件转换为swf文件
|
||||
//String paperSwfFile = swfFile.getPath().replace(".swf","%.swf");
|
||||
Process p = r.exec("G:/swftTools/pdf2swf.exe "+ waterPdfPath + " -o "+ swfFile.getPath() + " -f -T 9 -t -s languagedir=G:/xpdf/xpdf-chinese-simplified");
|
||||
logger.info("****swf转换成功,文件输出:" + swfFile.getPath() + "****");
|
||||
//如果源文件为doc类文件,将过渡的pdf文件删除
|
||||
if(".doc".equals(fileType) || ".docx".equals(fileType)){
|
||||
if (pdfFile.exists()) {
|
||||
if(!pdfFile.delete()){
|
||||
logger.error("文件删除失败!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
throw e;
|
||||
}
|
||||
} else if (ENVIRONMENT == 2) {// linux环境处理
|
||||
try {
|
||||
Process p = r.exec("pdf2swf " + pdfFile.getPath()
|
||||
+ " -o " + swfFile.getPath() + " -f -T 9 -t -s storeallcharacters");
|
||||
logger.info("****swf转换成功,文件输出:" + swfFile.getPath() + "****");
|
||||
if (pdfFile.exists()) {
|
||||
if(!pdfFile.delete()){
|
||||
logger.error("文件删除失败!!!");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.info("****pdf不存在,无法转换****");
|
||||
}
|
||||
} else {
|
||||
logger.info("****swf已经存在不需要转换****");
|
||||
}
|
||||
}*/
|
||||
|
||||
static String loadStream(InputStream in) throws IOException {
|
||||
|
||||
int ptr = 0;
|
||||
in = new BufferedInputStream(in);
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
while ((ptr = in.read()) != -1) {
|
||||
buffer.append((char) ptr);
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author yangxuenan
|
||||
* @Description 转换主方法
|
||||
* Date 2018/8/24 13:51
|
||||
* @Param [fileType]
|
||||
* @return boolean
|
||||
**/
|
||||
public boolean conver(String fileType) {
|
||||
|
||||
if (swfFile.exists()) {
|
||||
logger.info("****swf转换器开始工作,该文件已经转换为swf****");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ENVIRONMENT == 1) {
|
||||
logger.info("****swf转换器开始工作,当前设置运行环境windows****");
|
||||
} else {
|
||||
logger.info("****swf转换器开始工作,当前设置运行环境linux****");
|
||||
}
|
||||
try {
|
||||
//判断待转换文件类型,如果为doc文件需要先转为pdf类型文件
|
||||
if(".doc".equals(fileType) || ".docx".equals(fileType)){
|
||||
doc2pdf();
|
||||
// pdf2swf(fileType);
|
||||
} else if (".pdf".equals(fileType)){
|
||||
// pdf2swf(fileType);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (swfFile.exists()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author yangxuenan
|
||||
* @Description 返回文件路径
|
||||
* Date 2018/8/24 13:52
|
||||
* @Param []
|
||||
* @return java.lang.String
|
||||
**/
|
||||
public String getswfPath() {
|
||||
if (swfFile.exists()) {
|
||||
//获取转换后的swf文件路径
|
||||
String tempString = swfFile.getPath();
|
||||
tempString = tempString.replaceAll("\\\\", "/");
|
||||
return tempString;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author yangxuenan
|
||||
* @Description 设置输出路径
|
||||
* Date 2018/8/24 13:52
|
||||
* @Param [outputPath]
|
||||
* @return void
|
||||
**/
|
||||
public void setOutputPath(String outputPath) {
|
||||
this.outputPath = outputPath;
|
||||
if (!outputPath.equals("")) {
|
||||
String realName = fileName.substring(fileName.lastIndexOf("/"),
|
||||
fileName.lastIndexOf("."));
|
||||
if (outputPath.charAt(outputPath.length()) == '/') {
|
||||
swfFile = new File(outputPath + realName + ".swf");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,36 +1,24 @@
|
||||
package com.adc.da.convert.common;
|
||||
|
||||
import com.artofsolving.jodconverter.DocumentConverter;
|
||||
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
|
||||
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
|
||||
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
|
||||
import com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jodconverter.DocumentConverter;
|
||||
import org.jodconverter.OfficeDocumentConverter;
|
||||
import org.jodconverter.document.DefaultDocumentFormatRegistry;
|
||||
import org.jodconverter.office.DefaultOfficeManagerBuilder;
|
||||
import org.jodconverter.office.OfficeException;
|
||||
import org.jodconverter.office.OfficeManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class DocConverterPdf {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DocConverterPdf.class);
|
||||
|
||||
/**
|
||||
* 在所需的类里 添加下面配置
|
||||
* // 文档转换远程服务IP地址
|
||||
* @Value("${convert.host}")
|
||||
* private String convertHost;
|
||||
*
|
||||
*
|
||||
* fileString : 文件全路径
|
||||
* fileType : 文件后缀类型
|
||||
* 调用方法如下
|
||||
* DocConverterPdf d = new DocConverterPdf(fileString,fileType);
|
||||
* d.setConvertHost(convertHost);
|
||||
* //调用conver方法开始转换
|
||||
* File getPdf = d.conver(fileType);
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Autowired
|
||||
private DocumentConverter converter;
|
||||
|
||||
private static final int ENVIRONMENT = 1;// 环境 1:windows 2:linux
|
||||
private String fileString;// (只涉及pdf2swf路径问题)
|
||||
@@ -40,6 +28,7 @@ public class DocConverterPdf {
|
||||
private File convertPdfFile;
|
||||
private File swfFile;
|
||||
private File docFile;
|
||||
private String filesType;
|
||||
String waterPdfPath;
|
||||
|
||||
private String convertHost;
|
||||
@@ -67,6 +56,7 @@ public class DocConverterPdf {
|
||||
fileName = fileString.substring(0, fileString.lastIndexOf("."));
|
||||
if(".doc".equals(fileType.toLowerCase()) || ".docx".equals(fileType.toLowerCase()) || ".xlsx".equals(fileType.toLowerCase()) || ".xls".equals(fileType.toLowerCase()) || ".ppt".equals(fileType.toLowerCase()) || ".pptx".equals(fileType.toLowerCase())){
|
||||
docFile = new File(fileString);
|
||||
filesType = fileType.toLowerCase();
|
||||
convertPdfFile=new File(fileName+"_C"+ ".pdf");
|
||||
pdfFile = new File(fileName + ".pdf");
|
||||
swfFile = new File(fileName + ".swf");
|
||||
@@ -76,6 +66,38 @@ public class DocConverterPdf {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* openOffice目录,window 可能在C://Program Files (x86)//OpenOffice 4
|
||||
*/
|
||||
private static final String openOfficeHome = "E://Software//rtpro//Foton//File//openOffice//4";
|
||||
|
||||
/**
|
||||
* openOffice端口
|
||||
*/
|
||||
private static final int openOfficePort = 8100;
|
||||
|
||||
/**
|
||||
* 转化文档
|
||||
* @param input
|
||||
* @param output
|
||||
*/
|
||||
public static void convertFile(File input , File output) throws OfficeException {
|
||||
try {
|
||||
DefaultOfficeManagerBuilder defaultOfficeManagerBuilder = new DefaultOfficeManagerBuilder();
|
||||
defaultOfficeManagerBuilder.setOfficeHome(openOfficeHome);
|
||||
OfficeManager officeManager = defaultOfficeManagerBuilder.build();
|
||||
officeManager.start();
|
||||
|
||||
//转换,自动识别转化类型
|
||||
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
|
||||
converter.convert(input, output);
|
||||
|
||||
officeManager.stop();
|
||||
} catch (OfficeException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转为PDF
|
||||
*
|
||||
@@ -83,22 +105,16 @@ public class DocConverterPdf {
|
||||
*/
|
||||
private void doc2pdf() throws Exception {
|
||||
if (!pdfFile.exists()) {
|
||||
OpenOfficeConnection connection = null;
|
||||
logger.info("转换服务地址接口:"+convertHost);
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
if(StringUtils.isNotBlank(convertHost)){
|
||||
connection = new SocketOpenOfficeConnection(convertHost,8100);
|
||||
}else{
|
||||
connection = new SocketOpenOfficeConnection(8100);
|
||||
}
|
||||
connection.connect();
|
||||
DocumentConverter converter = new StreamOpenOfficeDocumentConverter(connection);
|
||||
converter.convert(docFile, convertPdfFile);
|
||||
|
||||
//addWaterToPdf(pdfFile,userId);
|
||||
|
||||
// in = new FileInputStream(docFile);
|
||||
// out = new FileOutputStream(convertPdfFile);
|
||||
convertFile(docFile,convertPdfFile);
|
||||
// converter.convert(in).as(DefaultDocumentFormatRegistry.getFormatByMediaType(filesType)).
|
||||
// to(out).as(DefaultDocumentFormatRegistry.PDF);
|
||||
// close the connection
|
||||
connection.disconnect();
|
||||
// 开始设置PDF文档相关属性保证其安全性
|
||||
logger.info("开始设置转换后的PDF文件安全性相关设置");
|
||||
PDFEditUtils.setPDFFileSecurity(pdfFile.getAbsolutePath(),convertPdfFile.getAbsolutePath());
|
||||
@@ -107,10 +123,6 @@ public class DocConverterPdf {
|
||||
logger.error(e.getMessage(),e);
|
||||
logger.info("****pdf转换器异常,openoffice服务未启动!****");
|
||||
throw e;
|
||||
} catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
logger.info("****pdf转换器异常,读取转换文件失败****");
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
throw e;
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
package com.adc.da.convert.common;
|
||||
|
||||
import com.artofsolving.jodconverter.DocumentConverter;
|
||||
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
|
||||
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
|
||||
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class DocConverterPdfOld {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DocConverterPdf.class);
|
||||
|
||||
private static final int ENVIRONMENT = 1;// 环境 1:windows 2:linux
|
||||
private String fileString;// (只涉及pdf2swf路径问题)
|
||||
private String outputPath = "";// 输入路径 ,如果不设置就输出在默认的位置
|
||||
private String fileName;
|
||||
private File pdfFile;
|
||||
private File convertPdfFile;
|
||||
private File swfFile;
|
||||
private File docFile;
|
||||
String waterPdfPath;
|
||||
|
||||
public DocConverterPdfOld(String fileString, String fileType) {
|
||||
ini(fileString,fileType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新设置file
|
||||
*
|
||||
* @param fileString
|
||||
*/
|
||||
public void setFile(String fileString,String fileType) {
|
||||
ini(fileString,fileType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @param fileString
|
||||
*/
|
||||
private void ini(String fileString,String fileType) {
|
||||
this.fileString = fileString;
|
||||
fileName = fileString.substring(0, fileString.lastIndexOf("."));
|
||||
if(".doc".equals(fileType) || ".docx".equals(fileType) || ".xlsx".equals(fileType) || ".xls".equals(fileType) || ".ppt".equals(fileType) || ".pptx".equals(fileType)){
|
||||
docFile = new File(fileString);
|
||||
convertPdfFile=new File(fileName+"_C"+ ".pdf");
|
||||
pdfFile = new File(fileName + ".pdf");
|
||||
swfFile = new File(fileName + ".swf");
|
||||
} else if (".pdf".equals(fileType)){
|
||||
pdfFile = new File(fileName + ".pdf");
|
||||
swfFile = new File(fileName + ".swf");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转为PDF
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
private void doc2pdf() throws Exception {
|
||||
if (!pdfFile.exists()) {
|
||||
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
|
||||
try {
|
||||
connection.connect();
|
||||
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
|
||||
converter.convert(docFile, convertPdfFile);
|
||||
|
||||
//addWaterToPdf(pdfFile,userId);
|
||||
|
||||
// close the connection
|
||||
connection.disconnect();
|
||||
// 开始设置PDF文档相关属性保证其安全性
|
||||
logger.info("开始设置转换后的PDF文件安全性相关设置");
|
||||
logger.info("****pdf转换成功,PDF输出:" + pdfFile.getPath()+ "****");
|
||||
} catch (java.net.ConnectException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
logger.info("****pdf转换器异常,openoffice服务未启动!****");
|
||||
throw e;
|
||||
} catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
logger.info("****pdf转换器异常,读取转换文件失败****");
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
logger.info("****已经转换为pdf,不需要再进行转化****");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换成 swf
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
/*private void pdf2swf(String fileType) throws Exception {
|
||||
Runtime r = Runtime.getRuntime();
|
||||
if (!swfFile.exists()) {
|
||||
if (pdfFile.exists()) {
|
||||
if (ENVIRONMENT == 1) {// windows环境处理
|
||||
try {
|
||||
//String paperSwfFile = swfFile.getPath().replace(".swf","%.swf");
|
||||
Process p = r.exec("G:/swftTools/pdf2swf.exe "+ waterPdfPath + " -o "+ swfFile.getPath() + " -f -T 9 -t -s languagedir=G:/xpdf/xpdf-chinese-simplified");
|
||||
logger.info("****swf转换成功,文件输出:" + swfFile.getPath() + "****");
|
||||
if(".doc".equals(fileType) || ".docx".equals(fileType)){
|
||||
*//*if (pdfFile.exists()) {
|
||||
pdfFile.delete();
|
||||
}*//*
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
throw e;
|
||||
}
|
||||
} else if (ENVIRONMENT == 2) {// linux环境处理
|
||||
try {
|
||||
Process p = r.exec("pdf2swf " + pdfFile.getPath()
|
||||
+ " -o " + swfFile.getPath() + " -f -T 9 -t -s storeallcharacters");
|
||||
logger.info("****swf转换成功,文件输出:" + swfFile.getPath() + "****");
|
||||
if (pdfFile.exists()) {
|
||||
if(!pdfFile.delete()){
|
||||
logger.error("文件删除失败!!!");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.info("****pdf不存在,无法转换****");
|
||||
}
|
||||
} else {
|
||||
logger.info("****swf已经存在不需要转换****");
|
||||
}
|
||||
}*/
|
||||
|
||||
static String loadStream(InputStream in) throws IOException {
|
||||
|
||||
int ptr = 0;
|
||||
in = new BufferedInputStream(in);
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
while ((ptr = in.read()) != -1) {
|
||||
buffer.append((char) ptr);
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
/**
|
||||
* 转换主方法
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public File conver(String fileType) {
|
||||
if (ENVIRONMENT == 1) {
|
||||
logger.info("****swf转换器开始工作,当前设置运行环境windows****");
|
||||
} else {
|
||||
logger.info("****swf转换器开始工作,当前设置运行环境linux****");
|
||||
}
|
||||
try {
|
||||
if(".doc".equals(fileType) || ".docx".equals(fileType) || ".xlsx".equals(fileType) || ".xls".equals(fileType) || ".ppt".equals(fileType) || ".pptx".equals(fileType)){
|
||||
doc2pdf();
|
||||
/*pdf2swf(fileType);*/
|
||||
} else if (".pdf".equals(fileType)){
|
||||
/*pdf2swf(fileType);*/
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
return new File("");
|
||||
}
|
||||
|
||||
return pdfFile;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回文件路径
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
public String getswfPath() {
|
||||
if (swfFile.exists()) {
|
||||
String tempString = swfFile.getPath();
|
||||
tempString = tempString.replaceAll("\\\\", "/");
|
||||
return tempString;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getpdfPath() {
|
||||
if (!pdfFile.getPath().isEmpty()) {
|
||||
String tempString = pdfFile.getPath();
|
||||
tempString = tempString.replaceAll("\\\\", "/");
|
||||
return tempString;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置输出路径
|
||||
*/
|
||||
public void setOutputPath(String outputPath) {
|
||||
this.outputPath = outputPath;
|
||||
if (!outputPath.equals("")) {
|
||||
String realName = fileName.substring(fileName.lastIndexOf("/"), fileName.lastIndexOf("."));
|
||||
//TODO 此处的if判断执行的代码逻辑完全一样, 因此将其判断注释掉,直接执行
|
||||
/* if (outputPath.charAt(outputPath.length()) == '/') {
|
||||
swfFile = new File(outputPath + realName + ".swf");
|
||||
} else {
|
||||
swfFile = new File(outputPath + realName + ".swf");
|
||||
}*/
|
||||
swfFile = new File(outputPath + realName + ".swf");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,13 +2,12 @@ package com.adc.da.convert.mq;
|
||||
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import com.adc.da.att.service.IAttFileEOService;
|
||||
import com.adc.da.common.ConvertMqEO;
|
||||
import com.adc.da.common.SarTypeEnum;
|
||||
import com.adc.da.common.UseModuleEnum;
|
||||
import com.adc.da.convert.common.DocConverterPdf;
|
||||
import com.adc.da.convert.otConvertMq.entity.OtConvertMq;
|
||||
import com.adc.da.convert.otConvertMq.service.IOtConvertMqService;
|
||||
import com.adc.da.mq.service.CreateMQService;
|
||||
import com.adc.da.mq.CreateMQService;
|
||||
import com.adc.da.slrs.otConvertMq.entity.OtConvertMq;
|
||||
import com.adc.da.slrs.otConvertMq.service.IOtConvertMqService;
|
||||
import com.adc.da.slrs.sarBussStandFile.dao.SarBussStandFileDao;
|
||||
import com.adc.da.slrs.sarBussStandFile.entity.SarBussStandFile;
|
||||
import com.adc.da.slrs.sarStandFile.dao.SarStandFileDao;
|
||||
@@ -84,7 +83,6 @@ public class SendConvertMQService {
|
||||
}finally {
|
||||
Long tag = (Long) message.getHeaders().get(AmqpHeaders.DELIVERY_TAG);
|
||||
channel.basicAck(tag,false);
|
||||
logger.debug("文档转换消息确认成功!!!!!!!!!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -236,7 +234,7 @@ public class SendConvertMQService {
|
||||
}
|
||||
|
||||
public ResponseMessage restartUploadConvert(OtConvertMq convertInfo) throws Exception{
|
||||
ConvertMqEO convertMqEO = new ConvertMqEO();
|
||||
OtConvertMq convertMqEO = new com.adc.da.slrs.otConvertMq.entity.OtConvertMq();
|
||||
convertMqEO.setLawsId(convertInfo.getLawsId());
|
||||
convertMqEO.setConvertType(convertInfo.getConvertType());
|
||||
convertMqEO.setAttId(convertInfo.getAttId());
|
||||
@@ -271,7 +269,7 @@ public class SendConvertMQService {
|
||||
lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
lawsFile.setModifyTime(new Date());
|
||||
lawsFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
|
||||
countSuccess = sarStandFileEODao.updateById(lawsFile);
|
||||
countSuccess = sarStandFileEODao.updateByPrimaryKeySelective(lawsFile);
|
||||
} else if (SarTypeEnum.LAWS.getValue().equals(convertMq.getConvertType())) {
|
||||
// SarLawsFile lawsFile = new SarLawsFile();
|
||||
// lawsFile.setId(convertMq.getPdfId());
|
||||
@@ -287,7 +285,7 @@ public class SendConvertMQService {
|
||||
lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
lawsFile.setUseModule(UseModuleEnum.WEB_FILE.getValue());
|
||||
lawsFile.setModifyTime(new Date());
|
||||
countSuccess = sarBussStandFileEODao.updateById(lawsFile);
|
||||
countSuccess = sarBussStandFileEODao.updateByPrimaryKeySelective(lawsFile);
|
||||
}else if (SarTypeEnum.RECORDS.getValue().equals(convertMq.getConvertType())) {
|
||||
// SarBussRecordsFileEO lawsFile = new SarBussRecordsFileEO();
|
||||
// lawsFile.setId(convertMq.getPdfId());
|
||||
@@ -337,7 +335,7 @@ public class SendConvertMQService {
|
||||
lawsFile.setStandFileClassify(convertMq.getStandFileClassify());
|
||||
lawsFile.setFileName(fileOriName+".pdf");
|
||||
lawsFile.setFileSuffix("pdf");
|
||||
countSuccess = sarStandFileEODao.insert(lawsFile);
|
||||
countSuccess = sarStandFileEODao.insertSelective(lawsFile);
|
||||
} else if (SarTypeEnum.LAWS.getValue().equals(convertMq.getConvertType())) {
|
||||
// SarLawsFile lawsFile = new SarLawsFile();
|
||||
// lawsFile.setId(UUID.randomUUID(20));
|
||||
@@ -367,7 +365,7 @@ public class SendConvertMQService {
|
||||
lawsFile.setValidFlag(0);
|
||||
lawsFile.setCreationTime(new Date());
|
||||
lawsFile.setModifyTime(new Date());
|
||||
countSuccess = sarBussStandFileEODao.insert(lawsFile);
|
||||
countSuccess = sarBussStandFileEODao.insertSelective(lawsFile);
|
||||
}
|
||||
else if (SarTypeEnum.RECORDS.getValue().equals(convertMq.getConvertType())) {
|
||||
// SarBussRecordsFileEO lawsFile = new SarBussRecordsFileEO();
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
package com.adc.da.convert.otConvertMq.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.adc.da.convert.otConvertMq.entity.OtConvertMq;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 文档转换记录信息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-08-20
|
||||
*/
|
||||
@RestController
|
||||
@Api(description = "|OtConvertMq|")
|
||||
@RequestMapping("/otConvertMq/ot-convert-mq")
|
||||
public class OtConvertMqController extends BaseController<OtConvertMq> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.adc.da.convert.otConvertMq.dao;
|
||||
|
||||
import com.adc.da.convert.otConvertMq.entity.OtConvertMq;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 文档转换记录信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-08-20
|
||||
*/
|
||||
public interface OtConvertMqDao extends BaseMapper<OtConvertMq> {
|
||||
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.adc.da.convert.otConvertMq.entity;
|
||||
|
||||
import com.adc.da.base.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 文档转换记录信息表
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-08-20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="OtConvertMq对象", description="文档转换记录信息表")
|
||||
public class OtConvertMq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
@TableId("ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "消息队列编码")
|
||||
@TableField("MQ_CODE")
|
||||
private String mqCode;
|
||||
|
||||
@ApiModelProperty(value = "队列状态")
|
||||
@TableField("MQ_STATE")
|
||||
private Integer mqState;
|
||||
|
||||
@TableField("USER_ID")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "文件路径")
|
||||
@TableField("FILE_PATH")
|
||||
private String filePath;
|
||||
|
||||
@ApiModelProperty(value = "文件ID")
|
||||
@TableField("ATT_ID")
|
||||
private String attId;
|
||||
|
||||
@ApiModelProperty(value = "是否有效")
|
||||
@TableField("VALID_FLAG")
|
||||
private Integer validFlag;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField("CREATION_TIME")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date creationTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
@TableField("MODIFY_TIME")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date modifyTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String fileOriginPath;
|
||||
|
||||
//向文件表添加信息
|
||||
@TableField(exist = false)
|
||||
private String lawsId;
|
||||
@TableField(exist = false)
|
||||
private String resId;
|
||||
@TableField(exist = false)
|
||||
private String convertType;
|
||||
@TableField(exist = false)
|
||||
private String pdfPath;
|
||||
@TableField(exist = false)
|
||||
private String pdfId;
|
||||
@TableField(exist = false)
|
||||
private String addOrUp;
|
||||
@TableField(exist = false)
|
||||
private String oldFileName;
|
||||
@TableField(exist = false)
|
||||
private String standFileClassify;
|
||||
@TableField(exist = false)
|
||||
private String lawsFileClassify;
|
||||
@TableField(exist = false)
|
||||
private String oriAttId;
|
||||
@TableField(exist = false)
|
||||
private int againNum;
|
||||
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package com.adc.da.convert.otConvertMq.service;
|
||||
|
||||
import com.adc.da.convert.otConvertMq.entity.OtConvertMq;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 文档转换记录信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-08-20
|
||||
*/
|
||||
public interface IOtConvertMqService extends IService<OtConvertMq> {
|
||||
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
package com.adc.da.convert.otConvertMq.service.impl;
|
||||
|
||||
import com.adc.da.convert.otConvertMq.dao.OtConvertMqDao;
|
||||
import com.adc.da.convert.otConvertMq.entity.OtConvertMq;
|
||||
import com.adc.da.convert.otConvertMq.service.IOtConvertMqService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 文档转换记录信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-08-20
|
||||
*/
|
||||
@Service
|
||||
public class OtConvertMqServiceImpl extends ServiceImpl<OtConvertMqDao, OtConvertMq> implements IOtConvertMqService {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.adc.da.convert.otConvertMq.dao.OtConvertMqDao">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user