文档库--es新增
This commit is contained in:
+55
-39
@@ -243,9 +243,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
try {
|
||||
for (String id : ids) {
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.INDEX_NAME_DOCUMENT.getValue(), SearchEnum.TYPE_NAME_DOCUMENT.getValue(), id);
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.FULL_TEXT_SEARCH.getValue(), SearchEnum.FULL_TEXT_SEARCH.getValue(), id);
|
||||
for (String fileId : fileIdList) {
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.FULL_TEXT_SEARCH.getValue(), SearchEnum.FULL_TEXT_SEARCH.getValue(), id+fileId);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("文档库删除es失败");
|
||||
@@ -968,6 +970,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
map.remove("corresponding_standard_id");
|
||||
//字段属性
|
||||
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue());
|
||||
//获取搜索中心字段
|
||||
List<OnlCgformField> searchFieldList = fieldList.stream().filter(e -> YesOrNoEnum.YES.getValue().equals(e.getIsShowSearch())).collect(Collectors.toList());
|
||||
//文件类型字段
|
||||
List<OnlCgformField> fieldFileList = fieldList.stream().filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
//树形数据字典
|
||||
@@ -1053,32 +1057,60 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
List<OSSFile> fileInfos = iOSSFileService.getFileInfos(StringUtils.join(fileIdList, ","));
|
||||
List<Map<String,Object>> mapListTemp = new ArrayList<>();
|
||||
try {
|
||||
for (OSSFile ossFile : fileInfos) {
|
||||
Map<String,Object> stringMap = new HashMap<>();
|
||||
String fileText = "";
|
||||
if(ossFile.getFileName().endsWith(".doc")
|
||||
|| ossFile.getFileName().endsWith(".docx")
|
||||
|| ossFile.getFileName().endsWith(".DOC")
|
||||
|| ossFile.getFileName().endsWith(".DOCX")){
|
||||
String wordContent = ReadWordUtil.readWord(ossFile.getUrl());
|
||||
if(StringUtils.isNotBlank(wordContent)){
|
||||
fileText = wordContent;
|
||||
if(fileInfos.size() != 0){
|
||||
for (OSSFile ossFile : fileInfos) {
|
||||
Map<String,Object> stringMap = new HashMap<>();
|
||||
String fileText = "";
|
||||
if(ossFile.getFileName().endsWith(".doc")
|
||||
|| ossFile.getFileName().endsWith(".docx")
|
||||
|| ossFile.getFileName().endsWith(".DOC")
|
||||
|| ossFile.getFileName().endsWith(".DOCX")){
|
||||
String wordContent = ReadWordUtil.readWord(ossFile.getUrl());
|
||||
if(StringUtils.isNotBlank(wordContent)){
|
||||
fileText = wordContent;
|
||||
}
|
||||
}else if(ossFile.getFileName().endsWith(".pdf")||ossFile.getFileName().endsWith(".PDF")){
|
||||
String pdfContent = ReadPdfUtil.readPdf(ossFile.getUrl());
|
||||
if(StringUtils.isNotBlank(pdfContent)){
|
||||
fileText = pdfContent;
|
||||
}
|
||||
}
|
||||
}else if(ossFile.getFileName().endsWith(".pdf")||ossFile.getFileName().endsWith(".PDF")){
|
||||
String pdfContent = ReadPdfUtil.readPdf(ossFile.getUrl());
|
||||
if(StringUtils.isNotBlank(pdfContent)){
|
||||
fileText = pdfContent;
|
||||
for (OnlCgformField onlCgformField : searchFieldList) {
|
||||
String s = (String) map.get(onlCgformField.getDbFieldName());
|
||||
if(StringUtils.isBlank(s)){
|
||||
s = "";
|
||||
}
|
||||
stringMap.put(onlCgformField.getDbFieldName(),s);
|
||||
}
|
||||
|
||||
stringMap.put("id",idTemp+ossFile.getId());
|
||||
stringMap.put("module_type", "文档库");
|
||||
stringMap.put("serial_number", map.get("serial_number"));
|
||||
stringMap.put("title", map.get("title"));
|
||||
stringMap.put("content", sb.toString());
|
||||
stringMap.put("file_text",fileText);
|
||||
stringMap.put("file_name",ossFile.getFileName());
|
||||
mapListTemp.add(stringMap);
|
||||
}
|
||||
stringMap.put("id",idTemp+ossFile.getId());
|
||||
}else{
|
||||
Map<String,Object> stringMap = new HashMap<>();
|
||||
for (OnlCgformField onlCgformField : searchFieldList) {
|
||||
String s = (String) map.get(onlCgformField.getDbFieldName());
|
||||
if(StringUtils.isBlank(s)){
|
||||
s = "";
|
||||
}
|
||||
stringMap.put(onlCgformField.getDbFieldName(),s);
|
||||
}
|
||||
stringMap.put("id",idTemp);
|
||||
stringMap.put("module_type", "文档库");
|
||||
stringMap.put("serial_number", map.get("serial_number"));
|
||||
stringMap.put("title", map.get("title"));
|
||||
stringMap.put("content", sb.toString());
|
||||
stringMap.put("file_text",fileText);
|
||||
stringMap.put("file_name",ossFile.getFileName());
|
||||
stringMap.put("file_text","");
|
||||
stringMap.put("file_name","");
|
||||
mapListTemp.add(stringMap);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("文档库新增es错误");
|
||||
}
|
||||
@@ -1353,11 +1385,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
//数据值
|
||||
StringBuilder valuesBuilder = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Map<String,Object> mapFullText = new HashMap<>();
|
||||
mapFullText.put("id", id);
|
||||
mapFullText.put("module_type", "文档库");
|
||||
mapFullText.put("serial_number", map.get("serial_number"));
|
||||
mapFullText.put("title", map.get("title"));
|
||||
|
||||
List<List<String>> fileTextList = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
@@ -1416,23 +1444,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
}
|
||||
valuesBuilder.append("'" + value + "'" + ",");
|
||||
}
|
||||
// //判断文件是否修改
|
||||
// if (ObjectUtils.isNotEmpty(dataList.get(0).get(key)) && !dataList.get(0).get(key).equals(value)) {
|
||||
// String valueTemp = UUID.randomUUID().toString().replace("-", "");
|
||||
// //修改文件表关联信息connect_id
|
||||
// List<OSSFile> oSSFileList = new ArrayList<>();
|
||||
// for (String fileId : value.toString().split(",")) {
|
||||
// OSSFile ossFile = new OSSFile();
|
||||
// ossFile.setId(fileId);
|
||||
// ossFile.setConnectId(valueTemp);
|
||||
// oSSFileList.add(ossFile);
|
||||
// }
|
||||
// iOSSFileService.updateFileInfo(oSSFileList);
|
||||
// valuesBuilder.append("'" + valueTemp + "'" + ",");
|
||||
// } else {
|
||||
// valuesBuilder.append("'" + value + "'" + ",");
|
||||
// }
|
||||
|
||||
} else {
|
||||
//编辑时replaced_standard被代替标准不存值,通过查询得到
|
||||
if ("replaced_standard".equals(key)) {
|
||||
@@ -1445,6 +1456,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
fieldsBuilder.append(key + ",");
|
||||
}
|
||||
}
|
||||
Map<String,Object> mapFullText = new HashMap<>();
|
||||
mapFullText.put("id", id);
|
||||
mapFullText.put("module_type", "文档库");
|
||||
mapFullText.put("serial_number", map.get("serial_number"));
|
||||
mapFullText.put("title", map.get("title"));
|
||||
mapFullText.put("file_text", fileTextList);
|
||||
mapFullText.put("content", sb.toString());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user