文档库--修改数据格式

This commit is contained in:
zhn
2022-03-15 17:48:06 +08:00
parent 0c93a4278d
commit 18fe584df1
4 changed files with 84 additions and 60 deletions
@@ -1808,7 +1808,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
* @param entry * @param entry
* @param collect * @param collect
*/ */
private void dictItem(List<SysDictItem> sysDictItems, Map.Entry<String, Object> entry, List<OnlCgformField> collect, String cut) { public void dictItem(List<SysDictItem> sysDictItems, Map.Entry<String, Object> entry, List<OnlCgformField> collect, String cut) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
//通过dictField判断字段是否为下拉选(不为空则为下拉选) //通过dictField判断字段是否为下拉选(不为空则为下拉选)
if (collect.size() != 0 && StringUtils.isNotBlank(collect.get(0).getDictField())) { if (collect.size() != 0 && StringUtils.isNotBlank(collect.get(0).getDictField())) {
@@ -2590,7 +2590,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
* @param treeFieldList * @param treeFieldList
* @param cut * @param cut
*/ */
private void treeDictItem(List<SysCategory> categoryList, Map.Entry<String, Object> entry, List<OnlCgformField> treeFieldList, String cut) { public void treeDictItem(List<SysCategory> categoryList, Map.Entry<String, Object> entry, List<OnlCgformField> treeFieldList, String cut) {
List<String> treeFields = treeFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); List<String> treeFields = treeFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
String key = entry.getKey(); String key = entry.getKey();
if (treeFields.contains(entry.getKey())) { if (treeFields.contains(entry.getKey())) {
@@ -1,9 +1,8 @@
package com.jero.modules.searchcenter.controller; package com.jero.modules.searchcenter.controller;
import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.common.api.vo.Result; import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog; import com.jero.common.aspect.annotation.AutoLog;
import com.jero.modules.searchcenter.service.impl.DocumentSearchServiceImpl;
import com.jero.modules.searchcenter.service.impl.IDocumentSearchService; import com.jero.modules.searchcenter.service.impl.IDocumentSearchService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -14,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -66,7 +64,7 @@ public class DocumentSearchController {
@ApiOperation(value="列表查询", notes="列表查询") @ApiOperation(value="列表查询", notes="列表查询")
@GetMapping(value = "/getInfoList") @GetMapping(value = "/getInfoList")
public Result<?> getInfoList(@RequestParam Map<String,Object> map) { public Result<?> getInfoList(@RequestParam Map<String,Object> map) {
JSONObject infoList = iDocumentSearchService.getInfoList(map); IPage infoList = iDocumentSearchService.getInfoList(map);
return Result.OK(infoList); return Result.OK(infoList);
} }
} }
@@ -1,27 +1,29 @@
package com.jero.modules.searchcenter.service.impl; package com.jero.modules.searchcenter.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.common.constant.enums.ModuleEnum; import com.jero.common.constant.enums.ModuleEnum;
import com.jero.common.constant.enums.YesOrNoEnum; import com.jero.common.constant.enums.YesOrNoEnum;
import com.jero.common.es.JeroElasticsearchTemplate; import com.jero.common.es.JeroElasticsearchTemplate;
import com.jero.common.es.QueryStringBuilder;
import com.jero.generater.modules.online.cgform.entity.OnlCgformField; import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl; import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
import com.jero.modules.document.enums.FieldTypeEnum; import com.jero.modules.document.enums.FieldTypeEnum;
import com.jero.modules.document.service.IBussDocumentLibraryEOService; import com.jero.modules.document.service.IBussDocumentLibraryEOService;
import io.swagger.annotations.ApiOperation; import com.jero.modules.document.service.impl.BussDocumentLibraryEOServiceImpl;
import com.jero.modules.system.entity.SysCategory;
import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -37,7 +39,12 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
private JeroElasticsearchTemplate jeroElasticsearchTemplate; private JeroElasticsearchTemplate jeroElasticsearchTemplate;
@Autowired @Autowired
private OnlCgformFieldServiceImpl onlCgformFieldService; private OnlCgformFieldServiceImpl onlCgformFieldService;
@Autowired
private SysCategoryServiceImpl sysCategoryService;
@Autowired
private SysDictItemServiceImpl sysDictItemServiceImpl;
@Autowired
private BussDocumentLibraryEOServiceImpl bussDocumentLibraryEOService;
@Override @Override
@@ -54,7 +61,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
} }
@Override @Override
public JSONObject getInfoList(Map<String,Object> map) { public IPage getInfoList(Map<String, Object> map) {
//文档库所有的字段 //文档库所有的字段
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue()); List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue());
//需要查询的列表字段 //需要查询的列表字段
@@ -77,6 +84,19 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
.collect(Collectors.toList()); .collect(Collectors.toList());
List<String> otherFieldList = otherOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldEnName).collect(Collectors.toList()); List<String> otherFieldList = otherOnlCgformFieldList.stream().map(OnlCgformField::getDbFieldEnName).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<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> inputMap = new HashMap<>();//条件内容为输入框的
Map<String, Object> otherMap = new HashMap<>();//条件内容为下拉,日期,树形 Map<String, Object> otherMap = new HashMap<>();//条件内容为下拉,日期,树形
//区分输入框和下拉,树形,日期等字段 //区分输入框和下拉,树形,日期等字段
@@ -120,34 +140,40 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
// String indexName = "documentLibrary"; // String indexName = "documentLibrary";
// String typeName = "document"; // String typeName = "document";
JSONObject search = null;
try {
//封装查询条件 //封装查询条件
// Map<String,Object> queryMap = new HashMap<>();
// Map<String,Object> queryMap2 = new HashMap<>();
// queryMap2.put("serial_number","1332");
// queryMap.put("term",queryMap2);
// must.add(queryMap);
//
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(must, null, null); JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(must, null, null);
//封装分页和字段值 //封装分页和字段值
// JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(sourceList, jsonObject,null, 0,10);
JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(sourceList, jsonObject, null, Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString())); JSONObject queryObject = jeroElasticsearchTemplate.buildQuery(sourceList, jsonObject, null, Integer.parseInt(map.get("pageNo").toString()), Integer.parseInt(map.get("pageSize").toString()));
// //
//数据查询 //数据查询
search = jeroElasticsearchTemplate.search("documentLibrary", "document", queryObject); JSONObject search = jeroElasticsearchTemplate.search("documentLibrary", "document", queryObject);
// Map map1 = JSONObject.parseObject(search.toJSONString(), Map.class); //处理数据字典
// String s = search.toJSONString(); List<SysDictItem> sysDictItems = sysDictItemServiceImpl.selectItemsAll();//下拉数据字典
// Map<String,Object> map2 = JSON.parseObject(search.toJSONString(), Map.class); List<SysCategory> categoryList = sysCategoryService.list();//树形数据字典
// List<Map<String,Object>> list = ((Map) search.get("hits")).get("hits"); List<Map<String, Object>> list = (List<Map<String, Object>>) (((Map) search.get("hits")).get("hits"));
} catch (Exception e) { List<Map<String, Object>> mapList = new ArrayList<>();
e.printStackTrace(); for (Map<String, Object> stringObjectMap : list) {
Map<String, Object> mapTemp = (Map<String, Object>) stringObjectMap.get("_source");
mapList.add(mapTemp);
mapTemp.entrySet().forEach(entry -> {
//下拉选处理数据字典
bussDocumentLibraryEOService.treeDictItem(categoryList, entry, treeFieldList, (String) map.get("cut"));
});
//下拉单选和下拉多选数据字典处理
mapTemp.entrySet().forEach(entry -> {
if (fieldPullList.contains(entry.getKey())) {
//下拉选处理数据字典
bussDocumentLibraryEOService.dictItem(sysDictItems, entry, onlCgformFieldList, (String) map.get("cut"));
} }
return search; });
}
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;
} }
@@ -1,6 +1,6 @@
package com.jero.modules.searchcenter.service.impl; package com.jero.modules.searchcenter.service.impl;
import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -16,6 +16,6 @@ public interface IDocumentSearchService {
List<Map<String, Object>> getHeader(String flag, String cut, String searchFla); List<Map<String, Object>> getHeader(String flag, String cut, String searchFla);
JSONObject getInfoList(Map<String,Object> map); IPage getInfoList(Map<String, Object> map);
} }