文档库--搜索中心中英文切换
This commit is contained in:
+3
-1
@@ -8,7 +8,9 @@ package com.jero.modules.document.enums;
|
||||
public enum SearchEnum {
|
||||
INDEX_NAME_DOCUMENT("文档库索引名称","documentLibrary"),
|
||||
TYPE_NAME_DOCUMENT("文档库类型","document"),
|
||||
FULL_TEXT_SEARCH("全部","fulltextsearch");
|
||||
FULL_TEXT_SEARCH("全部中文","fulltextsearchcn"),
|
||||
FULL_TEXT_SEARCH_CN("全部中文","fulltextsearchcn"),
|
||||
FULL_TEXT_SEARCH_EN("全部英文","fulltextsearchen");
|
||||
|
||||
|
||||
|
||||
|
||||
+209
-80
@@ -220,9 +220,17 @@ 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);
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.FULL_TEXT_SEARCH_CN.getValue(), SearchEnum.FULL_TEXT_SEARCH_CN.getValue(), id);
|
||||
//删除全部英文的
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.FULL_TEXT_SEARCH_EN.getValue(), SearchEnum.FULL_TEXT_SEARCH_EN.getValue(), id);
|
||||
for (String fileId : fileIdList) {
|
||||
//删除全部中文的
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.FULL_TEXT_SEARCH.getValue(), SearchEnum.FULL_TEXT_SEARCH.getValue(), id + fileId);
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.FULL_TEXT_SEARCH_CN.getValue(), SearchEnum.FULL_TEXT_SEARCH_CN.getValue(), id + fileId);
|
||||
//删除全部英文的
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.FULL_TEXT_SEARCH_EN.getValue(), SearchEnum.FULL_TEXT_SEARCH_EN.getValue(), id + fileId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1111,15 +1119,18 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
StringBuilder fieldsBuilder = new StringBuilder();
|
||||
//数据值
|
||||
StringBuilder valuesBuilder = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
//sbCn sbEn 这两个字段作为es中英文切换
|
||||
StringBuilder sbCn = new StringBuilder();
|
||||
StringBuilder sbEn = new StringBuilder();
|
||||
List<List<String>> fileTextList = new ArrayList<>();
|
||||
List<OSSFile> oSSFileAll = new ArrayList<>();
|
||||
try {
|
||||
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
//es全文新增数据(数据转换)
|
||||
esFullText(cut, fieldList, categoryList, dictItemList, mapList, sb, entry);
|
||||
esFullText(cut, fieldList, categoryList, dictItemList, mapList, sbCn,sbEn, entry);
|
||||
|
||||
//处理日期格式
|
||||
if (fieldDateList.contains(key)) {
|
||||
@@ -1170,11 +1181,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
//多文件es iOSSFileService.getFileInfos(StringUtils.join(fileIdList, ","));
|
||||
List<String> fileIdList = oSSFileAll.stream().map(OSSFile::getId).collect(Collectors.toList());
|
||||
List<OSSFile> fileInfos = iOSSFileService.getFileInfos(StringUtils.join(fileIdList, ","));
|
||||
List<Map<String, Object>> mapListTemp = new ArrayList<>();
|
||||
List<Map<String, Object>> mapListTempCn = new ArrayList<>();
|
||||
List<Map<String, Object>> mapListTempEn = new ArrayList<>();
|
||||
try {
|
||||
if (fileInfos.size() != 0) {
|
||||
for (OSSFile ossFile : fileInfos) {
|
||||
Map<String, Object> stringMap = new HashMap<>();
|
||||
Map<String, Object> stringMapCn = new HashMap<>();
|
||||
Map<String, Object> stringMapEn = new HashMap<>();
|
||||
String fileText = "";
|
||||
if (ossFile.getFileName().endsWith(".doc")
|
||||
|| ossFile.getFileName().endsWith(".docx")
|
||||
@@ -1207,38 +1220,73 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
// s = "";
|
||||
// }
|
||||
if(StringUtils.isNotBlank(s)){
|
||||
stringMap.put(onlCgformField.getDbFieldName(), s);
|
||||
stringMapCn.put(onlCgformField.getDbFieldName(), s);
|
||||
stringMapEn.put(onlCgformField.getDbFieldName(), s);
|
||||
}
|
||||
}
|
||||
String cutCn = CutEnum.CN.getValue();
|
||||
String cutEn = CutEnum.EN.getValue();
|
||||
//封装中文的全文内容(es)
|
||||
putMapCn(idTemp + ossFile.getId(),
|
||||
(String) map.get("serial_number"),
|
||||
"文档库",
|
||||
sbCn.toString(),
|
||||
(String) map.get("title"),
|
||||
fileText,
|
||||
ossFile.getFileName(),
|
||||
cutCn,
|
||||
stringMapCn);
|
||||
//封装英文的全文内容(es)
|
||||
putMapCn(idTemp + ossFile.getId(),
|
||||
(String) map.get("serial_number"),
|
||||
"document library",
|
||||
sbEn.toString(),
|
||||
(String) map.get("title"),
|
||||
fileText,
|
||||
ossFile.getFileName(),
|
||||
cutEn,
|
||||
stringMapEn);
|
||||
|
||||
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);
|
||||
mapListTempCn.add(stringMapCn);
|
||||
mapListTempEn.add(stringMapEn);
|
||||
}
|
||||
} else {
|
||||
Map<String, Object> stringMap = new HashMap<>();
|
||||
Map<String, Object> stringMapCn = new HashMap<>();
|
||||
Map<String, Object> stringMapEn = new HashMap<>();
|
||||
for (OnlCgformField onlCgformField : searchFieldList) {
|
||||
String s = (String) map.get(onlCgformField.getDbFieldName());
|
||||
// if (StringUtils.isBlank(s)) {
|
||||
// s = "";
|
||||
// }
|
||||
if(StringUtils.isNotBlank(s)){
|
||||
stringMap.put(onlCgformField.getDbFieldName(), s);
|
||||
stringMapCn.put(onlCgformField.getDbFieldName(), s);
|
||||
stringMapEn.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", "");
|
||||
stringMap.put("file_name", "");
|
||||
mapListTemp.add(stringMap);
|
||||
String cutCn = CutEnum.CN.getValue();
|
||||
String cutEn = CutEnum.EN.getValue();
|
||||
//封装中文的全文内容(es)
|
||||
putMapCn(idTemp,
|
||||
(String) map.get("serial_number"),
|
||||
"文档库",
|
||||
sbCn.toString(),
|
||||
(String) map.get("title"),
|
||||
"",
|
||||
"",
|
||||
cutCn,
|
||||
stringMapCn);
|
||||
//封装英文的全文内容(es)
|
||||
putMapCn(idTemp,
|
||||
(String) map.get("serial_number"),
|
||||
"document library",
|
||||
sbEn.toString(),
|
||||
(String) map.get("title"),
|
||||
"",
|
||||
"",
|
||||
cutEn,
|
||||
stringMapEn);
|
||||
mapListTempCn.add(stringMapCn);
|
||||
mapListTempEn.add(stringMapEn);
|
||||
}
|
||||
|
||||
|
||||
@@ -1262,13 +1310,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
map.put("id", idTemp);
|
||||
map.put("module_type", "文档库");
|
||||
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(map));
|
||||
// JSONObject jsonObjectAll = JSON.parseObject(JSON.toJSONString(mapFullText));
|
||||
JSONArray array = JSONArray.parseArray(JSON.toJSONString(mapListTemp));
|
||||
|
||||
JSONArray arrayCn = JSONArray.parseArray(JSON.toJSONString(mapListTempCn));
|
||||
JSONArray arrayEn = JSONArray.parseArray(JSON.toJSONString(mapListTempEn));
|
||||
try {
|
||||
jeroElasticsearchTemplate.saveOrUpdate(SearchEnum.INDEX_NAME_DOCUMENT.getValue(), SearchEnum.TYPE_NAME_DOCUMENT.getValue(), idTemp, jsonObject);
|
||||
//全部
|
||||
jeroElasticsearchTemplate.saveBatch(SearchEnum.FULL_TEXT_SEARCH.getValue(), SearchEnum.FULL_TEXT_SEARCH.getValue(), array);
|
||||
jeroElasticsearchTemplate.saveBatch(SearchEnum.FULL_TEXT_SEARCH_CN.getValue(), SearchEnum.FULL_TEXT_SEARCH_CN.getValue(), arrayCn);
|
||||
jeroElasticsearchTemplate.saveBatch(SearchEnum.FULL_TEXT_SEARCH_EN.getValue(), SearchEnum.FULL_TEXT_SEARCH_EN.getValue(), arrayEn);
|
||||
} catch (Exception e) {
|
||||
log.error("文档库添加es失败");
|
||||
}
|
||||
@@ -1313,18 +1361,27 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
return result;
|
||||
}
|
||||
|
||||
private void esFullText(String cut, List<OnlCgformField> fieldList, List<SysCategory> categoryList, List<SysDictItem> dictItemList, List<Map<String, Object>> mapList, StringBuilder sb, Map.Entry<String, Object> entry) {
|
||||
private void esFullText(String cut, List<OnlCgformField> fieldList,
|
||||
List<SysCategory> categoryList,
|
||||
List<SysDictItem> dictItemList,
|
||||
List<Map<String, Object>> mapList,
|
||||
StringBuilder sbCn, StringBuilder sbEn,
|
||||
Map.Entry<String, Object> entry) {
|
||||
try {
|
||||
List<OnlCgformField> onlCgformFieldList = fieldList.stream().filter(e -> entry.getKey().equals(e.getDbFieldName())).collect(Collectors.toList());
|
||||
for (OnlCgformField onlCgformField : fieldList) {
|
||||
String fieldNameCn = onlCgformField.getDbFieldTxt();
|
||||
String fieldNameEn = onlCgformField.getDbFieldEnName();
|
||||
//输入框
|
||||
if ((FieldTypeEnum.TEXT_STRING.getValue().equals(onlCgformField.getFieldShowType())
|
||||
|| FieldTypeEnum.TEXT_NUMBER.getValue().equals(onlCgformField.getFieldShowType()))
|
||||
&& onlCgformField.getDbFieldName().equals(entry.getKey())) {
|
||||
if (ObjectUtils.isEmpty(entry.getValue())) {
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + "-- ");
|
||||
sbCn.append(fieldNameCn + ":" + "-- ");
|
||||
sbEn.append(fieldNameEn + ":" + "-- ");
|
||||
} else {
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + entry.getValue() + " ");
|
||||
sbCn.append(fieldNameCn + ":" + entry.getValue() + " ");
|
||||
sbEn.append(fieldNameEn + ":" + entry.getValue() + " ");
|
||||
}
|
||||
}
|
||||
//下拉框
|
||||
@@ -1332,25 +1389,32 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
|| FieldTypeEnum.PULL_MORE.getValue().equals(onlCgformField.getFieldShowType()))
|
||||
&& onlCgformField.getDbFieldName().equals(entry.getKey())) {
|
||||
if (ObjectUtils.isEmpty(entry.getValue())) {
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + "-- ");
|
||||
sbCn.append(fieldNameCn + ":" + "-- ");
|
||||
sbEn.append(fieldNameEn + ":" + "-- ");
|
||||
} else {
|
||||
if (onlCgformFieldList.size() != 0 && StringUtils.isNotBlank(onlCgformFieldList.get(0).getDictField())) {
|
||||
List<SysDictItem> dictItems = dictItemList.stream()
|
||||
.filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals(onlCgformFieldList.get(0).getDictField()))
|
||||
.collect(Collectors.toList());
|
||||
StringBuilder sbText = new StringBuilder();
|
||||
StringBuilder sbTextCn = new StringBuilder();
|
||||
StringBuilder sbTextEn = new StringBuilder();
|
||||
//处理数据字典
|
||||
for (String item : entry.getValue().toString().split(",")) {
|
||||
if (dictItems.size() != 0) {
|
||||
List<SysDictItem> itemValue = dictItems.stream().filter(e -> item.equals(e.getItemValue())).collect(Collectors.toList());
|
||||
if (itemValue.size() != 0) {
|
||||
sbText.append(itemValue.get(0).getItemText() + ",");
|
||||
sbTextCn.append(itemValue.get(0).getItemText() + ",");
|
||||
sbTextEn.append(itemValue.get(0).getEnName() + ",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(sbText)) {
|
||||
String substring = sbText.substring(0, sbText.length() - 1);
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + substring + " ");
|
||||
if (StringUtils.isNotBlank(sbTextCn)) {
|
||||
String substring = sbTextCn.substring(0, sbTextCn.length() - 1);
|
||||
sbCn.append(fieldNameCn + ":" + substring + " ");
|
||||
}
|
||||
if (StringUtils.isNotBlank(sbTextEn)) {
|
||||
String substring = sbTextEn.substring(0, sbTextEn.length() - 1);
|
||||
sbEn.append(fieldNameEn + ":" + substring + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1359,19 +1423,19 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
if (FieldTypeEnum.TREE.getValue().equals(onlCgformField.getFieldShowType())
|
||||
&& onlCgformField.getDbFieldName().equals(entry.getKey())) {
|
||||
if (ObjectUtils.isEmpty(entry.getValue())) {
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + "-- ");
|
||||
sbCn.append(fieldNameCn + ":" + "-- ");
|
||||
sbEn.append(fieldNameEn + ":" + "-- ");
|
||||
} else {
|
||||
StringBuilder sbTree = new StringBuilder();
|
||||
StringBuilder sbTreeCn = new StringBuilder();
|
||||
StringBuilder sbTreeEn = new StringBuilder();
|
||||
List<String> idList = Arrays.asList(entry.getValue().toString().split(","));
|
||||
List<SysCategory> sysCategoryList = categoryList.stream().filter(e -> idList.contains(e.getId())).collect(Collectors.toList());
|
||||
List<String> nameList = sysCategoryList.stream().map(SysCategory::getName).collect(Collectors.toList());
|
||||
List<String> nameEnList = sysCategoryList.stream().map(SysCategory::getEnName).collect(Collectors.toList());
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
sbTree.append(StringUtils.join(nameList, ","));
|
||||
} else {
|
||||
sbTree.append(StringUtils.join(nameEnList, ","));
|
||||
}
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + sbTree.toString() + " ");
|
||||
sbTreeCn.append(StringUtils.join(nameList, ","));
|
||||
sbTreeEn.append(StringUtils.join(nameEnList, ","));
|
||||
sbCn.append(fieldNameCn + ":" + sbTreeCn.toString() + " ");
|
||||
sbEn.append(fieldNameEn + ":" + sbTreeEn.toString() + " ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1379,16 +1443,19 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
if (FieldTypeEnum.DATE_SINGLE.getValue().equals(onlCgformField.getFieldShowType())
|
||||
&& onlCgformField.getDbFieldName().equals(entry.getKey())) {
|
||||
if (ObjectUtils.isEmpty(entry.getValue())) {
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + "-- ");
|
||||
sbCn.append(fieldNameCn + ":" + "-- ");
|
||||
sbEn.append(fieldNameEn + ":" + "-- ");
|
||||
} else {
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + entry.getValue().toString().split(" ")[0] + " ");
|
||||
sbCn.append(fieldNameCn + ":" + entry.getValue().toString().split(" ")[0] + " ");
|
||||
sbEn.append(fieldNameEn + ":" + entry.getValue().toString().split(" ")[0] + " ");
|
||||
}
|
||||
}
|
||||
//标准选择
|
||||
if (FieldTypeEnum.STANDARD.getValue().equals(onlCgformField.getFieldShowType())
|
||||
&& onlCgformField.getDbFieldName().equals(entry.getKey())) {
|
||||
if (ObjectUtils.isEmpty(entry.getValue())) {
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + "-- ");
|
||||
sbCn.append(fieldNameCn + ":" + "-- ");
|
||||
sbEn.append(fieldNameEn + ":" + "-- ");
|
||||
} else {
|
||||
StringBuilder standSb = new StringBuilder();
|
||||
if ("replaced_standard".equals(entry.getKey())) {
|
||||
@@ -1418,7 +1485,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
|
||||
if (StringUtils.isNotBlank(standSb)) {
|
||||
String substring = standSb.substring(0, standSb.length() - 1);
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + substring + " ");
|
||||
sbCn.append(fieldNameCn + ":" + substring + " ");
|
||||
sbEn.append(fieldNameEn + ":" + substring + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1427,11 +1495,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
if (FieldTypeEnum.FILE.getValue().equals(onlCgformField.getFieldShowType())
|
||||
&& onlCgformField.getDbFieldName().equals(entry.getKey())) {
|
||||
if (ObjectUtils.isEmpty(entry.getValue())) {
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + "-- ");
|
||||
sbCn.append(fieldNameCn + ":" + "-- ");
|
||||
sbEn.append(fieldNameEn + ":" + "-- ");
|
||||
} else {
|
||||
List<OSSFile> fileInfos = iOSSFileService.getFileInfos((String) entry.getValue());
|
||||
List<String> fileNameList = fileInfos.stream().map(OSSFile::getFileName).collect(Collectors.toList());
|
||||
sb.append(onlCgformField.getDbFieldTxt() + ":" + StringUtils.join(fileNameList, ",") + " ");
|
||||
sbCn.append(fieldNameCn + ":" + StringUtils.join(fileNameList, ",") + " ");
|
||||
sbEn.append(fieldNameEn + ":" + StringUtils.join(fileNameList, ",") + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1548,7 +1618,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
StringBuilder fieldsBuilder = new StringBuilder();
|
||||
//数据值
|
||||
StringBuilder valuesBuilder = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
//调整map中字段的顺序和新增表单中字段顺序一致
|
||||
Map<String, Object> mapNew = new LinkedHashMap<>();
|
||||
@@ -1568,11 +1638,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
}
|
||||
}
|
||||
List<OSSFile> oSSFileAll = new ArrayList<>();
|
||||
StringBuilder sbCn = new StringBuilder();
|
||||
StringBuilder sbEn = new StringBuilder();
|
||||
for (Map.Entry<String, Object> entry : mapNew.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
//es全文新增数据(数据转换)
|
||||
esFullText(cut, fieldList, categoryList, dictItemList, listMap, sb, entry);
|
||||
esFullText(cut, fieldList, categoryList, dictItemList, listMap, sbCn,sbEn, entry);
|
||||
|
||||
if (ObjectUtils.isNotEmpty(value)) {
|
||||
//处理修改人和修改时间
|
||||
@@ -1630,11 +1702,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
}
|
||||
List<String> fileIdList = oSSFileAll.stream().map(OSSFile::getId).collect(Collectors.toList());
|
||||
List<OSSFile> fileInfos = iOSSFileService.getFileInfos(StringUtils.join(fileIdList, ","));
|
||||
List<Map<String, Object>> mapListTemp = new ArrayList<>();
|
||||
List<Map<String, Object>> mapListTempCn = new ArrayList<>();
|
||||
List<Map<String, Object>> mapListTempEn = new ArrayList<>();
|
||||
try {
|
||||
if (fileInfos.size() != 0) {
|
||||
for (OSSFile ossFile : fileInfos) {
|
||||
Map<String, Object> stringMap = new HashMap<>();
|
||||
Map<String, Object> stringMapCn = new HashMap<>();
|
||||
Map<String, Object> stringMapEn = new HashMap<>();
|
||||
String fileText = "";
|
||||
if (ossFile.getFileName().endsWith(".doc")
|
||||
|| ossFile.getFileName().endsWith(".docx")
|
||||
@@ -1669,21 +1743,40 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
// s = "";
|
||||
// }
|
||||
if(StringUtils.isNotBlank(s)){
|
||||
stringMap.put(onlCgformField.getDbFieldName(), s);
|
||||
stringMapCn.put(onlCgformField.getDbFieldName(), s);
|
||||
stringMapEn.put(onlCgformField.getDbFieldName(), s);
|
||||
}
|
||||
}
|
||||
String cutCn = CutEnum.CN.getValue();
|
||||
String cutEn = CutEnum.EN.getValue();
|
||||
|
||||
stringMap.put("id", (String) map.get("id") + 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);
|
||||
//封装中文的全文内容(es)
|
||||
putMapCn((String) map.get("id") + ossFile.getId(),
|
||||
(String) map.get("serial_number"),
|
||||
"文档库",
|
||||
sbCn.toString(),
|
||||
(String) map.get("title"),
|
||||
fileText,
|
||||
ossFile.getFileName(),
|
||||
cutCn,
|
||||
stringMapCn);
|
||||
//封装英文的全文内容(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);
|
||||
|
||||
mapListTempCn.add(stringMapCn);
|
||||
mapListTempEn.add(stringMapEn);
|
||||
}
|
||||
} else {
|
||||
Map<String, Object> stringMap = new HashMap<>();
|
||||
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)){
|
||||
@@ -1693,17 +1786,35 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
// s = "";
|
||||
// }
|
||||
if(StringUtils.isNotBlank(s)){
|
||||
stringMap.put(onlCgformField.getDbFieldName(), s);
|
||||
stringMapCn.put(onlCgformField.getDbFieldName(), s);
|
||||
stringMapEn.put(onlCgformField.getDbFieldName(), s);
|
||||
}
|
||||
}
|
||||
stringMap.put("id", (String) map.get("id"));
|
||||
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", "");
|
||||
stringMap.put("file_name", "");
|
||||
mapListTemp.add(stringMap);
|
||||
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);
|
||||
//封装英文的全文内容(es)
|
||||
putMapCn((String) map.get("id"),
|
||||
(String) map.get("serial_number"),
|
||||
"document library",
|
||||
sbEn.toString(),
|
||||
(String) map.get("title"),
|
||||
"",
|
||||
"",
|
||||
cutEn,
|
||||
stringMapEn);
|
||||
|
||||
mapListTempCn.add(stringMapCn);
|
||||
mapListTempEn.add(stringMapEn);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -1745,20 +1856,24 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(objectMapTemp));
|
||||
JSONArray array = JSONArray.parseArray(JSON.toJSONString(mapListTemp));
|
||||
// JSONObject jsonObjectAll = JSON.parseObject(JSON.toJSONString(mapFullText));
|
||||
JSONArray arrayCn = JSONArray.parseArray(JSON.toJSONString(mapListTempCn));
|
||||
JSONArray arrayEn = JSONArray.parseArray(JSON.toJSONString(mapListTempEn));
|
||||
//修改es
|
||||
try {
|
||||
//删除文档库和全部
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.INDEX_NAME_DOCUMENT.getValue(), SearchEnum.TYPE_NAME_DOCUMENT.getValue(), (String) map.get("id"));
|
||||
//删除全部
|
||||
for (Map<String, Object> objectMap : mapListTemp) {
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.FULL_TEXT_SEARCH.getValue(), SearchEnum.FULL_TEXT_SEARCH.getValue(), (String) objectMap.get("id"));
|
||||
//删除全部中文
|
||||
for (Map<String, Object> objectMap : mapListTempCn) {
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.FULL_TEXT_SEARCH_CN.getValue(), SearchEnum.FULL_TEXT_SEARCH_CN.getValue(), (String) objectMap.get("id"));
|
||||
}
|
||||
//删除全部中文
|
||||
for (Map<String, Object> objectMap : mapListTempEn) {
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.FULL_TEXT_SEARCH_EN.getValue(), SearchEnum.FULL_TEXT_SEARCH_EN.getValue(), (String) objectMap.get("id"));
|
||||
}
|
||||
jeroElasticsearchTemplate.saveOrUpdate(SearchEnum.INDEX_NAME_DOCUMENT.getValue(), SearchEnum.TYPE_NAME_DOCUMENT.getValue(), (String) map.get("id"), jsonObject);
|
||||
//添加全文
|
||||
jeroElasticsearchTemplate.saveBatch(SearchEnum.FULL_TEXT_SEARCH.getValue(), SearchEnum.FULL_TEXT_SEARCH.getValue(), array);
|
||||
// jeroElasticsearchTemplate.saveOrUpdate(SearchEnum.FULL_TEXT_SEARCH.getValue(), SearchEnum.FULL_TEXT_SEARCH.getValue(), (String) map.get("id"), jsonObjectAll);
|
||||
jeroElasticsearchTemplate.saveBatch(SearchEnum.FULL_TEXT_SEARCH_CN.getValue(), SearchEnum.FULL_TEXT_SEARCH_CN.getValue(), arrayCn);
|
||||
jeroElasticsearchTemplate.saveBatch(SearchEnum.FULL_TEXT_SEARCH_EN.getValue(), SearchEnum.FULL_TEXT_SEARCH_EN.getValue(), arrayEn);
|
||||
} catch (Exception e) {
|
||||
log.error("文档库编辑es失败");
|
||||
}
|
||||
@@ -3866,4 +3981,18 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
return null;
|
||||
}
|
||||
|
||||
private void putMapCn(String id,String serialNumber,String moduleType,
|
||||
String content,String title,String fileText,
|
||||
String fileName,String cut,Map<String, Object> stringMap){
|
||||
stringMap.put("id", id);
|
||||
stringMap.put("serial_number", serialNumber);
|
||||
stringMap.put("module_type", moduleType);
|
||||
stringMap.put("content", content);
|
||||
stringMap.put("title", title);
|
||||
stringMap.put("file_text", fileText);
|
||||
stringMap.put("file_name", fileName);
|
||||
stringMap.put("cut",cut);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+32
-22
@@ -463,10 +463,17 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
@Override
|
||||
public IPage getFullTextInfoList(SearchVO searchVO) {
|
||||
//判断索引是否存在
|
||||
boolean flagTemp = jeroElasticsearchTemplate.indexExists(SearchEnum.FULL_TEXT_SEARCH.getValue());
|
||||
boolean flagTemp = true;
|
||||
if(CutEnum.CN.getValue().equals(searchVO.getCut())){
|
||||
flagTemp = jeroElasticsearchTemplate.indexExists(SearchEnum.FULL_TEXT_SEARCH_CN.getValue());
|
||||
}else{
|
||||
flagTemp = jeroElasticsearchTemplate.indexExists(SearchEnum.FULL_TEXT_SEARCH_EN.getValue());
|
||||
}
|
||||
|
||||
if (!flagTemp) {
|
||||
return new Page(searchVO.getPageNo(), searchVO.getPageSize());
|
||||
}
|
||||
|
||||
String selectValue = searchVO.getSelectValue();
|
||||
String selectValueTwo = searchVO.getSelectValueTwo();
|
||||
//不查询高亮字段
|
||||
@@ -523,7 +530,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
queryMapJsonAll.add(jsonObjectTwo);
|
||||
}
|
||||
|
||||
IPage page = getiPage(selectValue, selectValueTwo, queryMapJsonAll, null, pageNo, pageSize, null);
|
||||
IPage page = getiPage(selectValue, selectValueTwo, queryMapJsonAll, null, pageNo, pageSize, null,searchVO.getCut());
|
||||
|
||||
|
||||
return page;
|
||||
@@ -531,7 +538,8 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private IPage getiPage(String selectValue, String selectValueTwo, JSONArray queryMapJson, JSONArray should, Integer pageNo, Integer pageSize, String paragraphFlag) {
|
||||
private IPage getiPage(String selectValue, String selectValueTwo, JSONArray queryMapJson,
|
||||
JSONArray should, Integer pageNo, Integer pageSize, String paragraphFlag,String cut) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//基础添加封装
|
||||
if ("paragraphFlag".equals(paragraphFlag)) {
|
||||
@@ -549,22 +557,16 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
pageSize);
|
||||
// JSONObject queryObject11 = jeroElasticsearchTemplate.buildQuery(null, jsonObject11,highlightMap,null, Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString()));
|
||||
//2. 数据查询
|
||||
JSONObject search = jeroElasticsearchTemplate.search(SearchEnum.FULL_TEXT_SEARCH.getValue(),
|
||||
SearchEnum.FULL_TEXT_SEARCH.getValue(),
|
||||
queryObject);
|
||||
|
||||
|
||||
JSONObject queryObjectAll = jeroElasticsearchTemplate.buildQuery(null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
pageNo-1,
|
||||
pageSize);
|
||||
//全部的数据(调试接口用--最后删除即可)
|
||||
JSONObject searchAll = jeroElasticsearchTemplate.search(SearchEnum.FULL_TEXT_SEARCH.getValue(),
|
||||
SearchEnum.FULL_TEXT_SEARCH.getValue(),
|
||||
queryObjectAll);
|
||||
|
||||
JSONObject search = new JSONObject();
|
||||
if(CutEnum.CN.getValue().equals(cut)){
|
||||
search = jeroElasticsearchTemplate.search(SearchEnum.FULL_TEXT_SEARCH_CN.getValue(),
|
||||
SearchEnum.FULL_TEXT_SEARCH_CN.getValue(),
|
||||
queryObject);
|
||||
}else{
|
||||
search = jeroElasticsearchTemplate.search(SearchEnum.FULL_TEXT_SEARCH_EN.getValue(),
|
||||
SearchEnum.FULL_TEXT_SEARCH_EN.getValue(),
|
||||
queryObject);
|
||||
}
|
||||
|
||||
List<Map<String, Object>> list = (List<Map<String, Object>>) (((Map) search.get("hits")).get("hits"));
|
||||
|
||||
@@ -758,7 +760,8 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
jeroElasticsearchTemplate.removeIndex(SearchEnum.INDEX_NAME_DOCUMENT.getValue());
|
||||
jeroElasticsearchTemplate.removeIndex(SearchEnum.FULL_TEXT_SEARCH.getValue());
|
||||
jeroElasticsearchTemplate.removeIndex(SearchEnum.FULL_TEXT_SEARCH_CN.getValue());
|
||||
jeroElasticsearchTemplate.removeIndex(SearchEnum.FULL_TEXT_SEARCH_EN.getValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -770,9 +773,16 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
*/
|
||||
@Override
|
||||
public IPage getParagraphInfoList(Map<String, Object> map) {
|
||||
String cut = (String) map.get("cut");
|
||||
//module_type 代表文档库的段落
|
||||
//判断索引是否存在
|
||||
boolean flagTemp = jeroElasticsearchTemplate.indexExists(SearchEnum.FULL_TEXT_SEARCH.getValue());
|
||||
boolean flagTemp = true;
|
||||
if(CutEnum.CN.getValue().equals(cut)){
|
||||
flagTemp = jeroElasticsearchTemplate.indexExists(SearchEnum.FULL_TEXT_SEARCH_CN.getValue());
|
||||
}else{
|
||||
flagTemp = jeroElasticsearchTemplate.indexExists(SearchEnum.FULL_TEXT_SEARCH_EN.getValue());
|
||||
}
|
||||
|
||||
if (!flagTemp) {
|
||||
return new Page(Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString()));
|
||||
}
|
||||
@@ -843,7 +853,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
String paragraphFlag = "paragraphFlag";
|
||||
|
||||
|
||||
IPage iPage = getiPage(selectValue, selectValueTwo, must, should, pageNo, pageSize, paragraphFlag);
|
||||
IPage iPage = getiPage(selectValue, selectValueTwo, must, should, pageNo, pageSize, paragraphFlag,(String) map.get("cut"));
|
||||
return iPage;
|
||||
}
|
||||
|
||||
|
||||
+6
-46
@@ -14,19 +14,11 @@ public class SearchVO {
|
||||
private String ids;
|
||||
//记录从哪个索引表中查数据
|
||||
private String selectIndex;
|
||||
|
||||
|
||||
private String keywords;
|
||||
private String resultKeyword;
|
||||
|
||||
|
||||
// 条目搜索条件
|
||||
private String itemsName;
|
||||
private String itemsNum;
|
||||
private String parts;
|
||||
private Integer pageNo;
|
||||
private Integer pageSize;
|
||||
|
||||
private String cut;
|
||||
|
||||
public Integer getPageNo() {
|
||||
return pageNo;
|
||||
}
|
||||
@@ -75,43 +67,11 @@ public class SearchVO {
|
||||
this.selectIndex = selectIndex;
|
||||
}
|
||||
|
||||
public String getKeywords() {
|
||||
return keywords;
|
||||
public String getCut() {
|
||||
return cut;
|
||||
}
|
||||
|
||||
public void setKeywords(String keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public String getResultKeyword() {
|
||||
return resultKeyword;
|
||||
}
|
||||
|
||||
public void setResultKeyword(String resultKeyword) {
|
||||
this.resultKeyword = resultKeyword;
|
||||
}
|
||||
|
||||
public String getItemsName() {
|
||||
return itemsName;
|
||||
}
|
||||
|
||||
public void setItemsName(String itemsName) {
|
||||
this.itemsName = itemsName;
|
||||
}
|
||||
|
||||
public String getItemsNum() {
|
||||
return itemsNum;
|
||||
}
|
||||
|
||||
public void setItemsNum(String itemsNum) {
|
||||
this.itemsNum = itemsNum;
|
||||
}
|
||||
|
||||
public String getParts() {
|
||||
return parts;
|
||||
}
|
||||
|
||||
public void setParts(String parts) {
|
||||
this.parts = parts;
|
||||
public void setCut(String cut) {
|
||||
this.cut = cut;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user