文档库--文档库添加es,详情添加数量

This commit is contained in:
zhn
2022-03-16 09:26:08 +08:00
parent ee8709e90f
commit 7bee5e4f3a
2 changed files with 71 additions and 25 deletions
@@ -0,0 +1,37 @@
package com.jero.modules.document.enums;
/**
* @description
* @date 2022/1/21 15:22
* @auth zhn
*/
public enum SearchEnum {
INDEX_NAME_DOCUMENT("文档库索引名称","documentLibrary"),
TYPE_NAME_DOCUMENT("文档库类型","document");
String name;
String value;
private SearchEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@@ -26,6 +26,7 @@ import com.jero.modules.collection.entity.OnlCgformCollection;
import com.jero.modules.collection.service.IOnlCgformCollectionService;
import com.jero.modules.document.entity.BussDocumentLibraryEO;
import com.jero.modules.document.enums.FieldTypeEnum;
import com.jero.modules.document.enums.SearchEnum;
import com.jero.modules.document.mapper.BussDocumentLibraryEOMapper;
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
import com.jero.modules.domain.service.DomainUserRelService;
@@ -234,11 +235,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
sendWebsocket(StringUtils.join(serialNumberList, ","), StringUtils.join(serialNumberList, ","));
}
//删除es
// for (String id : ids) {
// jeroElasticsearchTemplate.delete();
// }
try {
for (String id : ids) {
jeroElasticsearchTemplate.delete(SearchEnum.INDEX_NAME_DOCUMENT.getValue(),SearchEnum.TYPE_NAME_DOCUMENT.getValue(),id);
}
} catch (Exception e) {
log.error("文档库删除es失败");
}
}
/**
@@ -767,16 +770,27 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//多文件处理
if (fileInfos.size() > 1) {
if (fileInfos.size() != 0) {
int i = 0;
for (OSSFile fileInfo : fileInfos) {
Map<String, Object> mapNew = new HashMap<>();
mapNew.put("value", fileInfo);
mapPut(cut, mapNew, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, null);
resultTemp.add(mapNew);
if(i==0){
Map<String, Object> mapNew = new HashMap<>();
mapNew.put("value", fileInfo);
mapPut(cut, mapNew, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, null);
mapNew.put("count",fileInfos.size());
resultTemp.add(mapNew);
i++;
}else{
Map<String, Object> mapNew = new HashMap<>();
mapNew.put("value", fileInfo);
mapPut(cut, mapNew, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, null);
resultTemp.add(mapNew);
}
}
}
} else if (fileInfos.size() == 1) {
//单个文件处理
Map<String, Object> mapNew = new HashMap<>();
mapNew.put("count",fileInfos.size());
mapNew.put("value", fileInfos.get(0));
mapPut(cut, mapNew, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, null);
resultTemp.add(mapNew);
@@ -954,17 +968,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
sendMsg(map, idTemp);
//添加es
map.put("id",idTemp);
String json = JSON.toJSONString(map);//map转String
String json = JSON.toJSONString(map);
JSONObject jsonObject = JSON.parseObject(json);
int a=0;
// try {
// jeroElasticsearchTemplate.saveOrUpdate("documentLibrary","document","cce8d7d2e8454606ad9c7697f6dc2607",jsonObject);
//// jeroElasticsearchTemplate.saveOrUpdate("documentLibrary","document",idTemp,jsonObject);
// } catch (Exception e) {
// int b = 0;
// e.printStackTrace();
// }
try {
jeroElasticsearchTemplate.saveOrUpdate(SearchEnum.INDEX_NAME_DOCUMENT.getValue(),SearchEnum.TYPE_NAME_DOCUMENT.getValue(),idTemp,jsonObject);
} catch (Exception e) {
log.error("文档库添加es失败");
}
}
private void sendMsg(Map<String, Object> map, String idTemp) {
@@ -1146,12 +1156,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
String json = JSON.toJSONString(map);//map转String
JSONObject jsonObject = JSON.parseObject(json);
//修改es
// try {
//// jeroElasticsearchTemplate.saveOrUpdate("documentLibrary","document","cce8d7d2e8454606ad9c7697f6dc2607",jsonObject);
// jeroElasticsearchTemplate.saveOrUpdate("documentLibrary","document",(String) map.get("id"),jsonObject);
// } catch (Exception e) {
// e.printStackTrace();
// }
try {
jeroElasticsearchTemplate.saveOrUpdate(SearchEnum.INDEX_NAME_DOCUMENT.getValue(),SearchEnum.TYPE_NAME_DOCUMENT.getValue(),(String) map.get("id"),jsonObject);
} catch (Exception e) {
log.error("文档库编辑es失败");
}
}
/**