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) {