搜索--编辑时同步更新带文件的的数据中拼接的内容
This commit is contained in:
+127
-105
@@ -1127,10 +1127,10 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
StringBuilder sbEn = new StringBuilder();
|
||||
List<List<String>> fileTextList = new ArrayList<>();
|
||||
List<OSSFile> oSSFileAll = new ArrayList<>();
|
||||
List<Map<String,Object>> maps = new ArrayList<>();
|
||||
Map<String,Object> stringObjectMap = new HashMap<>();
|
||||
try {
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
Map<String,Object> stringObjectMap = new HashMap<>();
|
||||
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
//es全文新增数据(数据转换)
|
||||
@@ -1155,7 +1155,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
if (fieldFile.size() != 0 && ObjectUtils.isNotEmpty(value)) {
|
||||
String valueTemp = UUID.randomUUID().toString().replace("-", "");
|
||||
stringObjectMap.put(key,valueTemp);
|
||||
maps.add(stringObjectMap);
|
||||
// value = valueTemp;
|
||||
//修改文件表关联信息connect_id
|
||||
List<OSSFile> oSSFileList = new ArrayList<>();
|
||||
@@ -1186,7 +1185,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
List<OSSFile> fileInfos = iOSSFileService.getFileInfos(StringUtils.join(fileIdList, ","));
|
||||
|
||||
//处理文件排序(发布稿 增补件 报批稿 征求意见稿 测试程序)
|
||||
List<OSSFile> ossFileList = fileSort(fieldFileList, fileInfos, maps);
|
||||
List<OSSFile> ossFileList = fileSort(fieldFileList, fileInfos, stringObjectMap);
|
||||
|
||||
List<Map<String, Object>> mapListTempCn = new ArrayList<>();
|
||||
List<Map<String, Object>> mapListTempEn = new ArrayList<>();
|
||||
@@ -1641,9 +1640,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
List<OSSFile> oSSFileAll = new ArrayList<>();
|
||||
StringBuilder sbCn = new StringBuilder();
|
||||
StringBuilder sbEn = new StringBuilder();
|
||||
List<Map<String,Object>> maps = new ArrayList<>();
|
||||
Map<String,Object> stringObjectMap = new HashMap<>();
|
||||
for (Map.Entry<String, Object> entry : mapNew.entrySet()) {
|
||||
Map<String,Object> stringObjectMap = new HashMap<>();
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
//es全文新增数据(数据转换)
|
||||
@@ -1672,7 +1670,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
|| (ObjectUtils.isEmpty(dataList.get(0).get(key)) && ObjectUtils.isNotEmpty(value))) {
|
||||
String valueTemp = UUID.randomUUID().toString().replace("-", "");
|
||||
stringObjectMap.put(key,valueTemp);
|
||||
maps.add(stringObjectMap);
|
||||
//修改文件表关联信息connect_id
|
||||
List<OSSFile> oSSFileList = new ArrayList<>();
|
||||
for (String fileId : value.toString().split(",")) {
|
||||
@@ -1709,44 +1706,41 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
List<OSSFile> fileInfos = iOSSFileService.getFileInfos(StringUtils.join(fileIdList, ","));
|
||||
|
||||
//处理文件排序(发布稿 增补件 报批稿 征求意见稿 测试程序)
|
||||
List<OSSFile> ossFileList = fileSort(fieldFileList, fileInfos, maps);
|
||||
List<OSSFile> ossFileList = fileSort(fieldFileList, fileInfos, stringObjectMap);
|
||||
|
||||
List<Map<String, Object>> mapListTempCn = new ArrayList<>();
|
||||
List<Map<String, Object>> mapListTempEn = new ArrayList<>();
|
||||
try {
|
||||
String cutCn = CutEnum.CN.getValue();
|
||||
String cutEn = CutEnum.EN.getValue();
|
||||
if (fileInfos.size() != 0) {
|
||||
String cutCn = CutEnum.CN.getValue();
|
||||
String cutEn = CutEnum.EN.getValue();
|
||||
Map<String, Object> mapBaseDateCn = new HashMap<>();
|
||||
Map<String, Object> mapBaseDateEn = new HashMap<>();
|
||||
for (OSSFile ossFile : fileInfos) {
|
||||
Map<String, Object> stringMapCn = new HashMap<>();
|
||||
Map<String, Object> stringMapEn = new HashMap<>();
|
||||
String fileText = "";
|
||||
if (ossFile.getFileName().endsWith(".doc")
|
||||
|| ossFile.getFileName().endsWith(".docx")
|
||||
|| ossFile.getFileName().endsWith(".DOC")
|
||||
|| ossFile.getFileName().endsWith(".DOCX")) {
|
||||
String wordContent = null;
|
||||
try {
|
||||
wordContent = ReadWordUtil.readWord(ossFile.getUrl());
|
||||
} catch (Exception e) {
|
||||
log.error("文档库:读取word文件内容失败");
|
||||
}
|
||||
if (StringUtils.isNotBlank(wordContent)) {
|
||||
fileText = wordContent;
|
||||
}
|
||||
} else if (ossFile.getFileName().endsWith(".pdf") || ossFile.getFileName().endsWith(".PDF")) {
|
||||
String pdfContent = null;
|
||||
try {
|
||||
pdfContent = ReadPdfUtil.readPdf(ossFile.getUrl());
|
||||
} catch (Exception e) {
|
||||
log.error("文档库读取PDF文件内容失败");
|
||||
}
|
||||
if (StringUtils.isNotBlank(pdfContent)) {
|
||||
fileText = pdfContent;
|
||||
//编辑时,有修改文件的情况
|
||||
updateEsInfo(map, searchFieldList, sbCn, sbEn, fileInfos, mapListTempCn, mapListTempEn, cutCn, cutEn);
|
||||
} else {
|
||||
//没有修改文件,获取之前上传过的文件
|
||||
List<OnlCgformField> fieldFileListTemp = fieldList.stream()
|
||||
.filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
List<String> fileFieldList = fieldFileListTemp.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||
List<String> connectIdList = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = String.valueOf(entry.getValue());
|
||||
if(fileFieldList.contains(key)){
|
||||
if(!"null".equals(value)){
|
||||
connectIdList.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(connectIdList.size()!= 0){
|
||||
List<OSSFile> oSSFileListTemp = iOSSFileService.getFileInfosByConnectId(StringUtils.join(connectIdList, ","));
|
||||
//处理文件排序(发布稿 增补件 报批稿 征求意见稿 测试程序)
|
||||
List<OSSFile> files = fileSort(fieldFileList, oSSFileListTemp, map);
|
||||
updateEsInfo(map, searchFieldList, sbCn, sbEn, files, mapListTempCn, mapListTempEn, cutCn, cutEn);
|
||||
|
||||
}else{
|
||||
//之前没有上传过文件
|
||||
Map<String, Object> stringMapCn = new HashMap<>();
|
||||
Map<String, Object> stringMapEn = new HashMap<>();
|
||||
for (OnlCgformField onlCgformField : searchFieldList) {
|
||||
String s = (String) map.get(onlCgformField.getDbFieldName());
|
||||
if(FieldTypeEnum.DATE_SINGLE.getValue().equals(onlCgformField.getFieldShowType()) && StringUtils.isNotBlank(s)){
|
||||
@@ -1759,68 +1753,19 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
}
|
||||
|
||||
//封装中文的全文内容(es)
|
||||
putMapCn((String) map.get("id") + ossFile.getId(), (String) map.get("serial_number"), "文档库",
|
||||
sbCn.toString(), (String) map.get("title"), fileText, ossFile.getFileName(),
|
||||
cutCn, stringMapCn,null);
|
||||
putMapCn((String) map.get("id"), (String) map.get("serial_number"), "文档库",
|
||||
sbCn.toString(), (String) map.get("title"), "", "",
|
||||
cutCn, stringMapCn,SEARCH_FLAG);
|
||||
stringMapCn.put("file_sort",(String) map.get("id")+"_"+1);
|
||||
//封装英文的全文内容(es)
|
||||
putMapCn((String) map.get("id") + ossFile.getId(), (String) map.get("serial_number"), "document library",
|
||||
sbEn.toString(), (String) map.get("title"), fileText, ossFile.getFileName(),
|
||||
cutEn, stringMapEn,null);
|
||||
putMapCn((String) map.get("id"), (String) map.get("serial_number"), "document library",
|
||||
sbEn.toString(), (String) map.get("title"), "", "",
|
||||
cutEn, stringMapEn,SEARCH_FLAG);
|
||||
stringMapEn.put("file_sort",(String) map.get("id")+"_"+1);
|
||||
|
||||
mapListTempCn.add(stringMapCn);
|
||||
mapListTempEn.add(stringMapEn);
|
||||
int a = 1;
|
||||
int b = 1;
|
||||
for (Map<String, Object> objectMap : mapListTempCn) {
|
||||
a++;
|
||||
objectMap.put("file_sort",(String) map.get("id")+"_"+a);
|
||||
}
|
||||
for (Map<String, Object> objectMap : mapListTempEn) {
|
||||
b++;
|
||||
objectMap.put("file_sort",(String) map.get("id")+"_"+b);
|
||||
}
|
||||
}
|
||||
|
||||
//基础数据中文(es)
|
||||
putMapCn((String) map.get("id"), (String) map.get("serial_number"), "文档库",
|
||||
sbCn.toString(), (String) map.get("title"), "", "",
|
||||
cutCn, mapBaseDateCn,SEARCH_FLAG);
|
||||
mapBaseDateCn.put("file_sort",(String) map.get("id")+"_"+1);
|
||||
//基础数据英文(es)
|
||||
putMapCn((String) map.get("id"), (String) map.get("serial_number"), "document library",
|
||||
sbEn.toString(), (String) map.get("title"), "", "",
|
||||
cutEn, mapBaseDateEn,SEARCH_FLAG);
|
||||
mapBaseDateEn.put("file_sort",(String) map.get("id")+"_"+1);
|
||||
mapListTempCn.add(mapBaseDateCn);
|
||||
mapListTempEn.add(mapBaseDateEn);
|
||||
} else {
|
||||
Map<String, Object> stringMapCn = new HashMap<>();
|
||||
Map<String, Object> stringMapEn = new HashMap<>();
|
||||
for (OnlCgformField onlCgformField : searchFieldList) {
|
||||
String s = (String) map.get(onlCgformField.getDbFieldName());
|
||||
if(FieldTypeEnum.DATE_SINGLE.getValue().equals(onlCgformField.getFieldShowType()) && StringUtils.isNotBlank(s)){
|
||||
s = s.split(" ")[0];
|
||||
}
|
||||
if(StringUtils.isNotBlank(s)){
|
||||
stringMapCn.put(onlCgformField.getDbFieldName(), s);
|
||||
stringMapEn.put(onlCgformField.getDbFieldName(), s);
|
||||
}
|
||||
}
|
||||
String cutCn = CutEnum.CN.getValue();
|
||||
String cutEn = CutEnum.EN.getValue();
|
||||
//封装中文的全文内容(es)
|
||||
putMapCn((String) map.get("id"), (String) map.get("serial_number"), "文档库",
|
||||
sbCn.toString(), (String) map.get("title"), "", "",
|
||||
cutCn, stringMapCn,SEARCH_FLAG);
|
||||
stringMapCn.put("file_sort",(String) map.get("id")+"_"+1);
|
||||
//封装英文的全文内容(es)
|
||||
putMapCn((String) map.get("id"), (String) map.get("serial_number"), "document library",
|
||||
sbEn.toString(), (String) map.get("title"), "", "",
|
||||
cutEn, stringMapEn,SEARCH_FLAG);
|
||||
stringMapEn.put("file_sort",(String) map.get("id")+"_"+1);
|
||||
|
||||
mapListTempCn.add(stringMapCn);
|
||||
mapListTempEn.add(stringMapEn);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -1901,6 +1846,85 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
}
|
||||
}
|
||||
|
||||
private void updateEsInfo(Map<String, Object> map, List<OnlCgformField> searchFieldList, StringBuilder sbCn, StringBuilder sbEn, List<OSSFile> fileInfos, List<Map<String, Object>> mapListTempCn, List<Map<String, Object>> mapListTempEn, String cutCn, String cutEn) {
|
||||
Map<String, Object> mapBaseDateCn = new HashMap<>();
|
||||
Map<String, Object> mapBaseDateEn = new HashMap<>();
|
||||
for (OSSFile ossFile : fileInfos) {
|
||||
Map<String, Object> stringMapCn = new HashMap<>();
|
||||
Map<String, Object> stringMapEn = new HashMap<>();
|
||||
String fileText = "";
|
||||
if (ossFile.getFileName().endsWith(".doc")
|
||||
|| ossFile.getFileName().endsWith(".docx")
|
||||
|| ossFile.getFileName().endsWith(".DOC")
|
||||
|| ossFile.getFileName().endsWith(".DOCX")) {
|
||||
String wordContent = null;
|
||||
try {
|
||||
wordContent = ReadWordUtil.readWord(ossFile.getUrl());
|
||||
} catch (Exception e) {
|
||||
log.error("文档库:读取word文件内容失败");
|
||||
}
|
||||
if (StringUtils.isNotBlank(wordContent)) {
|
||||
fileText = wordContent;
|
||||
}
|
||||
} else if (ossFile.getFileName().endsWith(".pdf") || ossFile.getFileName().endsWith(".PDF")) {
|
||||
String pdfContent = null;
|
||||
try {
|
||||
pdfContent = ReadPdfUtil.readPdf(ossFile.getUrl());
|
||||
} catch (Exception e) {
|
||||
log.error("文档库读取PDF文件内容失败");
|
||||
}
|
||||
if (StringUtils.isNotBlank(pdfContent)) {
|
||||
fileText = pdfContent;
|
||||
}
|
||||
}
|
||||
for (OnlCgformField onlCgformField : searchFieldList) {
|
||||
String s = (String) map.get(onlCgformField.getDbFieldName());
|
||||
if(FieldTypeEnum.DATE_SINGLE.getValue().equals(onlCgformField.getFieldShowType()) && StringUtils.isNotBlank(s)){
|
||||
s = s.split(" ")[0];
|
||||
}
|
||||
if(StringUtils.isNotBlank(s)){
|
||||
stringMapCn.put(onlCgformField.getDbFieldName(), s);
|
||||
stringMapEn.put(onlCgformField.getDbFieldName(), s);
|
||||
}
|
||||
}
|
||||
|
||||
//封装中文的全文内容(es)
|
||||
putMapCn((String) map.get("id") + ossFile.getId(), (String) map.get("serial_number"), "文档库",
|
||||
sbCn.toString(), (String) map.get("title"), fileText, ossFile.getFileName(),
|
||||
cutCn, stringMapCn,null);
|
||||
//封装英文的全文内容(es)
|
||||
putMapCn((String) map.get("id") + ossFile.getId(), (String) map.get("serial_number"), "document library",
|
||||
sbEn.toString(), (String) map.get("title"), fileText, ossFile.getFileName(),
|
||||
cutEn, stringMapEn,null);
|
||||
|
||||
mapListTempCn.add(stringMapCn);
|
||||
mapListTempEn.add(stringMapEn);
|
||||
int a = 1;
|
||||
int b = 1;
|
||||
for (Map<String, Object> objectMap : mapListTempCn) {
|
||||
a++;
|
||||
objectMap.put("file_sort",(String) map.get("id")+"_"+a);
|
||||
}
|
||||
for (Map<String, Object> objectMap : mapListTempEn) {
|
||||
b++;
|
||||
objectMap.put("file_sort",(String) map.get("id")+"_"+b);
|
||||
}
|
||||
}
|
||||
|
||||
//基础数据中文(es)
|
||||
putMapCn((String) map.get("id"), (String) map.get("serial_number"), "文档库",
|
||||
sbCn.toString(), (String) map.get("title"), "", "",
|
||||
cutCn, mapBaseDateCn,SEARCH_FLAG);
|
||||
mapBaseDateCn.put("file_sort",(String) map.get("id")+"_"+1);
|
||||
//基础数据英文(es)
|
||||
putMapCn((String) map.get("id"), (String) map.get("serial_number"), "document library",
|
||||
sbEn.toString(), (String) map.get("title"), "", "",
|
||||
cutEn, mapBaseDateEn,SEARCH_FLAG);
|
||||
mapBaseDateEn.put("file_sort",(String) map.get("id")+"_"+1);
|
||||
mapListTempCn.add(mapBaseDateCn);
|
||||
mapListTempEn.add(mapBaseDateEn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新log
|
||||
*
|
||||
@@ -4108,20 +4132,18 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
* @param oSSFileAll 所有文件
|
||||
* @param maps key-->字段 value-->关联文件connect_id
|
||||
*/
|
||||
public List<OSSFile> fileSort(List<OnlCgformField> fieldFileList,List<OSSFile> oSSFileAll,List<Map<String,Object>> maps){
|
||||
public List<OSSFile> fileSort(List<OnlCgformField> fieldFileList,List<OSSFile> oSSFileAll,Map<String,Object> map){
|
||||
List<OSSFile> result = new LinkedList<>();
|
||||
List<String> fileFeildList = fieldFileList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||
for (OnlCgformField onlCgformField : fieldFileList) {
|
||||
String dbFieldName = onlCgformField.getDbFieldName();
|
||||
for (Map<String, Object> map : maps) {
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = (String)entry.getValue();
|
||||
if(dbFieldName.equals(key)){
|
||||
List<OSSFile> files = oSSFileAll.stream().filter(e -> value.equals(e.getConnectId())).collect(Collectors.toList());
|
||||
if(files.size() != 0){
|
||||
result.addAll(files);
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = (String) entry.getValue();
|
||||
if (dbFieldName.equals(key)) {
|
||||
List<OSSFile> files = oSSFileAll.stream().filter(e -> StringUtils.isNotBlank(value) && value.equals(e.getConnectId())).collect(Collectors.toList());
|
||||
if (files.size() != 0) {
|
||||
result.addAll(files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user