Merge remote-tracking branch 'origin/develop_master' into develop_master

This commit is contained in:
zj
2022-05-04 17:27:26 +08:00
6 changed files with 161 additions and 90 deletions
@@ -80,7 +80,10 @@ public class SendStandMQService {
}
}
String sarStandAttrEOStr = infoEO.getSarStandAttrEOStr();
Map<String,Object> attrInfoMap = JSONObject.fromObject(sarStandAttrEOStr);
Map<String,Object> attrInfoMap = new TreeMap<>();
if(StringUtils.isNotBlank(sarStandAttrEOStr)){
attrInfoMap = JSONObject.fromObject(sarStandAttrEOStr);
}
Map<String,Object> infoMap = infoEO.getAttrInfoMap();
Map<String,String> infoEOMapItems = infoEO.getMapItems();
@@ -178,15 +181,25 @@ public class SendStandMQService {
// 动态存储属性字段
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();
String fieldValue = "";
try {
saveMap.put(field,attrInfoMap.getOrDefault(field,""));
if(infoMap.get(field) != null && StringUtils.isNotBlank(infoMap.get(field).toString())){
Object json= new JSONTokener(infoMap.get(field).toString()).nextValue();
if(json instanceof org.json.JSONArray){
fieldValue = String.join(",", com.alibaba.fastjson.JSONObject.parseArray(standMap.get(field).toString(),String.class));
}else {
if(!("null").equals(json)){
fieldValue = standMap.get(field).toString();
}
}
}
saveMap.put(field+"Name",fieldValue);
}catch (Exception e){
logger.info("国内外标准 消息队列: "+addOrUpdate+", 标准ID:"+infoEO.getId()+",问题字段:"+field);
saveMap.put(field+"Name",fieldValue);
}
saveMap.put(field+"Name",fieldValue);
}
if(infoEOMapItems != null && !infoEOMapItems.isEmpty()){
@@ -39,6 +39,17 @@ public class ResetSearchCenterController extends BaseController<Map<String, Obje
return resetSearchCenterService.resetALLSearchCenter(searchCenter);
}
@ApiOperation(value = "|SearchCenter|手动重新创建(---7天内---)ALL标准数据索引(凌晨有自动程序会跑)")
@PostMapping(value="/manualResetALLSearchCenter")
public ResponseMessage manualResetALLSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception{
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
return x;
}
return resetSearchCenterService.syncResetALLSearchCenter(searchCenter);
}
private ResponseMessage verifySearchCenter(SearchCenter searchCenter) {
if(searchCenter.getExecType() == null || "".equals(searchCenter.getExecType())){
return Result.error("执行参数 ALL 存在更新 不存在新增 ,UPD 只 更新存在 es 里的标准 ,ADD 只新增不存在 es 的标准, DEL 只删除不存在标准库的数据");
@@ -33,7 +33,6 @@ import com.adc.da.utils.util.FieldConvertUtil;
import com.adc.da.utils.util.InitStandAttrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.client.transport.TransportClient;
import org.json.JSONTokener;
@@ -165,7 +164,7 @@ public class ResetSearchCenterService {
SearchCenter lawsSearch = new SearchCenter();
lawsSearch.setExecType(searchCenter.getExecType());
SarLawsStandInfoPage lawsPage = new SarLawsStandInfoPage();
page.setSyncParam("sync");
lawsPage.setSyncParam("sync");
ResponseMessage laws = resetLawsSearchCenter(lawsPage,lawsSearch);
if(laws.isOk() && StringUtils.isNotBlank(laws.getData().toString())){
r.add(laws.getData().toString());
@@ -174,7 +173,7 @@ public class ResetSearchCenterService {
SearchCenter bussSearch = new SearchCenter();
bussSearch.setExecType(searchCenter.getExecType());
SarBussionessStandEOPage bussPage = new SarBussionessStandEOPage();
page.setSyncParam("sync");
bussPage.setSyncParam("sync");
ResponseMessage buss = resetBussStandSearchCenter(bussPage,bussSearch);
if(buss.isOk() && StringUtils.isNotBlank(buss.getData().toString())){
r.add(buss.getData().toString());
@@ -3012,47 +3012,50 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
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])) {
if (StringUtils.isNotEmpty(attidlist[i]) && !"null".equals(attidlist[i]) && attidlist[i].contains("att_file")) {
AttFileEO attFileEO = attFileEOService.getFileInfo(attidlist[i]);
String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName();
// String readFilePath = "E:\\上汽企标流程总览.pdf";
try {
// 判断文件是docx还是PDF
if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) {
if (attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX")) {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(readFilePath)));
if (FileMagic.valueOf(bis) == FileMagic.OOXML) {
XWPFDocument doc = new XWPFDocument(bis);
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
File existsFile = new File(readFilePath);
if(existsFile.exists()){
// 判断文件是docx还是PDF
if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) {
if (attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX")) {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(readFilePath)));
if (FileMagic.valueOf(bis) == FileMagic.OOXML) {
XWPFDocument doc = new XWPFDocument(bis);
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
String txt = extractor.getText();
content.append(txt);
extractor.close();
}else {
WordExtractor wordExtractor = new WordExtractor(bis);
String txt = wordExtractor.getText();
content.append(txt);
wordExtractor.close();
}
bis.close();
} else {
OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath);
XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
String txt = extractor.getText();
content.append(txt);
extractor.close();
}else {
WordExtractor wordExtractor = new WordExtractor(bis);
String txt = wordExtractor.getText();
content.append(txt);
wordExtractor.close();
opcPackage.close();
}
bis.close();
} else {
OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath);
XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
String txt = extractor.getText();
content.append(txt);
opcPackage.close();
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);
}
document.close();
}
} 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);
}
document.close();
}
} catch (Exception e) {
logger.error("搜索中心新增数据读取文档内容时失败");
@@ -3083,43 +3086,53 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
String[] attidlist = String.valueOf(attrInfoMap.get("content")).split(",");
StringBuilder content = new StringBuilder("");
for (int i = 0; i < attidlist.length; i++) {
if (StringUtils.isNotEmpty(attidlist[i]) && !"null".equals(attidlist[i])) {
if (StringUtils.isNotEmpty(attidlist[i]) && !"null".equals(attidlist[i]) && attidlist[i].contains("att_file")) {
AttFileEO attFileEO = attFileEOService.getFileInfo(attidlist[i]);
if (null == attFileEO) {
continue;
}
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);
File existsFile = new File(readFilePath);
if(existsFile.exists()){
// 判断文件是docx还是PDF
if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) {
if (attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX")) {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(readFilePath)));
if (FileMagic.valueOf(bis) == FileMagic.OOXML) {
XWPFDocument doc = new XWPFDocument(bis);
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
String txt = extractor.getText();
content.append(txt);
extractor.close();
}else {
WordExtractor wordExtractor = new WordExtractor(bis);
String txt = wordExtractor.getText();
content.append(txt);
wordExtractor.close();
}
bis.close();
} else {
OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath);
XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
String txt = extractor.getText();
content.append(txt);
opcPackage.close();
}
} 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);
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);
}
document.close();
}
}
// String readFilePath = "E:\\上汽企标流程总览.pdf";
// FileInputStream fis = new FileInputStream(readFilePath);
// WordExtractor wordExtractor = new WordExtractor(fis);
// String txt = wordExtractor.getText();
// content.append(txt);
} catch (Exception e) {
logger.error("搜索中心修改数据读取文档内容时失败");
logger.error(e.getMessage(), e);