搜索--编辑时同步更新带文件的的数据中拼接的内容
This commit is contained in:
+127
-105
@@ -1127,10 +1127,10 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
|||||||
StringBuilder sbEn = new StringBuilder();
|
StringBuilder sbEn = new StringBuilder();
|
||||||
List<List<String>> fileTextList = new ArrayList<>();
|
List<List<String>> fileTextList = new ArrayList<>();
|
||||||
List<OSSFile> oSSFileAll = new ArrayList<>();
|
List<OSSFile> oSSFileAll = new ArrayList<>();
|
||||||
List<Map<String,Object>> maps = new ArrayList<>();
|
Map<String,Object> stringObjectMap = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
Map<String,Object> stringObjectMap = new HashMap<>();
|
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
//es全文新增数据(数据转换)
|
//es全文新增数据(数据转换)
|
||||||
@@ -1155,7 +1155,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
|||||||
if (fieldFile.size() != 0 && ObjectUtils.isNotEmpty(value)) {
|
if (fieldFile.size() != 0 && ObjectUtils.isNotEmpty(value)) {
|
||||||
String valueTemp = UUID.randomUUID().toString().replace("-", "");
|
String valueTemp = UUID.randomUUID().toString().replace("-", "");
|
||||||
stringObjectMap.put(key,valueTemp);
|
stringObjectMap.put(key,valueTemp);
|
||||||
maps.add(stringObjectMap);
|
|
||||||
// value = valueTemp;
|
// value = valueTemp;
|
||||||
//修改文件表关联信息connect_id
|
//修改文件表关联信息connect_id
|
||||||
List<OSSFile> oSSFileList = new ArrayList<>();
|
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> 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>> mapListTempCn = new ArrayList<>();
|
||||||
List<Map<String, Object>> mapListTempEn = new ArrayList<>();
|
List<Map<String, Object>> mapListTempEn = new ArrayList<>();
|
||||||
@@ -1641,9 +1640,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
|||||||
List<OSSFile> oSSFileAll = new ArrayList<>();
|
List<OSSFile> oSSFileAll = new ArrayList<>();
|
||||||
StringBuilder sbCn = new StringBuilder();
|
StringBuilder sbCn = new StringBuilder();
|
||||||
StringBuilder sbEn = 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()) {
|
for (Map.Entry<String, Object> entry : mapNew.entrySet()) {
|
||||||
Map<String,Object> stringObjectMap = new HashMap<>();
|
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
//es全文新增数据(数据转换)
|
//es全文新增数据(数据转换)
|
||||||
@@ -1672,7 +1670,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
|||||||
|| (ObjectUtils.isEmpty(dataList.get(0).get(key)) && ObjectUtils.isNotEmpty(value))) {
|
|| (ObjectUtils.isEmpty(dataList.get(0).get(key)) && ObjectUtils.isNotEmpty(value))) {
|
||||||
String valueTemp = UUID.randomUUID().toString().replace("-", "");
|
String valueTemp = UUID.randomUUID().toString().replace("-", "");
|
||||||
stringObjectMap.put(key,valueTemp);
|
stringObjectMap.put(key,valueTemp);
|
||||||
maps.add(stringObjectMap);
|
|
||||||
//修改文件表关联信息connect_id
|
//修改文件表关联信息connect_id
|
||||||
List<OSSFile> oSSFileList = new ArrayList<>();
|
List<OSSFile> oSSFileList = new ArrayList<>();
|
||||||
for (String fileId : value.toString().split(",")) {
|
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> 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>> mapListTempCn = new ArrayList<>();
|
||||||
List<Map<String, Object>> mapListTempEn = new ArrayList<>();
|
List<Map<String, Object>> mapListTempEn = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
String cutCn = CutEnum.CN.getValue();
|
||||||
|
String cutEn = CutEnum.EN.getValue();
|
||||||
if (fileInfos.size() != 0) {
|
if (fileInfos.size() != 0) {
|
||||||
String cutCn = CutEnum.CN.getValue();
|
//编辑时,有修改文件的情况
|
||||||
String cutEn = CutEnum.EN.getValue();
|
updateEsInfo(map, searchFieldList, sbCn, sbEn, fileInfos, mapListTempCn, mapListTempEn, cutCn, cutEn);
|
||||||
Map<String, Object> mapBaseDateCn = new HashMap<>();
|
} else {
|
||||||
Map<String, Object> mapBaseDateEn = new HashMap<>();
|
//没有修改文件,获取之前上传过的文件
|
||||||
for (OSSFile ossFile : fileInfos) {
|
List<OnlCgformField> fieldFileListTemp = fieldList.stream()
|
||||||
Map<String, Object> stringMapCn = new HashMap<>();
|
.filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||||
Map<String, Object> stringMapEn = new HashMap<>();
|
List<String> fileFieldList = fieldFileListTemp.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||||
String fileText = "";
|
List<String> connectIdList = new ArrayList<>();
|
||||||
if (ossFile.getFileName().endsWith(".doc")
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
|| ossFile.getFileName().endsWith(".docx")
|
String key = entry.getKey();
|
||||||
|| ossFile.getFileName().endsWith(".DOC")
|
String value = String.valueOf(entry.getValue());
|
||||||
|| ossFile.getFileName().endsWith(".DOCX")) {
|
if(fileFieldList.contains(key)){
|
||||||
String wordContent = null;
|
if(!"null".equals(value)){
|
||||||
try {
|
connectIdList.add(value);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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) {
|
for (OnlCgformField onlCgformField : searchFieldList) {
|
||||||
String s = (String) map.get(onlCgformField.getDbFieldName());
|
String s = (String) map.get(onlCgformField.getDbFieldName());
|
||||||
if(FieldTypeEnum.DATE_SINGLE.getValue().equals(onlCgformField.getFieldShowType()) && StringUtils.isNotBlank(s)){
|
if(FieldTypeEnum.DATE_SINGLE.getValue().equals(onlCgformField.getFieldShowType()) && StringUtils.isNotBlank(s)){
|
||||||
@@ -1759,68 +1753,19 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
//封装中文的全文内容(es)
|
//封装中文的全文内容(es)
|
||||||
putMapCn((String) map.get("id") + ossFile.getId(), (String) map.get("serial_number"), "文档库",
|
putMapCn((String) map.get("id"), (String) map.get("serial_number"), "文档库",
|
||||||
sbCn.toString(), (String) map.get("title"), fileText, ossFile.getFileName(),
|
sbCn.toString(), (String) map.get("title"), "", "",
|
||||||
cutCn, stringMapCn,null);
|
cutCn, stringMapCn,SEARCH_FLAG);
|
||||||
|
stringMapCn.put("file_sort",(String) map.get("id")+"_"+1);
|
||||||
//封装英文的全文内容(es)
|
//封装英文的全文内容(es)
|
||||||
putMapCn((String) map.get("id") + ossFile.getId(), (String) map.get("serial_number"), "document library",
|
putMapCn((String) map.get("id"), (String) map.get("serial_number"), "document library",
|
||||||
sbEn.toString(), (String) map.get("title"), fileText, ossFile.getFileName(),
|
sbEn.toString(), (String) map.get("title"), "", "",
|
||||||
cutEn, stringMapEn,null);
|
cutEn, stringMapEn,SEARCH_FLAG);
|
||||||
|
stringMapEn.put("file_sort",(String) map.get("id")+"_"+1);
|
||||||
|
|
||||||
mapListTempCn.add(stringMapCn);
|
mapListTempCn.add(stringMapCn);
|
||||||
mapListTempEn.add(stringMapEn);
|
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) {
|
} 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
|
* 更新log
|
||||||
*
|
*
|
||||||
@@ -4108,20 +4132,18 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
|||||||
* @param oSSFileAll 所有文件
|
* @param oSSFileAll 所有文件
|
||||||
* @param maps key-->字段 value-->关联文件connect_id
|
* @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<OSSFile> result = new LinkedList<>();
|
||||||
List<String> fileFeildList = fieldFileList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
List<String> fileFeildList = fieldFileList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||||
for (OnlCgformField onlCgformField : fieldFileList) {
|
for (OnlCgformField onlCgformField : fieldFileList) {
|
||||||
String dbFieldName = onlCgformField.getDbFieldName();
|
String dbFieldName = onlCgformField.getDbFieldName();
|
||||||
for (Map<String, Object> map : maps) {
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
String key = entry.getKey();
|
||||||
String key = entry.getKey();
|
String value = (String) entry.getValue();
|
||||||
String value = (String)entry.getValue();
|
if (dbFieldName.equals(key)) {
|
||||||
if(dbFieldName.equals(key)){
|
List<OSSFile> files = oSSFileAll.stream().filter(e -> StringUtils.isNotBlank(value) && value.equals(e.getConnectId())).collect(Collectors.toList());
|
||||||
List<OSSFile> files = oSSFileAll.stream().filter(e -> value.equals(e.getConnectId())).collect(Collectors.toList());
|
if (files.size() != 0) {
|
||||||
if(files.size() != 0){
|
result.addAll(files);
|
||||||
result.addAll(files);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user