From 2c941e334b5e2b7ddd3e959a03e30c05c2fb4899 Mon Sep 17 00:00:00 2001 From: wangzhijiang <12345678> Date: Wed, 7 Sep 2022 18:34:25 +0800 Subject: [PATCH] =?UTF-8?q?59339=20=E6=B3=95=E8=A7=84=E6=8A=80=E6=9C=AF?= =?UTF-8?q?=E8=AF=84=E4=BC=B0=E5=AF=BC=E5=87=BA=E6=95=B0=E6=8D=AE=E6=9C=89?= =?UTF-8?q?=E8=AF=AF=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...logyEvaluationItemResultEOServiceImpl.java | 58 ++++++++++++++++++- .../impl/DocumentSearchServiceImpl.java | 2 +- .../impl/FileSplitItemsEOServiceImpl.java | 3 +- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/lawsTechnologyEvaluation/service/impl/LawsTechnologyEvaluationItemResultEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/lawsTechnologyEvaluation/service/impl/LawsTechnologyEvaluationItemResultEOServiceImpl.java index b788927a3..260cb2f41 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/lawsTechnologyEvaluation/service/impl/LawsTechnologyEvaluationItemResultEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/lawsTechnologyEvaluation/service/impl/LawsTechnologyEvaluationItemResultEOServiceImpl.java @@ -45,6 +45,9 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -298,10 +301,12 @@ public class LawsTechnologyEvaluationItemResultEOServiceImpl extends ServiceImpl cell.setCellValue(titleArr[i]); } + List allImgList = new ArrayList<>(); // 存储文件数据 + //设置导出数据 if(CollectionUtils.isNotEmpty(exportData)) { List allTableList = new ArrayList<>(); // 存储表格数据 - List allImgList = new ArrayList<>(); // 存储文件数据 + SarFileSplitItemsEOPage page = new SarFileSplitItemsEOPage(); for (int dataIndex = 0; dataIndex < exportData.size(); dataIndex++) { @@ -318,7 +323,11 @@ public class LawsTechnologyEvaluationItemResultEOServiceImpl extends ServiceImpl List getValList = this.sarFileSplitItemsValEOService.queryByList(valEOPage); List valContentList = this.fileSplitItemsEOService.combineItemValInfo(getValList,allTableList,allImgList,page); //TODO if(CollectionUtils.isNotEmpty(valContentList)){ - itemContent = valContentList.get(0).getValContent(); + String contents = ""; + for (FileSplitValExportDto fileSplitValExportDto : valContentList) { + contents += fileSplitValExportDto.getValContent() + "\n"; + } + itemContent = contents; } } @@ -341,6 +350,12 @@ public class LawsTechnologyEvaluationItemResultEOServiceImpl extends ServiceImpl fileTemp.delete(); } fileTemp.mkdirs(); + + //下载图片内容到导出的压缩包中 + if (allImgList != null && !allImgList.isEmpty()) { + downLoadImgList(allImgList,path); + } + //excel OutputStream excelOS = new FileOutputStream(path + File.separator + fileName); workbook.write(excelOS); @@ -434,4 +449,43 @@ public class LawsTechnologyEvaluationItemResultEOServiceImpl extends ServiceImpl } return evaluationMethodsName; } + + public void downLoadImgList(List allImgList, String fileNowPath) { + for(FileSplitValImgExportDto imgExportDto : allImgList){ + String oldPath = imgExportDto.getImgPath(); + String newPath = fileNowPath + File.separator + imgExportDto.getImgName(); + if (CosBootUtil.doesObjectExist(oldPath)){ + try (InputStream in = CosBootUtil.download(oldPath);) { + copyFile1(in, newPath); + } catch (IOException e) { + e.printStackTrace(); + log.error(e.getMessage(), e); + } + } + } + } + + public void copyFile1(InputStream in, String destPath) throws IOException { + BufferedInputStream bis = new BufferedInputStream(in); + BufferedOutputStream bos = + new BufferedOutputStream(Files.newOutputStream(Paths.get(destPath), + StandardOpenOption.CREATE, + StandardOpenOption.TRUNCATE_EXISTING, + StandardOpenOption.WRITE)); + // 打开输入流 +// FileInputStream fis = new FileInputStream(srcPath); + // 打开输出流 +// FileOutputStream fos = new FileOutputStream(destPath); + // 读取和写入信息 + byte[] bytes = new byte[1024 * 1024]; + int len; + while ((len = bis.read(bytes)) > 0) { + bos.write(bytes, 0, len); + } + // 关闭流 先开后关 后开先关 + // 先开后关,先开的输入流,再开的输出流,那么应该先关输出流,再关输入流 + // 先关外层,再关内层。如BufferedInputStream包装了一个FileInputStream,那么先关BufferedInputStream,再关FileInputStream。 + bos.close(); // 后开先关 + bis.close(); // 先开后关 + } } 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 a3082a93e..7bbdfb98d 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 @@ -1519,7 +1519,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { list1.add(""); mapTemp.put("pre_tags", list); mapTemp.put("post_tags", list1); - mapTemp.put("fragment_size", 500);//高亮字段内容长度,去除html样式标签,统计字数,设置为200 + mapTemp.put("fragment_size", 320);//高亮字段内容长度,去除html样式标签,统计字数,设置为200 mapTemp.put("number_of_fragments", 1);//高亮内容默认分为5段, 此处设置为一段 mapTemp.put("type", "plain"); mapHighlight.put(key, mapTemp); diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java index 6b37ba8b2..31f8f91a1 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java @@ -3209,7 +3209,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl