Merge branch 'develop_migration' into 'develop_master'
Develop migration See merge request !140
This commit is contained in:
+5
-13
@@ -24,19 +24,11 @@
|
||||
</dependency>
|
||||
<!-- openOffice 和 jobconverter-->
|
||||
<dependency>
|
||||
<groupId>org.jodconverter</groupId>
|
||||
<artifactId>jodconverter-core</artifactId>
|
||||
<version>4.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jodconverter</groupId>
|
||||
<artifactId>jodconverter-spring-boot-starter</artifactId>
|
||||
<version>4.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jodconverter</groupId>
|
||||
<artifactId>jodconverter-local</artifactId>
|
||||
<version>4.2.2</version>
|
||||
<groupId>com.artofsolving</groupId>
|
||||
<artifactId>jodconverter</artifactId>
|
||||
<scope>system</scope>
|
||||
<version>2.2.2</version>
|
||||
<systemPath>${basedir}/src/main/lib/jodconverter-2.2.2.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- openOffice end-->
|
||||
<dependency>
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
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);
|
||||
|
||||
@Autowired
|
||||
private DocumentConverter converter;
|
||||
|
||||
private static final int ENVIRONMENT = 1;// 环境 1:windows 2:linux
|
||||
private String fileString;// (只涉及pdf2swf路径问题)
|
||||
private String outputPath = "";// 输入路径 ,如果不设置就输出在默认的位置
|
||||
@@ -28,7 +22,6 @@ public class DocConverterPdf {
|
||||
private File convertPdfFile;
|
||||
private File swfFile;
|
||||
private File docFile;
|
||||
private String filesType;
|
||||
String waterPdfPath;
|
||||
|
||||
private String convertHost;
|
||||
@@ -56,7 +49,6 @@ 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");
|
||||
@@ -66,38 +58,6 @@ public class DocConverterPdf {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* openOffice目录,window 可能在C://Program Files (x86)//OpenOffice 4
|
||||
*/
|
||||
private static final String openOfficeHome = "/opt/openoffice4";
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@@ -105,16 +65,22 @@ public class DocConverterPdf {
|
||||
*/
|
||||
private void doc2pdf() throws Exception {
|
||||
if (!pdfFile.exists()) {
|
||||
OpenOfficeConnection connection = null;
|
||||
logger.info("转换服务地址接口:"+convertHost);
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
// in = new FileInputStream(docFile);
|
||||
// out = new FileOutputStream(convertPdfFile);
|
||||
convertFile(docFile,convertPdfFile);
|
||||
// converter.convert(in).as(DefaultDocumentFormatRegistry.getFormatByMediaType(filesType)).
|
||||
// to(out).as(DefaultDocumentFormatRegistry.PDF);
|
||||
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);
|
||||
|
||||
// close the connection
|
||||
connection.disconnect();
|
||||
// 开始设置PDF文档相关属性保证其安全性
|
||||
logger.info("开始设置转换后的PDF文件安全性相关设置");
|
||||
PDFEditUtils.setPDFFileSecurity(pdfFile.getAbsolutePath(),convertPdfFile.getAbsolutePath());
|
||||
@@ -123,6 +89,10 @@ 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;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -63,5 +64,6 @@ public class UtArea extends BaseEntity {
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date modifyTime;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> sarTypeList;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,6 +38,18 @@ public class UtAreaServiceImpl extends ServiceImpl<UtAreaDao, UtArea> implements
|
||||
}
|
||||
|
||||
public List<SelectionResult> getAreaSelList(UtArea utAreaEO){
|
||||
List<String> list = new ArrayList<>();
|
||||
if(utAreaEO.getSarType().equals("INLAND_STAND")){
|
||||
utAreaEO.setSarType(null);
|
||||
list.add("INLAND_STAND");
|
||||
list.add("STAND");
|
||||
utAreaEO.setSarTypeList(list);
|
||||
}else if(utAreaEO.getSarType().equals("FOREIGN_STAND")){
|
||||
utAreaEO.setSarType(null);
|
||||
list.add("FOREIGN_STAND");
|
||||
list.add("STAND");
|
||||
utAreaEO.setSarTypeList(list);
|
||||
}
|
||||
return dao.getAreaSelList(utAreaEO);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
</select>
|
||||
|
||||
<select id="getAreaSelList" parameterType="com.adc.da.slrs.utArea.entity.UtArea" resultType="com.adc.da.sys.common.SelectionResult">
|
||||
select id as value,area_name as label
|
||||
select id as value,area_name as label,sar_type AS sarType
|
||||
from UT_AREA
|
||||
where 1=1
|
||||
<if test="id != null" >
|
||||
@@ -191,6 +191,12 @@
|
||||
<if test="sarType != null" >
|
||||
and sar_type like concat(concat('%',#{sarType}),'%')
|
||||
</if>
|
||||
<if test="sarTypeList != null" >
|
||||
and sar_type in
|
||||
<foreach collection="sarTypeList" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
order by show_index,id
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -11,6 +11,8 @@ public class SelectionResult {
|
||||
|
||||
private String value;
|
||||
|
||||
private String sarType;
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
@@ -26,4 +28,12 @@ public class SelectionResult {
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getSarType() {
|
||||
return sarType;
|
||||
}
|
||||
|
||||
public void setSarType(String sarType) {
|
||||
this.sarType = sarType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user