From d944ffae03e7b754e17c08b00a5ce24cd83e6dce Mon Sep 17 00:00:00 2001 From: CD <1103614279@qq.com> Date: Sat, 8 Oct 2022 14:43:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=AF=B9=E6=AF=94=E5=9B=BE?= =?UTF-8?q?=E7=89=87bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SarFileCompareItemCommentServiceImpl.java | 149 ++++++------------ 1 file changed, 48 insertions(+), 101 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 c13dd7034..ba903bf84 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 @@ -278,57 +278,30 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl 1) { for (int j = 0; j < leftSplit.length; j++) { - if (j > 0) { - Row row2 = sheet.createRow(j + i); - if (leftSplit[j].contains(".jpg") || leftSplit[j].contains(".png")) { - row2.setHeight((short) 5000); //设置行高 - //先将图片下载到本地 - String fileLastName = leftSplit[j].substring(leftSplit[j].lastIndexOf("/") + 1); - if (CosBootUtil.doesObjectExist(leftSplit[j])) { - try (InputStream in = CosBootUtil.download(leftSplit[j])) { - copyFile2(in, dir + File.separator + fileLastName); - } catch (IOException e) { - e.printStackTrace(); - log.error(e.getMessage(), e); - } + Row row2 = sheet.createRow(j + i); + if (leftSplit[j].contains("/upFiles")) { + row2.setHeight((short) 5000); //设置行高 + //先将图片下载到本地 + String fileLastName = leftSplit[j].substring(leftSplit[j].lastIndexOf("/") + 1); + if (CosBootUtil.doesObjectExist(leftSplit[j])) { + try (InputStream in = CosBootUtil.download(leftSplit[j])) { + copyFile2(in, dir + File.separator + fileLastName); + } catch (IOException e) { + e.printStackTrace(); + log.error(e.getMessage(), e); } - File file = new File(dir + File.separator + fileLastName); - if (file.exists()) { - bufferImg = ImageIO.read(file); - ImageIO.write(bufferImg, "jpg", byteArrayOut); - //anchor主要用于设置图片的属性 - HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) 3, j + i, (short) 3, j + i); - patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); + } + File file = new File(dir + File.separator + fileLastName); + if (file.exists()) { + bufferImg = ImageIO.read(file); + ImageIO.write(bufferImg, "jpg", byteArrayOut); + //anchor主要用于设置图片的属性 + HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) 3, j + i, (short) 3, j + i); + patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); - } - } else { - row2.createCell(3).setCellValue(leftSplit[j]); } } else { - if (leftSplit[j].contains(".jpg") || leftSplit[j].contains(".png")) { - row.setHeight((short) 5000); //设置行高 - //先将图片下载到本地 - String fileLastName = leftSplit[j].substring(leftSplit[j].lastIndexOf("/") + 1); - if (CosBootUtil.doesObjectExist(leftSplit[j])) { - try (InputStream in = CosBootUtil.download(leftSplit[j])) { - copyFile2(in, dir + File.separator + fileLastName); - } catch (IOException e) { - e.printStackTrace(); - log.error(e.getMessage(), e); - } - } - File file = new File(dir + File.separator + fileLastName); - if (file.exists()) { - bufferImg = ImageIO.read(file); - ImageIO.write(bufferImg, "jpg", byteArrayOut); - //anchor主要用于设置图片的属性 - HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) 3, j + i, (short) 3, j + i); - patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); - - } - } else { - row.createCell(3).setCellValue(leftSplit[j]); - } + row2.createCell(3).setCellValue(leftSplit[j]); } } sarFileCompareExcelMergeCell.setLeftStart(i); @@ -357,57 +330,30 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl 1) { for (int j = 0; j < rightSplit.length; j++) { - if (j > 0) { - Row row2 = sheet.createRow(j + i); - if (rightSplit[j].contains(".jpg") || rightSplit[j].contains(".png")) { - row2.setHeight((short) 5000); //设置行高 - //先将图片下载到本地 - String fileLastName = rightSplit[j].substring(rightSplit[j].lastIndexOf("/") + 1); - if (CosBootUtil.doesObjectExist(rightSplit[j])) { - try (InputStream in = CosBootUtil.download(rightSplit[j])) { - copyFile2(in, dir + File.separator + fileLastName); - } catch (IOException e) { - e.printStackTrace(); - log.error(e.getMessage(), e); - } + Row row2 = sheet.createRow(j + i); + if (rightSplit[j].contains("/upFiles")) { + row2.setHeight((short) 5000); //设置行高 + //先将图片下载到本地 + String fileLastName = rightSplit[j].substring(rightSplit[j].lastIndexOf("/") + 1); + if (CosBootUtil.doesObjectExist(rightSplit[j])) { + try (InputStream in = CosBootUtil.download(rightSplit[j])) { + copyFile2(in, dir + File.separator + fileLastName); + } catch (IOException e) { + e.printStackTrace(); + log.error(e.getMessage(), e); } - File file = new File(dir + File.separator + fileLastName); - if (file.exists()) { - bufferImg = ImageIO.read(file); - ImageIO.write(bufferImg, "jpg", byteArrayOut); - //anchor主要用于设置图片的属性 - HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) 3, j + i, (short) 3, j + i); - patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); + } + File file = new File(dir + File.separator + fileLastName); + if (file.exists()) { + bufferImg = ImageIO.read(file); + ImageIO.write(bufferImg, "jpg", byteArrayOut); + //anchor主要用于设置图片的属性 + HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) 7, j + i, (short) 7, j + i); + patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); - } - } else { - row2.createCell(3).setCellValue(rightSplit[j]); } } else { - if (rightSplit[j].contains(".jpg") || rightSplit[j].contains(".png")) { - row.setHeight((short) 5000); //设置行高 - //先将图片下载到本地 - String fileLastName = rightSplit[j].substring(rightSplit[j].lastIndexOf("/") + 1); - if (CosBootUtil.doesObjectExist(rightSplit[j])) { - try (InputStream in = CosBootUtil.download(rightSplit[j])) { - copyFile2(in, dir + File.separator + fileLastName); - } catch (IOException e) { - e.printStackTrace(); - log.error(e.getMessage(), e); - } - } - File file = new File(dir + File.separator + fileLastName); - if (file.exists()) { - bufferImg = ImageIO.read(file); - ImageIO.write(bufferImg, "jpg", byteArrayOut); - //anchor主要用于设置图片的属性 - HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) 3, j + i, (short) 3, j + i); - patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); - - } - } else { - row.createCell(7).setCellValue(rightSplit[j]); - } + row2.createCell(7).setCellValue(rightSplit[j]); } } sarFileCompareExcelMergeCell.setRightStart(i); @@ -443,7 +389,8 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl mergeCellSet = new HashSet<>(mergeCells); + for (SarFileCompareExcelMergeCell mergeCell : mergeCellSet) { Integer leftCount = mergeCell.getLeftEnd() - mergeCell.getLeftStart() + 1; Integer rightCount = mergeCell.getRightEnd() - mergeCell.getRightStart() + 1; Integer start = leftCount - rightCount >= 0 ? mergeCell.getLeftStart() : mergeCell.getRightStart(); @@ -461,7 +408,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl")) { - 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("\"")); + if (text.contains("") + 3); + String img = text.substring(text.indexOf("")); + String path = img.substring(img.lastIndexOf("=") + 1)+"g"; text = txtLeft + "---" + path + "---" + txtRight; addImgdata(text, session); } else {