From 0a0597c8101a02ad3a6602782a5f5f2d2d747e97 Mon Sep 17 00:00:00 2001 From: zhn <947514737@qq.com> Date: Wed, 23 Mar 2022 17:10:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=BA=93--es=E6=96=B0?= =?UTF-8?q?=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BussDocumentLibraryEOServiceImpl.java | 94 +++++++++++-------- 1 file changed, 55 insertions(+), 39 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 3deec4dae..fcab7162f 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 @@ -243,9 +243,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue()); + //获取搜索中心字段 + List searchFieldList = fieldList.stream().filter(e -> YesOrNoEnum.YES.getValue().equals(e.getIsShowSearch())).collect(Collectors.toList()); //文件类型字段 List fieldFileList = fieldList.stream().filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList()); //树形数据字典 @@ -1053,32 +1057,60 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl fileInfos = iOSSFileService.getFileInfos(StringUtils.join(fileIdList, ",")); List> mapListTemp = new ArrayList<>(); try { - for (OSSFile ossFile : fileInfos) { - Map stringMap = new HashMap<>(); - String fileText = ""; - if(ossFile.getFileName().endsWith(".doc") - || ossFile.getFileName().endsWith(".docx") - || ossFile.getFileName().endsWith(".DOC") - || ossFile.getFileName().endsWith(".DOCX")){ - String wordContent = ReadWordUtil.readWord(ossFile.getUrl()); - if(StringUtils.isNotBlank(wordContent)){ - fileText = wordContent; + if(fileInfos.size() != 0){ + for (OSSFile ossFile : fileInfos) { + Map stringMap = new HashMap<>(); + String fileText = ""; + if(ossFile.getFileName().endsWith(".doc") + || ossFile.getFileName().endsWith(".docx") + || ossFile.getFileName().endsWith(".DOC") + || ossFile.getFileName().endsWith(".DOCX")){ + String wordContent = ReadWordUtil.readWord(ossFile.getUrl()); + if(StringUtils.isNotBlank(wordContent)){ + fileText = wordContent; + } + }else if(ossFile.getFileName().endsWith(".pdf")||ossFile.getFileName().endsWith(".PDF")){ + String pdfContent = ReadPdfUtil.readPdf(ossFile.getUrl()); + if(StringUtils.isNotBlank(pdfContent)){ + fileText = pdfContent; + } } - }else if(ossFile.getFileName().endsWith(".pdf")||ossFile.getFileName().endsWith(".PDF")){ - String pdfContent = ReadPdfUtil.readPdf(ossFile.getUrl()); - if(StringUtils.isNotBlank(pdfContent)){ - fileText = pdfContent; + for (OnlCgformField onlCgformField : searchFieldList) { + String s = (String) map.get(onlCgformField.getDbFieldName()); + if(StringUtils.isBlank(s)){ + s = ""; + } + stringMap.put(onlCgformField.getDbFieldName(),s); } + + stringMap.put("id",idTemp+ossFile.getId()); + stringMap.put("module_type", "文档库"); + stringMap.put("serial_number", map.get("serial_number")); + stringMap.put("title", map.get("title")); + stringMap.put("content", sb.toString()); + stringMap.put("file_text",fileText); + stringMap.put("file_name",ossFile.getFileName()); + mapListTemp.add(stringMap); } - stringMap.put("id",idTemp+ossFile.getId()); + }else{ + Map stringMap = new HashMap<>(); + for (OnlCgformField onlCgformField : searchFieldList) { + String s = (String) map.get(onlCgformField.getDbFieldName()); + if(StringUtils.isBlank(s)){ + s = ""; + } + stringMap.put(onlCgformField.getDbFieldName(),s); + } + stringMap.put("id",idTemp); stringMap.put("module_type", "文档库"); stringMap.put("serial_number", map.get("serial_number")); stringMap.put("title", map.get("title")); stringMap.put("content", sb.toString()); - stringMap.put("file_text",fileText); - stringMap.put("file_name",ossFile.getFileName()); + stringMap.put("file_text",""); + stringMap.put("file_name",""); mapListTemp.add(stringMap); } + } catch (Exception e) { log.error("文档库新增es错误"); } @@ -1353,11 +1385,7 @@ 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")); + List> fileTextList = new ArrayList<>(); for (Map.Entry entry : map.entrySet()) { String key = entry.getKey(); @@ -1416,23 +1444,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl oSSFileList = new ArrayList<>(); -// for (String fileId : value.toString().split(",")) { -// OSSFile ossFile = new OSSFile(); -// ossFile.setId(fileId); -// ossFile.setConnectId(valueTemp); -// oSSFileList.add(ossFile); -// } -// iOSSFileService.updateFileInfo(oSSFileList); -// valuesBuilder.append("'" + valueTemp + "'" + ","); -// } else { -// valuesBuilder.append("'" + value + "'" + ","); -// } - } else { //编辑时replaced_standard被代替标准不存值,通过查询得到 if ("replaced_standard".equals(key)) { @@ -1445,6 +1456,11 @@ 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());