diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/controller/DocumentSearchController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/controller/DocumentSearchController.java index d4f72bc3d..edc2c5995 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/controller/DocumentSearchController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/controller/DocumentSearchController.java @@ -65,8 +65,8 @@ public class DocumentSearchController { } @ApiOperation(value="列表查询", notes="列表查询") - @GetMapping(value = "/getInfoList") - public Result getInfoList(@RequestParam Map map) { + @PostMapping(value = "/getInfoList") + public Result getInfoList(@RequestBody Map map) { IPage infoList = iDocumentSearchService.getInfoList(map); return Result.OK(infoList); } 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 e8f381fcb..078fac3ca 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 @@ -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 inputMap = new HashMap<>();//条件内容为输入框的 - Map otherMap = new HashMap<>();//条件内容为下拉,日期,树形 - //区分输入框和下拉,树形,日期等字段 - if (ObjectUtils.isNotEmpty(map)) { - for (Map.Entry 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 mapOne = JSON.parseObject(one); + Map mapTwo = JSON.parseObject(two); JSONArray must = new JSONArray(); - //封装输入框查询条件 - if (ObjectUtils.isNotEmpty(inputMap)) { - Map queryMap = new HashMap<>(); - for (Map.Entry entry : inputMap.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - if(ObjectUtils.isNotEmpty(value)){ - Map 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 entry : otherMap.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - if(ObjectUtils.isNotEmpty(value)){ - Map queryMap = new HashMap<>(); - Map 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 mapOne, List inputFieldList, List otherFieldList, JSONArray must) { + Map inputMap = new HashMap<>();//条件内容为输入框的 + Map otherMap = new HashMap<>();//条件内容为下拉,日期,树形 + //区分输入框和下拉,树形,日期等字段 + if (ObjectUtils.isNotEmpty(mapOne)) { + for (Map.Entry 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 entry : inputMap.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<>(); + queryMapTemp.put(key, s); + queryMap.put("match", queryMapTemp); + must.add(queryMap); + } + } + } + } + //封装下拉,树形,日期查询条件 + if (ObjectUtils.isNotEmpty(otherMap)) { + for (Map.Entry entry : otherMap.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<>(); + queryMapTemp.put(key, s); + queryMap.put("match", queryMapTemp); + must.add(queryMap); + } + } + } + } + } +// @Override +// public IPage getInfoList(Map mapOne,Map 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 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())) +// .collect(Collectors.toList()); +// List inputFieldList = inputOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); +// //下拉,树形,日期等字段 +// List 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 otherFieldList = otherOnlCgformFieldList.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 inputMap = new HashMap<>();//条件内容为输入框的 +// Map otherMap = new HashMap<>();//条件内容为下拉,日期,树形 +// //区分输入框和下拉,树形,日期等字段 +// if (ObjectUtils.isNotEmpty(map)) { +// for (Map.Entry 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 entry : inputMap.entrySet()) { +// +// String key = entry.getKey(); +// String value = (String )entry.getValue(); +//// value = "车,机动"; +// if(ObjectUtils.isNotEmpty(value)){ +// for (String s : value.split(",")) { +// Map queryMap = new HashMap<>(); +// Map queryMapTemp = new HashMap<>(); +// queryMapTemp.put(key, s); +// queryMap.put("match", queryMapTemp); +// must.add(queryMap); +// } +// } +// } +// } +// //封装下拉,树形,日期查询条件 +// if (ObjectUtils.isNotEmpty(otherMap)) { +// for (Map.Entry entry : otherMap.entrySet()) { +// String key = entry.getKey(); +// String value = (String) entry.getValue(); +//// value = "1"; +// if(ObjectUtils.isNotEmpty(value)){ +// for (String s : value.split(",")) { +// Map queryMap = new HashMap<>(); +// Map 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 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"); +// //格式化时间字段 +// solveTime(mapTemp); +// mapList.add(mapTemp); +// List 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 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) {