From 82e5a2e374feecadac8d69de5702b102f4819626 Mon Sep 17 00:00:00 2001 From: zhn <947514737@qq.com> Date: Fri, 22 Dec 2023 16:49:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E4=B8=AD=E5=BF=83-=E6=AE=B5?= =?UTF-8?q?=E8=90=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DocumentSearchServiceImpl.java | 1543 +++-------------- 1 file changed, 260 insertions(+), 1283 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java index 15d747491..455c2ea5d 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java @@ -1237,6 +1237,23 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { */ @Override public IPage getParagraphInfoList(Map map) { + //文档库所有的字段 + List fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue()); + //下拉,树形,等字段 + List otherOnlCgformFieldList = fieldList.stream() + .filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType())//下拉单选 + || FieldTypeEnum.PULL_MORE.getValue().equals(e.getFieldShowType())//下拉多选 + || FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType())//树形 + || FieldTypeEnum.PERSON.getValue().equals(e.getFieldShowType()))//人员选择 + .collect(Collectors.toList()); + List otherFieldList = otherOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); + + //日期字段 + List dateOnlCgformFieldList = fieldList.stream() + .filter(e -> FieldTypeEnum.DATE_SINGLE.getValue().equals(e.getFieldShowType()))//日期单选 + .collect(Collectors.toList()); + List dateFieldList = dateOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); + //指定module_type_flag= WDK JSONArray queryJsonMust = new JSONArray(); Map mapModule = new HashMap<>(); @@ -1271,8 +1288,6 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { if (!flagTemp) { return new Page(Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString())); } - //文档库所有的字段 - List fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue()); //输入框字段 List inputOnlCgformFieldList = fieldList.stream() .filter(e -> FieldTypeEnum.TEXT_STRING.getValue().equals(e.getFieldShowType()) @@ -1286,118 +1301,30 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { Map mapOne = (Map) map.get("mapOne"); Map mapTwo = (Map) map.get("mapTwo"); - JSONArray queryMapJson = new JSONArray(); - JSONArray queryMapJsonTemp = new JSONArray(); - JSONArray queryMapJsonTwo = new JSONArray(); JSONArray queryMapJsonThree = new JSONArray(); JSONArray queryMapJsonAll = new JSONArray(); - //首次查询条件 + + + JSONArray must = new JSONArray(); + //处理首次查询条件 if (ObjectUtils.isNotEmpty(mapOne)) { -// if(StringUtils.isNotBlank((String)mapOne.get("title")) -// || StringUtils.isNotBlank((String)mapOne.get("serial_number"))){ -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// queryMapTemp.put("flag",SEARCH_FLAG ); -// queryMap.put("match_phrase", queryMapTemp); -// queryMapJsonTemp.add(queryMap); -// } - for (Map.Entry entry : mapOne.entrySet()) { - String key = entry.getKey(); - String value = (String) entry.getValue(); - if("serial_number".equals(key) || "title".equals(key) || "file_text".equals(key)){ - value = value.toLowerCase(); - } - if (ObjectUtils.isNotEmpty(value)) { - for (String s : value.split(",")) { - Map queryMap = new HashMap<>(); - Map queryMapTemp = new HashMap<>(); - Map queryMap3 = new HashMap<>(); - //特殊处理编号字段 - if (key.equals("serial_number") || key.equals("title") || key.equals("file_text")){ - queryMapTemp.put(key, "*" + s + "*"); - queryMap.put("wildcard",queryMapTemp); - queryMapJson.add(queryMap); - } else { - queryMap3.put("query",s); -// queryMap3.put("minimum_should_match",2); - queryMapTemp.put(key, queryMap3); - queryMap.put("match", queryMapTemp); - queryMapJson.add(queryMap); - } - } - } -// if (ObjectUtils.isNotEmpty(value)) { -// for (String s : value.split(",")) { -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// Map queryMap3 = new HashMap<>(); -// queryMap3.put("query",s); -//// queryMap3.put("minimum_should_match",2); -// queryMapTemp.put(key, queryMap3); -// queryMap.put("match", queryMapTemp); -// queryMapJson.add(queryMap); -// } -// } - } - if(CollectionUtils.isNotEmpty(queryMapJsonTemp)){ - JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJsonTemp, null, null); - queryMapJsonAll.add(jsonObject); - } - if(CollectionUtils.isNotEmpty(queryMapJson)){ - JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, null, null); - queryMapJsonAll.add(jsonObject); - } - if(CollectionUtils.isNotEmpty(queryJsonMust)){ - JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryJsonMust, null, null); - queryMapJsonAll.add(jsonObject); - } + queryCondition(mapOne, inputFieldList, otherFieldList,dateFieldList, must); + } + //处理二次查询条件 + if (ObjectUtils.isNotEmpty(mapTwo)) { + queryCondition(mapTwo, inputFieldList, otherFieldList,dateFieldList, must); + } + + if(CollectionUtils.isNotEmpty(must)){ + JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(must, null, null); + queryMapJsonAll.add(jsonObject); + } + if(CollectionUtils.isNotEmpty(queryJsonMust)){ + JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryJsonMust, null, null); + queryMapJsonAll.add(jsonObject); } String ids = (String) mapTwo.get("ids"); - //二次查询条件 - if (ObjectUtils.isNotEmpty(mapTwo)) { - mapTwo.remove("ids"); - for (Map.Entry entry : mapTwo.entrySet()) { - String key = entry.getKey(); - String value = (String) entry.getValue(); - if (ObjectUtils.isNotEmpty(value)) { - for (String s : value.split(",")) { - Map queryMap = new HashMap<>(); - Map queryMapTemp = new HashMap<>(); - Map queryMap3 = new HashMap<>(); - //特殊处理编号字段 - if (key.equals("serial_number")){ - queryMapTemp.put(key, "*" + s + "*"); - queryMap.put("wildcard",queryMapTemp); - queryMapJsonTwo.add(queryMap); - } else { - queryMap3.put("query",s); -// queryMap3.put("minimum_should_match",2); - queryMapTemp.put(key, queryMap3); - queryMap.put("match", queryMapTemp); - queryMapJsonTwo.add(queryMap); - } - } - } -// if (ObjectUtils.isNotEmpty(value)) { -// for (String s : value.split(",")) { -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// Map queryMap3 = new HashMap<>(); -// queryMap3.put("query",s); -//// queryMap3.put("minimum_should_match",2); -// queryMapTemp.put(key, queryMap3); -// queryMap.put("match", queryMapTemp); -// queryMapJsonTwo.add(queryMap); -// } -// } - } - if(CollectionUtils.isNotEmpty(queryMapJsonTwo)){ - JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJsonTwo, null, null); - queryMapJsonAll.add(jsonObject); - } - } - //ids查询条件 if (StringUtils.isNotBlank(ids)) { for (String s : ids.split(",")) { @@ -1415,11 +1342,6 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { //排序 JSONObject sort = new JSONObject(); -// Map mapSort = new HashMap<>(); -// Map mapSortTemp = new HashMap<>(); -// mapSort.put("order","asc"); -// mapSortTemp.put("file_sort.keyword",mapSort); -// sort.putAll(mapSortTemp); Map score = new HashMap<>(); Map score1 = new HashMap<>(); @@ -1460,6 +1382,231 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { pageNo, pageSize, paragraphFlag,(String) map.get("cut"),sort,queryJsonMustNot); return iPage; } +// @Override +// public IPage getParagraphInfoList(Map map) { +// //指定module_type_flag= WDK +// JSONArray queryJsonMust = new JSONArray(); +// Map mapModule = new HashMap<>(); +// Map mapModule1 = new HashMap<>(); +// Map mapModule2 = new HashMap<>(); +// mapModule.put("query", "WDK"); +// mapModule1.put("module_type_flag", mapModule); +// mapModule2.put("match", mapModule1); +// queryJsonMust.add(mapModule2); +// //段落, 有条件的时候,查询的数据中不含有魑的数据 +// JSONArray queryJsonMustNot = new JSONArray(); +// if(ObjectUtils.isEmpty(map.get("mapOne"))){ +// ((Map) map.get("mapOne")).put("flag",SEARCH_FLAG); +// }else{ +// Map mapTemp = new HashMap<>(); +// Map map1 = new HashMap<>(); +// Map map2 = new HashMap<>(); +// mapTemp.put("query", SEARCH_FLAG); +// map1.put("flag", mapTemp); +// map2.put("match", map1); +// queryJsonMustNot.add(map2); +// } +// String cut = (String) map.get("cut"); +// //module_type 代表文档库的段落 +// //判断索引是否存在 +// 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())); +// } +// //文档库所有的字段 +// List fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue()); +// //输入框字段 +// List inputOnlCgformFieldList = fieldList.stream() +// .filter(e -> FieldTypeEnum.TEXT_STRING.getValue().equals(e.getFieldShowType()) +// || FieldTypeEnum.TEXT_NUMBER.getValue().equals(e.getFieldShowType())) +// .collect(Collectors.toList()); +// List inputFieldList = inputOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); +// inputFieldList.add("file_text");//在输入框的类型中添加正文字段 +// inputFieldList.add("flag");//标识(默认展示基础数据,不展示文件数据) +// +// +// Map mapOne = (Map) map.get("mapOne"); +// Map mapTwo = (Map) map.get("mapTwo"); +// +// JSONArray queryMapJson = new JSONArray(); +// JSONArray queryMapJsonTemp = new JSONArray(); +// JSONArray queryMapJsonTwo = new JSONArray(); +// JSONArray queryMapJsonThree = new JSONArray(); +// JSONArray queryMapJsonAll = new JSONArray(); +// //首次查询条件 +// if (ObjectUtils.isNotEmpty(mapOne)) { +//// if(StringUtils.isNotBlank((String)mapOne.get("title")) +//// || StringUtils.isNotBlank((String)mapOne.get("serial_number"))){ +//// Map queryMap = new HashMap<>(); +//// Map queryMapTemp = new HashMap<>(); +//// queryMapTemp.put("flag",SEARCH_FLAG ); +//// queryMap.put("match_phrase", queryMapTemp); +//// queryMapJsonTemp.add(queryMap); +//// } +// for (Map.Entry entry : mapOne.entrySet()) { +// String key = entry.getKey(); +// String value = (String) entry.getValue(); +// if("serial_number".equals(key) || "title".equals(key) || "file_text".equals(key)){ +// value = value.toLowerCase(); +// } +// if (ObjectUtils.isNotEmpty(value)) { +// for (String s : value.split(",")) { +// Map queryMap = new HashMap<>(); +// Map queryMapTemp = new HashMap<>(); +// Map queryMap3 = new HashMap<>(); +// //特殊处理编号字段 +// if (key.equals("serial_number") || key.equals("title") || key.equals("file_text")){ +// queryMapTemp.put(key, "*" + s + "*"); +// queryMap.put("wildcard",queryMapTemp); +// queryMapJson.add(queryMap); +// } else { +// queryMap3.put("query",s); +//// queryMap3.put("minimum_should_match",2); +// queryMapTemp.put(key, queryMap3); +// queryMap.put("match", queryMapTemp); +// queryMapJson.add(queryMap); +// } +// } +// } +//// if (ObjectUtils.isNotEmpty(value)) { +//// for (String s : value.split(",")) { +//// Map queryMap = new HashMap<>(); +//// Map queryMapTemp = new HashMap<>(); +//// Map queryMap3 = new HashMap<>(); +//// queryMap3.put("query",s); +////// queryMap3.put("minimum_should_match",2); +//// queryMapTemp.put(key, queryMap3); +//// queryMap.put("match", queryMapTemp); +//// queryMapJson.add(queryMap); +//// } +//// } +// } +// if(CollectionUtils.isNotEmpty(queryMapJsonTemp)){ +// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJsonTemp, null, null); +// queryMapJsonAll.add(jsonObject); +// } +// if(CollectionUtils.isNotEmpty(queryMapJson)){ +// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, null, null); +// queryMapJsonAll.add(jsonObject); +// } +// if(CollectionUtils.isNotEmpty(queryJsonMust)){ +// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryJsonMust, null, null); +// queryMapJsonAll.add(jsonObject); +// } +// } +// +// String ids = (String) mapTwo.get("ids"); +// //二次查询条件 +// if (ObjectUtils.isNotEmpty(mapTwo)) { +// mapTwo.remove("ids"); +// for (Map.Entry entry : mapTwo.entrySet()) { +// String key = entry.getKey(); +// String value = (String) entry.getValue(); +// if (ObjectUtils.isNotEmpty(value)) { +// for (String s : value.split(",")) { +// Map queryMap = new HashMap<>(); +// Map queryMapTemp = new HashMap<>(); +// Map queryMap3 = new HashMap<>(); +// //特殊处理编号字段 +// if (key.equals("serial_number")){ +// queryMapTemp.put(key, "*" + s + "*"); +// queryMap.put("wildcard",queryMapTemp); +// queryMapJsonTwo.add(queryMap); +// } else { +// queryMap3.put("query",s); +//// queryMap3.put("minimum_should_match",2); +// queryMapTemp.put(key, queryMap3); +// queryMap.put("match", queryMapTemp); +// queryMapJsonTwo.add(queryMap); +// } +// } +// } +//// if (ObjectUtils.isNotEmpty(value)) { +//// for (String s : value.split(",")) { +//// Map queryMap = new HashMap<>(); +//// Map queryMapTemp = new HashMap<>(); +//// Map queryMap3 = new HashMap<>(); +//// queryMap3.put("query",s); +////// queryMap3.put("minimum_should_match",2); +//// queryMapTemp.put(key, queryMap3); +//// queryMap.put("match", queryMapTemp); +//// queryMapJsonTwo.add(queryMap); +//// } +//// } +// } +// if(CollectionUtils.isNotEmpty(queryMapJsonTwo)){ +// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJsonTwo, null, null); +// queryMapJsonAll.add(jsonObject); +// } +// } +// +// //ids查询条件 +// if (StringUtils.isNotBlank(ids)) { +// for (String s : ids.split(",")) { +// Map queryMap = new HashMap<>(); +// Map queryMapTemp = new HashMap<>(); +// queryMapTemp.put("id", s); +// queryMap.put("match_phrase", queryMapTemp); +// queryMapJsonThree.add(queryMap); +// } +// } +// if(CollectionUtils.isNotEmpty(queryMapJsonThree)){ +// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJsonThree); +// queryMapJsonAll.add(jsonObject); +// } +// +// //排序 +// JSONObject sort = new JSONObject(); +//// Map mapSort = new HashMap<>(); +//// Map mapSortTemp = new HashMap<>(); +//// mapSort.put("order","asc"); +//// mapSortTemp.put("file_sort.keyword",mapSort); +//// sort.putAll(mapSortTemp); +// +// Map score = new HashMap<>(); +// Map score1 = new HashMap<>(); +// score.put("order","desc"); +// score1.put("_score",score); +// sort.putAll(score1); +// +// int pageNo = Integer.parseInt(map.get("pageNo").toString()); +// int pageSize = Integer.parseInt(map.get("pageSize").toString()); +// //判断第一次传参和第二次传参 inputFieldList +// String selectValue = ""; +// String selectValueTwo = ""; +// Map mapHighlight = new HashMap<>(); +// Map mapHighlight1 = new HashMap<>(); +// for (Map.Entry entry : mapOne.entrySet()) { +// String key = entry.getKey(); +// String value = (String) entry.getValue(); +// if (inputFieldList.contains(key) && StringUtils.isNotBlank(value)) { +// selectValue = value; +// highlight(mapHighlight, key); +// } +// mapHighlight1.put("fields",mapHighlight); +// } +// for (Map.Entry entry : mapTwo.entrySet()) { +// String key = entry.getKey(); +// String value = (String) entry.getValue(); +// if (inputFieldList.contains(key) && StringUtils.isNotBlank(value)) { +// selectValueTwo = value; +// highlight(mapHighlight, key); +// } +// mapHighlight1.put("fields",mapHighlight); +// } +// //段落的标识 +// String paragraphFlag = "paragraphFlag"; +// +// +// IPage iPage = getiPage(selectValue, selectValueTwo, queryMapJsonAll, mapHighlight1,null, +// pageNo, pageSize, paragraphFlag,(String) map.get("cut"),sort,queryJsonMustNot); +// return iPage; +// } private void highlight(Map mapHighlight, String key) { Map mapTemp = new HashMap<>(); @@ -1893,1173 +2040,3 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { } } - - -//--------------------------------------------------------------------------------------------------------------------------------------------------------------- -//package com.jero.modules.searchcenter.service.impl; -// -//import com.alibaba.fastjson.JSONArray; -//import com.alibaba.fastjson.JSONObject; -//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -//import com.baomidou.mybatisplus.core.metadata.IPage; -//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.jero.common.constant.enums.CutEnum; -//import com.jero.common.constant.enums.ModuleEnum; -//import com.jero.common.constant.enums.YesOrNoEnum; -//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.collection.entity.OnlCgformCollection; -//import com.jero.modules.collection.service.IOnlCgformCollectionService; -//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.searchcenter.vo.SearchVO; -//import com.jero.modules.subscribe.entity.OnlCgformSubscribe; -//import com.jero.modules.subscribe.service.IOnlCgformSubscribeService; -//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.collections.CollectionUtils; -//import org.apache.commons.lang3.ObjectUtils; -//import org.apache.commons.lang3.StringUtils; -//import org.jetbrains.annotations.NotNull; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Component; -// -//import java.util.ArrayList; -//import java.util.HashMap; -//import java.util.List; -//import java.util.Map; -//import java.util.stream.Collectors; -// -///** -// * @description -// * @date 2022/3/14 10:03 -// * @auth zhn -// */ -//@Component -//public class DocumentSearchServiceImpl implements IDocumentSearchService { -// @Autowired -// private IBussDocumentLibraryEOService iBussDocumentLibraryEOService; -// @Autowired -// private JeroElasticsearchTemplate jeroElasticsearchTemplate; -// @Autowired -// private OnlCgformFieldServiceImpl onlCgformFieldService; -// @Autowired -// private SysCategoryServiceImpl sysCategoryService; -// @Autowired -// private SysDictItemServiceImpl sysDictItemServiceImpl; -// @Autowired -// private BussDocumentLibraryEOServiceImpl bussDocumentLibraryEOService; -// @Autowired -// private IOSSFileService iOSSFileService; -// @Autowired -// private IOnlCgformCollectionService iOnlCgformCollectionService; -// @Autowired -// private IOnlCgformSubscribeService iOnlCgformSubscribeService; -// public static final String SEARCH_FLAG = "魑";//标识(es数据带此标识的代表全文和段落的数据,不带此标识的代表列表数据) -// -// -// @Override -// public List> queryCondition(String flag, String cut, String searchFlag) { -// List> mapList = iBussDocumentLibraryEOService.queryCondition(flag, cut, searchFlag); -// //搜索条件手动添加正文 -// if ("1".equals(searchFlag)) { -// int index = -1; -// for (Map objectMap : mapList) { -// index++; -// if ("中文标题".equals(objectMap.get("db_field_txt"))) { -// objectMap.put("db_field_txt", "标题"); -// } -// if ("title_en".equals(objectMap.get("db_field_name"))) { -// break; -// } -// } -// //删除英文标题 -// mapList.remove(index); -// //添加正文 -// Map map = new HashMap<>(); -// if(CutEnum.CN.getValue().equals(cut)){ -// map.put("db_field_txt", "正文"); -// }else{ -// map.put("db_field_txt", "main body"); -// } -// map.put("field_show_type", "1"); -// map.put("db_field_name", "file_text"); -// mapList.add(map); -// } -// return mapList; -// } -// -// @Override -// public List> getHeader(String flag, String cut, String searchFlag) { -// List> header = iBussDocumentLibraryEOService.getHeader(flag, cut, searchFlag); -// return header; -// } -// -// /** -// * 文档库列表 -// * @param map -// * @return -// */ -// @Override -// public IPage getInfoList(Map map) { -// 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 fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue()); -// //需要查询的列表字段 -// List hearOnlCgformFieldList = fieldList.stream() -// .filter(e -> YesOrNoEnum.YES.getValue().equals(e.getIsShowSearch())).collect(Collectors.toList()); -// List sourceList = hearOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); -// sourceList.add("id"); -// -// //输入框字段 -// List inputOnlCgformFieldList = fieldList.stream() -// .filter(e -> FieldTypeEnum.TEXT_STRING.getValue().equals(e.getFieldShowType()) -// || FieldTypeEnum.TEXT_NUMBER.getValue().equals(e.getFieldShowType()) -// || FieldTypeEnum.PERSON.getValue().equals(e.getFieldShowType())//人员选择 -// || FieldTypeEnum.STANDARD.getValue().equals(e.getFieldShowType())//标准选择 -// || FieldTypeEnum.TEXT.getValue().equals(e.getFieldShowType())//文本框 -// || FieldTypeEnum.TEXT_LINK.getValue().equals(e.getFieldShowType()))//输入框(链接) -// .collect(Collectors.toList()); -// List inputFieldList = inputOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); -// inputFieldList.add("file_text"); -// -// //下拉,树形,等字段 -// List otherOnlCgformFieldList = fieldList.stream() -// .filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType())//下拉单选 -// || FieldTypeEnum.PULL_MORE.getValue().equals(e.getFieldShowType())//下拉多选 -// || FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType())//树形 -// || FieldTypeEnum.PERSON.getValue().equals(e.getFieldShowType()))//人员选择 -// .collect(Collectors.toList()); -// List otherFieldList = otherOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); -// -// //日期字段 -// List dateOnlCgformFieldList = fieldList.stream() -// .filter(e -> FieldTypeEnum.DATE_SINGLE.getValue().equals(e.getFieldShowType()))//日期单选 -// .collect(Collectors.toList()); -// List dateFieldList = dateOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); -// -// //过滤出下拉选 -// List onlCgformFieldList = fieldList.stream() -// .filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType()) -// || FieldTypeEnum.PULL_MORE.getValue().equals(e.getFieldShowType())) -// .collect(Collectors.toList()); -// //过滤出文件类型字段 -// List onlCgformFieldFileList = fieldList.stream() -// .filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())) -// .collect(Collectors.toList()); -// //文件字段 -// List FieldFileList = onlCgformFieldFileList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); -// sourceList.addAll(FieldFileList); -// -// //下拉选字段 -// List fieldPullList = onlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); -// -// //过滤出树形字段 -// List treeFieldList = fieldList.stream() -// .filter(e -> FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType())) -// .collect(Collectors.toList()); -// Map mapOne = (Map) map.get("mapOne"); -// Map mapTwo = (Map) map.get("mapTwo"); -// JSONArray must = new JSONArray(); -// //处理首次查询条件 -// if (ObjectUtils.isNotEmpty(mapOne)) { -// queryCondition(mapOne, inputFieldList, otherFieldList,dateFieldList, must); -// } -// //处理二次查询条件 -// if (ObjectUtils.isNotEmpty(mapTwo)) { -// queryCondition(mapTwo, inputFieldList, otherFieldList,dateFieldList, must); -// } -// //处理ids -// JSONArray should = new JSONArray(); -// String ids = (String) mapTwo.get("ids"); -// if (StringUtils.isNotBlank(ids)) { -// for (String s : ids.split(",")) { -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// queryMapTemp.put("id", s); -// queryMap.put("match_phrase", queryMapTemp); -// should.add(queryMap); -// } -// } -// String orderBy = (String)map.get("orderBy"); -// String orderByField = (String) map.get("orderByField"); -// JSONArray jsonArrySort = new JSONArray(); -// JSONObject sort = new JSONObject(); -// Map mapSort = new HashMap<>(); -// Map mapSortTemp = new HashMap<>(); -// if(StringUtils.isNotBlank(orderBy) && StringUtils.isNotBlank(orderByField)){ -// //orderBy=1正序,orderBy=1倒序 -// if("1".equals(orderBy)){ -// mapSort.put("order","asc"); -// }else{ -// mapSort.put("order","desc"); -// } -// if("state".equals(orderByField) || "region".equals(orderByField)){ -// mapSortTemp.put(orderByField+".keyword",mapSort); -// }else{ -// mapSortTemp.put(orderByField,mapSort); -// } -// }else{ -// mapSortTemp.put("issue_time","desc"); -// } -// sort.putAll(mapSortTemp); -// jsonArrySort.add(sort); -// -// //封装查询条件 -// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(must, null, should); -// //1. 封装分页和字段值 -// JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(sourceList, jsonObject, null, jsonArrySort, -// Integer.parseInt(map.get("pageNo").toString())-1, Integer.parseInt(map.get("pageSize").toString())); -// //2. 数据查询 -// JSONObject search = jeroElasticsearchTemplate.search(SearchEnum.INDEX_NAME_DOCUMENT.getValue(), -// SearchEnum.TYPE_NAME_DOCUMENT.getValue(), queryObject); -// -// -// //处理数据字典 -// List sysDictItems = sysDictItemServiceImpl.selectItemsAll();//下拉数据字典 -// List categoryList = sysCategoryService.list();//树形数据字典 -// List> list = (List>) (((Map) search.get("hits")).get("hits")); -// List> mapList = new ArrayList<>(); -// for (Map stringObjectMap : list) { -// Map mapTemp = (Map) stringObjectMap.get("_source"); -// //处理收藏(已收藏为1,未收藏为0) -// LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); -// lambdaQueryWrapper.in(OnlCgformCollection::getDocumentId, mapTemp.get("id")); -// List collectList = iOnlCgformCollectionService.list(lambdaQueryWrapper); -// if (collectList.size() > 0) { -// mapTemp.put("collectFlag", "1"); -// } else { -// mapTemp.put("collectFlag", "0"); -// } -// //处理订阅 -// LambdaQueryWrapper lambdaQueryWrapperTemp = new LambdaQueryWrapper<>(); -// lambdaQueryWrapperTemp.in(OnlCgformSubscribe::getDocumentId, mapTemp.get("id")); -// List readList = iOnlCgformSubscribeService.list(lambdaQueryWrapperTemp); -// if (readList.size() > 0) { -// mapTemp.put("subscribeFlag", "1"); -// } else { -// mapTemp.put("subscribeFlag", "0"); -// } -// //格式化时间字段 -// solveTime(mapTemp); -// mapList.add(mapTemp); -// List fileList = new ArrayList<>(); -// mapTemp.entrySet().forEach(entry -> { -// //下拉选处理数据字典 -// bussDocumentLibraryEOService.treeDictItem(categoryList, entry, treeFieldList, (String) map.get("cut"),null); -// -// //下拉单选和下拉多选数据字典处理 -// if (fieldPullList.contains(entry.getKey())) { -// bussDocumentLibraryEOService.dictItem(sysDictItems, entry, (String) map.get("cut"), fieldList,null); -// } -// //处理文件 -// if (FieldFileList.contains(entry.getKey())) { -// List 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; -// } -// -// -// private void queryCondition(Map mapOne, List inputFieldList, -// List otherFieldList, List dateFieldList,JSONArray must) { -// Map inputMap = new HashMap<>();//条件内容为输入框的 -// Map otherMap = new HashMap<>();//条件内容为下拉,日期,树形 -// Map dateMap = new HashMap<>();//条件内容为下拉,树形 -// //区分输入框和下拉,树形,日期等字段 -// if (ObjectUtils.isNotEmpty(mapOne)) { -// for (Map.Entry entry : mapOne.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); -// } -// if(dateFieldList.contains(key)){ -// dateMap.put(key, value); -// } -// } -// } -// -// //封装输入框查询条件 -// if (ObjectUtils.isNotEmpty(inputMap)) { -// for (Map.Entry entry : inputMap.entrySet()) { -// String key = entry.getKey(); -// String value = (String) entry.getValue(); -// if (ObjectUtils.isNotEmpty(value)) { -// for (String s : value.split(",")) { -// Map map = new HashMap<>(); -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// queryMapTemp.put("query", s); -// queryMapTemp.put("minimum_should_match", 2); -// queryMap.put(key, queryMapTemp); -// map.put("match",queryMap); -// must.add(map); -// } -// } -// } -// } -// //封装下拉,树形查询条件 -// if (ObjectUtils.isNotEmpty(otherMap)) { -// for (Map.Entry entry : otherMap.entrySet()) { -// String key = entry.getKey(); -// String value = (String) entry.getValue(); -// if("technology_territory".equals(key) && ObjectUtils.isNotEmpty(value)){ -// Map queryMapNew = new HashMap<>(); -// Map queryMapTempNew = new HashMap<>(); -// queryMapTempNew.put(key, "*"+value.replaceAll(",","*")+"*"); -// queryMapNew.put("wildcard", queryMapTempNew); -// must.add(queryMapNew); -// }else{ -// Map map = new HashMap<>(); -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// queryMapTemp.put("query", value); -// queryMap.put(key, queryMapTemp); -// map.put("match",queryMap); -// must.add(map); -// } -// } -// } -// //封装时间类型字段查询(时间范围) -// if (ObjectUtils.isNotEmpty(dateMap)) { -// for (Map.Entry entry : dateMap.entrySet()) { -// String key = entry.getKey(); -// String value = (String) entry.getValue(); -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// if (ObjectUtils.isNotEmpty(value)) { -// Map 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 -// public IPage getFullTextInfoList(SearchVO searchVO) { -// JSONArray queryJsonMustNot = new JSONArray(); -// if(StringUtils.isNotBlank(searchVO.getSelectValue())){ -// Map map = new HashMap<>(); -// Map map1 = new HashMap<>(); -// Map map2 = new HashMap<>(); -// map.put("query",SEARCH_FLAG); -// map1.put("flag",map); -// map2.put("match",map1); -// queryJsonMustNot.add(map2); -// } -// if(StringUtils.isBlank(searchVO.getSelectValue())){ -// searchVO.setSelectValue(SEARCH_FLAG); -// } -// -// //判断索引是否存在 -// 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(); -// //1. 需要查询的字段 -// List fieldList = new ArrayList<>(); -// fieldList.add("serial_number");//权重6 -// fieldList.add("title");//权重5 -// fieldList.add("file_text");//权重4 -// fieldList.add("content");//权重3 -// fieldList.add("file_name");//权重2 -// fieldList.add("module_type"); -// fieldList.add("id"); -// fieldList.add("flag"); -// -// JSONArray queryMapJson = new JSONArray(); -// JSONArray queryMapJsonTwo = new JSONArray(); -// JSONArray queryMapJsonThree = new JSONArray(); -// JSONArray queryMapJsonAll = new JSONArray(); -// -// Map mapHighlight = new HashMap<>(); -// Map mapHighlight1 = new HashMap<>(); -// //封装首次的条件 -// if (StringUtils.isNotBlank(selectValue)) { -// for (String field : fieldList) { -// Map map2 = new HashMap<>(); -// Map map3 = new HashMap<>(); -// Map map4 = new HashMap<>(); -// map3.put("query",selectValue); -// map3.put("minimum_should_match",2); -//// if("serial_number".equals(field)){ -//// map3.put("boost",6); -//// }else if("title".equals(field)){ -//// map3.put("boost",5); -//// }else if("file_text".equals(field)){ -//// map3.put("boost",4); -//// }else if("content".equals(field)){ -//// map3.put("boost",3); -//// }else if("file_name".equals(field)){ -//// map3.put("boost",2); -//// } -// map2.put(field, map3); -// map4.put("match",map2); -// queryMapJson.add(map4); -// //高亮 -// if(!"flag".equals(field)){ -// highlight(mapHighlight, field); -// } -// } -// mapHighlight1.put("fields",mapHighlight); -// } -// if(CollectionUtils.isNotEmpty(queryMapJson)){ -// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJson); -// queryMapJsonAll.add(jsonObject); -// } -// //封装二次的条件 -// if (StringUtils.isNotBlank(selectValueTwo)) { -// for (String field : fieldList) { -// Map queryMap = new HashMap<>(); -// Map map2 = new HashMap<>(); -// Map map3 = new HashMap<>(); -// map3.put("query",selectValueTwo); -// map3.put("minimum_should_match",2); -// map2.put(field, map3); -// queryMap.put("match", map2); -// queryMapJsonTwo.add(queryMap); -// //高亮 -// if(!"flag".equals(field)){ -// highlight(mapHighlight, field); -// } -// } -// mapHighlight1.put("fields",mapHighlight); -// } -// if(CollectionUtils.isNotEmpty(queryMapJsonTwo)){ -// JSONObject jsonObjectTwo = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJsonTwo); -// queryMapJsonAll.add(jsonObjectTwo); -// } -// //ids进行三次封装 -// if (StringUtils.isNotBlank(searchVO.getIds())) { -// for (String s : searchVO.getIds().split(",")) { -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// queryMapTemp.put("id", s); -// queryMap.put("match_phrase", queryMapTemp); -// queryMapJsonThree.add(queryMap); -// } -// } -// if(CollectionUtils.isNotEmpty(queryMapJsonThree)){ -// JSONObject jsonObjectThree = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJsonThree); -// queryMapJsonAll.add(jsonObjectThree); -// } -// JSONObject sort = new JSONObject(); -// Map score = new HashMap<>(); -// Map score1 = new HashMap<>(); -// score.put("order","desc"); -// score1.put("_score",score); -// sort.putAll(score1); -// -//// Map mapSort = new HashMap<>(); -//// Map mapSortTemp = new HashMap<>(); -//// mapSort.put("order","asc"); -//// mapSortTemp.put("file_sort.keyword",mapSort); -//// sort.putAll(mapSortTemp); -// -// Integer pageNo = searchVO.getPageNo(); -// Integer pageSize = searchVO.getPageSize(); -// IPage page = getiPage(selectValue, selectValueTwo, queryMapJsonAll, mapHighlight1,null, -// pageNo, pageSize, null,searchVO.getCut(),sort,queryJsonMustNot); -// return page; -// } -// -// @NotNull -// private IPage getiPage(String selectValue, String selectValueTwo, JSONArray queryMapJson,Map highlightMap, -// JSONArray should, Integer pageNo, Integer pageSize, String paragraphFlag, -// String cut,JSONObject querySort,JSONArray queryMustNot) { -// JSONObject jsonObject = new JSONObject(); -// //基础添加封装 -// if ("paragraphFlag".equals(paragraphFlag)) { -// jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, queryMustNot, null); -// } else { -// jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, queryMustNot, null); -// } -// JSONArray jsonArraySort = new JSONArray(); -// jsonArraySort.add(querySort); -// -// //1. 条件,分页 -// JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(null, -// jsonObject, -// highlightMap, -// jsonArraySort, -// pageNo-1, -// pageSize); -// //2. 数据查询 -// 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> list = (List>) (((Map) search.get("hits")).get("hits")); -// List> mapList = new ArrayList<>(); -// for (Map map : list) { -// Map mapSource = (Map) map.get("_source"); -// Map mapHighlight = (Map) map.get("highlight"); -// if(ObjectUtils.isNotEmpty(mapHighlight)){ -// for (Map.Entry entry : mapHighlight.entrySet()) { -// String key = entry.getKey(); -// List value = (List) entry.getValue(); -// String fieldConyent= ""; -// for (String s : value) { -// fieldConyent += s; -// } -// mapSource.put(key,fieldConyent); -//// String key = entry.getKey(); -//// List value = (List) entry.getValue(); -//// if(value.size() != 0){ -//// String fieldContent= value.get(0); -//// mapSource.put(key,fieldContent); -//// } -// } -// } -// mapList.add(mapSource); -// } -// -// //处理分页 -// IPage page = new Page(pageNo, pageSize); -// if (StringUtils.isNotBlank(selectValueTwo)) { -// //二次搜索的结果 -// page.setTotal(Long.parseLong(String.valueOf(((Map) search.get("hits")).get("total")))); -// page.setRecords(mapList); -// } else { -// //首次搜索的结果 -// page.setTotal(Long.parseLong(String.valueOf(((Map) search.get("hits")).get("total")))); -// page.setRecords(mapList); -// } -// return page; -// } -//// @NotNull -//// private IPage getiPage(String selectValue, String selectValueTwo, JSONArray queryMapJson,Map highlightMap, -//// JSONArray should, Integer pageNo, Integer pageSize, String paragraphFlag, -//// String cut,JSONObject querySort) { -//// JSONObject jsonObject = new JSONObject(); -//// //基础添加封装 -//// if ("paragraphFlag".equals(paragraphFlag)) { -//// jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, null, null); -//// } else { -//// jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, null, null); -//// } -//// JSONArray jsonArraySort = new JSONArray(); -//// jsonArraySort.add(querySort); -//// -//// //1. 条件,分页 -//// JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(null, -//// jsonObject, -//// highlightMap, -//// jsonArraySort, -//// pageNo-1, -//// pageSize); -//// //2. 数据查询 -//// 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> list = (List>) (((Map) search.get("hits")).get("hits")); -//// -//// //首次搜索结果 -//// List> mapList = new ArrayList<>(); -//// //二次搜索结果 -//// List> mapListTwo = new ArrayList<>(); -//// -//// for (Map stringObjectMap : list) { -//// Map mapSource = (Map) stringObjectMap.get("_source"); -//// if(StringUtils.isBlank(selectValue)){ -//// mapSource.put("file_text",""); -//// } -//// if (StringUtils.isNotBlank(selectValueTwo)) { -//// //二次查询 -//// int count = 0; -//// for (Map.Entry entry : mapSource.entrySet()) { -//// String valueHighlight = ""; -//// String value = (String) entry.getValue(); -//// //判断value中是否包含二次搜索中的字符 -//// if(StringUtils.isNotBlank(value)){ -//// if(value.contains(selectValueTwo)){ -//// value = subFileText(value, selectValueTwo); -//// count++; -//// String replacementTwo = "" + selectValueTwo + ""; -//// valueHighlight = value.replaceAll(selectValueTwo, replacementTwo); -//// //第一次搜索的也高亮 -//// if(value.contains(selectValue) && !selectValueTwo.contains(selectValue)){ -//// String replacementOne = "" + selectValue + ""; -//// valueHighlight = valueHighlight.replaceAll(selectValue,replacementOne); -//// } -//// if (ObjectUtils.isNotEmpty(valueHighlight)) { -//// entry.setValue(valueHighlight); -//// } -//// }else{ -//// //第二次搜索的时候file_text中不包含搜索条件的时候将file_text赋值空(此时展示拼接的内容) -////// if ("file_text".equals(entry.getKey())) { -////// entry.setValue(""); -////// value = ""; -////// } -////// count++; -//// } -//// } -//// } -//// if (count > 0) { -//// mapListTwo.add(mapSource); -//// } -//// } else { -//// //首次查询(没有输入查询条件) -//// mapList.add(mapSource); -//// //处理高亮module_type,title,serial_number,file_text(输入查询条件后,处理高亮字段) -//// if (StringUtils.isNotBlank(selectValue)) { -//// for (Map.Entry entry : mapSource.entrySet()) { -//// String key = entry.getKey(); -//// String value = String.valueOf(entry.getValue()); -////// StringBuilder sb = new StringBuilder(); -//// String valueHighlight = ""; -//// if (StringUtils.isNotBlank(value)) { -//// //file_text需要单独处理(截取第一处高亮的前后100个字符) -//// if ("file_text".equals(key)) { -//// //判断value中是否包含搜索中的字符 -//// for (String s : selectValue.split(" ")) { -//// if(value.contains(s)){ -//// //截取第一处高亮的前后100个字符 -//// value = subFileText(value, s); -//// break; -//// }else{ -//// //第一次搜索的时候file_text中不包含搜索条件的时候将file_text赋值空(此时展示拼接的内容) -//// entry.setValue(""); -//// value = ""; -//// } -//// } -//// } -//// if ("content".equals(key)) { -//// for (String s : selectValue.split(" ")) { -//// if(value.contains(s)){ -//// value = subFileText(value, s); -//// break; -//// } -//// } -//// } -//// for (String s : selectValue.split(" ")) { -//// String replacement = "" + s + ""; -//// value = value.replaceAll(s, replacement); -//// } -//// -////// String replacement = "" + selectValue + ""; -////// valueHighlight = value.replaceAll(selectValue, replacement); -//// } -//// if (ObjectUtils.isNotEmpty(value)) { -//// entry.setValue(value); -//// } -//// } -//// } -//// } -//// } -//// -//// //处理分页 -//// IPage page = new Page(pageNo, pageSize); -//// if (StringUtils.isNotBlank(selectValueTwo)) { -//// //二次搜索的结果 -//// page.setTotal(Long.parseLong(String.valueOf(((Map) search.get("hits")).get("total")))); -//// page.setRecords(mapListTwo); -//// } else { -//// //首次搜索的结果 -//// page.setTotal(Long.parseLong(String.valueOf(((Map) search.get("hits")).get("total")))); -//// page.setRecords(mapList); -//// } -//// return page; -//// } -// -// private String subFileText(String fileTextInfo, String selectValue) { -// int i = fileTextInfo.indexOf(selectValue); -// String start = ""; -// String end = ""; -// if(i <100 && (fileTextInfo.length() - i) <100){ -// start = fileTextInfo.substring(0,i); -// end = fileTextInfo.substring(i, fileTextInfo.length()); -// }else if(i <100 && (fileTextInfo.length() - i) >= 100){ -// start = fileTextInfo.substring(0, i); -// end = fileTextInfo.substring(i, i+100); -// }else if(i >= 100 && (fileTextInfo.length() - i) >= 100){ -// start = fileTextInfo.substring(i-100, i); -// end = fileTextInfo.substring(i, i+100); -// }else if(i >= 100 && (fileTextInfo.length() - i) < 100){ -// start = fileTextInfo.substring(i-100, i); -// end = fileTextInfo.substring(i, fileTextInfo.length()); -// } -// String result = start + end; -// return result; -// } -// private String getFileText(String fileTextInfo, String selectValue) { -// String beginStr = ""; -// String endStr = ""; -// for (int i = 0; i < fileTextInfo.length(); i++) { -// String chStr = String.valueOf(fileTextInfo.charAt(i)); -// if (selectValue.contains(chStr)) { -// if (i >= 100) { -// int begin = i - 100; -// beginStr = fileTextInfo.substring(begin, i); -// int b = 0; -// } else { -// beginStr = fileTextInfo.substring(0, i); -// } -// int index = fileTextInfo.length() - i; -// if (index <= 100) { -// endStr = fileTextInfo.substring(i, fileTextInfo.length()); -// } else { -// endStr = fileTextInfo.substring(i, i + 100); -// } -// break; -// } -// } -// String result = beginStr + endStr; -// return result; -// } -// -// private boolean judgeContains(String oldStr, String newStr) { -// if (StringUtils.isBlank(oldStr) || StringUtils.isBlank(newStr)) { -// return false; -// } -// int count = 0; -// for (int i = 0; i < newStr.length(); i++) { -// String chStr = String.valueOf(newStr.charAt(i)); -// if (oldStr.contains(chStr)) { -// count++; -// } -// } -// if (count > 0) { -// return true; -// } else { -// return false; -// } -// } -// -// -// private void solveTime(Map 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()); -// jeroElasticsearchTemplate.removeIndex(SearchEnum.FULL_TEXT_SEARCH_CN.getValue()); -// jeroElasticsearchTemplate.removeIndex(SearchEnum.FULL_TEXT_SEARCH_EN.getValue()); -// } -// -// -// /** -// * 查询段落 -// * -// * @param map -// * @return -// */ -// @Override -// public IPage getParagraphInfoList(Map map) { -// if(ObjectUtils.isEmpty(map.get("mapOne"))){ -// ((Map) map.get("mapOne")).put("flag",SEARCH_FLAG); -// } -// String cut = (String) map.get("cut"); -// //module_type 代表文档库的段落 -// //判断索引是否存在 -// 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())); -// } -// //文档库所有的字段 -// List fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue()); -// //输入框字段 -// List inputOnlCgformFieldList = fieldList.stream() -// .filter(e -> FieldTypeEnum.TEXT_STRING.getValue().equals(e.getFieldShowType()) -// || FieldTypeEnum.TEXT_NUMBER.getValue().equals(e.getFieldShowType())) -// .collect(Collectors.toList()); -// List inputFieldList = inputOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); -// inputFieldList.add("file_text");//在输入框的类型中添加正文字段 -// inputFieldList.add("flag");//标识(默认展示基础数据,不展示文件数据) -// -// -// Map mapOne = (Map) map.get("mapOne"); -// Map mapTwo = (Map) map.get("mapTwo"); -// -// JSONArray queryMapJson = new JSONArray(); -// JSONArray queryMapJsonTemp = new JSONArray(); -// JSONArray queryMapJsonTwo = new JSONArray(); -// JSONArray queryMapJsonThree = new JSONArray(); -// JSONArray queryMapJsonAll = new JSONArray(); -// //首次查询条件 -// if (ObjectUtils.isNotEmpty(mapOne)) { -// if(StringUtils.isNotBlank((String)mapOne.get("title")) -// || StringUtils.isNotBlank((String)mapOne.get("serial_number"))){ -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// queryMapTemp.put("flag",SEARCH_FLAG ); -// queryMap.put("match_phrase", queryMapTemp); -// queryMapJsonTemp.add(queryMap); -// } -// for (Map.Entry entry : mapOne.entrySet()) { -// String key = entry.getKey(); -// String value = (String) entry.getValue(); -// if (ObjectUtils.isNotEmpty(value)) { -// for (String s : value.split(",")) { -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// Map queryMap3 = new HashMap<>(); -// queryMap3.put("query",s); -// queryMap3.put("minimum_should_match",2); -// queryMapTemp.put(key, queryMap3); -// queryMap.put("match", queryMapTemp); -// queryMapJson.add(queryMap); -// } -// } -// } -// if(CollectionUtils.isNotEmpty(queryMapJsonTemp)){ -// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJsonTemp, null, null); -// queryMapJsonAll.add(jsonObject); -// } -// if(CollectionUtils.isNotEmpty(queryMapJson)){ -// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, null, null); -// queryMapJsonAll.add(jsonObject); -// } -// } -// -// String ids = (String) mapTwo.get("ids"); -// //二次查询条件 -// if (ObjectUtils.isNotEmpty(mapTwo)) { -// mapTwo.remove("ids"); -// for (Map.Entry entry : mapTwo.entrySet()) { -// String key = entry.getKey(); -// String value = (String) entry.getValue(); -// if (ObjectUtils.isNotEmpty(value)) { -// for (String s : value.split(",")) { -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// Map queryMap3 = new HashMap<>(); -// queryMap3.put("query",s); -// queryMap3.put("minimum_should_match",2); -// queryMapTemp.put(key, queryMap3); -// queryMap.put("match", queryMapTemp); -// queryMapJsonTwo.add(queryMap); -// } -// } -// } -// if(CollectionUtils.isNotEmpty(queryMapJsonTwo)){ -// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJsonTwo, null, null); -// queryMapJsonAll.add(jsonObject); -// } -// } -// -// //ids查询条件 -// if (StringUtils.isNotBlank(ids)) { -// for (String s : ids.split(",")) { -// Map queryMap = new HashMap<>(); -// Map queryMapTemp = new HashMap<>(); -// queryMapTemp.put("id", s); -// queryMap.put("match_phrase", queryMapTemp); -// queryMapJsonThree.add(queryMap); -// } -// } -// if(CollectionUtils.isNotEmpty(queryMapJsonThree)){ -// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJsonThree); -// queryMapJsonAll.add(jsonObject); -// } -// -// //排序 -// JSONObject sort = new JSONObject(); -//// Map mapSort = new HashMap<>(); -//// Map mapSortTemp = new HashMap<>(); -//// mapSort.put("order","asc"); -//// mapSortTemp.put("file_sort.keyword",mapSort); -//// sort.putAll(mapSortTemp); -// -// Map score = new HashMap<>(); -// Map score1 = new HashMap<>(); -// score.put("order","desc"); -// score1.put("_score",score); -// sort.putAll(score1); -// -// int pageNo = Integer.parseInt(map.get("pageNo").toString()); -// int pageSize = Integer.parseInt(map.get("pageSize").toString()); -// //判断第一次传参和第二次传参 inputFieldList -// String selectValue = ""; -// String selectValueTwo = ""; -// Map mapHighlight = new HashMap<>(); -// Map mapHighlight1 = new HashMap<>(); -// for (Map.Entry entry : mapOne.entrySet()) { -// String key = entry.getKey(); -// String value = (String) entry.getValue(); -// if (inputFieldList.contains(key) && StringUtils.isNotBlank(value)) { -// selectValue = value; -// highlight(mapHighlight, key); -// } -// mapHighlight1.put("fields",mapHighlight); -// } -// for (Map.Entry entry : mapTwo.entrySet()) { -// String key = entry.getKey(); -// String value = (String) entry.getValue(); -// if (inputFieldList.contains(key) && StringUtils.isNotBlank(value)) { -// selectValueTwo = value; -// highlight(mapHighlight, key); -// } -// mapHighlight1.put("fields",mapHighlight); -// } -// //段落的标识 -// String paragraphFlag = "paragraphFlag"; -// -// -// IPage iPage = getiPage(selectValue, selectValueTwo, queryMapJsonAll, mapHighlight1,null, -// pageNo, pageSize, paragraphFlag,(String) map.get("cut"),sort,null); -// return iPage; -// } -// -// private void highlight(Map mapHighlight, String key) { -// Map mapTemp = new HashMap<>(); -// List list = new ArrayList<>(); -// list.add(""); -// List list1 = new ArrayList<>(); -// list1.add(""); -// mapTemp.put("pre_tags", list); -// mapTemp.put("post_tags", list1); -// mapTemp.put("fragment_size", 200);//高亮字段内容长度,去除html样式标签,统计字数,设置为200 -// mapTemp.put("number_of_fragments", 1);//高亮内容默认分为5段, 此处设置为一段 -// mapTemp.put("type", "plain"); -// mapHighlight.put(key, mapTemp); -// } -//// @Override -//// public IPage getParagraphInfoList(Map map) { -//// if(ObjectUtils.isEmpty(map.get("mapOne"))){ -//// ((Map) map.get("mapOne")).put("flag",SEARCH_FLAG); -//// } -//// String cut = (String) map.get("cut"); -//// //module_type 代表文档库的段落 -//// //判断索引是否存在 -//// 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())); -//// } -//// //文档库所有的字段 -//// List fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue()); -//// //输入框字段 -//// List inputOnlCgformFieldList = fieldList.stream() -//// .filter(e -> FieldTypeEnum.TEXT_STRING.getValue().equals(e.getFieldShowType()) -//// || FieldTypeEnum.TEXT_NUMBER.getValue().equals(e.getFieldShowType())) -//// .collect(Collectors.toList()); -//// List inputFieldList = inputOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); -//// inputFieldList.add("file_text");//在输入框的类型中添加正文字段 -//// inputFieldList.add("flag");//标识(默认展示基础数据,不展示文件数据) -//// -//// -//// Map mapOne = (Map) map.get("mapOne"); -//// Map mapTwo = (Map) map.get("mapTwo"); -//// -//// JSONArray queryMapJson = new JSONArray(); -//// JSONArray queryMapJsonTemp = new JSONArray(); -//// JSONArray queryMapJsonTwo = new JSONArray(); -//// JSONArray queryMapJsonThree = new JSONArray(); -//// JSONArray queryMapJsonAll = new JSONArray(); -//// //首次查询条件 -//// if (ObjectUtils.isNotEmpty(mapOne)) { -//// if(StringUtils.isNotBlank((String)mapOne.get("title")) -//// || StringUtils.isNotBlank((String)mapOne.get("serial_number"))){ -//// Map queryMap = new HashMap<>(); -//// Map queryMapTemp = new HashMap<>(); -//// queryMapTemp.put("flag",SEARCH_FLAG ); -//// queryMap.put("match_phrase", queryMapTemp); -//// queryMapJsonTemp.add(queryMap); -//// } -//// for (Map.Entry entry : mapOne.entrySet()) { -//// String key = entry.getKey(); -//// String value = (String) entry.getValue(); -//// if (ObjectUtils.isNotEmpty(value)) { -//// for (String s : value.split(",")) { -//// Map queryMap = new HashMap<>(); -//// Map queryMapTemp = new HashMap<>(); -//// Map queryMap3 = new HashMap<>(); -//// queryMap3.put("query",s); -//// queryMap3.put("minimum_should_match",2); -//// queryMapTemp.put(key, queryMap3); -//// queryMap.put("match", queryMapTemp); -//// queryMapJson.add(queryMap); -//// } -////// for (String s : value.split(",")) { -////// Map queryMap = new HashMap<>(); -////// Map queryMapTemp = new HashMap<>(); -////// Map queryMap3 = new HashMap<>(); -////// queryMap3.put("query",s); -////// queryMap3.put("slop",1); -////// queryMapTemp.put(key, queryMap3); -////// queryMap.put("match_phrase", queryMapTemp); -////// queryMapJson.add(queryMap); -////// } -//// } -//// } -//// if(CollectionUtils.isNotEmpty(queryMapJsonTemp)){ -//// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJsonTemp, null, null); -//// queryMapJsonAll.add(jsonObject); -//// } -//// if(CollectionUtils.isNotEmpty(queryMapJson)){ -//// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, null, null); -//// queryMapJsonAll.add(jsonObject); -//// } -//// } -//// -//// String ids = (String) mapTwo.get("ids"); -//// //二次查询条件 -//// if (ObjectUtils.isNotEmpty(mapTwo)) { -//// mapTwo.remove("ids"); -//// for (Map.Entry entry : mapTwo.entrySet()) { -//// String key = entry.getKey(); -//// String value = (String) entry.getValue(); -//// if (ObjectUtils.isNotEmpty(value)) { -//// for (String s : value.split(",")) { -//// Map queryMap = new HashMap<>(); -//// Map queryMapTemp = new HashMap<>(); -//// Map queryMap3 = new HashMap<>(); -//// queryMap3.put("query",s); -//// queryMap3.put("minimum_should_match",2); -//// queryMapTemp.put(key, queryMap3); -//// queryMap.put("match", queryMapTemp); -//// queryMapJsonTwo.add(queryMap); -//// } -////// for (String s : value.split(",")) { -////// Map queryMap = new HashMap<>(); -////// Map queryMapTemp = new HashMap<>(); -////// Map queryMap3 = new HashMap<>(); -////// queryMap3.put("query",s); -////// queryMap3.put("slop",1); -////// queryMapTemp.put(key, queryMap3); -////// queryMap.put("match_phrase", queryMapTemp); -////// queryMapJsonTwo.add(queryMap); -////// } -//// } -//// } -//// if(CollectionUtils.isNotEmpty(queryMapJsonTwo)){ -//// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJsonTwo, null, null); -//// queryMapJsonAll.add(jsonObject); -//// } -//// } -//// -//// //ids查询条件 -//// if (StringUtils.isNotBlank(ids)) { -//// for (String s : ids.split(",")) { -//// Map queryMap = new HashMap<>(); -//// Map queryMapTemp = new HashMap<>(); -//// queryMapTemp.put("id", s); -//// queryMap.put("match_phrase", queryMapTemp); -//// queryMapJsonThree.add(queryMap); -//// } -//// } -//// if(CollectionUtils.isNotEmpty(queryMapJsonThree)){ -//// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJsonThree); -//// queryMapJsonAll.add(jsonObject); -//// } -//// -//// //排序 -//// JSONObject sort = new JSONObject(); -//// Map mapSort = new HashMap<>(); -//// Map mapSortTemp = new HashMap<>(); -//// mapSort.put("order","asc"); -//// mapSortTemp.put("file_sort.keyword",mapSort); -//// sort.putAll(mapSortTemp); -//// -//// int pageNo = Integer.parseInt(map.get("pageNo").toString()); -//// int pageSize = Integer.parseInt(map.get("pageSize").toString()); -//// //判断第一次传参和第二次传参 inputFieldList -//// String selectValue = ""; -//// String selectValueTwo = ""; -//// for (Map.Entry entry : mapOne.entrySet()) { -//// String key = entry.getKey(); -//// String value = (String) entry.getValue(); -//// if (inputFieldList.contains(key) && StringUtils.isNotBlank(value)) { -//// selectValue = value; -//// } -//// } -//// for (Map.Entry entry : mapTwo.entrySet()) { -//// String key = entry.getKey(); -//// String value = (String) entry.getValue(); -//// if (inputFieldList.contains(key) && StringUtils.isNotBlank(value)) { -//// selectValueTwo = value; -//// } -//// } -//// //段落的标识 -//// String paragraphFlag = "paragraphFlag"; -//// -//// -//// IPage iPage = getiPage(selectValue, selectValueTwo, queryMapJsonAll, null,null, pageNo, pageSize, paragraphFlag,(String) map.get("cut"),sort); -//// return iPage; -//// } -// -//}