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 bc0fa2836..c236f5d0b 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 @@ -271,63 +271,65 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl", "").replace("

", "\r\n"); - ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); addImgdata(text,request.getSession()); String rowDataAndPath = (String) request.getSession().getAttribute("txtAndImg"); leftSplit = rowDataAndPath.split("---"); if (leftSplit.length > 1) { for (int j = 0; j < leftSplit.length; j++) { - BufferedImage bufferImg = null; - if (j > 0) { - 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); + if (ObjectUtils.isNotEmpty(leftSplit[j])) { + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + BufferedImage bufferImg = null; + if (j > 0) { + Row row2 = sheet.createRow(j + i); + if (leftSplit[j].contains("/upFiles")) { + row2.setHeight((short) 3000); //设置行高 + //先将图片下载到本地 + 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 { - 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); + if (leftSplit[j].contains("/upFiles")) { + row.setHeight((short) 3000); //设置行高 + //先将图片下载到本地 + 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 { + row.createCell(3).setCellValue(leftSplit[j]); } - } else { - row.createCell(3).setCellValue(leftSplit[j]); } } } @@ -350,63 +352,65 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl", "").replace("

", "\r\n"); - ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); addImgdata(text,request.getSession()); String rowDataAndPath = (String) request.getSession().getAttribute("txtAndImg"); rightSplit = rowDataAndPath.split("---"); if (rightSplit.length > 1) { for (int j = 0; j < rightSplit.length; j++) { - BufferedImage bufferImg = null; - if (j > 0) { - 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); + if (ObjectUtils.isNotEmpty(rightSplit[j])) { + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + BufferedImage bufferImg = null; + if (j > 0) { + Row row2 = sheet.createRow(j + i); + if (rightSplit[j].contains("/upFiles")) { + row2.setHeight((short) 3000); //设置行高 + //先将图片下载到本地 + 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) 7, j + i, (short) 7, 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(7).setCellValue(rightSplit[j]); } } else { - row2.createCell(7).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); + if (rightSplit[j].contains("/upFiles")) { + row.setHeight((short) 3000); //设置行高 + //先将图片下载到本地 + 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 { + row.createCell(7).setCellValue(rightSplit[j]); } - } else { - row.createCell(7).setCellValue(rightSplit[j]); } } }