add:集成es搜索模块
This commit is contained in:
@@ -11,6 +11,12 @@
|
||||
|
||||
<artifactId>adc-da-slrs</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-search</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-base</artifactId>
|
||||
@@ -35,6 +41,65 @@
|
||||
<version>3.1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-util</artifactId>
|
||||
<version>2.2.41</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk14</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- poi -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>4.1.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>1.8.8</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.5.13</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zip4j</groupId>
|
||||
<artifactId>zip4j</artifactId>
|
||||
<scope>system</scope>
|
||||
<version>1.3.1</version>
|
||||
<systemPath>${basedir}/src/main/lib/zip4j-1.3.1.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,223 @@
|
||||
package com.adc.da.common;
|
||||
|
||||
import com.adc.da.base.entity.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <b>功能:</b>OT_CONVERT_MQ OtConvertMqEOEntity<br>
|
||||
* <b>作者:</b>code generator<br>
|
||||
* <b>日期:</b> 2018-09-25 <br>
|
||||
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
|
||||
*/
|
||||
public class ConvertMqEO extends BaseEntity {
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date modifyTime;
|
||||
@org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date creationTime;
|
||||
private Integer validFlag;
|
||||
private String attId;
|
||||
private String filePath;
|
||||
private String fileOriginPath;
|
||||
private String userId;
|
||||
private Integer mqState;
|
||||
private String mqCode;
|
||||
private String id;
|
||||
private String addOrUp;
|
||||
|
||||
//向文件表添加信息
|
||||
private String lawsId;
|
||||
private String resId;
|
||||
private String convertType;
|
||||
private String pdfPath;
|
||||
private String pdfId;
|
||||
private String fileSuffix;
|
||||
private String standFileClassify;
|
||||
private String oriAttId;
|
||||
private String lawsFileClassify;
|
||||
|
||||
private int againNum;
|
||||
/** **/
|
||||
public Integer getValidFlag() {
|
||||
return this.validFlag;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public void setValidFlag(Integer validFlag) {
|
||||
this.validFlag = validFlag;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public String getAttId() {
|
||||
return this.attId;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public void setAttId(String attId) {
|
||||
this.attId = attId;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public String getFilePath() {
|
||||
return this.filePath;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public String getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public Integer getMqState() {
|
||||
return this.mqState;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public void setMqState(Integer mqState) {
|
||||
this.mqState = mqState;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public String getMqCode() {
|
||||
return this.mqCode;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public void setMqCode(String mqCode) {
|
||||
this.mqCode = mqCode;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/** **/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFileOriginPath() {
|
||||
return fileOriginPath;
|
||||
}
|
||||
|
||||
public void setFileOriginPath(String fileOriginPath) {
|
||||
this.fileOriginPath = fileOriginPath;
|
||||
}
|
||||
|
||||
public String getLawsId() {
|
||||
return lawsId;
|
||||
}
|
||||
|
||||
public void setLawsId(String lawsId) {
|
||||
this.lawsId = lawsId;
|
||||
}
|
||||
|
||||
public String getResId() {
|
||||
return resId;
|
||||
}
|
||||
|
||||
public void setResId(String resId) {
|
||||
this.resId = resId;
|
||||
}
|
||||
|
||||
public String getConvertType() {
|
||||
return convertType;
|
||||
}
|
||||
|
||||
public void setConvertType(String convertType) {
|
||||
this.convertType = convertType;
|
||||
}
|
||||
|
||||
public String getPdfPath() {
|
||||
return pdfPath;
|
||||
}
|
||||
|
||||
public void setPdfPath(String pdfPath) {
|
||||
this.pdfPath = pdfPath;
|
||||
}
|
||||
|
||||
public String getAddOrUp() {
|
||||
return addOrUp;
|
||||
}
|
||||
|
||||
public void setAddOrUp(String addOrUp) {
|
||||
this.addOrUp = addOrUp;
|
||||
}
|
||||
|
||||
public String getPdfId() {
|
||||
return pdfId;
|
||||
}
|
||||
|
||||
public void setPdfId(String pdfId) {
|
||||
this.pdfId = pdfId;
|
||||
}
|
||||
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public Date getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
public void setCreationTime(Date creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
public String getFileSuffix() {
|
||||
return fileSuffix;
|
||||
}
|
||||
|
||||
public void setFileSuffix(String fileSuffix) {
|
||||
this.fileSuffix = fileSuffix;
|
||||
}
|
||||
|
||||
public String getStandFileClassify() {
|
||||
return standFileClassify;
|
||||
}
|
||||
|
||||
public void setStandFileClassify(String standFileClassify) {
|
||||
this.standFileClassify = standFileClassify;
|
||||
}
|
||||
|
||||
public String getOriAttId() {
|
||||
return oriAttId;
|
||||
}
|
||||
|
||||
public void setOriAttId(String oriAttId) {
|
||||
this.oriAttId = oriAttId;
|
||||
}
|
||||
|
||||
public int getAgainNum() {
|
||||
return againNum;
|
||||
}
|
||||
|
||||
public void setAgainNum(int againNum) {
|
||||
this.againNum = againNum;
|
||||
}
|
||||
|
||||
public String getLawsFileClassify() {
|
||||
return lawsFileClassify;
|
||||
}
|
||||
|
||||
public void setLawsFileClassify(String lawsFileClassify) {
|
||||
this.lawsFileClassify = lawsFileClassify;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.adc.da.mq.dao;
|
||||
|
||||
import com.adc.da.common.ConvertMqEO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface OtConvertEODao extends BaseMapper<ConvertMqEO> {
|
||||
|
||||
int deleteByAttId(String value);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.adc.da.mq.service;
|
||||
|
||||
import com.adc.da.common.ConvertMqEO;
|
||||
import com.adc.da.mq.dao.OtConvertEODao;
|
||||
import com.adc.da.util.utils.StringUtils;
|
||||
import com.adc.da.util.utils.UUID;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class CreateMQService {
|
||||
@Autowired
|
||||
private AmqpTemplate rabbitTemplate;
|
||||
|
||||
@Autowired
|
||||
private OtConvertEODao otConvertEODao;
|
||||
/**
|
||||
* @Author yangxuenan
|
||||
* @Description 创建消息队列
|
||||
* Date 2018/8/24 13:59
|
||||
* @Param [convert, convertType]
|
||||
* @return int
|
||||
**/
|
||||
public void sendMQ(ConvertMqEO convert) throws Exception{
|
||||
String otId = UUID.randomUUID(20);
|
||||
//向OT_CONVERT_EO表中添加/修改数据
|
||||
//判断用户是初次发送还是重新发送,初次将添加到数据库,重新发送将修改原数据信息
|
||||
convert.setMqState(0);
|
||||
convert.setModifyTime(new Date());
|
||||
if("0".equals(convert.getAddOrUp()) && StringUtils.isEmpty(convert.getId())){
|
||||
convert.setId(otId);
|
||||
convert.setMqCode(convert.getConvertType());
|
||||
convert.setCreationTime(new Date());
|
||||
convert.setValidFlag(0);
|
||||
otConvertEODao.insert(convert);
|
||||
} else {
|
||||
otConvertEODao.updateById(convert);
|
||||
}
|
||||
|
||||
//将数据信息保存并发送给消息队列
|
||||
Map<String,Object> convertInfo = new HashMap<String,Object>();
|
||||
//标准/政策ID
|
||||
convertInfo.put("lawsId", convert.getLawsId());
|
||||
//标准/政策关联的res表ID
|
||||
convertInfo.put("resId", convert.getResId());
|
||||
//文档的ID
|
||||
convertInfo.put("attId", convert.getAttId());
|
||||
//判断当前操作是新增还是修改
|
||||
convertInfo.put("addUpFlag", convert.getAddOrUp());
|
||||
//资源类型(标准,政策,企标)
|
||||
convertInfo.put("convertType", convert.getConvertType());
|
||||
//文档路径
|
||||
convertInfo.put("path", convert.getFilePath());
|
||||
convertInfo.put("standFileClassify", convert.getStandFileClassify());
|
||||
convertInfo.put("lawsFileClassify", convert.getLawsFileClassify());
|
||||
if("0".equals(convert.getAddOrUp())){
|
||||
//otId在转换表中数据ID
|
||||
convertInfo.put("otId", otId);
|
||||
//在stand_file等资源与文件关联表中转换成功的pdf数据ID
|
||||
convertInfo.put("standFilePdfId", UUID.randomUUID(20));
|
||||
convertInfo.put("againNum",0);
|
||||
} else {
|
||||
convertInfo.put("otId", convert.getId());
|
||||
convertInfo.put("standFilePdfId", convert.getPdfId());
|
||||
convertInfo.put("againNum",convert.getAgainNum());
|
||||
}
|
||||
|
||||
//发送消息队列
|
||||
this.rabbitTemplate.convertAndSend("convert-exchange_SQ_GSAR", "convert-key_SQ_GSAR", convertInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.adc.da.mq.service;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class CreateStandMQService {
|
||||
@Autowired
|
||||
private AmqpTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sarStandardsInfoEO 标准实体
|
||||
* @param addOrUpdate
|
||||
* @throws Exception
|
||||
*/
|
||||
public void sendStandMQ(Object sarStandardsInfoEO, String addOrUpdate) throws Exception{
|
||||
JSONObject json = JSONObject.fromObject(sarStandardsInfoEO);
|
||||
String sarStandardsInfoStr = json.toString();
|
||||
Map<String,Object> standMap = new HashMap<String,Object>();
|
||||
standMap.put("sarStandards", sarStandardsInfoStr);
|
||||
standMap.put("addOrUpdate", addOrUpdate);
|
||||
|
||||
//发送消息队列
|
||||
this.rabbitTemplate.convertAndSend("stand-exchange_SQ_GSAR", "stand-key_SQ_GSAR", standMap);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
package com.adc.da.mq.service;
|
||||
|
||||
import com.adc.da.slrs.otSvpps.entity.OtSvpps;
|
||||
import com.adc.da.slrs.otSvpps.service.IOtSvppsService;
|
||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
|
||||
import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
|
||||
import com.adc.da.slrs.sysInfo.service.SysInfoEOService;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SendStandMQService {
|
||||
|
||||
@Autowired
|
||||
private ISarStandardsInfoService sarStandardsInfoService;
|
||||
|
||||
@Autowired
|
||||
private SysInfoEOService sysInfoEOService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IOtSvppsService otSvppsEOService;
|
||||
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SendStandMQService.class);
|
||||
|
||||
@RabbitListener(bindings = @QueueBinding(
|
||||
value = @Queue(value = "createStandMQ_SQ_GSAR", durable = "true"),
|
||||
exchange = @Exchange(value = "stand-exchange_SQ_GSAR", ignoreDeclarationExceptions = "true"),
|
||||
key = "stand-key_SQ_GSAR"))
|
||||
public void createMQ(Map<String,Object> standMap, Message message, Channel channel) throws Exception{
|
||||
try{
|
||||
try{
|
||||
Thread.sleep(5000);
|
||||
insertOrUpdateStandInfo(standMap);
|
||||
}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 insertOrUpdateStandInfo(Map<String,Object> standMap){
|
||||
String addOrUpdate = standMap.get("addOrUpdate").toString();
|
||||
String sarStandards = standMap.get("sarStandards").toString();
|
||||
JSONObject jsonobject = JSONObject.fromObject(sarStandards);
|
||||
SarStandardsInfo infoEO = (SarStandardsInfo) JSONObject.toBean(jsonobject,SarStandardsInfo.class);
|
||||
String attr = infoEO.getSarStandAttrEOStr();
|
||||
JSONObject jsonobject1 = JSONObject.fromObject(attr);
|
||||
Map<String,Object> map = (Map)jsonobject1;
|
||||
String GZZXX = String.valueOf(map.get("GZZXX"));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// 往索引表中插入数据
|
||||
String getCodeName = "";
|
||||
Map<String,Object> saveMap = new HashMap<>();
|
||||
String baseSearchContent = "";
|
||||
// 开始存放数据
|
||||
saveMap.put("id",infoEO.getId());
|
||||
saveMap.put("BYYBJ", map.getOrDefault("BYYBJ", ""));
|
||||
saveMap.put("BDTBH", map.getOrDefault("BDTBH", ""));
|
||||
saveMap.put("country",infoEO.getCountry());
|
||||
|
||||
if (StringUtils.isNotEmpty(infoEO.getCountry())) {
|
||||
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getCountry());
|
||||
saveMap.put("countryShow",codeName);
|
||||
}
|
||||
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("standNumber",infoEO.getStandNumber());
|
||||
saveMap.put("stand_number",infoEO.getStandNumber());
|
||||
saveMap = dealNumberMsg(saveMap,infoEO,getCodeName);
|
||||
saveMap.put("standYear",infoEO.getStandYear());
|
||||
saveMap.put("stand_year",infoEO.getStandYear());
|
||||
saveMap.put("nameshow",infoEO.getStandName());
|
||||
saveMap.put("stand_name",infoEO.getStandName());
|
||||
saveMap.put("standEnName",infoEO.getStandEnName());
|
||||
saveMap.put("stand_en_name",infoEO.getStandEnName());
|
||||
|
||||
if ("1".equals(infoEO.getIsRelateAccess())) {
|
||||
saveMap.put("isRelateAccess","A" );
|
||||
}else{
|
||||
saveMap.put("isRelateAccess","B" );
|
||||
}
|
||||
if (StringUtils.isNotEmpty(infoEO.getStandState())) {
|
||||
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandState());
|
||||
saveMap.put("standstateshow",codeName);
|
||||
}
|
||||
saveMap.put("issueTime",infoEO.getIssueTime());
|
||||
|
||||
String newDate = infoEO.getIssueTime();
|
||||
if (StringUtils.isNotBlank(infoEO.getIssueTime()) && StringUtils.isNotBlank(infoEO.getIssueTime().trim()) && infoEO.getIssueTime().trim().length()>10) {
|
||||
newDate = infoEO.getIssueTime().trim().substring(0,10);
|
||||
}
|
||||
|
||||
saveMap.put("issue_time",newDate);
|
||||
Date issue_time_data = null;
|
||||
if (StringUtils.isNotBlank(infoEO.getIssueTime())) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
issue_time_data = format.parse(newDate+" 00:00:00");
|
||||
} catch (ParseException ignored) {
|
||||
}
|
||||
}
|
||||
if (issue_time_data != null) {
|
||||
saveMap.put("issue_time_data",issue_time_data.getTime());
|
||||
}else{
|
||||
saveMap.put("issue_time_data",0L);
|
||||
}
|
||||
saveMap.put("synopsis",infoEO.getSynopsis());
|
||||
saveMap.put("standType",infoEO.getStandType());
|
||||
// 自定义属性字段
|
||||
String sarStandAttrEOStr = infoEO.getSarStandAttrEOStr();
|
||||
Map<String,Object> attrInfoMap = JSONObject.fromObject(sarStandAttrEOStr);
|
||||
if (attrInfoMap != null && !attrInfoMap.isEmpty()) {
|
||||
attrInfoMap = sysInfoEOService.changeSelectInfo(attrInfoMap, "stand",baseSearchContent);
|
||||
saveMap.putAll(attrInfoMap);
|
||||
}
|
||||
saveMap.put("baseSearchContent",baseSearchContent);
|
||||
saveMap.put("type","stand");
|
||||
saveMap.put("validFlag","0");
|
||||
saveMap.put("content",infoEO.getFileIds());
|
||||
saveMap.put("CHJL",infoEO.getCHJL());
|
||||
|
||||
String SVPPSSting = "";
|
||||
if (attrInfoMap != null) {
|
||||
if (attrInfoMap.containsKey("SVPPS")){
|
||||
String svpps = String.valueOf(attrInfoMap.get("SVPPS"));
|
||||
List<String> ids = new ArrayList<>(Arrays.asList(svpps.split(",")));
|
||||
for (String id: ids){
|
||||
String num = "";
|
||||
try {
|
||||
OtSvpps otSvppsEO = otSvppsEOService.getById(id);
|
||||
if (null != otSvppsEO) {
|
||||
if ("NA".equals(otSvppsEO.getTNum())) {
|
||||
if ("NA".equals(otSvppsEO.getSNum())) {
|
||||
num = otSvppsEO.getFNum();
|
||||
} else {
|
||||
num = otSvppsEO.getSNum();
|
||||
}
|
||||
} else {
|
||||
num = otSvppsEO.getTNum();
|
||||
}
|
||||
}
|
||||
if ("".equals(SVPPSSting)){
|
||||
SVPPSSting = num;
|
||||
}else {
|
||||
SVPPSSting = SVPPSSting + "," + num;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
saveMap.put("SVPPSName",SVPPSSting);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Date XCXSSRQ_data = null;
|
||||
if (StringUtils.isNotBlank(String.valueOf(saveMap.get("XCXSSRQ")))) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if (String.valueOf(saveMap.get("XCXSSRQ")).trim().length()>10) {
|
||||
XCXSSRQ_data = format.parse(String.valueOf(saveMap.get("XCXSSRQ")).trim().substring(0,10) + " 00:00:00");
|
||||
saveMap.put("XCXSSRQ",String.valueOf(saveMap.get("XCXSSRQ")).trim().substring(0,10));
|
||||
}else{
|
||||
XCXSSRQ_data = format.parse(String.valueOf(saveMap.get("XCXSSRQ")).trim() + " 00:00:00");
|
||||
saveMap.put("XCXSSRQ",String.valueOf(saveMap.get("XCXSSRQ")).trim());
|
||||
}
|
||||
} catch (ParseException ignored) {
|
||||
}
|
||||
}
|
||||
if (XCXSSRQ_data != null) {
|
||||
saveMap.put("XCXSSRQ_data",XCXSSRQ_data.getTime());
|
||||
}else{
|
||||
saveMap.put("XCXSSRQ_data",0L);
|
||||
}
|
||||
saveMap.put("XCXSSRQ",String.valueOf(saveMap.get("XCXSSRQ")+" "));
|
||||
|
||||
Date ZCCSSRQ_data = null;
|
||||
if (StringUtils.isNotBlank(String.valueOf(saveMap.get("ZCCSSRQ")))) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if (String.valueOf(saveMap.get("ZCCSSRQ")).trim().length()>10) {
|
||||
ZCCSSRQ_data = format.parse(String.valueOf(saveMap.get("ZCCSSRQ")).trim().substring(0, 10) + " 00:00:00");
|
||||
saveMap.put("ZCCSSRQ",String.valueOf(saveMap.get("ZCCSSRQ")).trim().substring(0, 10));
|
||||
}else {
|
||||
ZCCSSRQ_data = format.parse(String.valueOf(saveMap.get("ZCCSSRQ")).trim() + " 00:00:00");
|
||||
saveMap.put("ZCCSSRQ",String.valueOf(saveMap.get("ZCCSSRQ")).trim());
|
||||
}
|
||||
} catch (ParseException ignored) {
|
||||
}
|
||||
}
|
||||
if (ZCCSSRQ_data != null) {
|
||||
saveMap.put("ZCCSSRQ_data",ZCCSSRQ_data.getTime());
|
||||
}else{
|
||||
saveMap.put("ZCCSSRQ_data",0L);
|
||||
}
|
||||
saveMap.put("ZCCSSRQ",String.valueOf(saveMap.get("ZCCSSRQ")+" "));
|
||||
|
||||
Date EOPSSRQ_data = null;
|
||||
String ESSRQ= null;
|
||||
if (StringUtils.isNotBlank(String.valueOf(saveMap.get("EOPSSRQ")))) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if (String.valueOf(saveMap.get("EOPSSRQ")).trim().length()>10){
|
||||
ESSRQ = String.valueOf(saveMap.get("EOPSSRQ")).trim().substring(0,10);
|
||||
}else {
|
||||
ESSRQ = String.valueOf(saveMap.get("EOPSSRQ")).trim();
|
||||
}
|
||||
EOPSSRQ_data = format.parse(ESSRQ + " 00:00:00");
|
||||
} catch (ParseException ignored) {
|
||||
}
|
||||
map.put("EOPSSRQ",ESSRQ);
|
||||
}
|
||||
if (EOPSSRQ_data != null) {
|
||||
saveMap.put("EOPSSRQ_data",EOPSSRQ_data.getTime());
|
||||
}else{
|
||||
saveMap.put("EOPSSRQ_data",0L);
|
||||
}
|
||||
saveMap.put("EOPSSRQ",String.valueOf(saveMap.get("EOPSSRQ")+" "));
|
||||
|
||||
if (map.containsKey("DXBZ")){
|
||||
saveMap.put("DXBZ",map.get("DXBZ"));
|
||||
}else{
|
||||
saveMap.put("DXBZ","");
|
||||
}
|
||||
//当建立代替时,产生的没有文件的问题
|
||||
if (StringUtils.isBlank(String.valueOf(saveMap.get("content")))) {
|
||||
String context = String.valueOf(saveMap.get("FBGBJBD")) + ","
|
||||
+ String.valueOf(saveMap.get("XXZLXX")) + ","
|
||||
+ String.valueOf(saveMap.get("ZQYJG")) + ","
|
||||
+ String.valueOf(saveMap.get("BPG")) + ","
|
||||
+ String.valueOf(saveMap.get("CA")) + ","
|
||||
+ String.valueOf(saveMap.get("SSG")) + ","
|
||||
+ String.valueOf(saveMap.get("ZBJBD"));
|
||||
context = context.replace(",,", ",");
|
||||
saveMap.put("content", context);
|
||||
}
|
||||
if (StringUtils.isNotBlank(String.valueOf(saveMap.get("FO"))) && !"null".equals(String.valueOf(saveMap.get("FO")))){
|
||||
saveMap.put("FO",String.valueOf(saveMap.get("FO"))+" ");
|
||||
}
|
||||
if("add".equals(addOrUpdate)){
|
||||
sarStandardsInfoService.insertIntoIndexForMap(saveMap);
|
||||
} else {
|
||||
sarStandardsInfoService.updateIntoIndexForMap(saveMap);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String,Object> dealNumberMsg (Map<String,Object> saveMap,SarStandardsInfo infoEO,String getCodeName) {
|
||||
if(StringUtils.isNotEmpty(infoEO.getStandYear())){
|
||||
String number = getCodeName + " " + infoEO.getStandNumber() + "-" + infoEO.getStandYear();
|
||||
saveMap.put("numbershow",number);
|
||||
int index = infoEO.getStandNumber().indexOf(".");
|
||||
int index1 = infoEO.getStandNumber().indexOf(":");
|
||||
String numberExpNull = "";
|
||||
if(index > -1){
|
||||
numberExpNull = (getCodeName + infoEO.getStandNumber() + "-" + number.replaceAll(" ","")
|
||||
+ "-" + getCodeName + infoEO.getStandNumber().substring(0,index) + "-" + infoEO.getStandNumber().substring(0,index));
|
||||
} else if (index1 > -1) {
|
||||
numberExpNull = getCodeName + infoEO.getStandNumber() + "-" + number.replaceAll(" ","")
|
||||
+ "-" + getCodeName + infoEO.getStandNumber().substring(0,index1) + "-" + infoEO.getStandNumber().substring(0,index1);
|
||||
} else {
|
||||
numberExpNull = getCodeName + infoEO.getStandNumber() + "-" + number.replaceAll(" ","");
|
||||
}
|
||||
saveMap.put("numberExpNull",numberExpNull);
|
||||
} else {
|
||||
String num = getCodeName + " " + infoEO.getStandNumber();
|
||||
saveMap.put("numbershow",num);
|
||||
int index = infoEO.getStandNumber().indexOf(".");
|
||||
String numberExpNull = "";
|
||||
if(index > -1){
|
||||
numberExpNull = getCodeName + infoEO.getStandNumber() + "-" + num.replaceAll(" ","")
|
||||
+ "-" + getCodeName + infoEO.getStandNumber().substring(0,index) + "-" + infoEO.getStandNumber().substring(0,index);
|
||||
} else {
|
||||
numberExpNull = getCodeName + infoEO.getStandNumber() + "-" + num.replaceAll(" ","");
|
||||
}
|
||||
saveMap.put("numberExpNull",numberExpNull);
|
||||
}
|
||||
return saveMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+4
@@ -40,4 +40,8 @@ public interface ISarStandardsInfoService extends IService<SarStandardsInfo> {
|
||||
List<RecommendVO> selectRecommendStand(SarStandardsInfoEOPage pagenew);
|
||||
|
||||
List<ActSarItemsEO> getStandAndItemsForAct (SarStandardsInfoEOPage page) throws Exception;
|
||||
|
||||
void insertIntoIndexForMap(Map<String,Object> attrInfoMap);
|
||||
|
||||
void updateIntoIndexForMap(Map<String,Object> attrInfoMap);
|
||||
}
|
||||
|
||||
+136
@@ -10,6 +10,7 @@ import com.adc.da.person.dao.PersonCollectEODao;
|
||||
import com.adc.da.person.dao.PersonShareEODao;
|
||||
import com.adc.da.person.entity.PersonMsgEO;
|
||||
import com.adc.da.person.service.IPersonCollectEOService;
|
||||
import com.adc.da.search.service.StandLawsSearchService;
|
||||
import com.adc.da.slrs.sarLawsInfo.entity.SarLawsInfo;
|
||||
import com.adc.da.slrs.sarLawsInfo.page.SarLawsInfoEOPage;
|
||||
import com.adc.da.slrs.sarLawsInfo.page.SarLawsItemsEOPage;
|
||||
@@ -51,6 +52,13 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.util.PDFTextStripper;
|
||||
import org.apache.pdfbox.util.PDFTextStripperByArea;
|
||||
import org.apache.poi.hwpf.extractor.WordExtractor;
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -61,6 +69,7 @@ import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.sql.Clob;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@@ -151,6 +160,12 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
|
||||
@Autowired
|
||||
private SysInfoEOService sysInfoEOService;
|
||||
|
||||
@Autowired
|
||||
private StandLawsSearchService standLawsSearchService;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;//文件存储路径
|
||||
|
||||
|
||||
|
||||
/***
|
||||
@@ -1854,6 +1869,127 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
|
||||
return standList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertIntoIndexForMap(Map<String, Object> attrInfoMap) {
|
||||
Set<String> keys = attrInfoMap.keySet();
|
||||
for (String key:keys) {
|
||||
String value = String.valueOf(attrInfoMap.get(key));
|
||||
if (com.adc.da.util.utils.StringUtils.isNotBlank(value) && !"null".equals(value) && !"SVPPS".equals(key)){
|
||||
value = value.replace(" , ",",");
|
||||
value = value.replace(","," , ");
|
||||
attrInfoMap.put(key,value);
|
||||
}
|
||||
}
|
||||
// 根据文件attid 读取文件内容
|
||||
if (org.apache.commons.lang.StringUtils.isNotEmpty(String.valueOf(attrInfoMap.get("content")))) {
|
||||
String[] attidlist = String.valueOf(attrInfoMap.get("content")).split(" , ");
|
||||
StringBuilder content = new StringBuilder("");
|
||||
for (int i = 0; i < attidlist.length; i++) {
|
||||
if(org.apache.commons.lang.StringUtils.isNotEmpty(attidlist[i]) ){
|
||||
AttFileEO attFileEO = attFileEOService.getFileInfo(attidlist[i]);
|
||||
String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName();
|
||||
try {
|
||||
// 判断文件是docx还是PDF
|
||||
if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) {
|
||||
if(attFileEO.getFileSuffix().equals("doc")){
|
||||
FileInputStream fis = new FileInputStream(readFilePath);
|
||||
WordExtractor wordExtractor = new WordExtractor(fis);
|
||||
String txt = wordExtractor.getText();
|
||||
content.append(txt);
|
||||
}else {
|
||||
OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
|
||||
String txt = extractor.getText();
|
||||
content.append(txt);
|
||||
}
|
||||
} else {
|
||||
PDDocument document = PDDocument.load(new File(readFilePath));
|
||||
document.getClass();
|
||||
if (!document.isEncrypted()) {
|
||||
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
||||
stripper.setSortByPosition(true);
|
||||
PDFTextStripper tStripper = new PDFTextStripper();
|
||||
String pdfFileInText = tStripper.getText(document);
|
||||
// String[] lines = pdfFileInText.split("\\r?\\n");
|
||||
content.append(pdfFileInText);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("搜索中心新增数据读取文档内容时失败");
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
/*catch (IOException | OpenXML4JException | XmlException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
}*/
|
||||
attrInfoMap.put("content",content.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
attrInfoMap.put("content","");
|
||||
}
|
||||
standLawsSearchService.addStandLawsSearchForMap(attrInfoMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIntoIndexForMap(Map<String, Object> attrInfoMap) {
|
||||
Set<String> keys = attrInfoMap.keySet();
|
||||
for (String key:keys) {
|
||||
String value = String.valueOf(attrInfoMap.get(key));
|
||||
if (com.adc.da.util.utils.StringUtils.isNotBlank(value) && !"null".equals(value) && !"SVPPS".equals(key) && !"content".equals(key)){
|
||||
value = value.replace(" , ",",");
|
||||
value = value.replace(","," , ");
|
||||
attrInfoMap.put(key,value);
|
||||
}
|
||||
}
|
||||
// 根据文件attid 读取文件内容
|
||||
if (org.apache.commons.lang.StringUtils.isNotEmpty(String.valueOf(attrInfoMap.get("content")))) {
|
||||
String[] attidlist = String.valueOf(attrInfoMap.get("content")).split(" , ");
|
||||
StringBuilder content = new StringBuilder("");
|
||||
for (int i = 0; i < attidlist.length; i++) {
|
||||
if(org.apache.commons.lang.StringUtils.isNotEmpty(attidlist[i]) && !"null".equals(attidlist[i])){
|
||||
AttFileEO attFileEO = attFileEOService.getFileInfo(attidlist[i]);
|
||||
String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName();
|
||||
try {
|
||||
// 判断文件是docx还是PDF
|
||||
if (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc")) {
|
||||
if(attFileEO.getFileSuffix().equals("doc")){
|
||||
FileInputStream fis = new FileInputStream(readFilePath);
|
||||
WordExtractor wordExtractor = new WordExtractor(fis);
|
||||
String txt = wordExtractor.getText();
|
||||
content.append(txt);
|
||||
}else {
|
||||
OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
|
||||
String txt = extractor.getText();
|
||||
content.append(txt);
|
||||
}
|
||||
} else if (attFileEO.getFileSuffix().equals("pdf")){
|
||||
PDDocument document = PDDocument.load(new File(readFilePath));
|
||||
document.getClass();
|
||||
if (!document.isEncrypted()) {
|
||||
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
||||
stripper.setSortByPosition(true);
|
||||
PDFTextStripper tStripper = new PDFTextStripper();
|
||||
String pdfFileInText = tStripper.getText(document);
|
||||
// String[] lines = pdfFileInText.split("\\r?\\n");
|
||||
content.append(pdfFileInText);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("搜索中心修改数据读取文档内容时失败");
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
attrInfoMap.put("content",content.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
attrInfoMap.put("content","");
|
||||
}
|
||||
standLawsSearchService.updateStandLawsSearchForMap(attrInfoMap);
|
||||
}
|
||||
|
||||
public void getStandDetailsForAct (SarStandardsInfoEOPage page,String[] idArr,String standState,List<ActSarItemsEO> standList) throws Exception{
|
||||
page.setPageSize(100);
|
||||
page.setIdlist(idArr);
|
||||
|
||||
Reference in New Issue
Block a user