文档库--文档库二次搜索
This commit is contained in:
+2
-2
@@ -65,8 +65,8 @@ public class DocumentSearchController {
|
||||
}
|
||||
|
||||
@ApiOperation(value="列表查询", notes="列表查询")
|
||||
@GetMapping(value = "/getInfoList")
|
||||
public Result<?> getInfoList(@RequestParam Map<String,Object> map) {
|
||||
@PostMapping(value = "/getInfoList")
|
||||
public Result<?> getInfoList(@RequestBody Map<String,Object> map) {
|
||||
IPage infoList = iDocumentSearchService.getInfoList(map);
|
||||
return Result.OK(infoList);
|
||||
}
|
||||
|
||||
+224
-44
@@ -1,5 +1,6 @@
|
||||
package com.jero.modules.searchcenter.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -120,58 +121,28 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
.filter(e -> FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Map<String, Object> inputMap = new HashMap<>();//条件内容为输入框的
|
||||
Map<String, Object> otherMap = new HashMap<>();//条件内容为下拉,日期,树形
|
||||
//区分输入框和下拉,树形,日期等字段
|
||||
if (ObjectUtils.isNotEmpty(map)) {
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
if (inputFieldList.contains(key)) {
|
||||
inputMap.put(key, value);
|
||||
}
|
||||
if (otherFieldList.contains(key)) {
|
||||
otherMap.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONArray should = new JSONArray();
|
||||
String one = (String)map.get("mapOne");
|
||||
String two = (String)map.get("mapTwo");
|
||||
Map<String,Object> mapOne = JSON.parseObject(one);
|
||||
Map<String,Object> mapTwo = JSON.parseObject(two);
|
||||
JSONArray must = new JSONArray();
|
||||
//封装输入框查询条件
|
||||
if (ObjectUtils.isNotEmpty(inputMap)) {
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
for (Map.Entry<String, Object> entry : inputMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
if(ObjectUtils.isNotEmpty(value)){
|
||||
Map<String, Object> queryMapTemp = new HashMap<>();
|
||||
queryMapTemp.put(key, value);
|
||||
queryMap.put("match", queryMapTemp);
|
||||
must.add(queryMap);
|
||||
}
|
||||
}
|
||||
//处理首次查询条件
|
||||
if(ObjectUtils.isNotEmpty(mapOne)){
|
||||
queryCondition(mapOne, inputFieldList, otherFieldList, must);
|
||||
}
|
||||
//封装下拉,树形,日期查询条件
|
||||
if (ObjectUtils.isNotEmpty(otherMap)) {
|
||||
for (Map.Entry<String, Object> entry : otherMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
if(ObjectUtils.isNotEmpty(value)){
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
Map<String, Object> queryMapTemp = new HashMap<>();
|
||||
queryMapTemp.put(key, value);
|
||||
queryMap.put("match", queryMapTemp);
|
||||
must.add(queryMap);
|
||||
}
|
||||
}
|
||||
//处理二次查询条件
|
||||
if(ObjectUtils.isNotEmpty(mapTwo)){
|
||||
queryCondition(mapTwo, inputFieldList, otherFieldList, must);
|
||||
}
|
||||
//列表
|
||||
//封装查询条件
|
||||
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(must, null, null);
|
||||
//1. 封装分页和字段值
|
||||
JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(sourceList, jsonObject, null, null, Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString()));
|
||||
JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(sourceList, jsonObject, null, null,
|
||||
Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString()));
|
||||
//2. 数据查询
|
||||
JSONObject search = jeroElasticsearchTemplate.search(SearchEnum.INDEX_NAME_DOCUMENT.getValue(), SearchEnum.TYPE_NAME_DOCUMENT.getValue(), queryObject);
|
||||
JSONObject search = jeroElasticsearchTemplate.search(SearchEnum.INDEX_NAME_DOCUMENT.getValue(),
|
||||
SearchEnum.TYPE_NAME_DOCUMENT.getValue(), queryObject);
|
||||
|
||||
|
||||
//处理数据字典
|
||||
@@ -213,6 +184,215 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
||||
return page;
|
||||
}
|
||||
|
||||
private void queryCondition(Map<String, Object> mapOne, List<String> inputFieldList, List<String> otherFieldList, JSONArray must) {
|
||||
Map<String, Object> inputMap = new HashMap<>();//条件内容为输入框的
|
||||
Map<String, Object> otherMap = new HashMap<>();//条件内容为下拉,日期,树形
|
||||
//区分输入框和下拉,树形,日期等字段
|
||||
if (ObjectUtils.isNotEmpty(mapOne)) {
|
||||
for (Map.Entry<String, Object> entry : mapOne.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
//处理二次搜索中选择列表数据
|
||||
if("ids".equals(key) && ObjectUtils.isNotEmpty(value)){
|
||||
inputMap.put("id", value);
|
||||
}
|
||||
if (inputFieldList.contains(key)) {
|
||||
inputMap.put(key, value);
|
||||
}
|
||||
if (otherFieldList.contains(key)) {
|
||||
otherMap.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//封装输入框查询条件
|
||||
if (ObjectUtils.isNotEmpty(inputMap)) {
|
||||
for (Map.Entry<String, Object> entry : inputMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = (String )entry.getValue();
|
||||
if(ObjectUtils.isNotEmpty(value)){
|
||||
for (String s : value.split(",")) {
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
Map<String, Object> queryMapTemp = new HashMap<>();
|
||||
queryMapTemp.put(key, s);
|
||||
queryMap.put("match", queryMapTemp);
|
||||
must.add(queryMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//封装下拉,树形,日期查询条件
|
||||
if (ObjectUtils.isNotEmpty(otherMap)) {
|
||||
for (Map.Entry<String, Object> entry : otherMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = (String) entry.getValue();
|
||||
if(ObjectUtils.isNotEmpty(value)){
|
||||
for (String s : value.split(",")) {
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
Map<String, Object> queryMapTemp = new HashMap<>();
|
||||
queryMapTemp.put(key, s);
|
||||
queryMap.put("match", queryMapTemp);
|
||||
must.add(queryMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// public IPage getInfoList(Map<String, Object> mapOne,Map<String,Object> mapTwoTwo) {
|
||||
// boolean flagTemp = jeroElasticsearchTemplate.indexExists(SearchEnum.INDEX_NAME_DOCUMENT.getValue());
|
||||
// if(!flagTemp){
|
||||
// return new Page(Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString()));
|
||||
// }
|
||||
// //文档库所有的字段
|
||||
// List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue());
|
||||
// //需要查询的列表字段
|
||||
// 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())
|
||||
// || FieldTypeEnum.TEXT_NUMBER.getValue().equals(e.getFieldShowType()))
|
||||
// .collect(Collectors.toList());
|
||||
// List<String> inputFieldList = inputOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||
// //下拉,树形,日期等字段
|
||||
// List<OnlCgformField> otherOnlCgformFieldList = fieldList.stream()
|
||||
// .filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType())//下拉单选
|
||||
// || FieldTypeEnum.PULL_MORE.getValue().equals(e.getFieldShowType())//下拉多选
|
||||
// || FieldTypeEnum.DATE_SINGLE.getValue().equals(e.getFieldShowType())//日期单选
|
||||
// || FieldTypeEnum.DATE_MORE.getValue().equals(e.getFieldShowType())//日期多选
|
||||
// || FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType()))//树形
|
||||
// .collect(Collectors.toList());
|
||||
// List<String> otherFieldList = otherOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||
//
|
||||
// //过滤出下拉选
|
||||
// List<OnlCgformField> onlCgformFieldList = fieldList.stream()
|
||||
// .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());
|
||||
//
|
||||
// //过滤出树形字段
|
||||
// List<OnlCgformField> treeFieldList = fieldList.stream()
|
||||
// .filter(e -> FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType()))
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
// Map<String, Object> inputMap = new HashMap<>();//条件内容为输入框的
|
||||
// Map<String, Object> otherMap = new HashMap<>();//条件内容为下拉,日期,树形
|
||||
// //区分输入框和下拉,树形,日期等字段
|
||||
// if (ObjectUtils.isNotEmpty(map)) {
|
||||
// for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
// String key = entry.getKey();
|
||||
// Object value = entry.getValue();
|
||||
// //二次搜索中选择列表数据的情况
|
||||
// if("ids".equals(key) && StringUtils.isNotBlank((String)value)){
|
||||
// inputMap.put("id", value);
|
||||
// }
|
||||
// if (inputFieldList.contains(key)) {
|
||||
// inputMap.put(key, value);
|
||||
// }
|
||||
// if (otherFieldList.contains(key)) {
|
||||
// otherMap.put(key, value);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// JSONArray should = new JSONArray();
|
||||
// JSONArray must = new JSONArray();
|
||||
// //封装输入框查询条件
|
||||
// if (ObjectUtils.isNotEmpty(inputMap)) {
|
||||
// for (Map.Entry<String, Object> entry : inputMap.entrySet()) {
|
||||
//
|
||||
// String key = entry.getKey();
|
||||
// String value = (String )entry.getValue();
|
||||
//// value = "车,机动";
|
||||
// if(ObjectUtils.isNotEmpty(value)){
|
||||
// for (String s : value.split(",")) {
|
||||
// Map<String, Object> queryMap = new HashMap<>();
|
||||
// Map<String, Object> queryMapTemp = new HashMap<>();
|
||||
// queryMapTemp.put(key, s);
|
||||
// queryMap.put("match", queryMapTemp);
|
||||
// must.add(queryMap);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //封装下拉,树形,日期查询条件
|
||||
// if (ObjectUtils.isNotEmpty(otherMap)) {
|
||||
// for (Map.Entry<String, Object> entry : otherMap.entrySet()) {
|
||||
// String key = entry.getKey();
|
||||
// String value = (String) entry.getValue();
|
||||
//// value = "1";
|
||||
// if(ObjectUtils.isNotEmpty(value)){
|
||||
// for (String s : value.split(",")) {
|
||||
// Map<String, Object> queryMap = new HashMap<>();
|
||||
// Map<String, Object> queryMapTemp = new HashMap<>();
|
||||
// queryMapTemp.put(key, s);
|
||||
// queryMap.put("match", queryMapTemp);
|
||||
// must.add(queryMap);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //列表
|
||||
// //封装查询条件
|
||||
// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(must, null, null);
|
||||
// //1. 封装分页和字段值
|
||||
// JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(sourceList, jsonObject, null, null, Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString()));
|
||||
// //2. 数据查询
|
||||
// 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();//树形数据字典
|
||||
// List<Map<String, Object>> list = (List<Map<String, Object>>) (((Map) search.get("hits")).get("hits"));
|
||||
// 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"));
|
||||
//
|
||||
// //下拉单选和下拉多选数据字典处理
|
||||
// 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);
|
||||
// }
|
||||
// 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"))));
|
||||
// page.setRecords(mapList);
|
||||
// return page;
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public IPage getFullTextInfoList(SearchVO searchVO) {
|
||||
|
||||
Reference in New Issue
Block a user