From 6307e1ef28d1fb46767e0a818ad8af416d24d91b Mon Sep 17 00:00:00 2001
From: gaosong
Date: Tue, 9 Aug 2022 01:42:33 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3=E5=AF=B9?=
=?UTF-8?q?=E6=AF=94-=E6=B7=BB=E5=8A=A0=E5=AF=B9=E6=AF=94=E7=BB=93?=
=?UTF-8?q?=E6=9E=9C=E5=AF=BC=E5=87=BAExcel?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../SarFileCompareItemCommentServiceImpl.java | 86 +++++++++++++++++--
1 file changed, 81 insertions(+), 5 deletions(-)
diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/impl/SarFileCompareItemCommentServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/impl/SarFileCompareItemCommentServiceImpl.java
index 60ecb484c..7fb64f770 100644
--- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/impl/SarFileCompareItemCommentServiceImpl.java
+++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/impl/SarFileCompareItemCommentServiceImpl.java
@@ -11,17 +11,20 @@ import com.jero.modules.compare.service.ISarFileCompareInfoService;
import com.jero.modules.compare.service.ISarFileCompareItemCommentService;
import com.jero.modules.compare.service.ISarFileCompareItemService;
import com.jero.modules.system.util.StringUtils;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
+import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -169,6 +172,20 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl map, HttpServletResponse response, HttpServletRequest request) {
String cut = (String) map.get("cut");
+ //是否包含评论
+ String includeComments = (String) map.get("includeComments");
+ String infoId = (String) map.get("infoId");
+ String selectIds = (String) map.get("selectIds");
+
+ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(SarFileCompareItemComment::getInfoId, infoId);
+ if (!StringUtils.isEmpty(selectIds)) {
+ queryWrapper.in(SarFileCompareItemComment::getId, Arrays.asList(selectIds.split(",")));
+ }
+ queryWrapper.orderBy(true, true, SarFileCompareItemComment::getCreateTime);
+ List list = this.list(queryWrapper);
+ Map sfcItemMap = SarFileCompareItemServiceImpl.queryMapByInfoId(infoId);
+
OutputStream os = null;
Workbook workbook = new XSSFWorkbook();
try {
@@ -177,11 +194,70 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl", "").replace("
", "\r\n");
+ row.createCell(2).setCellValue(text);
+ }
+ }
+ String itemIdRight = itemComment.getItemsIdRight();
+ SarFileCompareItem itemRight = sfcItemMap.get(itemIdRight);
+ if (null != itemRight) {
+ row.createCell(3).setCellValue(itemRight.getItemsNum());
+ row.createCell(4).setCellValue(itemRight.getItemsName());
+ String text = itemRight.getItemsText();
+ text = text.replace("", "").replace("
", "\r\n");
+ row.createCell(5).setCellValue(text);
+ }
+ row.createCell(6).setCellValue(itemComment.getComment());
+ i++;
+ }
+ if (!StringUtils.isEmpty(includeComments) && includeComments.equals("1")) {
+ Row row = sheet.createRow(i);
+ if (CutEnum.CN.getValue().equals(cut)) {
+ row.createCell(0).setCellValue("全文评论");
+ } else {
+ row.createCell(0).setCellValue("The full text comments");
+ }
+ //合并单元格
+ CellRangeAddress rangeAddress = new CellRangeAddress(row.getRowNum(), row.getRowNum(), 1, 6);
+ sheet.addMergedRegion(rangeAddress);
+ SarFileCompareInfo compareInfo = sarFileCompareInfoServiceImpl.queryById(infoId);
+ row.createCell(1).setCellValue(compareInfo.getComments());
+ }
+ for (int j = 0; j < 7; j++) {
+ sheet.autoSizeColumn(j, true);//设置列宽
+ }
os = response.getOutputStream();
+// File file = new File("C://work/ee.xlsx");
+// os = new FileOutputStream(file);
workbook.write(os);
os.flush();
} catch (IOException e) {