From e104f16d95ebfb0b0a9044ca7d146174ec6add18 Mon Sep 17 00:00:00 2001 From: zhn <947514737@qq.com> Date: Fri, 1 Apr 2022 20:56:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2--=E7=BC=96=E8=BE=91=E6=97=B6?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=9B=B4=E6=96=B0=E5=B8=A6=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E7=9A=84=E6=95=B0=E6=8D=AE=E4=B8=AD=E6=8B=BC=E6=8E=A5?= =?UTF-8?q?=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BussDocumentLibraryEOServiceImpl.java | 232 ++++++++++-------- 1 file changed, 127 insertions(+), 105 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 ab9ed4868..80bfb88fd 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 @@ -1127,10 +1127,10 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl> fileTextList = new ArrayList<>(); List oSSFileAll = new ArrayList<>(); - List> maps = new ArrayList<>(); + Map stringObjectMap = new HashMap<>(); try { for (Map.Entry entry : map.entrySet()) { - Map stringObjectMap = new HashMap<>(); + String key = entry.getKey(); Object value = entry.getValue(); //es全文新增数据(数据转换) @@ -1155,7 +1155,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl oSSFileList = new ArrayList<>(); @@ -1186,7 +1185,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl fileInfos = iOSSFileService.getFileInfos(StringUtils.join(fileIdList, ",")); //处理文件排序(发布稿 增补件 报批稿 征求意见稿 测试程序) - List ossFileList = fileSort(fieldFileList, fileInfos, maps); + List ossFileList = fileSort(fieldFileList, fileInfos, stringObjectMap); List> mapListTempCn = new ArrayList<>(); List> mapListTempEn = new ArrayList<>(); @@ -1641,9 +1640,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl oSSFileAll = new ArrayList<>(); StringBuilder sbCn = new StringBuilder(); StringBuilder sbEn = new StringBuilder(); - List> maps = new ArrayList<>(); + Map stringObjectMap = new HashMap<>(); for (Map.Entry entry : mapNew.entrySet()) { - Map stringObjectMap = new HashMap<>(); String key = entry.getKey(); Object value = entry.getValue(); //es全文新增数据(数据转换) @@ -1672,7 +1670,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl oSSFileList = new ArrayList<>(); for (String fileId : value.toString().split(",")) { @@ -1709,44 +1706,41 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl fileInfos = iOSSFileService.getFileInfos(StringUtils.join(fileIdList, ",")); //处理文件排序(发布稿 增补件 报批稿 征求意见稿 测试程序) - List ossFileList = fileSort(fieldFileList, fileInfos, maps); + List ossFileList = fileSort(fieldFileList, fileInfos, stringObjectMap); List> mapListTempCn = new ArrayList<>(); List> mapListTempEn = new ArrayList<>(); try { + String cutCn = CutEnum.CN.getValue(); + String cutEn = CutEnum.EN.getValue(); if (fileInfos.size() != 0) { - String cutCn = CutEnum.CN.getValue(); - String cutEn = CutEnum.EN.getValue(); - Map mapBaseDateCn = new HashMap<>(); - Map mapBaseDateEn = new HashMap<>(); - for (OSSFile ossFile : fileInfos) { - Map stringMapCn = new HashMap<>(); - Map stringMapEn = new HashMap<>(); - String fileText = ""; - if (ossFile.getFileName().endsWith(".doc") - || ossFile.getFileName().endsWith(".docx") - || ossFile.getFileName().endsWith(".DOC") - || ossFile.getFileName().endsWith(".DOCX")) { - String wordContent = null; - try { - wordContent = ReadWordUtil.readWord(ossFile.getUrl()); - } catch (Exception e) { - log.error("文档库:读取word文件内容失败"); - } - if (StringUtils.isNotBlank(wordContent)) { - fileText = wordContent; - } - } else if (ossFile.getFileName().endsWith(".pdf") || ossFile.getFileName().endsWith(".PDF")) { - String pdfContent = null; - try { - pdfContent = ReadPdfUtil.readPdf(ossFile.getUrl()); - } catch (Exception e) { - log.error("文档库读取PDF文件内容失败"); - } - if (StringUtils.isNotBlank(pdfContent)) { - fileText = pdfContent; + //编辑时,有修改文件的情况 + updateEsInfo(map, searchFieldList, sbCn, sbEn, fileInfos, mapListTempCn, mapListTempEn, cutCn, cutEn); + } else { + //没有修改文件,获取之前上传过的文件 + List fieldFileListTemp = fieldList.stream() + .filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList()); + List fileFieldList = fieldFileListTemp.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); + List connectIdList = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + String key = entry.getKey(); + String value = String.valueOf(entry.getValue()); + if(fileFieldList.contains(key)){ + if(!"null".equals(value)){ + connectIdList.add(value); } } + } + if(connectIdList.size()!= 0){ + List oSSFileListTemp = iOSSFileService.getFileInfosByConnectId(StringUtils.join(connectIdList, ",")); + //处理文件排序(发布稿 增补件 报批稿 征求意见稿 测试程序) + List files = fileSort(fieldFileList, oSSFileListTemp, map); + updateEsInfo(map, searchFieldList, sbCn, sbEn, files, mapListTempCn, mapListTempEn, cutCn, cutEn); + + }else{ + //之前没有上传过文件 + Map stringMapCn = new HashMap<>(); + Map stringMapEn = new HashMap<>(); for (OnlCgformField onlCgformField : searchFieldList) { String s = (String) map.get(onlCgformField.getDbFieldName()); if(FieldTypeEnum.DATE_SINGLE.getValue().equals(onlCgformField.getFieldShowType()) && StringUtils.isNotBlank(s)){ @@ -1759,68 +1753,19 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl objectMap : mapListTempCn) { - a++; - objectMap.put("file_sort",(String) map.get("id")+"_"+a); - } - for (Map objectMap : mapListTempEn) { - b++; - objectMap.put("file_sort",(String) map.get("id")+"_"+b); - } } - - //基础数据中文(es) - putMapCn((String) map.get("id"), (String) map.get("serial_number"), "文档库", - sbCn.toString(), (String) map.get("title"), "", "", - cutCn, mapBaseDateCn,SEARCH_FLAG); - mapBaseDateCn.put("file_sort",(String) map.get("id")+"_"+1); - //基础数据英文(es) - putMapCn((String) map.get("id"), (String) map.get("serial_number"), "document library", - sbEn.toString(), (String) map.get("title"), "", "", - cutEn, mapBaseDateEn,SEARCH_FLAG); - mapBaseDateEn.put("file_sort",(String) map.get("id")+"_"+1); - mapListTempCn.add(mapBaseDateCn); - mapListTempEn.add(mapBaseDateEn); - } else { - Map stringMapCn = new HashMap<>(); - Map stringMapEn = new HashMap<>(); - for (OnlCgformField onlCgformField : searchFieldList) { - String s = (String) map.get(onlCgformField.getDbFieldName()); - if(FieldTypeEnum.DATE_SINGLE.getValue().equals(onlCgformField.getFieldShowType()) && StringUtils.isNotBlank(s)){ - s = s.split(" ")[0]; - } - if(StringUtils.isNotBlank(s)){ - stringMapCn.put(onlCgformField.getDbFieldName(), s); - stringMapEn.put(onlCgformField.getDbFieldName(), s); - } - } - String cutCn = CutEnum.CN.getValue(); - String cutEn = CutEnum.EN.getValue(); - //封装中文的全文内容(es) - putMapCn((String) map.get("id"), (String) map.get("serial_number"), "文档库", - sbCn.toString(), (String) map.get("title"), "", "", - cutCn, stringMapCn,SEARCH_FLAG); - stringMapCn.put("file_sort",(String) map.get("id")+"_"+1); - //封装英文的全文内容(es) - putMapCn((String) map.get("id"), (String) map.get("serial_number"), "document library", - sbEn.toString(), (String) map.get("title"), "", "", - cutEn, stringMapEn,SEARCH_FLAG); - stringMapEn.put("file_sort",(String) map.get("id")+"_"+1); - - mapListTempCn.add(stringMapCn); - mapListTempEn.add(stringMapEn); } } catch (Exception e) { @@ -1901,6 +1846,85 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl map, List searchFieldList, StringBuilder sbCn, StringBuilder sbEn, List fileInfos, List> mapListTempCn, List> mapListTempEn, String cutCn, String cutEn) { + Map mapBaseDateCn = new HashMap<>(); + Map mapBaseDateEn = new HashMap<>(); + for (OSSFile ossFile : fileInfos) { + Map stringMapCn = new HashMap<>(); + Map stringMapEn = new HashMap<>(); + String fileText = ""; + if (ossFile.getFileName().endsWith(".doc") + || ossFile.getFileName().endsWith(".docx") + || ossFile.getFileName().endsWith(".DOC") + || ossFile.getFileName().endsWith(".DOCX")) { + String wordContent = null; + try { + wordContent = ReadWordUtil.readWord(ossFile.getUrl()); + } catch (Exception e) { + log.error("文档库:读取word文件内容失败"); + } + if (StringUtils.isNotBlank(wordContent)) { + fileText = wordContent; + } + } else if (ossFile.getFileName().endsWith(".pdf") || ossFile.getFileName().endsWith(".PDF")) { + String pdfContent = null; + try { + pdfContent = ReadPdfUtil.readPdf(ossFile.getUrl()); + } catch (Exception e) { + log.error("文档库读取PDF文件内容失败"); + } + if (StringUtils.isNotBlank(pdfContent)) { + fileText = pdfContent; + } + } + for (OnlCgformField onlCgformField : searchFieldList) { + String s = (String) map.get(onlCgformField.getDbFieldName()); + if(FieldTypeEnum.DATE_SINGLE.getValue().equals(onlCgformField.getFieldShowType()) && StringUtils.isNotBlank(s)){ + s = s.split(" ")[0]; + } + if(StringUtils.isNotBlank(s)){ + stringMapCn.put(onlCgformField.getDbFieldName(), s); + stringMapEn.put(onlCgformField.getDbFieldName(), s); + } + } + + //封装中文的全文内容(es) + putMapCn((String) map.get("id") + ossFile.getId(), (String) map.get("serial_number"), "文档库", + sbCn.toString(), (String) map.get("title"), fileText, ossFile.getFileName(), + cutCn, stringMapCn,null); + //封装英文的全文内容(es) + putMapCn((String) map.get("id") + ossFile.getId(), (String) map.get("serial_number"), "document library", + sbEn.toString(), (String) map.get("title"), fileText, ossFile.getFileName(), + cutEn, stringMapEn,null); + + mapListTempCn.add(stringMapCn); + mapListTempEn.add(stringMapEn); + int a = 1; + int b = 1; + for (Map objectMap : mapListTempCn) { + a++; + objectMap.put("file_sort",(String) map.get("id")+"_"+a); + } + for (Map objectMap : mapListTempEn) { + b++; + objectMap.put("file_sort",(String) map.get("id")+"_"+b); + } + } + + //基础数据中文(es) + putMapCn((String) map.get("id"), (String) map.get("serial_number"), "文档库", + sbCn.toString(), (String) map.get("title"), "", "", + cutCn, mapBaseDateCn,SEARCH_FLAG); + mapBaseDateCn.put("file_sort",(String) map.get("id")+"_"+1); + //基础数据英文(es) + putMapCn((String) map.get("id"), (String) map.get("serial_number"), "document library", + sbEn.toString(), (String) map.get("title"), "", "", + cutEn, mapBaseDateEn,SEARCH_FLAG); + mapBaseDateEn.put("file_sort",(String) map.get("id")+"_"+1); + mapListTempCn.add(mapBaseDateCn); + mapListTempEn.add(mapBaseDateEn); + } + /** * 更新log * @@ -4108,20 +4132,18 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl字段 value-->关联文件connect_id */ - public List fileSort(List fieldFileList,List oSSFileAll,List> maps){ + public List fileSort(List fieldFileList,List oSSFileAll,Map map){ List result = new LinkedList<>(); List fileFeildList = fieldFileList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); for (OnlCgformField onlCgformField : fieldFileList) { String dbFieldName = onlCgformField.getDbFieldName(); - for (Map map : maps) { - for (Map.Entry entry : map.entrySet()) { - String key = entry.getKey(); - String value = (String)entry.getValue(); - if(dbFieldName.equals(key)){ - List files = oSSFileAll.stream().filter(e -> value.equals(e.getConnectId())).collect(Collectors.toList()); - if(files.size() != 0){ - result.addAll(files); - } + for (Map.Entry entry : map.entrySet()) { + String key = entry.getKey(); + String value = (String) entry.getValue(); + if (dbFieldName.equals(key)) { + List files = oSSFileAll.stream().filter(e -> StringUtils.isNotBlank(value) && value.equals(e.getConnectId())).collect(Collectors.toList()); + if (files.size() != 0) { + result.addAll(files); } } }