From d176d93d6bff21cfcd8978951de704c0f82cdea9 Mon Sep 17 00:00:00 2001 From: super_liu <396572590@qq.com> Date: Fri, 20 Aug 2021 14:07:37 +0800 Subject: [PATCH] feat: There is no way the Buss and Convert --- adc-da-convert/pom.xml | 6 + .../da/convert/mq/CreateConvertMQService.java | 2 +- .../da/convert/mq/SendConvertMQService.java | 629 ++++++++++------ .../controller/OtConvertController.java | 4 +- .../dao/OtConvertDao.java | 4 +- .../entity/OtConvert.java | 4 +- .../service/IOtConvertService.java | 4 +- .../service/impl/OtConvertServiceImpl.java | 8 +- .../controller/OtConvertMqController.java | 23 + .../otConvertMq/dao/OtConvertMqDao.java | 16 + .../otConvertMq/entity/OtConvertMq.java | 99 +++ .../service/IOtConvertMqService.java | 16 + .../service/impl/OtConvertMqServiceImpl.java | 20 + .../mapper/OtConvert/OtConvertMapper.xml | 2 +- .../mapper/otConvertMq/OtConvertMqMapper.xml | 5 + .../adc/da/mq/service/SendBussMQService.java | 699 ++++++++---------- .../entity/SarBussStandFile.java | 11 +- .../SarBussionessStandController.java | 26 +- .../entity/SarBussionessStand.java | 3 + .../impl/SarBussionessStandServiceImpl.java | 122 ++- .../dao/SarStandAttrInfoDao.java | 2 + .../sarStandFile/dao/SarStandFileDao.java | 2 + .../SarBussStandFileMapper.xml | 4 +- .../SarBussionessStandMapper.xml | 8 +- 24 files changed, 1046 insertions(+), 673 deletions(-) rename adc-da-convert/src/main/java/com/adc/da/convert/{OtConvert => otConvert}/controller/OtConvertController.java (93%) rename adc-da-convert/src/main/java/com/adc/da/convert/{OtConvert => otConvert}/dao/OtConvertDao.java (71%) rename adc-da-convert/src/main/java/com/adc/da/convert/{OtConvert => otConvert}/entity/OtConvert.java (96%) rename adc-da-convert/src/main/java/com/adc/da/convert/{OtConvert => otConvert}/service/IOtConvertService.java (70%) rename adc-da-convert/src/main/java/com/adc/da/convert/{OtConvert => otConvert}/service/impl/OtConvertServiceImpl.java (61%) create mode 100644 adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/controller/OtConvertMqController.java create mode 100644 adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/dao/OtConvertMqDao.java create mode 100644 adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/entity/OtConvertMq.java create mode 100644 adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/service/IOtConvertMqService.java create mode 100644 adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/service/impl/OtConvertMqServiceImpl.java create mode 100644 adc-da-convert/src/main/resources/mybatis/mapper/otConvertMq/OtConvertMqMapper.xml diff --git a/adc-da-convert/pom.xml b/adc-da-convert/pom.xml index cd99fdf3..b1922377 100644 --- a/adc-da-convert/pom.xml +++ b/adc-da-convert/pom.xml @@ -87,6 +87,12 @@ dom4j 2.0.0 + + com.adc + adc-da-slrs + 3.0.0 + compile + diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/mq/CreateConvertMQService.java b/adc-da-convert/src/main/java/com/adc/da/convert/mq/CreateConvertMQService.java index 0a01541f..0d12a3db 100644 --- a/adc-da-convert/src/main/java/com/adc/da/convert/mq/CreateConvertMQService.java +++ b/adc-da-convert/src/main/java/com/adc/da/convert/mq/CreateConvertMQService.java @@ -22,6 +22,6 @@ public class CreateConvertMQService { public void sendConvertMQ(AttFileEO attFileEO){ // 中间转换业务逻辑 //发送消息队列 - this.rabbitTemplate.convertAndSend("convert-exchange_SQ_GSAR", "convert-key_SQ_GSAR", attFileEO); +// this.rabbitTemplate.convertAndSend("convert-exchange_SQ_GSAR", "convert-key_SQ_GSAR", attFileEO); } } diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/mq/SendConvertMQService.java b/adc-da-convert/src/main/java/com/adc/da/convert/mq/SendConvertMQService.java index 36e4c5f1..810f4fd3 100644 --- a/adc-da-convert/src/main/java/com/adc/da/convert/mq/SendConvertMQService.java +++ b/adc-da-convert/src/main/java/com/adc/da/convert/mq/SendConvertMQService.java @@ -1,217 +1,412 @@ -//package com.adc.da.convert.mq; -// -//import com.adc.da.att.entity.AttFileEO; -//import com.adc.da.att.service.IAttFileEOService; -//import com.adc.da.convert.common.DocConverterPdf; -//import com.adc.da.util.http.ResponseMessage; -//import com.adc.da.util.http.Result; -//import com.adc.da.util.utils.StringUtils; -//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 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 = "createConvertStandMQ_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("文档转换消息确认成功!!!!!!!!!"); -// } -// -// } -// -// public void insertConvertMsg(Map convertInfo) throws Exception{ -// String attId = ""; -// String filePath = ""; -// String otId = ""; -// String addUpFlag = ""; -// String convertType = ""; -// String standFileClassify = ""; -// String lawsFileClassify = ""; -// //资源与文件关联表转换成功的ID -// String standFilePdfId = ""; -// if(convertInfo.get("attId") != null){ -// attId = convertInfo.get("attId").toString(); -// } -// if(convertInfo.get("path") != null){ -// filePath = convertInfo.get("path").toString(); -// } -// if(convertInfo.get("otId") != null){ -// otId = convertInfo.get("otId").toString(); -// } -// if(convertInfo.get("addUpFlag") != null){ -// addUpFlag = convertInfo.get("addUpFlag").toString(); -// } -// if(convertInfo.get("convertType") != null){ -// convertType = convertInfo.get("convertType").toString(); -// } -// if(convertInfo.get("standFilePdfId") != null){ -// standFilePdfId = convertInfo.get("standFilePdfId").toString(); -// } -// if(convertInfo.get("standFileClassify") != null){ -// standFileClassify = convertInfo.get("standFileClassify").toString(); -// } -// if(convertInfo.get("lawsFileClassify") != null){ -// lawsFileClassify = convertInfo.get("lawsFileClassify").toString(); -// } -// -// //更改完转换表信息后开始转换 -// OtConvertMqEO convertMqEO = new OtConvertMqEO(); -// if("0".equals(addUpFlag)){ -// convertMqEO.setLawsId(convertInfo.get("lawsId").toString()); -//// convertMqEO.setResId(convertInfo.get("resId").toString()); -// } -// convertMqEO.setConvertType(convertType); -// convertMqEO.setAttId(attId); -// convertMqEO.setOriAttId(attId); -// convertMqEO.setId(otId); -// convertMqEO.setFilePath(filePath); -// convertMqEO.setAddOrUp(addUpFlag); -// convertMqEO.setPdfId(standFilePdfId); -// convertMqEO.setStandFileClassify(standFileClassify); -// convertMqEO.setLawsFileClassify(lawsFileClassify); -// int i = Integer.valueOf(convertInfo.get("againNum").toString()); -// convertMqEO.setAgainNum(i); -// docUploadConvert(convertMqEO); -// } -// -// /** -// * @Author yangxuenan -// * @Description 文件转换 -// * Date 2018/8/21 15:51 -// * @Param [path] -// * @return com.adc.da.util.http.ResponseMessage -// **/ -// public ResponseMessage docUploadConvert(OtConvertMqEO convertMqEO) throws Exception{ -// //保存在数据库中的ID -// String path = localFilePath + convertMqEO.getFilePath(); -// String convertId = convertMqEO.getId(); -// try { -// //进入转换方法中,修改OT_CONVERT表中状态为转换中 -// convertMqEO.setId(convertId); -// convertMqEO.setModifyTime(new Date()); -// convertMqEO.setMqState(3); -// convertMqEOService.updateByPrimaryKeySelective(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(); -// logger.info("*****转换后的pdf文件路径*******"+dPath); -// //判断是否转换成功,修改数据状态 -// if(!dPath.isEmpty() && getPdf.length()>0){ -// // 上传转换后文件 -// String pdfId = attFileEOService.saveFileAttId(getPdf); -// 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.updateByPrimaryKeySelective(convertMqEO); -// } else { -// // 转换失败 -// convertMqEO.setModifyTime(new Date()); -// convertMqEO.setMqState(2); -// convertMqEOService.updateByPrimaryKeySelective(convertMqEO); -// } -// } else { -// // 转换失败 -// convertMqEO.setId(convertId); -// convertMqEO.setModifyTime(new Date()); -// convertMqEO.setMqState(2); -// convertMqEOService.updateByPrimaryKeySelective(convertMqEO); -// if(convertMqEO.getAgainNum()<=5){ -// throw new Exception("转换失败"); -// } -// } -// return Result.success(dPath); -// } else { -// logger.error("转换时未获取到文件路径!"); -// return Result.error("文件存储失败,请重试"); -// } -// } catch (Exception e) { -// // 转换失败 -// logger.error("转换过程中失败!"); -// logger.error(e.getMessage(),e); -// convertMqEO.setId(convertId); -// convertMqEO.setMqState(2); -// convertMqEOService.updateByPrimaryKeySelective(convertMqEO); -// this.restartUploadConvert(convertMqEO); -// return Result.error("r0072", "文件转换失败,请重试"); -// } -// } -// -// /** -// * 文档转换逻辑 -// * @param attFileEO -// */ -// public void insertOrUpdateStandInfo(AttFileEO attFileEO){ -// -// } -// -// -//} +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.ConvertMqEO; +import com.adc.da.common.SarTypeEnum; +import com.adc.da.common.UseModuleEnum; +import com.adc.da.convert.common.DocConverterPdf; +import com.adc.da.convert.otConvertMq.entity.OtConvertMq; +import com.adc.da.convert.otConvertMq.service.IOtConvertMqService; +import com.adc.da.mq.service.CreateMQService; +import com.adc.da.slrs.sarBussStandFile.dao.SarBussStandFileDao; +import com.adc.da.slrs.sarBussStandFile.entity.SarBussStandFile; +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 SendConvertMQService { + + // 文档转换远程服务IP地址 + @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; + + private static final Logger logger = LoggerFactory.getLogger(SendConvertMQService.class); + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(value = "createConvertStandMQ_SQ_GSAR", durable = "true"), + exchange = @Exchange(value = "convert-exchange_SQ_GSAR", ignoreDeclarationExceptions = "true"), + key = "convert-key_SQ_GSAR")) + public void createMQ(Map 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); + logger.debug("文档转换消息确认成功!!!!!!!!!"); + } + + } + + public void insertConvertMsg(Map convertInfo) throws Exception{ + String attId = ""; + String filePath = ""; + String otId = ""; + String addUpFlag = ""; + String convertType = ""; + String standFileClassify = ""; + String lawsFileClassify = ""; + //资源与文件关联表转换成功的ID + String standFilePdfId = ""; + if(convertInfo.get("attId") != null){ + attId = convertInfo.get("attId").toString(); + } + if(convertInfo.get("path") != null){ + filePath = convertInfo.get("path").toString(); + } + if(convertInfo.get("otId") != null){ + otId = convertInfo.get("otId").toString(); + } + if(convertInfo.get("addUpFlag") != null){ + addUpFlag = convertInfo.get("addUpFlag").toString(); + } + if(convertInfo.get("convertType") != null){ + convertType = convertInfo.get("convertType").toString(); + } + if(convertInfo.get("standFilePdfId") != null){ + standFilePdfId = convertInfo.get("standFilePdfId").toString(); + } + if(convertInfo.get("standFileClassify") != null){ + standFileClassify = convertInfo.get("standFileClassify").toString(); + } + if(convertInfo.get("lawsFileClassify") != null){ + lawsFileClassify = convertInfo.get("lawsFileClassify").toString(); + } + + //更改完转换表信息后开始转换 + OtConvertMq convertMqEO = new OtConvertMq(); + if("0".equals(addUpFlag)){ + convertMqEO.setLawsId(convertInfo.get("lawsId").toString()); +// convertMqEO.setResId(convertInfo.get("resId").toString()); + } + convertMqEO.setConvertType(convertType); + convertMqEO.setAttId(attId); + convertMqEO.setOriAttId(attId); + convertMqEO.setId(otId); + convertMqEO.setFilePath(filePath); + convertMqEO.setAddOrUp(addUpFlag); + convertMqEO.setPdfId(standFilePdfId); + convertMqEO.setStandFileClassify(standFileClassify); + convertMqEO.setLawsFileClassify(lawsFileClassify); + int i = Integer.valueOf(convertInfo.get("againNum").toString()); + convertMqEO.setAgainNum(i); + docUploadConvert(convertMqEO); + } + + /** + * @Author yangxuenan + * @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(); + 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(); + logger.info("*****转换后的pdf文件路径*******"+dPath); + //判断是否转换成功,修改数据状态 + if(!dPath.isEmpty() && getPdf.length()>0){ + // 上传转换后文件 + String pdfId = attFileEOService.saveFileAttId(getPdf); + 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(dPath); + } 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{ + ConvertMqEO convertMqEO = new ConvertMqEO(); + 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.updateById(lawsFile); + } else if (SarTypeEnum.LAWS.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 = sarLawsFileEODao.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.updateById(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.insert(lawsFile); + } else if (SarTypeEnum.LAWS.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 = sarLawsFileEODao.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.insert(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){ + + } + + +} diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/controller/OtConvertController.java b/adc-da-convert/src/main/java/com/adc/da/convert/otConvert/controller/OtConvertController.java similarity index 93% rename from adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/controller/OtConvertController.java rename to adc-da-convert/src/main/java/com/adc/da/convert/otConvert/controller/OtConvertController.java index de2c8e8a..054a1c48 100644 --- a/adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/controller/OtConvertController.java +++ b/adc-da-convert/src/main/java/com/adc/da/convert/otConvert/controller/OtConvertController.java @@ -1,4 +1,4 @@ -package com.adc.da.convert.OtConvert.controller; +package com.adc.da.convert.otConvert.controller; import com.adc.da.att.entity.AttFileEO; @@ -9,7 +9,7 @@ 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 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; diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/dao/OtConvertDao.java b/adc-da-convert/src/main/java/com/adc/da/convert/otConvert/dao/OtConvertDao.java similarity index 71% rename from adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/dao/OtConvertDao.java rename to adc-da-convert/src/main/java/com/adc/da/convert/otConvert/dao/OtConvertDao.java index 736f8ebd..dde7e784 100644 --- a/adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/dao/OtConvertDao.java +++ b/adc-da-convert/src/main/java/com/adc/da/convert/otConvert/dao/OtConvertDao.java @@ -1,6 +1,6 @@ -package com.adc.da.convert.OtConvert.dao; +package com.adc.da.convert.otConvert.dao; -import com.adc.da.convert.OtConvert.entity.OtConvert; +import com.adc.da.convert.otConvert.entity.OtConvert; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/entity/OtConvert.java b/adc-da-convert/src/main/java/com/adc/da/convert/otConvert/entity/OtConvert.java similarity index 96% rename from adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/entity/OtConvert.java rename to adc-da-convert/src/main/java/com/adc/da/convert/otConvert/entity/OtConvert.java index a6f90a3c..2d4e6567 100644 --- a/adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/entity/OtConvert.java +++ b/adc-da-convert/src/main/java/com/adc/da/convert/otConvert/entity/OtConvert.java @@ -1,8 +1,8 @@ -package com.adc.da.convert.OtConvert.entity; +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; diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/service/IOtConvertService.java b/adc-da-convert/src/main/java/com/adc/da/convert/otConvert/service/IOtConvertService.java similarity index 70% rename from adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/service/IOtConvertService.java rename to adc-da-convert/src/main/java/com/adc/da/convert/otConvert/service/IOtConvertService.java index 5533a728..d276ba98 100644 --- a/adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/service/IOtConvertService.java +++ b/adc-da-convert/src/main/java/com/adc/da/convert/otConvert/service/IOtConvertService.java @@ -1,6 +1,6 @@ -package com.adc.da.convert.OtConvert.service; +package com.adc.da.convert.otConvert.service; -import com.adc.da.convert.OtConvert.entity.OtConvert; +import com.adc.da.convert.otConvert.entity.OtConvert; import com.baomidou.mybatisplus.extension.service.IService; /** diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/service/impl/OtConvertServiceImpl.java b/adc-da-convert/src/main/java/com/adc/da/convert/otConvert/service/impl/OtConvertServiceImpl.java similarity index 61% rename from adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/service/impl/OtConvertServiceImpl.java rename to adc-da-convert/src/main/java/com/adc/da/convert/otConvert/service/impl/OtConvertServiceImpl.java index f873f1a6..a234a431 100644 --- a/adc-da-convert/src/main/java/com/adc/da/convert/OtConvert/service/impl/OtConvertServiceImpl.java +++ b/adc-da-convert/src/main/java/com/adc/da/convert/otConvert/service/impl/OtConvertServiceImpl.java @@ -1,8 +1,8 @@ -package com.adc.da.convert.OtConvert.service.impl; +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.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; diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/controller/OtConvertMqController.java b/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/controller/OtConvertMqController.java new file mode 100644 index 00000000..4d6a5473 --- /dev/null +++ b/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/controller/OtConvertMqController.java @@ -0,0 +1,23 @@ +package com.adc.da.convert.otConvertMq.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; +import com.adc.da.convert.otConvertMq.entity.OtConvertMq; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RestController; +import com.adc.da.base.web.BaseController; + +/** +*

+ * 文档转换记录信息表 前端控制器 + *

+* +* @author super_liu +* @since 2021-08-20 +*/ +@RestController +@Api(description = "|OtConvertMq|") +@RequestMapping("/otConvertMq/ot-convert-mq") +public class OtConvertMqController extends BaseController { + +} diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/dao/OtConvertMqDao.java b/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/dao/OtConvertMqDao.java new file mode 100644 index 00000000..51d2338c --- /dev/null +++ b/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/dao/OtConvertMqDao.java @@ -0,0 +1,16 @@ +package com.adc.da.convert.otConvertMq.dao; + +import com.adc.da.convert.otConvertMq.entity.OtConvertMq; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 文档转换记录信息表 Mapper 接口 + *

+ * + * @author super_liu + * @since 2021-08-20 + */ +public interface OtConvertMqDao extends BaseMapper { + +} diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/entity/OtConvertMq.java b/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/entity/OtConvertMq.java new file mode 100644 index 00000000..98d3b953 --- /dev/null +++ b/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/entity/OtConvertMq.java @@ -0,0 +1,99 @@ +package com.adc.da.convert.otConvertMq.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; + +/** + *

+ * 文档转换记录信息表 + *

+ * + * @author super_liu + * @since 2021-08-20 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@ApiModel(value="OtConvertMq对象", description="文档转换记录信息表") +public class OtConvertMq extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId("ID") + private String id; + + @ApiModelProperty(value = "消息队列编码") + @TableField("MQ_CODE") + private String mqCode; + + @ApiModelProperty(value = "队列状态") + @TableField("MQ_STATE") + private Integer mqState; + + @TableField("USER_ID") + private String userId; + + @ApiModelProperty(value = "文件路径") + @TableField("FILE_PATH") + private String filePath; + + @ApiModelProperty(value = "文件ID") + @TableField("ATT_ID") + private String attId; + + @ApiModelProperty(value = "是否有效") + @TableField("VALID_FLAG") + private Integer validFlag; + + @ApiModelProperty(value = "创建时间") + @TableField("CREATION_TIME") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + private Date creationTime; + + @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; + + @TableField(exist = false) + private String fileOriginPath; + + //向文件表添加信息 + @TableField(exist = false) + private String lawsId; + @TableField(exist = false) + private String resId; + @TableField(exist = false) + private String convertType; + @TableField(exist = false) + private String pdfPath; + @TableField(exist = false) + private String pdfId; + @TableField(exist = false) + private String addOrUp; + @TableField(exist = false) + private String oldFileName; + @TableField(exist = false) + private String standFileClassify; + @TableField(exist = false) + private String lawsFileClassify; + @TableField(exist = false) + private String oriAttId; + @TableField(exist = false) + private int againNum; + +} diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/service/IOtConvertMqService.java b/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/service/IOtConvertMqService.java new file mode 100644 index 00000000..52c0d7c9 --- /dev/null +++ b/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/service/IOtConvertMqService.java @@ -0,0 +1,16 @@ +package com.adc.da.convert.otConvertMq.service; + +import com.adc.da.convert.otConvertMq.entity.OtConvertMq; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 文档转换记录信息表 服务类 + *

+ * + * @author super_liu + * @since 2021-08-20 + */ +public interface IOtConvertMqService extends IService { + +} diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/service/impl/OtConvertMqServiceImpl.java b/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/service/impl/OtConvertMqServiceImpl.java new file mode 100644 index 00000000..41d28dcb --- /dev/null +++ b/adc-da-convert/src/main/java/com/adc/da/convert/otConvertMq/service/impl/OtConvertMqServiceImpl.java @@ -0,0 +1,20 @@ +package com.adc.da.convert.otConvertMq.service.impl; + +import com.adc.da.convert.otConvertMq.dao.OtConvertMqDao; +import com.adc.da.convert.otConvertMq.entity.OtConvertMq; +import com.adc.da.convert.otConvertMq.service.IOtConvertMqService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 文档转换记录信息表 服务实现类 + *

+ * + * @author super_liu + * @since 2021-08-20 + */ +@Service +public class OtConvertMqServiceImpl extends ServiceImpl implements IOtConvertMqService { + +} diff --git a/adc-da-convert/src/main/resources/mybatis/mapper/OtConvert/OtConvertMapper.xml b/adc-da-convert/src/main/resources/mybatis/mapper/OtConvert/OtConvertMapper.xml index b7f1df3f..c97fd46e 100644 --- a/adc-da-convert/src/main/resources/mybatis/mapper/OtConvert/OtConvertMapper.xml +++ b/adc-da-convert/src/main/resources/mybatis/mapper/OtConvert/OtConvertMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/adc-da-convert/src/main/resources/mybatis/mapper/otConvertMq/OtConvertMqMapper.xml b/adc-da-convert/src/main/resources/mybatis/mapper/otConvertMq/OtConvertMqMapper.xml new file mode 100644 index 00000000..480951b6 --- /dev/null +++ b/adc-da-convert/src/main/resources/mybatis/mapper/otConvertMq/OtConvertMqMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/adc-da-slrs/src/main/java/com/adc/da/mq/service/SendBussMQService.java b/adc-da-slrs/src/main/java/com/adc/da/mq/service/SendBussMQService.java index 0779b64e..36afcafe 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/mq/service/SendBussMQService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/mq/service/SendBussMQService.java @@ -1,408 +1,291 @@ -//package com.adc.da.mq.service; -// -//import com.adc.da.lawss.entity.OtSvppsEO; -//import com.adc.da.lawss.entity.SarBussionessStandEO; -//import com.adc.da.lawss.entity.SarFullNumEO; -//import com.adc.da.lawss.page.SarFullNumEOPage; -//import com.adc.da.lawss.service.OtSvppsEOService; -//import com.adc.da.lawss.service.SarFullNumEOService; -//import com.adc.da.lawss.service.SarStandAndLawsEOService; -//import com.adc.da.lawss.service.SysInfoEOService; -//import com.adc.da.search.entity.StandLawsEO; -//import com.adc.da.slrs.otSvpps.service.IOtSvppsService; -//import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand; -//import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService; -//import com.adc.da.slrs.sysInfo.service.SysInfoEOService; -//import com.adc.da.sys.dao.DicTypeEODao; -//import com.adc.da.utils.util.InitStandAttrUtil; -//import com.rabbitmq.client.Channel; -//import net.sf.json.JSONObject; -//import org.apache.commons.lang.StringUtils; -//import org.json.JSONTokener; -//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.messaging.Message; -//import org.springframework.stereotype.Component; -// -//import java.text.ParseException; -//import java.text.SimpleDateFormat; -//import java.util.*; -//import java.util.stream.Collectors; -// -//@Component -//public class SendBussMQService { -// -// @Autowired -// private ISarStandardsInfoService sarStandardsInfoService; -// -// @Autowired -// private SysInfoEOService sysInfoEOService; -// -// @Autowired -// private DicTypeEODao dicTypeEODao; -// -// @Autowired -// private IOtSvppsService otSvppsEOService; -// -// private static final Logger logger = LoggerFactory.getLogger(SendBussMQService.class); -// -// -// @RabbitListener(bindings = @QueueBinding( -// value = @Queue(value = "createBussMQ_SQ_GSAR", durable = "true"), -// exchange = @Exchange(value = "buss-exchange_SQ_GSAR", ignoreDeclarationExceptions = "true"), -// key = "buss-key_SQ_GSAR")) -// public void createMQ(Map bussMap, Message message, Channel channel) throws Exception{ -// try{ -// try{ -// Thread.sleep(5000); -// insertOrUpdateBussInfo(bussMap); -// }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("消息确认成功!!!!!!!!!"); -// } -// } -// -// public void insertOrUpdateBussInfo(Map bussMap) throws Exception { -// String addOrUpdate = bussMap.get("addOrUpdate").toString(); -// String FZRQFSRQ = null; -// if ("updateFromAct".equals(addOrUpdate)){ -// addOrUpdate = "update"; -// FZRQFSRQ = "1"; -// } -// String sarBuss = bussMap.get("sarBuss").toString(); -// JSONObject jsonobject = JSONObject.fromObject(sarBuss); -// SarBussionessStand infoEO = (SarBussionessStand) JSONObject.toBean(jsonobject, SarBussionessStand.class); -// String jsonobject1 = infoEO.getSarStandAttrEOStr(); -// Map map1 = new HashMap<>(); -// if (StringUtils.isEmpty(jsonobject1)){ -// map1.put("null","null"); -// }else { -// map1 = JSONObject.fromObject(jsonobject1); -// } -// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); -// //修改索引信息表 -// // 往索引表中插入数据 -// String baseSearchContent = ""; -// String getCodeName = ""; -// Map saveMap = new HashMap<>(); -// String a = null; -// try{ -// a = sdf.format(infoEO.getIssueTime()); -// saveMap.put("issue_time"," "+a); -// }catch (Exception e){ -// saveMap.put("issue_time"," "); -// } -// -// -// -// //发布日期 高级查询 -// Date issue_time_data = null; -// if (StringUtils.isNotBlank(a)) { -// try { -// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); -// issue_time_data = format.parse(saveMap.get("issue_time")+" 00:00:00"); -// } catch (ParseException ignored) { -// } -// } -// if (issue_time_data != null) { -// Calendar calendar = Calendar.getInstance(); -// calendar.setTime(issue_time_data); -// int month = calendar.get(Calendar.MONTH)+1; -// String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH)); -// saveMap.put("issue_time_data",Long.valueOf(times)); -// }else{ -// saveMap.put("issue_time_data",-1000000000000000000L); -// } -// -// try{ -// saveMap.put("put_time"," "+ sdf.format(infoEO.getPutTime())); -// }catch (Exception e){ -// saveMap.put("put_time"," "); -// } -// -// //实施日期 高级查询 -// Date put_time_data = null; -// if (StringUtils.isNotBlank(a)) { -// try { -// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); -// put_time_data = format.parse(saveMap.get("put_time")+" 00:00:00"); -// } catch (ParseException ignored) { -// } -// } -// if (put_time_data != null) { -// Calendar calendar = Calendar.getInstance(); -// calendar.setTime(put_time_data); -// int month = calendar.get(Calendar.MONTH)+1; -// String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH)); -// saveMap.put("put_time_data",Long.valueOf(times)); -// }else{ -// saveMap.put("put_time_data",-1000000000000000000L); -// } -//// saveMap.put("put_time",sdf.format(infoEO.getPutTime())); -// -// saveMap.put("id",infoEO.getId()); -// saveMap.put("standSort",infoEO.getStandSort()); -// saveMap.put("stand_sort",infoEO.getStandSort()); -// if(StringUtils.isNotEmpty(infoEO.getStandSort())){ -// String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandSort()); -// saveMap.put("standSortShow",codeName); -// getCodeName = codeName; -// } -// String realContent = ""; -// if (map1.containsKey("QBWB")) { -// String content = String.valueOf(map1.get("QBWB")); -// String[] ids = content.split(","); -// for (String id :ids) { -// if (!"null".equals(id) && StringUtils.isNotBlank(id)) { -// if ("".equals(realContent)) { -// realContent += id; -// } else { -// realContent = realContent + "," + id; -// } -// } -// } -// } -// if (map1.containsKey("GCWB")) { -// String content = String.valueOf(map1.get("GCWB")); -// String[] ids = content.split(","); -// for (String id :ids) { -// if (!"null".equals(id) && StringUtils.isNotBlank(id)) { -// if ("".equals(realContent)) { -// realContent += id; -// } else { -// realContent = realContent + "," + id; -// } -// } -// } -// } -// saveMap.put("content",realContent); -// saveMap.put("standYear",infoEO.getStandYear()); -// saveMap.put("stand_year",infoEO.getStandYear()); -// saveMap.put("standNumber",infoEO.getStandCode()); -// saveMap.put("stand_code",infoEO.getStandCode()); -// saveMap = dealNumberMsg(saveMap,infoEO,getCodeName); -// saveMap.put("nameshow",infoEO.getStandName()); -// saveMap.put("stand_name",infoEO.getStandName()); -// saveMap.put("standEnName",infoEO.getStandEnName()); -// saveMap.put("stand_en_name",infoEO.getStandEnName()); -// saveMap.put("replaceStandNum",infoEO.getReplaceStandNum()); -// saveMap.put("replace_stand_num",infoEO.getReplaceStandNum()); -// saveMap.put("replacedStandNum",infoEO.getReplacedStandNum()); -// saveMap.put("replaced_stand_num",infoEO.getReplacedStandNum()); -// saveMap.put("statecode",infoEO.getStandStatus()); -// saveMap.put("stand_status",infoEO.getStandStatus()); -// if (StringUtils.isNotEmpty(infoEO.getStandStatus())) { -// String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandStatus()); -// saveMap.put("standstateshow",codeName); -// } -// //新加字段 -// saveMap.put("country",infoEO.getApplyCountry()); -// if(StringUtils.isNotEmpty(infoEO.getApplyCountry())){ -// String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getApplyCountry()); -// saveMap.put("countryShow",codeName); -// } -// // 自定义属性字段 -// String sarStandAttrEOStr = infoEO.getSarStandAttrEOStr(); -// Map attrInfoMap = new HashMap<>(); -// if (StringUtils.isEmpty(sarStandAttrEOStr)){ -// attrInfoMap.put("null","null"); -// }else { -// attrInfoMap = JSONObject.fromObject(sarStandAttrEOStr); -// } -// if (attrInfoMap != null && !attrInfoMap.isEmpty()) { -// attrInfoMap = sysInfoEOService.changeSelectInfo(attrInfoMap, "bussstand",baseSearchContent); -// saveMap.putAll(attrInfoMap); -// } -// String FSRQ = null; -// if (attrInfoMap != null) { -// if (attrInfoMap.containsKey("FSRQ")){ -// if ("1".equals(FZRQFSRQ)){ -// Long times = Long.valueOf(String.valueOf(attrInfoMap.get("FSRQ")).trim()); -// Date fsrq1 = new Date(times); -// attrInfoMap.put("FSRQ",sdf.format(fsrq1)); -// } -// try{ -// if (String.valueOf(attrInfoMap.get("FSRQ")).trim().length()>10) { -// FSRQ = String.valueOf(attrInfoMap.get("FSRQ")).trim().substring(0, 10) + " 00:00:00"; -// }else{ -// FSRQ = String.valueOf(attrInfoMap.get("FSRQ")).trim() + " 00:00:00"; -// } -// -// saveMap.put("FSRQString"," "+FSRQ.substring(0, 10)); -// saveMap.put("FSRQDate"," "+FSRQ.substring(0, 10).replace("-","")); -// FSRQ = String.valueOf(FSRQ.substring(0, 10).replace("-","")); -// saveMap.put("FSRQ"," "+FSRQ); -// }catch (Exception e){ -// saveMap.put("FSRQString"," "); -// saveMap.put("FSRQDate"," "+" "); -// } -// }else{ -// saveMap.put("FSRQString"," "); -// saveMap.put("FSRQDate"," "+" "); -// } -// } -// -// String FZRQ = null; -// if (attrInfoMap != null && attrInfoMap.containsKey("FZRQ")) { -// if ("1".equals(FZRQFSRQ)){ -// Long times = Long.valueOf(String.valueOf(attrInfoMap.get("FZRQ")).trim()); -// Date fzrq1 = new Date(times); -// String timeFzrq = sdf.format(fzrq1); -// if (timeFzrq.trim().length()>10){ -// timeFzrq = timeFzrq.trim().substring(0,10); -// } -// attrInfoMap.put("FZRQ",timeFzrq); -// } -// -// try{ -// if (String.valueOf(attrInfoMap.get("FZRQ")).trim().length()>10) { -// FZRQ = String.valueOf(attrInfoMap.get("FZRQ")).trim().substring(0, 10) + " 00:00:00"; -// }else{ -// FZRQ = String.valueOf(attrInfoMap.get("FZRQ")).trim() + " 00:00:00"; -// } -// -// saveMap.put("FZRQString"," "+FZRQ.substring(0,10)); -// saveMap.put("FZRQDate"," "+FZRQ.replace("-","")); -// FZRQ = String.valueOf(sdf.parse(FZRQ).getTime()); -// saveMap.put("FZRQ"," "+FZRQ); -// }catch (Exception e) { -// saveMap.put("FZRQString", " " + FZRQ); -// saveMap.put("FZRQDate"," "+" "); -// } -// } else { -// saveMap.put("FZRQString", " "); -// saveMap.put("FZRQDate"," "+" "); -// } -// -// //废止日期 高级查询 -// Date fzrq_time_data = null; -// if (StringUtils.isNotBlank(a)) { -// try { -// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); -// fzrq_time_data = format.parse(saveMap.get("FZRQString")+" 00:00:00"); -// } catch (ParseException ignored) { -// } -// } -// if (fzrq_time_data != null) { -// Calendar calendar = Calendar.getInstance(); -// calendar.setTime(fzrq_time_data); -// int month = calendar.get(Calendar.MONTH)+1; -// String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH)); -// saveMap.put("FZRQ",Long.valueOf(times)); -// }else{ -// saveMap.put("FZRQ",-1000000000000000000L); -// } -// saveMap.put("type","bussstand"); -// -// String fieldInfo = InitStandAttrUtil.queryField; -// List fieldInfoList = Arrays.asList(fieldInfo .split(",")).stream().map(s -> (s.trim())).collect(Collectors.toList()); -// -// // 动态存储属性字段 -// for (String field : fieldInfoList) { -// saveMap.put(field,attrInfoMap.getOrDefault(field,"")); -// String fieldValue = ""; -// if(infoMap.get(field) != null && StringUtils.isNotBlank(infoMap.get(field).toString())){ -// Object json= new JSONTokener(infoMap.get(field).toString()).nextValue(); -// if(!json.toString().equals("null")){ -// fieldValue = infoMap.get(field).toString(); -// } -// } -// saveMap.put(field+"Name",fieldValue); -// } -// -// //添加次数 -// SarFullNumEOPage sarFullNumEOPage = new SarFullNumEOPage(); -// sarFullNumEOPage.setSarId(infoEO.getId()); -// List sarFullNumEOList = sarFullNumEOService.queryByList(sarFullNumEOPage); -// String num = ""; -// if (null != sarFullNumEOList && !sarFullNumEOList.isEmpty()){ -// num = sarFullNumEOList.get(0).getReadNum(); -// } -// if (StringUtils.isEmpty(num)){ -// saveMap.put("readNum", 0L); -// }else { -// saveMap.put("readNum", Long.valueOf(num)); -// } -// if (saveMap.containsKey("QBMJ") && null != saveMap.get("QBMJ") && !String.valueOf(saveMap.get("QBMJ")).equals("ACF675Z88W")) { -// saveMap.put("baseSearchContent", baseSearchContent); -// saveMap.put("validFlag", "0"); -// saveMap.put("content", infoEO.getFileIds()); -// if ("add".equals(addOrUpdate)) { -// sarStandAndLawsEOService.insertIntoIndexForMap(saveMap); -// } else { -// sarStandAndLawsEOService.updateIntoIndexForMap(saveMap); -// } -// }else{ -// if (saveMap.containsKey("QBMJ") && null != saveMap.get("QBMJ") && String.valueOf(saveMap.get("QBMJ")).equals("ACF675Z88W")){ -// StandLawsEO standLawsEO = new StandLawsEO(); -// standLawsEO.setId(infoEO.getId()); -// standLawsEO.setType("bussstand"); -// sarStandAndLawsEOService.deleteFomrIndex(standLawsEO); -// }else{ -// if ("add".equals(addOrUpdate)) { -// sarStandAndLawsEOService.insertIntoIndexForMap(saveMap); -// } else { -// sarStandAndLawsEOService.updateIntoIndexForMap(saveMap); -// } -// } -// } -// } -// -// public Map dealNumberMsg (Map saveMap,SarBussionessStand infoEO,String getCodeName) { -// /*if(StringUtils.isNotEmpty(infoEO.getStandYear())){ -// String num = getCodeName + " " + infoEO.getStandCode() + "-" + infoEO.getStandYear(); -// saveMap.put("numbershow",num); -// int index = infoEO.getStandCode().indexOf("."); -// int index1 = infoEO.getStandCode().indexOf(":"); -// String numberExpNull = ""; -// if(index > -1){ -// numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","") -// + "-" + getCodeName + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index); -// }else if(index1 > -1){ -// numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","") -// + "-" + getCodeName + infoEO.getStandCode().substring(0,index1) + "-" + infoEO.getStandCode().substring(0,index1); -// }else{ -// numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ",""); -// } -// } else { -// String number = getCodeName + " " + infoEO.getStandCode(); -// saveMap.put("numbershow",number); -// String numberExpNull = ""; -// int index = infoEO.getStandCode().indexOf("."); -// if(index > -1){ -// numberExpNull = getCodeName + infoEO.getStandCode() + "-" + number.replaceAll(" ","") -// + "-" + getCodeName + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index); -// }else{ -// numberExpNull = getCodeName + infoEO.getStandCode() + "-" + number.replaceAll(" ",""); -// } -// saveMap.put("numberExpNull",numberExpNull); -// }*/ -// String number = infoEO.getStandCode(); -// saveMap.put("numbershow",number); -// String numberExpNull = ""; -// int index = infoEO.getStandCode().indexOf("."); -// if(index > -1){ -// numberExpNull = infoEO.getStandCode() + "-" + number.replaceAll(" ","") -// + "-" + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index); -// }else{ -// numberExpNull = infoEO.getStandCode() + "-" + number.replaceAll(" ",""); -// } -// saveMap.put("numberExpNull",numberExpNull); -// return saveMap; -// } -// -//} +package com.adc.da.mq.service; + +import com.adc.da.search.entity.StandLawsEO; +import com.adc.da.slrs.otSvpps.service.IOtSvppsService; +import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand; +import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService; +import com.adc.da.slrs.sysInfo.service.SysInfoEOService; +import com.adc.da.sys.dao.DicTypeEODao; +import com.adc.da.utils.util.InitStandAttrUtil; +import com.rabbitmq.client.Channel; +import net.sf.json.JSONObject; +import org.apache.commons.lang.StringUtils; +import org.json.JSONTokener; +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.messaging.Message; +import org.springframework.stereotype.Component; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +@Component +public class SendBussMQService { + + @Autowired + private ISarStandardsInfoService sarStandardsInfoService; + + @Autowired + private SysInfoEOService sysInfoEOService; + + @Autowired + private DicTypeEODao dicTypeEODao; + + @Autowired + private IOtSvppsService otSvppsEOService; + + private static final Logger logger = LoggerFactory.getLogger(SendBussMQService.class); + + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(value = "createBussMQ_SQ_GSAR", durable = "true"), + exchange = @Exchange(value = "buss-exchange_SQ_GSAR", ignoreDeclarationExceptions = "true"), + key = "buss-key_SQ_GSAR")) + public void createMQ(Map bussMap, Message message, Channel channel) throws Exception{ + try{ + try{ + Thread.sleep(5000); + insertOrUpdateBussInfo(bussMap); + }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("消息确认成功!!!!!!!!!"); + } + } + + public void insertOrUpdateBussInfo(Map bussMap) throws Exception { + String addOrUpdate = bussMap.get("addOrUpdate").toString(); + String FZRQFSRQ = null; + if ("updateFromAct".equals(addOrUpdate)){ + addOrUpdate = "update"; + FZRQFSRQ = "1"; + } + String sarBuss = bussMap.get("sarBuss").toString(); + JSONObject jsonobject = JSONObject.fromObject(sarBuss); + SarBussionessStand infoEO = (SarBussionessStand) JSONObject.toBean(jsonobject, SarBussionessStand.class); + String jsonobject1 = infoEO.getSarStandAttrEOStr(); + Map map1 = new HashMap<>(); + if (StringUtils.isEmpty(jsonobject1)){ + map1.put("null","null"); + }else { + map1 = JSONObject.fromObject(jsonobject1); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + //修改索引信息表 + // 往索引表中插入数据 + String baseSearchContent = ""; + String getCodeName = ""; + Map saveMap = new HashMap<>(); + String a = null; + try{ + a = sdf.format(infoEO.getIssueTime()); + saveMap.put("issue_time"," "+a); + }catch (Exception e){ + saveMap.put("issue_time"," "); + } + + + + //发布日期 高级查询 + Date issue_time_data = null; + if (StringUtils.isNotBlank(a)) { + try { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + issue_time_data = format.parse(saveMap.get("issue_time")+" 00:00:00"); + } catch (ParseException ignored) { + } + } + if (issue_time_data != null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(issue_time_data); + int month = calendar.get(Calendar.MONTH)+1; + String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH)); + saveMap.put("issue_time_data",Long.valueOf(times)); + }else{ + saveMap.put("issue_time_data",-1000000000000000000L); + } + + try{ + saveMap.put("put_time"," "+ sdf.format(infoEO.getPutTime())); + }catch (Exception e){ + saveMap.put("put_time"," "); + } + + //实施日期 高级查询 + Date put_time_data = null; + if (StringUtils.isNotBlank(a)) { + try { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + put_time_data = format.parse(saveMap.get("put_time")+" 00:00:00"); + } catch (ParseException ignored) { + } + } + if (put_time_data != null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(put_time_data); + int month = calendar.get(Calendar.MONTH)+1; + String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH)); + saveMap.put("put_time_data",Long.valueOf(times)); + }else{ + saveMap.put("put_time_data",-1000000000000000000L); + } +// saveMap.put("put_time",sdf.format(infoEO.getPutTime())); + + saveMap.put("id",infoEO.getId()); + saveMap.put("standSort",infoEO.getStandSort()); + saveMap.put("stand_sort",infoEO.getStandSort()); + if(StringUtils.isNotEmpty(infoEO.getStandSort())){ + String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandSort()); + saveMap.put("standSortShow",codeName); + getCodeName = codeName; + } + saveMap.put("standYear",infoEO.getStandYear()); + saveMap.put("stand_year",infoEO.getStandYear()); + saveMap.put("standNumber",infoEO.getStandCode()); + saveMap.put("stand_code",infoEO.getStandCode()); + saveMap = dealNumberMsg(saveMap,infoEO,getCodeName); + saveMap.put("nameshow",infoEO.getStandName()); + saveMap.put("stand_name",infoEO.getStandName()); + saveMap.put("standEnName",infoEO.getStandEnName()); + saveMap.put("stand_en_name",infoEO.getStandEnName()); + saveMap.put("replaceStandNum",infoEO.getReplaceStandNum()); + saveMap.put("replace_stand_num",infoEO.getReplaceStandNum()); + saveMap.put("replacedStandNum",infoEO.getReplacedStandNum()); + saveMap.put("replaced_stand_num",infoEO.getReplacedStandNum()); + saveMap.put("statecode",infoEO.getStandStatus()); + saveMap.put("stand_status",infoEO.getStandStatus()); + if (StringUtils.isNotEmpty(infoEO.getStandStatus())) { + String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandStatus()); + saveMap.put("standstateshow",codeName); + } + //新加字段 + saveMap.put("country",infoEO.getApplyCountry()); + if(StringUtils.isNotEmpty(infoEO.getApplyCountry())){ + String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getApplyCountry()); + saveMap.put("countryShow",codeName); + } + // 自定义属性字段 + String sarStandAttrEOStr = infoEO.getSarStandAttrEOStr(); + Map attrInfoMap = JSONObject.fromObject(sarStandAttrEOStr); + Map infoMap = infoEO.getAttrInfoMap(); + + if (attrInfoMap != null && !attrInfoMap.isEmpty()) { + attrInfoMap = sysInfoEOService.changeSelectInfo(attrInfoMap, "stand",baseSearchContent); + saveMap.putAll(attrInfoMap); + } + + saveMap.put("type","bussstand"); + saveMap.put("validFlag","0"); + saveMap.put("content",infoEO.getFileIds()); + + String fieldInfo = InitStandAttrUtil.queryField; + List fieldInfoList = Arrays.asList(fieldInfo .split(",")).stream().map(s -> (s.trim())).collect(Collectors.toList()); + + // 动态存储属性字段 + for (String field : fieldInfoList) { + saveMap.put(field,attrInfoMap.getOrDefault(field,"")); + String fieldValue = ""; + if(infoMap.get(field) != null && StringUtils.isNotBlank(infoMap.get(field).toString())){ + Object json= new JSONTokener(infoMap.get(field).toString()).nextValue(); + if(!json.toString().equals("null")){ + fieldValue = infoMap.get(field).toString(); + } + } + saveMap.put(field+"Name",fieldValue); + } + + //当建立代替时,产生的没有文件的问题 + if (StringUtils.isBlank(String.valueOf(saveMap.get("content")))) { + String context = filterStringIsNotBlank(String.valueOf(saveMap.get("FBGBUSS")),true) + + filterStringIsNotBlank(String.valueOf(saveMap.get("BZSMBUSS")),true) + + filterStringIsNotBlank(String.valueOf(saveMap.get("LSBBBUSS")),true) + + filterStringIsNotBlank(String.valueOf(saveMap.get("QTWJBUSS")),true) + + filterStringIsNotBlank(String.valueOf(saveMap.get("GLWJBUSS")),true); + context = context.replace(",,", ","); + saveMap.put("content", context); + } + if("add".equals(addOrUpdate)){ + sarStandardsInfoService.insertIntoIndexForMap(saveMap); + } else { + sarStandardsInfoService.updateIntoIndexForMap(saveMap); + } + } + + private String filterStringIsNotBlank(String str,boolean boo){ + String f = ","; + return (str == null || str.equals("") || str.equals("null")) ? "" : (boo ? str+f : str); + } + + private String dateFormatToStr(String dateStr){ + if(dateStr == null || dateStr.equals("")){ + return ""; + } + String dateToStr = ""; + try { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + dateToStr = dateFormat.format(dateFormat.parse(dateStr.trim().substring(0,10))); + }catch (Exception e){ + e.getMessage(); + } + return dateToStr; + } + + public Map dealNumberMsg (Map saveMap,SarBussionessStand infoEO,String getCodeName) { + /*if(StringUtils.isNotEmpty(infoEO.getStandYear())){ + String num = getCodeName + " " + infoEO.getStandCode() + "-" + infoEO.getStandYear(); + saveMap.put("numbershow",num); + int index = infoEO.getStandCode().indexOf("."); + int index1 = infoEO.getStandCode().indexOf(":"); + String numberExpNull = ""; + if(index > -1){ + numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","") + + "-" + getCodeName + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index); + }else if(index1 > -1){ + numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","") + + "-" + getCodeName + infoEO.getStandCode().substring(0,index1) + "-" + infoEO.getStandCode().substring(0,index1); + }else{ + numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ",""); + } + } else { + String number = getCodeName + " " + infoEO.getStandCode(); + saveMap.put("numbershow",number); + String numberExpNull = ""; + int index = infoEO.getStandCode().indexOf("."); + if(index > -1){ + numberExpNull = getCodeName + infoEO.getStandCode() + "-" + number.replaceAll(" ","") + + "-" + getCodeName + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index); + }else{ + numberExpNull = getCodeName + infoEO.getStandCode() + "-" + number.replaceAll(" ",""); + } + saveMap.put("numberExpNull",numberExpNull); + }*/ + String number = infoEO.getStandCode(); + saveMap.put("numbershow",number); + String numberExpNull = ""; + int index = infoEO.getStandCode().indexOf("."); + if(index > -1){ + numberExpNull = infoEO.getStandCode() + "-" + number.replaceAll(" ","") + + "-" + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index); + }else{ + numberExpNull = infoEO.getStandCode() + "-" + number.replaceAll(" ",""); + } + saveMap.put("numberExpNull",numberExpNull); + return saveMap; + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandFile/entity/SarBussStandFile.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandFile/entity/SarBussStandFile.java index 81e1708e..dbe87ab6 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandFile/entity/SarBussStandFile.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandFile/entity/SarBussStandFile.java @@ -67,7 +67,7 @@ public class SarBussStandFile extends BaseEntity { @ApiModelProperty(value = "是否有效") @TableField("VALID_FLAG") - private String validFlag; + private Integer validFlag; @ApiModelProperty(value = "创建时间") @TableField("CREATION_TIME") @@ -86,4 +86,13 @@ public class SarBussStandFile extends BaseEntity { @TableField(exist = false) private List idList = new ArrayList<>(); + @TableField(exist = false) + private String useModule; + @TableField(exist = false) + private String resId; + @TableField(exist = false) + private Integer pageCount; + @TableField(exist = false) + private String fileOldName; + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/controller/SarBussionessStandController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/controller/SarBussionessStandController.java index 14d6e5a5..c6a92e00 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/controller/SarBussionessStandController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/controller/SarBussionessStandController.java @@ -10,10 +10,10 @@ import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage; import com.adc.da.slrs.sarUser.service.ITsUserService; import com.adc.da.sys.entity.DicTypeEO; import com.adc.da.sys.service.IDicTypeEOService; -import com.adc.da.sys.util.LoginUserUtil; import com.adc.da.http.PageInfo; import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; +import com.adc.da.util.LoginUserUtil; import com.adc.da.util.utils.StringUtils; import com.adc.da.utils.util.SarAdvanceSearchUtil; import com.alibaba.fastjson.JSONObject; @@ -168,33 +168,15 @@ public class SarBussionessStandController extends BaseController qw = new QueryWrapper<>(); - qw.eq("ID",page.getMenuId()); - qw.isNull("PARENT_ID"); - List children = iTsResourceService.list(qw); - if(!children.isEmpty() || page.getMenuId().equals("nomenu")){ - List rows = sarBussionessStandEOService.getSarBussionStandPage(page); - return Result.success(getPageInfo(page.getPager(), rows)); - } - List getMenuIdList = tsUserService.getResourceId(new TsResource()); - if (getMenuIdList != null && !getMenuIdList.isEmpty()) { - page.setMenuRoleList(getMenuIdList); - } else { - page.setMenuRoleList(null); - } - List ids = iTsResourceService.getChildMenuList(page.getMenuId()); - if (ids != null && !ids.isEmpty()) { - page.setMenuAllChildrenIdList(ids); - } - } List rows = sarBussionessStandEOService.getSarBussionStandPage(page); return Result.success(getPageInfo(page.getPager(), rows)); // if (StringUtils.isNotBlank(page.getAdvanceSearchVOStr())) { diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/entity/SarBussionessStand.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/entity/SarBussionessStand.java index 908b96b3..77b9cb49 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/entity/SarBussionessStand.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/entity/SarBussionessStand.java @@ -180,6 +180,9 @@ public class SarBussionessStand extends BaseEntity { @TableField(exist = false) private Map attrInfoMap = new LinkedHashMap<>(); //属性表字段与值 + @TableField(exist = false) + private Map attrInfoCaseMap = new LinkedHashMap<>(); //属性表字段与值小写前端带入渲染 + @TableField(exist = false) private String sarStandAttrEOStr; //新增修改时属性表信息 diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java index 7ef1e6ea..9754981c 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java @@ -6,6 +6,7 @@ import com.adc.da.common.ConvertMqEO; import com.adc.da.common.SarTypeEnum; import com.adc.da.common.SelectionTypeEnum; import com.adc.da.common.UseModuleEnum; +import com.adc.da.http.Result; import com.adc.da.mq.dao.OtConvertEODao; import com.adc.da.mq.service.CreateMQService; import com.adc.da.mq.service.CreateStandMQService; @@ -27,6 +28,7 @@ import com.adc.da.slrs.sarBussionessStand.dao.SarBussionessStandDao; import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService; import com.adc.da.slrs.sarResource.entity.TsResource; import com.adc.da.slrs.sarResource.service.ITsResourceService; +import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao; import com.adc.da.slrs.sarStandFile.entity.SarStandFile; import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao; import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage; @@ -42,9 +44,11 @@ import com.adc.da.sys.util.LoginUserUtil; import com.adc.da.util.UUIDUtils; import com.adc.da.utils.util.FieldConvertUtil; import com.adc.da.utils.util.InitStandAttrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; +import org.json.JSONTokener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -89,6 +93,9 @@ public class SarBussionessStandServiceImpl extends ServiceImpl entry : getAttrMap.entrySet()) { String name = entry.getKey(); String value = ""; - if (entry.getValue() != null && InitStandAttrUtil.fileFieldList != null && InitStandAttrUtil.fileFieldList.size() > 0 && InitStandAttrUtil.fileFieldList.contains(name)) { + if (entry.getValue() != null && InitStandAttrUtil.fileFieldListBuss != null && InitStandAttrUtil.fileFieldListBuss.size() > 0 && InitStandAttrUtil.fileFieldListBuss.contains(name)) { value = entry.getValue().toString(); - if (org.apache.commons.lang3.StringUtils.isNotBlank(value)) { + if (StringUtils.isNotBlank(value)) { List fileObj = attFileEOService.getMultiFileInfos(value); entry.setValue(fileObj); } - }else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) { + }else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) { value = entry.getValue().toString(); List valArr = Arrays.asList(value.split(",")); value = dicTypeEODao.getDicNamesByCodes(valArr); @@ -564,6 +571,26 @@ public class SarBussionessStandServiceImpl extends ServiceImpl getSarBussionStandPage(SarBussionessStandEOPage page) throws Exception { + //查询当前登录人角色拥有权限的菜单 + if(page.getMenuId() != null && page.getUserId() != null && StringUtils.isNotBlank(page.getUserId())){ + QueryWrapper qw = new QueryWrapper<>(); + qw.eq("ID",page.getMenuId()); + qw.isNull("PARENT_ID"); + List children = iTsResourceService.list(qw); + if(children.isEmpty() && !page.getMenuId().equals("nomenu")){ + List getMenuIdList = tsUserService.getResourceUserId(page.getUserId()); + if (getMenuIdList != null && !getMenuIdList.isEmpty()) { + page.setMenuRoleList(getMenuIdList); + } else { + page.setMenuRoleList(null); + } + List ids = iTsResourceService.getChildMenuList(page.getMenuId()); + if (ids != null && !ids.isEmpty()) { + page.setMenuAllChildrenIdList(ids); + } + } + } + Integer rowCount = this.baseMapper.getBussionessStandInfoCount(page); page.getPager().setRowCount(rowCount); List sarlist = this.baseMapper.getBussionessStandInfoPage(page); @@ -578,7 +605,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl sarlist) throws Exception { for(SarBussionessStand row : sarlist){ - attrInfo1(row); + attrInfoDetails(row); } } @@ -601,6 +628,85 @@ public class SarBussionessStandServiceImpl extends ServiceImpl getAttrMap = row.getAttrInfoMap(); + if (getAttrMap != null && getAttrMap.size() > 0) { + for (Map.Entry entry : getAttrMap.entrySet()) { + String name = entry.getKey(); + String value = ""; + List valArr = new ArrayList<>(); + if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) { + if(StringUtils.isNotBlank(entry.getValue().toString())){ + Object json= new JSONTokener(entry.getValue().toString()).nextValue(); + if(json instanceof org.json.JSONArray){ + valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class); + }else { + value = entry.getValue().toString(); + valArr = Arrays.asList(value.split(",")); + } + if(!valArr.isEmpty()){ + value = dicTypeEODao.getDicNamesByCodes(valArr); + } + } + entry.setValue(value); + } + } + } + } + } + + public void attrInfoSearchDetails(SarBussionessStand row,String type) throws Exception { + String fieldInfo = InitStandAttrUtil.queryField; + String collectId = personCollectEOService.queryCollectByUserAndId(row.getId()); + row.setCollectId(collectId); + // 查询属性表数据 + if (StringUtils.isNotBlank(fieldInfo)) { + Map getAttrMap = new TreeMap<>(); + if(type.equals("add")){ + String sarStandAttrEOStr = row.getSarStandAttrEOStr(); + getAttrMap = JSONObject.fromObject(sarStandAttrEOStr); + }else { + getAttrMap = sarStandAttrInfoEODao.selectStandFieldAndData(fieldInfo, row.getId()); + } + if (InitStandAttrUtil.clobFieldList != null && !InitStandAttrUtil.clobFieldList.isEmpty()) { + // 遍历修改所有clob类型的值 + for (String clobField : InitStandAttrUtil.clobFieldList) { + Clob clobValue = (Clob) getAttrMap.get(clobField); + String fieldValue = FieldConvertUtil.ClobToString(clobValue); + getAttrMap.put(clobField, fieldValue); + } + } + + if (getAttrMap != null && !getAttrMap.isEmpty()) { + row.setAttrInfoCaseMap(transformUpperCase(getAttrMap)); + } + + row.setAttrInfoMap(getAttrMap); + } + } + + private Map transformUpperCase(Map orgMap) { + Map resultMap = new HashMap<>(); + + for (Map.Entry entry : orgMap.entrySet()) { + String newKey = entry.getKey().toLowerCase(); + resultMap.put(newKey, orgMap.get(entry.getKey())); + if (entry.getValue() != null && InitStandAttrUtil.fileFieldListBuss != null && !InitStandAttrUtil.fileFieldListBuss.isEmpty() && InitStandAttrUtil.fileFieldListBuss.contains(entry.getKey())) { + String value = entry.getValue().toString(); + if (StringUtils.isNotBlank(value)) { + List fileObj = attFileEOService.getMultiFileInfos(value); + if(!fileObj.isEmpty()){ + resultMap.put(newKey + "Name", fileObj.get(0).getOldFileName()); + } + } + } + } + + return resultMap; + } + public void attrInfoDetails (SarBussionessStand row) throws Exception { String fieldInfo = InitStandAttrUtil.queryFieldBuss; String collectId = personCollectEOService.queryCollectByUserAndId(row.getId()); @@ -649,6 +755,10 @@ public class SarBussionessStandServiceImpl extends ServiceImpl { void alterStandAttr(@Param("fieldInfo") String fieldInfo); diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandFile/dao/SarStandFileDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandFile/dao/SarStandFileDao.java index 04e5ea64..87f47cbb 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandFile/dao/SarStandFileDao.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandFile/dao/SarStandFileDao.java @@ -2,6 +2,7 @@ package com.adc.da.slrs.sarStandFile.dao; import com.adc.da.slrs.sarStandFile.entity.SarStandFile; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; import java.util.List; @@ -13,6 +14,7 @@ import java.util.List; * @author super_liu * @since 2021-06-02 */ +@Repository public interface SarStandFileDao extends BaseMapper { List selectFileByStandId(String lawsId); diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandFile/SarBussStandFileMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandFile/SarBussStandFileMapper.xml index f5f571df..370bd60d 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandFile/SarBussStandFileMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandFile/SarBussStandFileMapper.xml @@ -185,9 +185,9 @@ and stand_id = #{standId} - + and id not in - + #{item} diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml index 04eea3a6..1e3996d7 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml @@ -20,6 +20,7 @@ + @@ -35,12 +36,13 @@ + modify_time, creation_time, valid_flag, stand_status, replaced_stand_num,replace_stand_num, - put_time, issue_time,stand_en_name,stand_name, stand_code, id,apply_country, stand_nature, stand_sort + put_time, issue_time,stand_en_name,stand_name, stand_code, id,apply_country, stand_nature, stand_sort,text_status_buss stand_year,dicapplyCountry.DIC_TYPE_NAME as applyCountryShow,dicstandSort.DIC_TYPE_NAME as standSortShow, @@ -48,7 +50,7 @@ SAR_BUSSIONESS_STAND.creation_time, SAR_BUSSIONESS_STAND.valid_flag, SAR_BUSSIONESS_STAND.apply_country, SAR_BUSSIONESS_STAND.stand_nature,SAR_BUSSIONESS_STAND.stand_sort, stand_status, replaced_stand_num,replace_stand_num,put_time,issue_time,stand_en_name, - stand_name, stand_code,SAR_BUSSIONESS_STAND.id,dicstandStatus.DIC_TYPE_NAME as standStatusShow + stand_name, stand_code,SAR_BUSSIONESS_STAND.id,dicstandStatus.DIC_TYPE_NAME as standStatusShow,SAR_BUSSIONESS_STAND.text_status_buss @@ -352,7 +354,7 @@ - left join TS_DICTYPE dicstandStatus ON ( dicstandStatus.dic_type_code = SAR_BUSSIONESS_STAND.STAND_STATUS AND dicstandStatus.dic_id IS NOT NULL and dicstandStatus.valid_flag = 0) + left join TS_DICTYPE dicstandStatus ON ( dicstandStatus.dic_type_code = SAR_BUSSIONESS_STAND.TEXT_STATUS_BUSS AND dicstandStatus.dic_id IS NOT NULL and dicstandStatus.valid_flag = 0) left join TS_DICTYPE dicstandNature ON ( dicstandNature.dic_type_code = SAR_BUSSIONESS_STAND.STAND_NATURE AND dicstandNature.dic_id IS NOT NULL and dicstandNature.valid_flag = 0) left join TS_DICTYPE dicstandSort ON ( dicstandSort.dic_type_code = SAR_BUSSIONESS_STAND.STAND_SORT AND dicstandSort.dic_id IS NOT NULL and dicstandSort.valid_flag = 0) left join TS_DICTYPE dicapplyCountry ON ( dicapplyCountry.dic_type_code = SAR_BUSSIONESS_STAND.APPLY_COUNTRY AND dicapplyCountry.dic_id IS NOT NULL and dicapplyCountry.valid_flag = 0)