文档库--数据字典

This commit is contained in:
zhn
2022-03-28 17:35:11 +08:00
parent de7ce43ae7
commit c61ec86e0a
2 changed files with 274 additions and 287 deletions
@@ -473,8 +473,10 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} }
return resultTemp; return resultTemp;
} }
/** /**
* 模板下载字段 * 模板下载字段
*
* @return * @return
*/ */
public List<Map<String, Object>> getField(String flag, String cut, String type) { public List<Map<String, Object>> getField(String flag, String cut, String type) {
@@ -805,10 +807,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
}); });
//下拉单选和下拉多选数据字典处理 //下拉单选和下拉多选数据字典处理
List<OnlCgformField> finalFieldList = fieldList;
dataList.get(0).entrySet().forEach(entry -> { dataList.get(0).entrySet().forEach(entry -> {
if (fieldPullList.contains(entry.getKey())) { if (fieldPullList.contains(entry.getKey())) {
//下拉选处理数据字典 //下拉选处理数据字典
dictItem(sysDictItems, entry, onlCgformFieldList, cut); dictItem(sysDictItems, entry, cut, finalFieldList);
} }
}); });
@@ -1124,8 +1127,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} }
} catch (Exception e) { } catch (Exception e) {
log.error("文档库新增es错误"); log.error("文档库新增es错误");
} }
@@ -1160,6 +1161,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
/** /**
* //读取word或PDF文件内容 * //读取word或PDF文件内容
*
* @param oSSFileList * @param oSSFileList
*/ */
public List<String> readFileContent(List<OSSFile> oSSFileList) { public List<String> readFileContent(List<OSSFile> oSSFileList) {
@@ -1185,8 +1187,10 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} }
return result; return result;
} }
private void esFullText(String cut, List<OnlCgformField> fieldList, List<SysCategory> categoryList, List<SysDictItem> dictItemList, List<Map<String, Object>> mapList, StringBuilder sb, Map.Entry<String, Object> entry) { private void esFullText(String cut, List<OnlCgformField> fieldList, List<SysCategory> categoryList, List<SysDictItem> dictItemList, List<Map<String, Object>> mapList, StringBuilder sb, Map.Entry<String, Object> entry) {
try { try {
List<OnlCgformField> onlCgformFieldList = fieldList.stream().filter(e -> entry.getKey().equals(e.getDbFieldName())).collect(Collectors.toList());
for (OnlCgformField onlCgformField : fieldList) { for (OnlCgformField onlCgformField : fieldList) {
//输入框 //输入框
if ((FieldTypeEnum.TEXT_STRING.getValue().equals(onlCgformField.getFieldShowType()) if ((FieldTypeEnum.TEXT_STRING.getValue().equals(onlCgformField.getFieldShowType())
@@ -1205,8 +1209,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if (ObjectUtils.isEmpty(entry.getValue())) { if (ObjectUtils.isEmpty(entry.getValue())) {
sb.append(onlCgformField.getDbFieldTxt() + ":" + "-- "); sb.append(onlCgformField.getDbFieldTxt() + ":" + "-- ");
} else { } else {
if (onlCgformFieldList.size() != 0 && StringUtils.isNotBlank(onlCgformFieldList.get(0).getDictField())) {
List<SysDictItem> dictItems = dictItemList.stream() List<SysDictItem> dictItems = dictItemList.stream()
.filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals(entry.getKey())) .filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals(onlCgformFieldList.get(0).getDictField()))
.collect(Collectors.toList()); .collect(Collectors.toList());
StringBuilder sbText = new StringBuilder(); StringBuilder sbText = new StringBuilder();
//处理数据字典 //处理数据字典
@@ -1224,6 +1229,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} }
} }
} }
}
//树形 //树形
if (FieldTypeEnum.TREE.getValue().equals(onlCgformField.getFieldShowType()) if (FieldTypeEnum.TREE.getValue().equals(onlCgformField.getFieldShowType())
&& onlCgformField.getDbFieldName().equals(entry.getKey())) { && onlCgformField.getDbFieldName().equals(entry.getKey())) {
@@ -1656,19 +1662,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
List<SysCategory> categoryList = sysCategoryService.list(); List<SysCategory> categoryList = sysCategoryService.list();
//下拉选处理数据字典 //下拉选处理数据字典
for (Map.Entry<String, Object> entry : dataList.get(0).entrySet()) { for (Map.Entry<String, Object> entry : dataList.get(0).entrySet()) {
List<OnlCgformField> collect = fieldPullList.stream()
.filter(e -> entry.getKey().equals(e.getDictField()))
.collect(Collectors.toList());
//下拉选处理数据字典 //下拉选处理数据字典
dictItem(sysDictItems, entry, collect, cut); dictItem(sysDictItems, entry, cut, fieldList);
treeDictItem(categoryList, entry, treeFieldList, cut); treeDictItem(categoryList, entry, treeFieldList, cut);
} }
for (Map.Entry<String, Object> entry : mapTemp.entrySet()) { for (Map.Entry<String, Object> entry : mapTemp.entrySet()) {
List<OnlCgformField> collect = fieldPullList.stream()
.filter(e -> entry.getKey().equals(e.getDictField()))
.collect(Collectors.toList());
//下拉选处理数据字典 //下拉选处理数据字典
dictItem(sysDictItems, entry, collect, cut); dictItem(sysDictItems, entry, cut, fieldList);
treeDictItem(categoryList, entry, treeFieldList, cut); treeDictItem(categoryList, entry, treeFieldList, cut);
} }
@@ -1944,23 +1944,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//查询内容 //查询内容
String field = " id,serial_number,title,state"; String field = " id,serial_number,title,state";
//需求变更,搜索条件有原来的编码和标题改为和文档库一致
// //查询条件
// StringBuilder conditionSb = new StringBuilder("where 1 = 1");
//
// //编码
// String serialNumber = (String) parameter.get("serialNumber");
//
// //标题
// String title = (String) parameter.get("title");
// if (StringUtils.isNotBlank(serialNumber)) {
// conditionSb.append(" and " + "serial_number" + " like concat(concat('%','" + serialNumber + "'),'%')");
// }
// if (StringUtils.isNotBlank(title)) {
// conditionSb.append(" and " + "title" + " like concat(concat('%','" + title + "'),'%')");
// }
//
// conditionSb.append(" order by create_time desc");
//封装查询条件 //封装查询条件
String condition = getConditionStr(parameter); String condition = getConditionStr(parameter);
int pageNo = Integer.parseInt(parameter.get("pageNo").toString()); int pageNo = Integer.parseInt(parameter.get("pageNo").toString());
@@ -1989,9 +1972,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
for (Map.Entry<String, Object> entry : record1.entrySet()) { for (Map.Entry<String, Object> entry : record1.entrySet()) {
treeDictItem(categoryList, entry, treeFieldList, (String) parameter.get("cut")); treeDictItem(categoryList, entry, treeFieldList, (String) parameter.get("cut"));
if ("state".equals(entry.getKey())) { if ("state".equals(entry.getKey())) {
List<OnlCgformField> onlCgformFieldList = fieldList.stream().filter(e -> entry.getKey().equals(e.getDbFieldName())).collect(Collectors.toList());
//状态数据字典 //状态数据字典
if (onlCgformFieldList.size() != 0 && StringUtils.isNotBlank(onlCgformFieldList.get(0).getDictField())) {
List<SysDictItem> stateList = sysDictItems.stream() List<SysDictItem> stateList = sysDictItems.stream()
.filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals("state")) .filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals(onlCgformFieldList.get(0).getDictField()))
.collect(Collectors.toList()); .collect(Collectors.toList());
List<SysDictItem> state = stateList.stream().filter(e -> e.getItemValue().equals(entry.getValue())).collect(Collectors.toList()); List<SysDictItem> state = stateList.stream().filter(e -> e.getItemValue().equals(entry.getValue())).collect(Collectors.toList());
if (state.size() != 0) { if (state.size() != 0) {
@@ -2000,6 +1985,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} }
} }
} }
}
return infoPage; return infoPage;
} }
@@ -2076,8 +2062,10 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
for (Map.Entry<String, Object> entry : record1.entrySet()) { for (Map.Entry<String, Object> entry : record1.entrySet()) {
//状态数据字典 //状态数据字典
if ("state".equals(entry.getKey())) { if ("state".equals(entry.getKey())) {
List<OnlCgformField> onlCgformFieldList = fieldList.stream().filter(e -> entry.getKey().equals(e.getDbFieldName())).collect(Collectors.toList());
if (onlCgformFieldList.size() != 0 && StringUtils.isNotBlank(onlCgformFieldList.get(0).getDictField())) {
List<SysDictItem> stateList = sysDictItems.stream() List<SysDictItem> stateList = sysDictItems.stream()
.filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals("state")) .filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals(onlCgformFieldList.get(0).getDictField()))
.collect(Collectors.toList()); .collect(Collectors.toList());
List<SysDictItem> state = stateList.stream().filter(e -> e.getItemValue().equals(entry.getValue())).collect(Collectors.toList()); List<SysDictItem> state = stateList.stream().filter(e -> e.getItemValue().equals(entry.getValue())).collect(Collectors.toList());
if (state.size() != 0) { if (state.size() != 0) {
@@ -2088,6 +2076,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} }
} }
} }
}
//添加文本信息 //添加文本信息
String connectId = (String) record1.get("connect_id"); String connectId = (String) record1.get("connect_id");
if (connectId.equals(entry.getValue())) { if (connectId.equals(entry.getValue())) {
@@ -2158,11 +2147,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
Map<String, Object> record1 = (Map) record; Map<String, Object> record1 = (Map) record;
idList.add((String) record1.get("id")); idList.add((String) record1.get("id"));
for (Map.Entry<String, Object> entry : record1.entrySet()) { for (Map.Entry<String, Object> entry : record1.entrySet()) {
List<OnlCgformField> collect = fieldList.stream()
.filter(e -> entry.getKey().equals(e.getDictField()) && !FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType()))
.collect(Collectors.toList());
//下拉选处理数据字典 //下拉选处理数据字典
dictItem(sysDictItems, entry, collect, cut); dictItem(sysDictItems, entry, cut, fieldList);
treeDictItem(categoryList, entry, treeFieldList, cut); treeDictItem(categoryList, entry, treeFieldList, cut);
} }
} }
@@ -2289,21 +2275,22 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
* *
* @param sysDictItems * @param sysDictItems
* @param entry * @param entry
* @param collect
*/ */
public 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, String cut, List<OnlCgformField> fieldList) {
Map<String, Object> map = new HashMap<>();
//通过dictField判断字段是否为下拉选(不为空则为下拉选) //通过dictField判断字段是否为下拉选(不为空则为下拉选)
if (collect.size() != 0 && StringUtils.isNotBlank(collect.get(0).getDictField())) { List<OnlCgformField> onlCgformFieldList = fieldList.stream().filter(e -> entry.getKey().equals(e.getDbFieldName())).collect(Collectors.toList());
String value = (String) entry.getValue();
//数据字典中文 //数据字典中文
List<String> dictItemsCh = new ArrayList<>(); List<String> dictItemsCh = new ArrayList<>();
List<String> dictItemsEn = new ArrayList<>(); List<String> dictItemsEn = new ArrayList<>();
if (StringUtils.isNotBlank(value)) { for (OnlCgformField onlCgformField : onlCgformFieldList) {
if (FieldTypeEnum.PULL_SINGLE.getValue().equals(onlCgformField.getFieldShowType())
|| FieldTypeEnum.PULL_MORE.getValue().equals(onlCgformField.getFieldShowType())) {
String value = (String) entry.getValue();
if (StringUtils.isNotBlank(value) && onlCgformFieldList.size() != 0 && StringUtils.isNotBlank(onlCgformFieldList.get(0).getDictField())) {
for (String itemValue : value.split(",")) { for (String itemValue : value.split(",")) {
//字段的数据字典 //字段的数据字典
List<SysDictItem> dictItemList = sysDictItems.stream() List<SysDictItem> dictItemList = sysDictItems.stream()
.filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals(entry.getKey())) .filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals(onlCgformFieldList.get(0).getDictField()))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (dictItemList.size() != 0) { if (dictItemList.size() != 0) {
List<SysDictItem> dictItems = dictItemList.stream() List<SysDictItem> dictItems = dictItemList.stream()
@@ -2322,6 +2309,10 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} }
} }
} }
}
}
if (onlCgformFieldList.size() != 0 && StringUtils.isNotBlank(onlCgformFieldList.get(0).getDictField())) {
if (CutEnum.CN.getValue().equals(cut)) { if (CutEnum.CN.getValue().equals(cut)) {
entry.setValue(StringUtils.join(dictItemsCh, ",")); entry.setValue(StringUtils.join(dictItemsCh, ","));
} else { } else {
@@ -2642,11 +2633,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
for (Map<String, Object> data : datas) { for (Map<String, Object> data : datas) {
for (Map.Entry<String, Object> entry : data.entrySet()) { for (Map.Entry<String, Object> entry : data.entrySet()) {
List<OnlCgformField> collect = fieldList.stream()
.filter(e -> entry.getKey().equals(e.getDictField()) && !FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType()))
.collect(Collectors.toList());
//下拉选处理数据字典 //下拉选处理数据字典
dictItem(sysDictItems, entry, collect, cut); dictItem(sysDictItems, entry, cut, fieldList);
//处理树形数据字典 //处理树形数据字典
treeDictItem(categoryList, entry, treeFieldList, cut); treeDictItem(categoryList, entry, treeFieldList, cut);
} }
@@ -1,6 +1,5 @@
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.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -100,7 +99,6 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
} }
@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());
@@ -222,7 +220,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
//下拉单选和下拉多选数据字典处理 //下拉单选和下拉多选数据字典处理
if (fieldPullList.contains(entry.getKey())) { if (fieldPullList.contains(entry.getKey())) {
bussDocumentLibraryEOService.dictItem(sysDictItems, entry, onlCgformFieldList, (String) map.get("cut")); bussDocumentLibraryEOService.dictItem(sysDictItems, entry, (String) map.get("cut"), fieldList);
} }
//处理文件 //处理文件
@@ -730,6 +728,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
/** /**
* 查询段落 * 查询段落
*
* @param map * @param map
* @return * @return
*/ */