feat: 新增 convert 转换pdf子项目 MQ
This commit is contained in:
+4
-153
@@ -10,141 +10,18 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>adc-da-convert</artifactId>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.7</java.version>
|
||||
<java_source_version>1.7</java_source_version>
|
||||
<java_target_version>1.7</java_target_version>
|
||||
<spring.version>4.3.9.RELEASE</spring.version>
|
||||
<mybatis.version>3.4.0</mybatis.version>
|
||||
<shiro.version>1.4.0-RC2</shiro.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>adc</id>
|
||||
<url>http://60.247.58.121:8182/nexus/content/groups/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>thirdparty</id>
|
||||
<name>Nexus Thirdparty Repository</name>
|
||||
<url>http://60.247.58.121:8182/nexus/content/repositories/thirdparty/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-base</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-sys</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-util</artifactId>
|
||||
<version>2.2.4</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk14</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<version>${mybatis.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
</dependency>
|
||||
<!-- SECURITY begin -->
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<version>${shiro.version}</version>
|
||||
</dependency>
|
||||
<!-- SECURITY end -->
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-excel</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!-- poi begin -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- poi end -->
|
||||
|
||||
<!--上传文件-->
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-file</artifactId>
|
||||
<version>RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-file</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--OFFICE CONVERTER BEGIN-->
|
||||
<dependency>
|
||||
<groupId>com.servlets</groupId>
|
||||
<artifactId>cos</artifactId>
|
||||
<version>05Nov2002</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>com.artofsolving</groupId>
|
||||
<artifactId>jodconverter</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.artofsolving</groupId>
|
||||
<artifactId>jodconverter</artifactId>
|
||||
@@ -167,22 +44,11 @@
|
||||
<artifactId>ridl</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<version>1.7.21</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openoffice</groupId>
|
||||
<artifactId>unoil</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<!--OFFICE CONVERTER END-->
|
||||
|
||||
<!--ITEXT7 PDF文档编辑-->
|
||||
@@ -217,27 +83,12 @@
|
||||
<version>7.0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.18</version>
|
||||
<groupId>org.dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<compilerVersion>${java.version}</compilerVersion>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.adc.da.convert.OtConvert.controller;
|
||||
|
||||
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import com.adc.da.convert.mq.CreateConvertMQService;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.adc.da.convert.OtConvert.entity.OtConvert;
|
||||
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-12
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "|OtConvert| 文档转换")
|
||||
@RequestMapping("/OtConvert")
|
||||
public class OtConvertController extends BaseController<OtConvert> {
|
||||
|
||||
@Autowired
|
||||
private CreateConvertMQService createConvertMQService;
|
||||
|
||||
/**
|
||||
* @Author super_liu
|
||||
* @Description 查询文件信息
|
||||
* Date 2018/10/10 18:41
|
||||
* @Param [fileId]
|
||||
* @return com.adc.da.util.http.ResponseMessage<com.adc.da.att.entity.AttFileEO>
|
||||
**/
|
||||
@ApiOperation(value = "|File|查询文件信息")
|
||||
@GetMapping("/OtConvert")
|
||||
public ResponseMessage<String> getAttFileInfo(AttFileEO attFileEO){
|
||||
createConvertMQService.sendConvertMQ(attFileEO);
|
||||
return Result.success("");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.adc.da.convert.OtConvert.dao;
|
||||
|
||||
import com.adc.da.convert.OtConvert.entity.OtConvert;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 流程文档转换记录表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-08-12
|
||||
*/
|
||||
public interface OtConvertDao extends BaseMapper<OtConvert> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.adc.da.convert.OtConvert.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-12
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="OtConvert对象", description="流程文档转换记录表")
|
||||
public class OtConvert extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
@TableId("ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "待转换文件ID")
|
||||
@TableField("ACT_FILE_ID")
|
||||
private String actFileId;
|
||||
|
||||
@ApiModelProperty(value = "转换状态:LODING:待转换 SUCCESS:成功 ERROR:错误")
|
||||
@TableField("CONVERT_STATE")
|
||||
private String convertState;
|
||||
|
||||
@ApiModelProperty(value = "转换后文件ID")
|
||||
@TableField("CONVERT_FILE_ID")
|
||||
private String convertFileId;
|
||||
|
||||
@ApiModelProperty(value = "数据创建时间")
|
||||
@TableField("CREATE_TIME")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@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;
|
||||
|
||||
@ApiModelProperty(value = "是否有效")
|
||||
@TableField("VALID_FLAG")
|
||||
private Integer validFlag;
|
||||
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.adc.da.convert.OtConvert.service;
|
||||
|
||||
import com.adc.da.convert.OtConvert.entity.OtConvert;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 流程文档转换记录表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-08-12
|
||||
*/
|
||||
public interface IOtConvertService extends IService<OtConvert> {
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.adc.da.convert.OtConvert.service.impl;
|
||||
|
||||
import com.adc.da.convert.OtConvert.entity.OtConvert;
|
||||
import com.adc.da.convert.OtConvert.dao.OtConvertDao;
|
||||
import com.adc.da.convert.OtConvert.service.IOtConvertService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 流程文档转换记录表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-08-12
|
||||
*/
|
||||
@Service
|
||||
public class OtConvertServiceImpl extends ServiceImpl<OtConvertDao, OtConvert> implements IOtConvertService {
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@ 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.itextpdf.kernel.pdf.PdfReader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.adc.da.convert.mq;
|
||||
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class CreateConvertMQService {
|
||||
@Autowired
|
||||
private AmqpTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param attFileEO 文件对象
|
||||
* @throws Exception
|
||||
*/
|
||||
public void sendConvertMQ(AttFileEO attFileEO){
|
||||
// 中间转换业务逻辑
|
||||
//发送消息队列
|
||||
this.rabbitTemplate.convertAndSend("convert-exchange_SQ_GSAR", "convert-key_SQ_GSAR", attFileEO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.adc.da.convert.mq;
|
||||
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import com.adc.da.att.service.IAttFileEOService;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.amqp.support.AmqpHeaders;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SendConvertMQService {
|
||||
|
||||
// 文档转换远程服务IP地址
|
||||
@Value("${convert.host}")
|
||||
private String convertHost;
|
||||
|
||||
@Autowired
|
||||
private IAttFileEOService iAttFileEOService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SendConvertMQService.class);
|
||||
|
||||
@RabbitListener(bindings = @QueueBinding(
|
||||
value = @Queue(value = "createStandMQ_SQ_GSAR", durable = "true"),
|
||||
exchange = @Exchange(value = "convert-exchange_SQ_GSAR", ignoreDeclarationExceptions = "true"),
|
||||
key = "convert-key_SQ_GSAR"))
|
||||
public void createMQ(AttFileEO attFileEO, Message message, Channel channel) throws Exception{
|
||||
try{
|
||||
try{
|
||||
Thread.sleep(5000);
|
||||
insertOrUpdateStandInfo(attFileEO);
|
||||
}catch(InterruptedException e){
|
||||
logger.error(e.toString());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("文档转换消息队列进入添加数据方法前失败!");
|
||||
logger.error(e.getMessage(),e);
|
||||
}finally {
|
||||
Long tag = (Long) message.getHeaders().get(AmqpHeaders.DELIVERY_TAG);
|
||||
channel.basicAck(tag,false);
|
||||
logger.debug("文档转换消息确认成功!!!!!!!!!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档转换逻辑
|
||||
* @param attFileEO
|
||||
*/
|
||||
public void insertOrUpdateStandInfo(AttFileEO attFileEO){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.OtConvert.dao.OtConvertDao">
|
||||
|
||||
</mapper>
|
||||
@@ -24,6 +24,11 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-convert</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-slrs</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user