From 5e48545a731c8a237ae7b3b6ebf0748677032aa6 Mon Sep 17 00:00:00 2001
From: CD <1103614279@qq.com>
Date: Tue, 27 Sep 2022 15:28:42 +0800
Subject: [PATCH] bug
---
.../SarFileCompareItemCommentController.java | 4 +-
.../ISarFileCompareItemCommentService.java | 2 +-
.../SarFileCompareItemCommentServiceImpl.java | 90 ++++++++++++++++---
3 files changed, 80 insertions(+), 16 deletions(-)
diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/controller/SarFileCompareItemCommentController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/controller/SarFileCompareItemCommentController.java
index 2856b2102..e0b474d01 100644
--- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/controller/SarFileCompareItemCommentController.java
+++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/controller/SarFileCompareItemCommentController.java
@@ -165,8 +165,8 @@ public class SarFileCompareItemCommentController extends JeroController list = null;
if (includeComments && StringUtils.isEmpty(selectIds)) {
//只导出全文评论的情况
@@ -180,8 +199,10 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl sfcItemMap = SarFileCompareItemServiceImpl.queryMapByInfoId(infoId);
+ SarFileCompareInfo sarFileCompareInfo = sarFileCompareInfoServiceImpl.queryById(infoId);
+
OutputStream os = null;
- Workbook workbook = new XSSFWorkbook();
+ Workbook workbook = new HSSFWorkbook();
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String fileName = "导出对比结果 " + sdf.format(new Date()) + ".xlsx";
@@ -195,15 +216,15 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl", "").replace("
", "\r\n");
- row.createCell(2).setCellValue(text);
+ BufferedImage bufferImg = null;
+ ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+ addImgdata(text,request.getSession());
+ String rowdata = "";
+ String rowDataAndPath = (String) request.getSession().getAttribute("txtAndImg");
+ for (String s : rowDataAndPath.split("---")) {
+ if (s.contains(".jpg") || s.contains(".png")) {
+ File file = new File(filePath + s);
+ if (file.exists()) {
+ bufferImg = ImageIO.read(file);
+ ImageIO.write(bufferImg, "jpg", byteArrayOut);
+ //anchor主要用于设置图片的属性
+ HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200,(short)3, i, (short) 3, i);
+ patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
+
+ }
+ } else {
+ rowdata = rowdata + s;
+ }
+ }
+
+
+ row.createCell(3).setCellValue(rowdata);
row.setRowStyle(cellStyle);
}
}
@@ -235,15 +280,15 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl", "").replace("", "\r\n");
- row.createCell(5).setCellValue(text);
+ row.createCell(7).setCellValue(text);
row.setRowStyle(cellStyle);
}
}
- row.createCell(6).setCellValue(itemComment.getComment());
+ row.createCell(8).setCellValue(itemComment.getComment());
for (int j = 0; j < 7; j++) {
Cell cell = row.getCell(j);
if (null != cell) {
@@ -280,4 +325,23 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl标签内容中的图片路径,并重新按顺序拼接
+ * @param text
+ * @return
+ */
+ private void addImgdata(String text,HttpSession session) {
+ if (text.contains("<") || text.contains(">")) {
+ String txtLeft = text.substring(0, text.indexOf("<"));
+ String txtRight = text.substring(text.indexOf(">") + 1);
+ String img = text.substring(text.indexOf("<"), text.indexOf(">"));
+ String path = img.substring(img.lastIndexOf("=") + 1, img.lastIndexOf("\""));
+ text = txtLeft + "---" + path + "---" + txtRight;
+ addImgdata(text, session);
+ } else {
+ session.setAttribute("txtAndImg", text);
+ }
+ }
+
}