搜索--时间搜索改为时间范围搜索
This commit is contained in:
+45
-15
@@ -104,7 +104,11 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文档库列表
|
||||||
|
* @param map
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IPage getInfoList(Map<String, Object> map) {
|
public IPage getInfoList(Map<String, Object> map) {
|
||||||
boolean flagTemp = jeroElasticsearchTemplate.indexExists(SearchEnum.INDEX_NAME_DOCUMENT.getValue());
|
boolean flagTemp = jeroElasticsearchTemplate.indexExists(SearchEnum.INDEX_NAME_DOCUMENT.getValue());
|
||||||
@@ -126,16 +130,21 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
List<String> inputFieldList = inputOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
List<String> inputFieldList = inputOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||||
inputFieldList.add("file_text");
|
inputFieldList.add("file_text");
|
||||||
//下拉,树形,日期等字段
|
|
||||||
|
//下拉,树形,等字段
|
||||||
List<OnlCgformField> otherOnlCgformFieldList = fieldList.stream()
|
List<OnlCgformField> otherOnlCgformFieldList = fieldList.stream()
|
||||||
.filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType())//下拉单选
|
.filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType())//下拉单选
|
||||||
|| FieldTypeEnum.PULL_MORE.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()))//树形
|
|| FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType()))//树形
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
List<String> otherFieldList = otherOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
List<String> otherFieldList = otherOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||||
|
|
||||||
|
//日期字段
|
||||||
|
List<OnlCgformField> dateOnlCgformFieldList = fieldList.stream()
|
||||||
|
.filter(e -> FieldTypeEnum.DATE_SINGLE.getValue().equals(e.getFieldShowType()))//日期单选
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<String> dateFieldList = dateOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||||
|
|
||||||
//过滤出下拉选
|
//过滤出下拉选
|
||||||
List<OnlCgformField> onlCgformFieldList = fieldList.stream()
|
List<OnlCgformField> onlCgformFieldList = fieldList.stream()
|
||||||
.filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType())
|
.filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType())
|
||||||
@@ -161,11 +170,11 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
JSONArray must = new JSONArray();
|
JSONArray must = new JSONArray();
|
||||||
//处理首次查询条件
|
//处理首次查询条件
|
||||||
if (ObjectUtils.isNotEmpty(mapOne)) {
|
if (ObjectUtils.isNotEmpty(mapOne)) {
|
||||||
queryCondition(mapOne, inputFieldList, otherFieldList, must);
|
queryCondition(mapOne, inputFieldList, otherFieldList,dateFieldList, must);
|
||||||
}
|
}
|
||||||
//处理二次查询条件
|
//处理二次查询条件
|
||||||
if (ObjectUtils.isNotEmpty(mapTwo)) {
|
if (ObjectUtils.isNotEmpty(mapTwo)) {
|
||||||
queryCondition(mapTwo, inputFieldList, otherFieldList, must);
|
queryCondition(mapTwo, inputFieldList, otherFieldList,dateFieldList, must);
|
||||||
}
|
}
|
||||||
//处理ids
|
//处理ids
|
||||||
JSONArray should = new JSONArray();
|
JSONArray should = new JSONArray();
|
||||||
@@ -179,7 +188,6 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
should.add(queryMap);
|
should.add(queryMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//列表
|
|
||||||
//封装查询条件
|
//封装查询条件
|
||||||
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(must, null, should);
|
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(must, null, should);
|
||||||
//1. 封装分页和字段值
|
//1. 封装分页和字段值
|
||||||
@@ -206,7 +214,6 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
} else {
|
} else {
|
||||||
mapTemp.put("collectFlag", "0");
|
mapTemp.put("collectFlag", "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理订阅
|
//处理订阅
|
||||||
LambdaQueryWrapper<OnlCgformSubscribe> lambdaQueryWrapperTemp = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<OnlCgformSubscribe> lambdaQueryWrapperTemp = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapperTemp.in(OnlCgformSubscribe::getDocumentId, mapTemp.get("id"));
|
lambdaQueryWrapperTemp.in(OnlCgformSubscribe::getDocumentId, mapTemp.get("id"));
|
||||||
@@ -216,7 +223,6 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
} else {
|
} else {
|
||||||
mapTemp.put("subscribeFlag", "0");
|
mapTemp.put("subscribeFlag", "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
//格式化时间字段
|
//格式化时间字段
|
||||||
solveTime(mapTemp);
|
solveTime(mapTemp);
|
||||||
mapList.add(mapTemp);
|
mapList.add(mapTemp);
|
||||||
@@ -229,7 +235,6 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
if (fieldPullList.contains(entry.getKey())) {
|
if (fieldPullList.contains(entry.getKey())) {
|
||||||
bussDocumentLibraryEOService.dictItem(sysDictItems, entry, (String) map.get("cut"), fieldList);
|
bussDocumentLibraryEOService.dictItem(sysDictItems, entry, (String) map.get("cut"), fieldList);
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理文件
|
//处理文件
|
||||||
if (FieldFileList.contains(entry.getKey())) {
|
if (FieldFileList.contains(entry.getKey())) {
|
||||||
List<OSSFile> fileInfos = iOSSFileService.getFileInfos((String) entry.getValue());
|
List<OSSFile> fileInfos = iOSSFileService.getFileInfos((String) entry.getValue());
|
||||||
@@ -250,9 +255,11 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void queryCondition(Map<String, Object> mapOne, List<String> inputFieldList, List<String> otherFieldList, JSONArray must) {
|
private void queryCondition(Map<String, Object> mapOne, List<String> inputFieldList,
|
||||||
|
List<String> otherFieldList, List<String> dateFieldList,JSONArray must) {
|
||||||
Map<String, Object> inputMap = new HashMap<>();//条件内容为输入框的
|
Map<String, Object> inputMap = new HashMap<>();//条件内容为输入框的
|
||||||
Map<String, Object> otherMap = new HashMap<>();//条件内容为下拉,日期,树形
|
Map<String, Object> otherMap = new HashMap<>();//条件内容为下拉,日期,树形
|
||||||
|
Map<String, Object> dateMap = new HashMap<>();//条件内容为下拉,树形
|
||||||
//区分输入框和下拉,树形,日期等字段
|
//区分输入框和下拉,树形,日期等字段
|
||||||
if (ObjectUtils.isNotEmpty(mapOne)) {
|
if (ObjectUtils.isNotEmpty(mapOne)) {
|
||||||
for (Map.Entry<String, Object> entry : mapOne.entrySet()) {
|
for (Map.Entry<String, Object> entry : mapOne.entrySet()) {
|
||||||
@@ -265,6 +272,9 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
if (otherFieldList.contains(key)) {
|
if (otherFieldList.contains(key)) {
|
||||||
otherMap.put(key, value);
|
otherMap.put(key, value);
|
||||||
}
|
}
|
||||||
|
if(dateFieldList.contains(key)){
|
||||||
|
dateMap.put(key, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +294,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//封装下拉,树形,日期查询条件
|
//封装下拉,树形查询条件
|
||||||
if (ObjectUtils.isNotEmpty(otherMap)) {
|
if (ObjectUtils.isNotEmpty(otherMap)) {
|
||||||
for (Map.Entry<String, Object> entry : otherMap.entrySet()) {
|
for (Map.Entry<String, Object> entry : otherMap.entrySet()) {
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
@@ -300,8 +310,31 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//封装时间类型字段查询(时间范围)
|
||||||
|
if (ObjectUtils.isNotEmpty(dateMap)) {
|
||||||
|
for (Map.Entry<String, Object> entry : dateMap.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
String value = (String) entry.getValue();
|
||||||
|
Map<String, Object> queryMap = new HashMap<>();
|
||||||
|
Map<String, Object> queryMapTemp = new HashMap<>();
|
||||||
|
if (ObjectUtils.isNotEmpty(value)) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("gte", value.split(",")[0]);
|
||||||
|
map.put("lte", value.split(",")[1]);
|
||||||
|
map.put("format", "yyyy-MM-dd");
|
||||||
|
queryMap.put(key, map);
|
||||||
|
queryMapTemp.put("range", queryMap);
|
||||||
|
must.add(queryMapTemp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全文
|
||||||
|
* @param searchVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IPage getFullTextInfoList(SearchVO searchVO) {
|
public IPage getFullTextInfoList(SearchVO searchVO) {
|
||||||
if(StringUtils.isBlank(searchVO.getSelectValue())){
|
if(StringUtils.isBlank(searchVO.getSelectValue())){
|
||||||
@@ -321,7 +354,6 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
}
|
}
|
||||||
String selectValue = searchVO.getSelectValue();
|
String selectValue = searchVO.getSelectValue();
|
||||||
String selectValueTwo = searchVO.getSelectValueTwo();
|
String selectValueTwo = searchVO.getSelectValueTwo();
|
||||||
//不查询高亮字段
|
|
||||||
//1. 需要查询的字段
|
//1. 需要查询的字段
|
||||||
List<String> fieldList = new ArrayList<>();
|
List<String> fieldList = new ArrayList<>();
|
||||||
fieldList.add("module_type");
|
fieldList.add("module_type");
|
||||||
@@ -408,7 +440,6 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
JSONArray jsonArraySort = new JSONArray();
|
JSONArray jsonArraySort = new JSONArray();
|
||||||
jsonArraySort.add(querySort);
|
jsonArraySort.add(querySort);
|
||||||
|
|
||||||
//全部
|
|
||||||
//1. 条件,分页
|
//1. 条件,分页
|
||||||
JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(null,
|
JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(null,
|
||||||
jsonObject,
|
jsonObject,
|
||||||
@@ -435,7 +466,6 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
//二次搜索结果
|
//二次搜索结果
|
||||||
List<Map<String, Object>> mapListTwo = new ArrayList<>();
|
List<Map<String, Object>> mapListTwo = new ArrayList<>();
|
||||||
|
|
||||||
List<Map<String, Object>> listNew = new ArrayList<>();
|
|
||||||
for (Map<String, Object> stringObjectMap : list) {
|
for (Map<String, Object> stringObjectMap : list) {
|
||||||
Map<String, Object> mapSource = (Map<String, Object>) stringObjectMap.get("_source");
|
Map<String, Object> mapSource = (Map<String, Object>) stringObjectMap.get("_source");
|
||||||
if (StringUtils.isNotBlank(selectValueTwo)) {
|
if (StringUtils.isNotBlank(selectValueTwo)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user