feat: 新增 convert 转换pdf子项目 MQ
This commit is contained in:
+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){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user