文档库--es列表文件处理
This commit is contained in:
+13
@@ -67,4 +67,17 @@ public class DocumentSearchController {
|
||||
IPage infoList = iDocumentSearchService.getInfoList(map);
|
||||
return Result.OK(infoList);
|
||||
}
|
||||
|
||||
@ApiOperation(value="删除", notes="删除")
|
||||
@GetMapping(value = "/deleteById")
|
||||
public Result<?> deleteById(@RequestParam String ids) {
|
||||
iDocumentSearchService.deleteById(ids);
|
||||
return Result.OK();
|
||||
}
|
||||
@ApiOperation(value="删除", notes="删除")
|
||||
@GetMapping(value = "/deleteAll")
|
||||
public Result<?> deleteAll() {
|
||||
iDocumentSearchService.deleteAll();
|
||||
return Result.OK();
|
||||
}
|
||||
}
|
||||
|
||||
+67
-5
@@ -10,13 +10,17 @@ import com.jero.common.es.JeroElasticsearchTemplate;
|
||||
import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
|
||||
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
||||
import com.jero.modules.document.enums.FieldTypeEnum;
|
||||
import com.jero.modules.document.enums.SearchEnum;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
import com.jero.modules.document.service.impl.BussDocumentLibraryEOServiceImpl;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.system.entity.SysCategory;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
|
||||
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -45,6 +49,8 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
private SysDictItemServiceImpl sysDictItemServiceImpl;
|
||||
@Autowired
|
||||
private BussDocumentLibraryEOServiceImpl bussDocumentLibraryEOService;
|
||||
@Autowired
|
||||
private IOSSFileService iOSSFileService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -68,6 +74,8 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
List<OnlCgformField> hearOnlCgformFieldList = fieldList.stream()
|
||||
.filter(e -> YesOrNoEnum.YES.getValue().equals(e.getIsShowSearch())).collect(Collectors.toList());
|
||||
List<String> sourceList = hearOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||
sourceList.add("id");
|
||||
|
||||
//输入框字段
|
||||
List<OnlCgformField> inputOnlCgformFieldList = fieldList.stream()
|
||||
.filter(e -> FieldTypeEnum.TEXT_STRING.getValue().equals(e.getFieldShowType())
|
||||
@@ -89,6 +97,14 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
.filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType())
|
||||
|| FieldTypeEnum.PULL_MORE.getValue().equals(e.getFieldShowType()))
|
||||
.collect(Collectors.toList());
|
||||
//过滤出文件类型字段
|
||||
List<OnlCgformField> onlCgformFieldFileList = fieldList.stream()
|
||||
.filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType()))
|
||||
.collect(Collectors.toList());
|
||||
//文件字段
|
||||
List<String> FieldFileList = onlCgformFieldFileList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||
sourceList.addAll(FieldFileList);
|
||||
|
||||
//下拉选字段
|
||||
List<String> fieldPullList = onlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||
|
||||
@@ -148,7 +164,10 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(sourceList, jsonObject, null, Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString()));
|
||||
//
|
||||
//数据查询
|
||||
JSONObject search = jeroElasticsearchTemplate.search("documentLibrary", "document", queryObject);
|
||||
JSONObject search = jeroElasticsearchTemplate.search(SearchEnum.INDEX_NAME_DOCUMENT.getValue(), SearchEnum.TYPE_NAME_DOCUMENT.getValue(), queryObject);
|
||||
|
||||
|
||||
|
||||
//处理数据字典
|
||||
List<SysDictItem> sysDictItems = sysDictItemServiceImpl.selectItemsAll();//下拉数据字典
|
||||
List<SysCategory> categoryList = sysCategoryService.list();//树形数据字典
|
||||
@@ -156,19 +175,39 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
List<Map<String, Object>> mapList = new ArrayList<>();
|
||||
for (Map<String, Object> stringObjectMap : list) {
|
||||
Map<String, Object> mapTemp = (Map<String, Object>) stringObjectMap.get("_source");
|
||||
//格式化时间字段
|
||||
solveTime(mapTemp);
|
||||
mapList.add(mapTemp);
|
||||
List<OSSFile> fileList = new ArrayList<>();
|
||||
mapTemp.entrySet().forEach(entry -> {
|
||||
//下拉选处理数据字典
|
||||
bussDocumentLibraryEOService.treeDictItem(categoryList, entry, treeFieldList, (String) map.get("cut"));
|
||||
});
|
||||
|
||||
//下拉单选和下拉多选数据字典处理
|
||||
mapTemp.entrySet().forEach(entry -> {
|
||||
//下拉单选和下拉多选数据字典处理
|
||||
if (fieldPullList.contains(entry.getKey())) {
|
||||
//下拉选处理数据字典
|
||||
bussDocumentLibraryEOService.dictItem(sysDictItems, entry, onlCgformFieldList, (String) map.get("cut"));
|
||||
}
|
||||
|
||||
//处理文件
|
||||
if(FieldFileList.contains(entry.getKey())){
|
||||
List<OSSFile> fileInfos = iOSSFileService.getFileInfos((String) entry.getValue());
|
||||
if (fileInfos.size() > 0) {
|
||||
for (OSSFile fileInfo : fileInfos) {
|
||||
fileList.add(fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
mapTemp.put("file_name",fileList);
|
||||
|
||||
//下拉单选和下拉多选数据字典处理
|
||||
// mapTemp.entrySet().forEach(entry -> {
|
||||
// if (fieldPullList.contains(entry.getKey())) {
|
||||
// //下拉选处理数据字典
|
||||
// bussDocumentLibraryEOService.dictItem(sysDictItems, entry, onlCgformFieldList, (String) map.get("cut"));
|
||||
// }
|
||||
// });
|
||||
}
|
||||
IPage page = new Page(Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString()));
|
||||
page.setTotal(Long.parseLong(String.valueOf(((Map) search.get("hits")).get("total"))));
|
||||
@@ -176,5 +215,28 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
return page;
|
||||
}
|
||||
|
||||
private void solveTime(Map<String, Object> mapTemp) {
|
||||
String implementTime = (String) mapTemp.get("implement_time");
|
||||
String issueTime = (String) mapTemp.get("issue_time");
|
||||
if(StringUtils.isNotBlank(implementTime)){
|
||||
mapTemp.put("implement_time",implementTime.split(" ")[0]);
|
||||
}
|
||||
if(StringUtils.isNotBlank(issueTime)){
|
||||
mapTemp.put("issue_time",issueTime.split(" ")[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String ids) {
|
||||
for (String id : ids.split(",")) {
|
||||
jeroElasticsearchTemplate.delete(SearchEnum.INDEX_NAME_DOCUMENT.getValue(),SearchEnum.TYPE_NAME_DOCUMENT.getValue(),id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
jeroElasticsearchTemplate.removeIndex(SearchEnum.INDEX_NAME_DOCUMENT.getValue());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -18,4 +18,7 @@ public interface IDocumentSearchService {
|
||||
|
||||
IPage getInfoList(Map<String, Object> map);
|
||||
|
||||
void deleteById(String ids);
|
||||
void deleteAll();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user