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>
|
</dependency>
|
||||||
<!-- openOffice 和 jobconverter-->
|
<!-- openOffice 和 jobconverter-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jodconverter</groupId>
|
<groupId>com.artofsolving</groupId>
|
||||||
<artifactId>jodconverter-core</artifactId>
|
<artifactId>jodconverter</artifactId>
|
||||||
<version>4.2.2</version>
|
<scope>system</scope>
|
||||||
</dependency>
|
<version>2.2.2</version>
|
||||||
<dependency>
|
<systemPath>${basedir}/src/main/lib/jodconverter-2.2.2.jar</systemPath>
|
||||||
<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>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- openOffice end-->
|
<!-- openOffice end-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
package com.adc.da.convert.common;
|
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.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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class DocConverterPdf {
|
public class DocConverterPdf {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DocConverterPdf.class);
|
private static final Logger logger = LoggerFactory.getLogger(DocConverterPdf.class);
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DocumentConverter converter;
|
|
||||||
|
|
||||||
private static final int ENVIRONMENT = 1;// 环境 1:windows 2:linux
|
private static final int ENVIRONMENT = 1;// 环境 1:windows 2:linux
|
||||||
private String fileString;// (只涉及pdf2swf路径问题)
|
private String fileString;// (只涉及pdf2swf路径问题)
|
||||||
private String outputPath = "";// 输入路径 ,如果不设置就输出在默认的位置
|
private String outputPath = "";// 输入路径 ,如果不设置就输出在默认的位置
|
||||||
@@ -28,7 +22,6 @@ public class DocConverterPdf {
|
|||||||
private File convertPdfFile;
|
private File convertPdfFile;
|
||||||
private File swfFile;
|
private File swfFile;
|
||||||
private File docFile;
|
private File docFile;
|
||||||
private String filesType;
|
|
||||||
String waterPdfPath;
|
String waterPdfPath;
|
||||||
|
|
||||||
private String convertHost;
|
private String convertHost;
|
||||||
@@ -56,7 +49,6 @@ public class DocConverterPdf {
|
|||||||
fileName = fileString.substring(0, fileString.lastIndexOf("."));
|
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())){
|
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);
|
docFile = new File(fileString);
|
||||||
filesType = fileType.toLowerCase();
|
|
||||||
convertPdfFile=new File(fileName+"_C"+ ".pdf");
|
convertPdfFile=new File(fileName+"_C"+ ".pdf");
|
||||||
pdfFile = new File(fileName + ".pdf");
|
pdfFile = new File(fileName + ".pdf");
|
||||||
swfFile = new File(fileName + ".swf");
|
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
|
* 转为PDF
|
||||||
*
|
*
|
||||||
@@ -105,16 +65,22 @@ public class DocConverterPdf {
|
|||||||
*/
|
*/
|
||||||
private void doc2pdf() throws Exception {
|
private void doc2pdf() throws Exception {
|
||||||
if (!pdfFile.exists()) {
|
if (!pdfFile.exists()) {
|
||||||
|
OpenOfficeConnection connection = null;
|
||||||
logger.info("转换服务地址接口:"+convertHost);
|
logger.info("转换服务地址接口:"+convertHost);
|
||||||
InputStream in = null;
|
|
||||||
OutputStream out = null;
|
|
||||||
try {
|
try {
|
||||||
// in = new FileInputStream(docFile);
|
if(StringUtils.isNotBlank(convertHost)){
|
||||||
// out = new FileOutputStream(convertPdfFile);
|
connection = new SocketOpenOfficeConnection(convertHost,8100);
|
||||||
convertFile(docFile,convertPdfFile);
|
}else{
|
||||||
// converter.convert(in).as(DefaultDocumentFormatRegistry.getFormatByMediaType(filesType)).
|
connection = new SocketOpenOfficeConnection(8100);
|
||||||
// to(out).as(DefaultDocumentFormatRegistry.PDF);
|
}
|
||||||
|
connection.connect();
|
||||||
|
DocumentConverter converter = new StreamOpenOfficeDocumentConverter(connection);
|
||||||
|
converter.convert(docFile, convertPdfFile);
|
||||||
|
|
||||||
|
//addWaterToPdf(pdfFile,userId);
|
||||||
|
|
||||||
// close the connection
|
// close the connection
|
||||||
|
connection.disconnect();
|
||||||
// 开始设置PDF文档相关属性保证其安全性
|
// 开始设置PDF文档相关属性保证其安全性
|
||||||
logger.info("开始设置转换后的PDF文件安全性相关设置");
|
logger.info("开始设置转换后的PDF文件安全性相关设置");
|
||||||
PDFEditUtils.setPDFFileSecurity(pdfFile.getAbsolutePath(),convertPdfFile.getAbsolutePath());
|
PDFEditUtils.setPDFFileSecurity(pdfFile.getAbsolutePath(),convertPdfFile.getAbsolutePath());
|
||||||
@@ -123,6 +89,10 @@ public class DocConverterPdf {
|
|||||||
logger.error(e.getMessage(),e);
|
logger.error(e.getMessage(),e);
|
||||||
logger.info("****pdf转换器异常,openoffice服务未启动!****");
|
logger.info("****pdf转换器异常,openoffice服务未启动!****");
|
||||||
throw e;
|
throw e;
|
||||||
|
} catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
logger.info("****pdf转换器异常,读取转换文件失败****");
|
||||||
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(),e);
|
logger.error(e.getMessage(),e);
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.math.BigDecimal;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
@@ -63,5 +64,6 @@ public class UtArea extends BaseEntity {
|
|||||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
private Date modifyTime;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -37,6 +38,18 @@ public class UtAreaServiceImpl extends ServiceImpl<UtAreaDao, UtArea> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<SelectionResult> getAreaSelList(UtArea utAreaEO){
|
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);
|
return dao.getAreaSelList(utAreaEO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getAreaSelList" parameterType="com.adc.da.slrs.utArea.entity.UtArea" resultType="com.adc.da.sys.common.SelectionResult">
|
<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
|
from UT_AREA
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="id != null" >
|
<if test="id != null" >
|
||||||
@@ -191,6 +191,12 @@
|
|||||||
<if test="sarType != null" >
|
<if test="sarType != null" >
|
||||||
and sar_type like concat(concat('%',#{sarType}),'%')
|
and sar_type like concat(concat('%',#{sarType}),'%')
|
||||||
</if>
|
</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
|
order by show_index,id
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ public class SelectionResult {
|
|||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
private String sarType;
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
@@ -26,4 +28,12 @@ public class SelectionResult {
|
|||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSarType() {
|
||||||
|
return sarType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSarType(String sarType) {
|
||||||
|
this.sarType = sarType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user