feat: There is no way the,
This commit is contained in:
@@ -0,0 +1,368 @@
|
||||
//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.SarTypeEnum;
|
||||
//import com.adc.da.common.UseModuleEnum;
|
||||
//import com.adc.da.convert.common.AsposeOfficeConvertUtils;
|
||||
//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.sarLawsFile.dao.SarLawsFileDao;
|
||||
//import com.adc.da.slrs.sarLawsFile.entity.SarLawsFile;
|
||||
//import com.adc.da.slrs.sarStandFile.dao.SarStandFileDao;
|
||||
//import com.adc.da.slrs.sarStandFile.entity.SarStandFile;
|
||||
//import com.adc.da.sys.util.LoginUserUtil;
|
||||
//import com.adc.da.util.http.ResponseMessage;
|
||||
//import com.adc.da.util.http.Result;
|
||||
//import com.adc.da.util.utils.StringUtils;
|
||||
//import com.adc.da.util.utils.UUID;
|
||||
//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;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.util.Date;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//@Component
|
||||
//public class SendUploadConvertService {
|
||||
//
|
||||
// // 文档转换远程服务IP地址s
|
||||
// @Value("${convert.host}")
|
||||
// private String convertHost;
|
||||
//
|
||||
// @Value("${server.port}")
|
||||
// private String port;
|
||||
//
|
||||
// @Value("${file.path}")
|
||||
// private String localFilePath;
|
||||
//
|
||||
// @Autowired
|
||||
// private IAttFileEOService attFileEOService;
|
||||
//
|
||||
// @Autowired
|
||||
// private CreateMQService convertMq;
|
||||
//
|
||||
// @Autowired
|
||||
// private IOtConvertMqService convertMqEOService;
|
||||
//
|
||||
// @Autowired
|
||||
// private SarStandFileDao sarStandFileEODao;
|
||||
//
|
||||
// @Autowired
|
||||
// private SarBussStandFileDao sarBussStandFileEODao;
|
||||
//
|
||||
// @Autowired
|
||||
// private SarLawsFileDao sarLawsFileDao;
|
||||
//
|
||||
// private static final Logger logger = LoggerFactory.getLogger(SendUploadConvertService.class);
|
||||
//
|
||||
// @RabbitListener(bindings = @QueueBinding(
|
||||
// value = @Queue(value = "createUploadConvertMQ_SQ_GSAR_RELEASE", durable = "true"),
|
||||
// exchange = @Exchange(value = "convertUpload-exchange_SQ_GSAR_RELEASE", ignoreDeclarationExceptions = "true"),
|
||||
// key = "convertUpload-key_SQ_GSAR_RELEASE"))
|
||||
// public void createMQ(Map<String,Object> convertInfo, Message message, Channel channel) throws Exception{
|
||||
// try{
|
||||
// try{
|
||||
// Thread.sleep(5000);
|
||||
// insertConvertMsg(convertInfo);
|
||||
// }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);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void insertConvertMsg(Map<String,Object> convertInfo) throws Exception{
|
||||
// docUploadConvert(convertMqEO);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @Description 文件转换
|
||||
// * Date 2018/8/21 15:51
|
||||
// * @Param [path]
|
||||
// * @return com.adc.da.util.http.ResponseMessage
|
||||
// **/
|
||||
// public ResponseMessage docUploadConvert(OtConvertMq convertMqEO) throws Exception{
|
||||
// //保存在数据库中的ID
|
||||
// String path = localFilePath + convertMqEO.getFilePath();
|
||||
// path = path.replace("//","/");
|
||||
// String convertId = convertMqEO.getId();
|
||||
// try {
|
||||
// //进入转换方法中,修改OT_CONVERT表中状态为转换中
|
||||
// convertMqEO.setId(convertId);
|
||||
// convertMqEO.setModifyTime(new Date());
|
||||
// convertMqEO.setMqState(3);
|
||||
// convertMqEOService.updateById(convertMqEO);
|
||||
// //开始转换。。。。。。
|
||||
// if(!"".equals(path)){
|
||||
// String converfilename = path.replaceAll("\\\\", "/");
|
||||
// logger.info("*****上传路径:*******"+localFilePath);
|
||||
// logger.info("************文件路径:**********" + convertMqEO.getFilePath());
|
||||
//// logger.info("************接口:**********" + port);
|
||||
// logger.info("*****上传路径替换,加入文件名*******"+converfilename);
|
||||
// //截取文件类型
|
||||
// int index = converfilename.lastIndexOf(".");
|
||||
// String fileType = converfilename.substring(index,converfilename.length());
|
||||
// String fileOriName = converfilename.substring(0,index);
|
||||
//// //调用转换类DocConverter,并将需要转换的文件传递给该类的构造方法
|
||||
//// DocConverterPdf d = new DocConverterPdf(converfilename,fileType);
|
||||
//// d.setConvertHost(convertHost);
|
||||
//// //调用conver方法开始转换,先执行doc2pdf()将office文件转换为pdf;再执行pdf2swf()将pdf转换为swf;
|
||||
//// File getPdf = d.conver(fileType);
|
||||
//// //调用getswfPath()方法,打印转换后的swf文件路径
|
||||
//// String dPath = d.getpdfPath();
|
||||
// String savePdfFileName = converfilename.substring(0, converfilename.lastIndexOf("."));
|
||||
// String savePdfPath = savePdfFileName+".pdf";
|
||||
// AsposeOfficeConvertUtils.convertOfficeFileToPDF(fileType,converfilename,savePdfPath);
|
||||
// File pdfFile = new File(savePdfPath);
|
||||
// logger.info("*****转换后的pdf文件路径*******"+savePdfPath);
|
||||
// //判断是否转换成功,修改数据状态
|
||||
// if(!savePdfPath.isEmpty() && pdfFile.length()>0){
|
||||
// // 上传转换后文件
|
||||
// String pdfId = attFileEOService.saveFileAttId(pdfFile);
|
||||
// logger.info("////////转换后文件id"+pdfId);
|
||||
// int count = 0;
|
||||
// if("0".equals(convertMqEO.getAddOrUp())){
|
||||
// count = insertConvertDocToFiles(convertMqEO,pdfId,fileOriName,fileType);
|
||||
// } else {
|
||||
// //查询之前在资源与文件关联表中是否有转换成功的数据,如果有执行修改,没有执行新增
|
||||
// if(StringUtils.isNotEmpty(convertMqEO.getPdfId())){
|
||||
// count = updateConvertDocToFIles(convertMqEO,pdfId);
|
||||
// } else {
|
||||
// count = insertConvertDocToFiles(convertMqEO,pdfId,fileOriName,fileType);
|
||||
// }
|
||||
// }
|
||||
// convertMqEO.setId(convertId);
|
||||
// if (count>0) {
|
||||
// // 转换成功
|
||||
// convertMqEO.setModifyTime(new Date());
|
||||
// convertMqEO.setMqState(1);
|
||||
// convertMqEOService.updateById(convertMqEO);
|
||||
// } else {
|
||||
// // 转换失败
|
||||
// convertMqEO.setModifyTime(new Date());
|
||||
// convertMqEO.setMqState(2);
|
||||
// convertMqEOService.updateById(convertMqEO);
|
||||
// }
|
||||
// } else {
|
||||
// // 转换失败
|
||||
// convertMqEO.setId(convertId);
|
||||
// convertMqEO.setModifyTime(new Date());
|
||||
// convertMqEO.setMqState(2);
|
||||
// convertMqEOService.updateById(convertMqEO);
|
||||
//// if(convertMqEO.getAgainNum()<=5){
|
||||
//// throw new Exception("转换失败");
|
||||
//// }
|
||||
// }
|
||||
// return Result.success(savePdfPath);
|
||||
// } else {
|
||||
// logger.error("转换时未获取到文件路径!");
|
||||
// return Result.error("文件存储失败,请重试");
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// // 转换失败
|
||||
// logger.error("转换过程中失败!");
|
||||
// logger.error(e.getMessage(),e);
|
||||
// convertMqEO.setId(convertId);
|
||||
// convertMqEO.setMqState(2);
|
||||
// convertMqEOService.updateById(convertMqEO);
|
||||
//// this.restartUploadConvert(convertMqEO);
|
||||
// return Result.error("r0072", "文件转换失败,请重试");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public ResponseMessage restartUploadConvert(OtConvertMq convertInfo) throws Exception{
|
||||
// OtConvertMq convertMqEO = new OtConvertMq();
|
||||
// convertMqEO.setLawsId(convertInfo.getLawsId());
|
||||
// convertMqEO.setConvertType(convertInfo.getConvertType());
|
||||
// convertMqEO.setAttId(convertInfo.getAttId());
|
||||
// convertMqEO.setOriAttId(convertInfo.getOriAttId());
|
||||
// convertMqEO.setId(convertInfo.getId());
|
||||
// convertMqEO.setFilePath(convertInfo.getFilePath());
|
||||
// convertMqEO.setAddOrUp(convertInfo.getAddOrUp());
|
||||
// convertMqEO.setPdfId(convertInfo.getPdfId());
|
||||
// convertMqEO.setStandFileClassify(convertInfo.getStandFileClassify());
|
||||
// int countAdd = 0;
|
||||
// convertMqEO.setAddOrUp("1");
|
||||
// int againNumNew = Integer.valueOf(convertInfo.getAgainNum());
|
||||
// convertMqEO.setAgainNum(againNumNew+1);
|
||||
// convertMq.sendMQ(convertMqEO);
|
||||
// return Result.success("true","已重新加入转换","");
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @Author yangxuenan
|
||||
// * @Description 修改标准法规文件表pdf信息
|
||||
// * Date 2018/10/31 17:09
|
||||
// * @Param [convertMq, pdfId]
|
||||
// * @return int
|
||||
// **/
|
||||
// public int updateConvertDocToFIles(OtConvertMq convertMq,String pdfId){
|
||||
// int countSuccess = 0;
|
||||
// if(SarTypeEnum.STAND.getValue().equals(convertMq.getConvertType())){
|
||||
// SarStandFile lawsFile = new SarStandFile();
|
||||
// lawsFile.setId(convertMq.getPdfId());
|
||||
// lawsFile.setAttId(pdfId);
|
||||
// lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
// lawsFile.setModifyTime(new Date());
|
||||
// lawsFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
|
||||
// countSuccess = sarStandFileEODao.updateByPrimaryKeySelective(lawsFile);
|
||||
// } else if (SarTypeEnum.LAWS_STAND.getValue().equals(convertMq.getConvertType())) {
|
||||
// SarLawsFile lawsFile = new SarLawsFile();
|
||||
// lawsFile.setId(convertMq.getPdfId());
|
||||
// lawsFile.setAttId(pdfId);
|
||||
// lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
// lawsFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
|
||||
// lawsFile.setModifyTime(new Date());
|
||||
// countSuccess = sarLawsFileDao.updateByPrimaryKeySelective(lawsFile);
|
||||
// } else if (SarTypeEnum.BUSINESS.getValue().equals(convertMq.getConvertType())) {
|
||||
// SarBussStandFile lawsFile = new SarBussStandFile();
|
||||
// lawsFile.setId(convertMq.getPdfId());
|
||||
// lawsFile.setAttId(pdfId);
|
||||
// lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
// lawsFile.setUseModule(UseModuleEnum.WEB_FILE.getValue());
|
||||
// lawsFile.setModifyTime(new Date());
|
||||
// countSuccess = sarBussStandFileEODao.updateByPrimaryKeySelective(lawsFile);
|
||||
// }else if (SarTypeEnum.RECORDS.getValue().equals(convertMq.getConvertType())) {
|
||||
//// SarBussRecordsFileEO lawsFile = new SarBussRecordsFileEO();
|
||||
//// lawsFile.setId(convertMq.getPdfId());
|
||||
//// lawsFile.setRecordsId(convertMq.getLawsId());
|
||||
//// lawsFile.setAttId(pdfId);
|
||||
//// lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
//// lawsFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
|
||||
//// lawsFile.setValidFlag("0");
|
||||
//// lawsFile.setCreationTime(new Date());
|
||||
//// lawsFile.setModifyTime(new Date());
|
||||
//// countSuccess = sarBussRecordsFileEODao.updateByPrimaryKeySelective(lawsFile);
|
||||
// }
|
||||
// else {
|
||||
//// SarFileSplitItemsFileEO lawsFile = new SarFileSplitItemsFileEO();
|
||||
//// lawsFile.setId(convertMq.getPdfId());
|
||||
//// lawsFile.setAttId(pdfId);
|
||||
////// lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
//// lawsFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
|
||||
//// lawsFile.setModifyTime(new Date());
|
||||
//// countSuccess = sarFileSplitItemsFileEODao.updateByPrimaryKeySelective(lawsFile);
|
||||
// }
|
||||
// return countSuccess;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @Author yangxuenan
|
||||
// * @Description 添加标准法规文件表pdf信息
|
||||
// * Date 2018/10/30 21:52
|
||||
// * @Param [convertMq]
|
||||
// * @return int
|
||||
// **/
|
||||
// public int insertConvertDocToFiles(OtConvertMq convertMq,String pdfId,String fileOriName,String fileType) {
|
||||
// int countSuccess = 0;
|
||||
// String creationUser = LoginUserUtil.getUserId();
|
||||
// if(SarTypeEnum.STAND.getValue().equals(convertMq.getConvertType())){
|
||||
// SarStandFile lawsFile = new SarStandFile();
|
||||
// lawsFile.setId(UUID.randomUUID(20));
|
||||
// lawsFile.setStandId(convertMq.getLawsId());
|
||||
//// lawsFile.setResId(convertMq.getResId());
|
||||
// lawsFile.setAttId(pdfId);
|
||||
// lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
// lawsFile.setValidFlag("0");
|
||||
// lawsFile.setCreationUser(creationUser);
|
||||
// lawsFile.setCreationTime(new Date());
|
||||
// lawsFile.setModifyTime(new Date());
|
||||
// lawsFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
|
||||
// lawsFile.setStandFileClassify(convertMq.getStandFileClassify());
|
||||
// lawsFile.setFileName(fileOriName+".pdf");
|
||||
// lawsFile.setFileSuffix("pdf");
|
||||
// countSuccess = sarStandFileEODao.insertSelective(lawsFile);
|
||||
// } else if (SarTypeEnum.LAWS_STAND.getValue().equals(convertMq.getConvertType())) {
|
||||
// SarLawsFile lawsFile = new SarLawsFile();
|
||||
// lawsFile.setId(UUID.randomUUID(20));
|
||||
// lawsFile.setLawsId(convertMq.getLawsId());
|
||||
// lawsFile.setResId(convertMq.getResId());
|
||||
// lawsFile.setAttId(pdfId);
|
||||
// lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
// lawsFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
|
||||
// lawsFile.setValidFlag(0);
|
||||
// lawsFile.setCreationTime(new Date());
|
||||
// lawsFile.setModifyTime(new Date());
|
||||
// lawsFile.setLawsFileClassify(convertMq.getLawsFileClassify());
|
||||
// lawsFile.setFileName(fileOriName+".pdf");
|
||||
// lawsFile.setFileSuffix("pdf");
|
||||
// countSuccess = sarLawsFileDao.insertSelective(lawsFile);
|
||||
// } else if (SarTypeEnum.BUSINESS.getValue().equals(convertMq.getConvertType())) {
|
||||
// SarBussStandFile lawsFile = new SarBussStandFile();
|
||||
// lawsFile.setId(UUID.randomUUID(20));
|
||||
// lawsFile.setStandId(convertMq.getLawsId());
|
||||
// lawsFile.setResId(convertMq.getResId());
|
||||
// lawsFile.setAttId(pdfId);
|
||||
// lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
// lawsFile.setUseModule(UseModuleEnum.WEB_FILE.getValue());
|
||||
// lawsFile.setStandFileClassify(convertMq.getStandFileClassify());
|
||||
// lawsFile.setFileName(fileOriName+".pdf");
|
||||
// lawsFile.setFileSuffix("pdf");
|
||||
// lawsFile.setValidFlag(0);
|
||||
// lawsFile.setCreationTime(new Date());
|
||||
// lawsFile.setModifyTime(new Date());
|
||||
// countSuccess = sarBussStandFileEODao.insertSelective(lawsFile);
|
||||
// }
|
||||
// else if (SarTypeEnum.RECORDS.getValue().equals(convertMq.getConvertType())) {
|
||||
//// SarBussRecordsFileEO lawsFile = new SarBussRecordsFileEO();
|
||||
//// lawsFile.setId(UUID.randomUUID(20));
|
||||
//// lawsFile.setRecordsId(convertMq.getLawsId());
|
||||
//// lawsFile.setResId(convertMq.getResId());
|
||||
//// lawsFile.setAttId(pdfId);
|
||||
//// lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
//// lawsFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
|
||||
//// lawsFile.setRecordsFileClassify(convertMq.getStandFileClassify());
|
||||
//// lawsFile.setFileName(fileOriName+".pdf");
|
||||
//// lawsFile.setFileSuffix("pdf");
|
||||
//// lawsFile.setValidFlag("0");
|
||||
//// lawsFile.setCreationTime(new Date());
|
||||
//// lawsFile.setModifyTime(new Date());
|
||||
//// countSuccess = sarBussRecordsFileEODao.insertSelective(lawsFile);
|
||||
// }else {
|
||||
//// SarFileSplitItemsFileEO lawsFile = new SarFileSplitItemsFileEO();
|
||||
//// lawsFile.setId(UUID.randomUUID(20));
|
||||
//// lawsFile.setStandId(convertMq.getLawsId());
|
||||
//// lawsFile.setResId(convertMq.getResId());
|
||||
//// lawsFile.setAttId(pdfId);
|
||||
////// lawsFile.setOriAttId(convertMq.getOriAttId());
|
||||
//// lawsFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
|
||||
//// lawsFile.setValidFlag(0);
|
||||
//// lawsFile.setCreationTime(new Date());
|
||||
//// lawsFile.setModifyTime(new Date());
|
||||
//// countSuccess = sarFileSplitItemsFileEODao.insertSelective(lawsFile);
|
||||
// }
|
||||
// return countSuccess;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 文档转换逻辑
|
||||
// * @param attFileEO
|
||||
// */
|
||||
// public void insertOrUpdateStandInfo(AttFileEO attFileEO){
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
+63
-4
@@ -1,18 +1,38 @@
|
||||
package com.adc.da.convert.otConvert.controller;
|
||||
|
||||
|
||||
import com.adc.da.att.controller.AttFileEOController;
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import com.adc.da.att.service.IAttFileEOService;
|
||||
import com.adc.da.att.vo.AttFileVo;
|
||||
import com.adc.da.convert.common.AsposeOfficeConvertUtils;
|
||||
import com.adc.da.convert.mq.CreateConvertMQService;
|
||||
import com.adc.da.convert.otConvert.service.IOtConvertService;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
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;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -24,12 +44,51 @@ import com.adc.da.base.web.BaseController;
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "|OtConvert| 文档转换")
|
||||
@RequestMapping("/OtConvert")
|
||||
@RequestMapping("/${restPath}/OtConvert")
|
||||
public class OtConvertController extends BaseController<OtConvert> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OtConvertController.class);
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;//文件存储路径
|
||||
|
||||
@Value("${upload.file.white.lists}")
|
||||
private String uploadFileWhiteLists; //上传文件白名单
|
||||
|
||||
@Autowired
|
||||
private IOtConvertService iOtConvertService;
|
||||
|
||||
@Autowired
|
||||
private IAttFileEOService attFileEOService;
|
||||
|
||||
@Autowired
|
||||
private CreateConvertMQService createConvertMQService;
|
||||
|
||||
@ApiOperation(value = "|OtActConvertEO|根据文件ID获取流程转换文档")
|
||||
@GetMapping(value = "/getConvertFileByAttId")
|
||||
public ResponseMessage getConvertFileByAttId(String attId) throws Exception {
|
||||
// 根据attId查到地址
|
||||
if(StringUtils.isNotBlank(attId)){
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("ACT_FILE_ID",attId);
|
||||
List<OtConvert> resultList = iOtConvertService.list(wrapper);
|
||||
if(resultList!=null && !resultList.isEmpty()){
|
||||
OtConvert convertEO = resultList.get(0);
|
||||
if(StringUtils.isNotBlank(convertEO.getConvertFileId())){
|
||||
AttFileEO attFileEO = attFileEOService.getFileInfo(convertEO.getConvertFileId());
|
||||
convertEO.setConvertFileInfo(attFileEO);
|
||||
return Result.success(convertEO);
|
||||
}else{
|
||||
return Result.success("-100","查询的转件文件未找到,请检查状态",convertEO);
|
||||
}
|
||||
}else{
|
||||
return Result.error("-1","查询的转换记录不存在",null);
|
||||
}
|
||||
}else{
|
||||
return Result.error("-1","查询的转换文档ID不存在",null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author super_liu
|
||||
* @Description 查询文件信息
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.adc.da.convert.otConvert.entity;
|
||||
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import com.adc.da.base.entity.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <b>功能:</b>OT_ACT_CONVERT OtActConvertEOEntity<br>
|
||||
* <b>作者:</b>code generator<br>
|
||||
* <b>日期:</b> 2021-03-19 <br>
|
||||
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
|
||||
*/
|
||||
public class OtActConvertEO extends BaseEntity {
|
||||
|
||||
private String id;
|
||||
private String actFileId;
|
||||
private String convertState;
|
||||
private String convertFileId;
|
||||
@org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date modifyTime;
|
||||
|
||||
// 转换后文件信息
|
||||
private AttFileEO ConvertFileInfo;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* java字段名转换为原始数据库列名。<b>如果不存在则返回null</b><br>
|
||||
* <p>字段列表:</p>
|
||||
* <li>id -> id</li>
|
||||
* <li>actFileId -> act_file_id</li>
|
||||
* <li>convertState -> convert_state</li>
|
||||
* <li>convertFileId -> convert_file_id</li>
|
||||
* <li>createTime -> create_time</li>
|
||||
* <li>modifyTime -> modify_time</li>
|
||||
*/
|
||||
public static String fieldToColumn(String fieldName) {
|
||||
if (fieldName == null) { return null; };
|
||||
switch (fieldName) {
|
||||
case "id": return "id";
|
||||
case "actFileId": return "act_file_id";
|
||||
case "convertState": return "convert_state";
|
||||
case "convertFileId": return "convert_file_id";
|
||||
case "createTime": return "create_time";
|
||||
case "modifyTime": return "modify_time";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 原始数据库列名转换为java字段名。<b>如果不存在则返回null</b><br>
|
||||
* <p>字段列表:</p>
|
||||
* <li>id -> id</li>
|
||||
* <li>act_file_id -> actFileId</li>
|
||||
* <li>convert_state -> convertState</li>
|
||||
* <li>convert_file_id -> convertFileId</li>
|
||||
* <li>create_time -> createTime</li>
|
||||
* <li>modify_time -> modifyTime</li>
|
||||
*/
|
||||
public static String columnToField(String columnName) {
|
||||
if (columnName == null) { return null; };
|
||||
switch (columnName) {
|
||||
case "id": return "id";
|
||||
case "act_file_id": return "actFileId";
|
||||
case "convert_state": return "convertState";
|
||||
case "convert_file_id": return "convertFileId";
|
||||
case "create_time": return "createTime";
|
||||
case "modify_time": return "modifyTime";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** 主键 **/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/** 主键 **/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/** 流程中待转换文件ID **/
|
||||
public String getActFileId() {
|
||||
return this.actFileId;
|
||||
}
|
||||
|
||||
/** 流程中待转换文件ID **/
|
||||
public void setActFileId(String actFileId) {
|
||||
this.actFileId = actFileId;
|
||||
}
|
||||
|
||||
/** 转换状态:LODING:待转换 SUCCESS:成功 ERROR:错误 **/
|
||||
public String getConvertState() {
|
||||
return this.convertState;
|
||||
}
|
||||
|
||||
/** 转换状态:LODING:待转换 SUCCESS:成功 ERROR:错误 **/
|
||||
public void setConvertState(String convertState) {
|
||||
this.convertState = convertState;
|
||||
}
|
||||
|
||||
/** 转换后文件ID **/
|
||||
public String getConvertFileId() {
|
||||
return this.convertFileId;
|
||||
}
|
||||
|
||||
/** 转换后文件ID **/
|
||||
public void setConvertFileId(String convertFileId) {
|
||||
this.convertFileId = convertFileId;
|
||||
}
|
||||
|
||||
/** 数据创建时间 **/
|
||||
public Date getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
/** 数据创建时间 **/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/** 数据修改时间 **/
|
||||
public Date getModifyTime() {
|
||||
return this.modifyTime;
|
||||
}
|
||||
|
||||
/** 数据修改时间 **/
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
|
||||
public AttFileEO getConvertFileInfo() {
|
||||
return ConvertFileInfo;
|
||||
}
|
||||
|
||||
public void setConvertFileInfo(AttFileEO convertFileInfo) {
|
||||
ConvertFileInfo = convertFileInfo;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.adc.da.convert.otConvert.entity;
|
||||
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import com.adc.da.base.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
@@ -62,5 +63,7 @@ public class OtConvert extends BaseEntity {
|
||||
@TableField("VALID_FLAG")
|
||||
private Integer validFlag;
|
||||
|
||||
|
||||
// 转换后文件信息
|
||||
@TableField(exist = false)
|
||||
private AttFileEO ConvertFileInfo;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
addInterceptor.excludePathPatterns("/api/sarStandUnqualified/sar-stand-unqualified/exportStandUnqulifiedExcel");
|
||||
//文件预览
|
||||
addInterceptor.excludePathPatterns("/api/att/attFile/getFileInfo");
|
||||
// onlyOffice 回调
|
||||
addInterceptor.excludePathPatterns("/api/att/attFile/recieveFile");
|
||||
|
||||
addInterceptor.excludePathPatterns("/api/att/attFile/getSyncPdfFileInfo");
|
||||
//附件下载
|
||||
addInterceptor.excludePathPatterns("/api/att/attFile/downloadFileForSar");
|
||||
//水印下载
|
||||
|
||||
@@ -138,8 +138,11 @@ verifyCodeMode=1
|
||||
# =============================================================================
|
||||
# file模块上传文件的服务器地址
|
||||
file.path=D:/uploadfile/bus
|
||||
# 文件下载地址参数
|
||||
file.downloadUrl=http://39.98.140.126:10001/uploadPath
|
||||
|
||||
stand.edit.file.path = /usr/laws/file/
|
||||
# onlyoffice 预览地址
|
||||
file.downloadUrl=http://10.100.5.116:1080/file/
|
||||
|
||||
#上传文件白名单-以,分隔
|
||||
upload.file.white.lists = doc,docx,xls,xlsx,pdf,PDF,png,jpg,pptx,ppt
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import sun.misc.BASE64Encoder;
|
||||
@@ -30,6 +31,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -56,6 +59,9 @@ public class AttFileEOController {
|
||||
@Value("${file.path}")
|
||||
private String filePath;//文件存储路径
|
||||
|
||||
@Value("${stand.edit.file.path}")
|
||||
private String standEditFilePath;
|
||||
|
||||
// @Autowired
|
||||
// private RoleEOService roleEOService;
|
||||
//
|
||||
@@ -66,6 +72,89 @@ public class AttFileEOController {
|
||||
private String uploadFileWhiteLists; //上传文件白名单
|
||||
|
||||
|
||||
@ApiOperation(value = "|获取企标文件")
|
||||
@GetMapping("/getBusStandFileByAttId")
|
||||
public ResponseMessage<AttFileEO> getBusStandFileByAttId(String attId){
|
||||
AttFileEO attFileEO = attFileEOService.saveOrGetBusFileInfo(attId);
|
||||
return Result.success(attFileEO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "|onlyOffice接收文件")
|
||||
@PostMapping("/recieveFile")
|
||||
public void recieveFile(HttpServletRequest request, HttpServletResponse response, String fileNm,String standNo){
|
||||
logger.info("**********进入onlyoffice接收文档接口************");
|
||||
try {
|
||||
PrintWriter writer = response.getWriter();
|
||||
String body = "";
|
||||
try {
|
||||
Scanner scanner = new Scanner(request.getInputStream());
|
||||
scanner.useDelimiter("\\A");
|
||||
body = scanner.hasNext() ? scanner.next() : "";
|
||||
scanner.close();
|
||||
} catch (Exception ex) {
|
||||
writer.write("get request.getInputStream error:" + ex.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (body.isEmpty()) {
|
||||
writer.write("empty request.getInputStream");
|
||||
return;
|
||||
}
|
||||
|
||||
net.sf.json.JSONObject jsonObj = net.sf.json.JSONObject.fromObject(body);
|
||||
logger.info("**********onlyoffice接收文档接口获得结果body************" + body);
|
||||
int status = (Integer) jsonObj.get("status");
|
||||
|
||||
int saved = 0;
|
||||
if (status == 2 || status == 3)//MustSave, Corrupted
|
||||
{
|
||||
String downloadUri = (String) jsonObj.get("url");
|
||||
|
||||
try {
|
||||
logger.info("**********onlyoffice接收文档接口获得downloadUri************" + downloadUri);
|
||||
if (StringUtils.isNotEmpty(downloadUri)) {
|
||||
File file = new File(standEditFilePath + standNo + "\\" + fileNm);
|
||||
downloadNetFile(downloadUri, file);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
saved = 1;
|
||||
logger.info("**********onlyoffice接收文档接口异常************" + ex.getMessage());
|
||||
logger.error(ex.getMessage(),ex);
|
||||
}
|
||||
} else if (status == 4) {
|
||||
logger.info("**********onlyoffice接收文档接口开始修改文件状态状态4************");
|
||||
|
||||
logger.info("**********onlyoffice接收文档接口修改文件状态成功状态4************");
|
||||
}
|
||||
logger.info("onlyoffice编辑完成--------------");
|
||||
writer.write("{\"error\":" + saved + "}");
|
||||
} catch (IOException e) {
|
||||
logger.info("**********onlyoffice接收文档接口异常************" + e.getMessage());
|
||||
logger.error(e.getMessage(),e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void downloadNetFile(String downloadUrl, File file) {
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
URL url = new URL(downloadUrl);
|
||||
URLConnection connection = url.openConnection();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
int length = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
while ((length = inputStream.read(bytes)) != -1) {
|
||||
fileOutputStream.write(bytes, 0, length);
|
||||
}
|
||||
fileOutputStream.close();
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
logger.error("download error ! url :{}, exception:{}", downloadUrl, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value="|File|上传文件")
|
||||
@PostMapping(value="/upload",consumes="multipart/*",headers="content-type=multipart/form-data" )
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@@ -104,6 +193,8 @@ public class AttFileEOController {
|
||||
String standName = oriFileName.replace(standNumber,"");
|
||||
fileInfo.setStandName(standName);
|
||||
}
|
||||
// 上传转换文件
|
||||
fileToConvert();
|
||||
return Result.success("true", "上传成功", fileInfo);
|
||||
} else {
|
||||
return Result.error("文件上传失败");
|
||||
@@ -116,6 +207,12 @@ public class AttFileEOController {
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
void fileToConvert(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value="|File|上传文件")
|
||||
@PostMapping(value="/uploadFiles",consumes="multipart/*",headers="content-type=multipart/form-data" )
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.util.List;
|
||||
|
||||
public interface IAttFileEOService extends IService<AttFileEO> {
|
||||
|
||||
AttFileEO saveOrGetBusFileInfo(String attId);
|
||||
|
||||
public AttFileVo saveFileInfo(File file);
|
||||
|
||||
public AttFileVo saveFileInfo(MultipartFile file);
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@@ -28,10 +30,77 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class AttFileEOServiceImpl extends ServiceImpl<AttFileEODao, AttFileEO> implements IAttFileEOService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AttFileEOServiceImpl.class);
|
||||
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;//文件存储路径
|
||||
|
||||
/**
|
||||
* 文件下载路径
|
||||
*/
|
||||
@Value("${file.downloadUrl}")
|
||||
private String downloadUrl;
|
||||
|
||||
public AttFileEO saveOrGetBusFileInfo(String attId){
|
||||
AttFileEO attFileEO=new AttFileEO();
|
||||
if(StringUtils.isNotBlank(attId)){
|
||||
attFileEO = this.getFileInfo(attId);
|
||||
//2020年10月25日 此处补充文件的下载地址
|
||||
StringBuffer downloadFileUrl = new StringBuffer();
|
||||
downloadFileUrl.append(downloadUrl).append(attFileEO.getFilePath()).append(attFileEO.getFileName());
|
||||
attFileEO.setDownLoadUrl(downloadFileUrl.toString());
|
||||
}else{
|
||||
String fileId = UUIDUtils.randomUUID20();
|
||||
try {
|
||||
String uuidPath = UUIDUtils.getUUIDPath(fileId);
|
||||
|
||||
String FileSavePath = filePath + uuidPath;
|
||||
File dir = new File(FileSavePath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
File defaultBusFile =new File(filePath+"/modal/newStandFile.docx");
|
||||
if(!defaultBusFile.exists()){
|
||||
logger.error("默认标准文件不存在");
|
||||
}
|
||||
String fileName = "标准正文.docx";
|
||||
String fileSuffix = ".docx";
|
||||
String newFileName = fileId + fileSuffix;
|
||||
File saveFile = new File(FileSavePath + newFileName);
|
||||
// FileUtil.copyInputStreamToFile(file.get, saveFile);
|
||||
FileUtils.copyFile(defaultBusFile,saveFile);
|
||||
//开始存储文件信息
|
||||
String tableName = UUIDUtils.getAttTable();
|
||||
int existTable = this.baseMapper.existTable(tableName);
|
||||
if (existTable == 0) {
|
||||
this.baseMapper.creatTableInfo(tableName);
|
||||
}
|
||||
fileId = tableName + "_" + fileId;
|
||||
|
||||
attFileEO.setTableName(tableName);
|
||||
attFileEO.setId(fileId);
|
||||
attFileEO.setOldFileName(fileName);
|
||||
attFileEO.setFileSuffix(fileSuffix);
|
||||
attFileEO.setFilePath(uuidPath);
|
||||
attFileEO.setFileName(newFileName);
|
||||
attFileEO.setValidFlag(ValidFlagEnum.VALID_TRUE.getValue());
|
||||
attFileEO.setCreationTime(new Date());
|
||||
attFileEO.setModifyTime(new Date());
|
||||
this.baseMapper.insert(attFileEO);
|
||||
//2020年10月25日 此处补充文件的下载地址
|
||||
StringBuffer downloadFileUrl=new StringBuffer();
|
||||
downloadFileUrl.append(filePath).append(uuidPath).append(newFileName);
|
||||
attFileEO.setDownLoadUrl(downloadFileUrl.toString());
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
return attFileEO;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存文件并返回文件ID
|
||||
|
||||
Reference in New Issue
Block a user