From acc9c296c06f506ef049eef5190381c08f934c71 Mon Sep 17 00:00:00 2001 From: zhn <947514737@qq.com> Date: Fri, 25 Mar 2022 21:16:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=BA=93--=E5=85=A8=E6=96=87?= =?UTF-8?q?=E6=90=9C=E7=B4=A2(=E4=BC=98=E5=85=88=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E6=AD=A3=E6=96=87,=E6=AD=A3=E6=96=87=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E5=88=99=E5=B1=95=E7=A4=BA=E6=8B=BC=E6=8E=A5=E5=86=85?= =?UTF-8?q?=E5=AE=B9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BussDocumentLibraryEOServiceImpl.java | 9 ---- .../impl/DocumentSearchServiceImpl.java | 51 +++++++++++-------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java index 5d7b07420..05c8c925d 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java @@ -1413,7 +1413,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl> fileTextList = new ArrayList<>(); List oSSFileAll = new ArrayList<>(); for (Map.Entry entry : map.entrySet()) { String key = entry.getKey(); @@ -1475,14 +1474,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl mapFullText = new HashMap<>(); - mapFullText.put("id", id); - mapFullText.put("module_type", "文档库"); - mapFullText.put("serial_number", map.get("serial_number")); - mapFullText.put("title", map.get("title")); - mapFullText.put("file_text", fileTextList); - mapFullText.put("content", sb.toString()); - List fileIdList = oSSFileAll.stream().map(OSSFile::getId).collect(Collectors.toList()); List fileInfos = iOSSFileService.getFileInfos(StringUtils.join(fileIdList, ",")); List> mapListTemp = new ArrayList<>(); 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 37853567f..68c3bbcc7 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 @@ -497,34 +497,45 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { //二次查询 int count = 0; for (Map.Entry entry : mapSource.entrySet()) { - String key = entry.getKey(); String value = (String) entry.getValue(); - //二次搜索的file_text是在一次搜索的基础上 - if("file_text".equals(key)){ - //判断value中是否包含首次搜索中的字符 - boolean flag = judgeContains(value, selectValue); - if(flag){ - //截取第一处高亮的前后100个字符 - value = getFileText(value, selectValue); - } - } //判断value中是否包含二次搜索中的字符 boolean flag = judgeContains(value, selectValueTwo); + StringBuilder sb = new StringBuilder(); if (flag) { //截取第一处高亮的前后100个字符 - value = getFileText(value, selectValue); + value = getFileText(value, selectValueTwo); count++; - StringBuilder sb = new StringBuilder(); - if (StringUtils.isNotBlank(value)) { + for (int i = 0; i < value.length(); i++) { + String chStr = String.valueOf(value.charAt(i)); + //第一次的搜索条件也需要高亮 + String condition = selectValueTwo + selectValue; + if (condition.contains(String.valueOf(chStr))) { + chStr = "" + chStr + ""; + } + sb.append(String.valueOf(chStr)); + } + entry.setValue(sb.toString()); + }else{ + //第二次搜索的时候file_text中不包含搜索条件的时候将file_text赋值空(此时展示拼接的内容) + if("file_text".equals(entry.getKey())){ + entry.setValue(""); + } + count++; + //如果内容中不包含第二次搜索条件,则继续高亮第一处 + //判断value中是否包含首次搜索中的字符(因为其他的字段有可能包含二次的搜索条件查出来的这条数据,所以还得判断value中是否包含首次搜索中的字符) + boolean flagOne = judgeContains(value, selectValue); + if(flagOne){ + //如果包含第一次的搜索条件,先前后截取100字符后再高亮 + value = getFileText(value, selectValue); for (int i = 0; i < value.length(); i++) { String chStr = String.valueOf(value.charAt(i)); - if (selectValueTwo.contains(String.valueOf(chStr))) { + if (selectValue.contains(String.valueOf(chStr))) { chStr = "" + chStr + ""; } sb.append(String.valueOf(chStr)); } + entry.setValue(sb.toString()); } - entry.setValue(sb.toString()); } } if (count > 0) { @@ -545,15 +556,14 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { //判断value中是否包含搜索中的字符 boolean flag = judgeContains(value, selectValue); if(flag){ -// mapSource.put("file_text_flag","true"); //截取第一处高亮的前后100个字符 value = getFileText(value, selectValue); + }else{ + //第一次搜索的时候file_text中不包含搜索条件的时候将file_text赋值空(此时展示拼接的内容) + entry.setValue(""); + value = ""; } } - if("content".equals(key)){ - //判断value中是否包含搜索中的字符 - boolean flag = judgeContains(value, selectValue); - } for (int i = 0; i < value.length(); i++) { String chStr = String.valueOf(value.charAt(i)); if (selectValue.contains(String.valueOf(chStr))) { @@ -677,6 +687,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { || FieldTypeEnum.TEXT_NUMBER.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())//下拉单选