update 文档拆分导出 图片译文

This commit is contained in:
lijiarao
2024-08-01 17:37:59 +08:00
parent 61327952c7
commit 7df9803cd6
@@ -3960,18 +3960,34 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
@Override @Override
public void downLoadImgList(List<FileSplitValImgExportDto> allImgList, String fileNowPath) { public void downLoadImgList(List<FileSplitValImgExportDto> allImgList, String fileNowPath) {
for(FileSplitValImgExportDto imgExportDto : allImgList){ for(FileSplitValImgExportDto imgExportDto : allImgList){
String oldPath = uploadCospath + "/" + imgExportDto.getImgPath(); String imgName = imgExportDto.getImgName();
String newPath = fileNowPath + File.separator + imgExportDto.getImgName(); String fileName = imgExportDto.getImgPath();
if (MinioUtil.doesObjectExist(oldPath)){ String oldPath = getPath(fileName);
try (InputStream in = MinioUtil.download(oldPath);) { String newPath = fileNowPath + File.separator + imgName;
copyFile1(in, newPath); try (InputStream in = ObsBootUtil.getOssFile(oldPath)) {
copyFile1(in, newPath);
} catch (IOException e) {
log.error(e.getMessage(), e);
}
String fileNameTranslation = imgExportDto.getImgPathTranslation();
if (StringUtils.isNotBlank(fileNameTranslation)){
String imgNameTranslation = imgName.substring(0,imgName.indexOf("."))+"translation.png";
String oldPathTranslation = getPath(fileNameTranslation);
String newPathTranslation = fileNowPath + File.separator + imgNameTranslation;
try (InputStream in = ObsBootUtil.getOssFile(oldPathTranslation)) {
copyFile1(in, newPathTranslation);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
} }
} }
}
private String getPath(String fileName){
if (!fileName.contains("temp")){
fileName = "temp\\" + fileName;
}
return fileName.replace("\\\\", "\\");
} }
@Override @Override
@@ -3979,13 +3995,10 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
for(OSSFile fileExportDto : allRelevFileList){ for(OSSFile fileExportDto : allRelevFileList){
String oldPath = fileExportDto.getUrl(); String oldPath = fileExportDto.getUrl();
String newPath = fileNowPath + File.separator + fileExportDto.getFileName(); String newPath = fileNowPath + File.separator + fileExportDto.getFileName();
if (MinioUtil.doesObjectExist(oldPath)){ try (InputStream in = ObsBootUtil.getOssFile(oldPath)) {
try (InputStream in = MinioUtil.download(oldPath);) { copyFile1(in, newPath);
copyFile1(in, newPath); } catch (IOException e) {
} catch (IOException e) { log.error(e.getMessage(), e);
e.printStackTrace();
log.error(e.getMessage(), e);
}
} }
} }
@@ -4209,7 +4222,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
row1.getCell(cellNum).setCellStyle(cellStyleLink); row1.getCell(cellNum).setCellStyle(cellStyleLink);
} else if ("IMG".equals(fileSplitValExportDto.getValType())) { } else if ("IMG".equals(fileSplitValExportDto.getValType())) {
/* 连接跳转*/ /* 连接跳转*/
content = fileSplitValExportDto.getValContent()+"translation"; content = fileSplitValExportDto.getValContent();
content = content.substring(0,content.indexOf("."))+"translation.png";
CreationHelper createHelper = workbook.getCreationHelper(); CreationHelper createHelper = workbook.getCreationHelper();
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE); Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
String imgName = content; String imgName = content;
@@ -4237,7 +4251,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
} }
if (allRow > startRow) { if (allRow > startRow) {
for(int cellNum = 0; cellNum < fieldList.size(); cellNum++) { for(int cellNum = 0; cellNum < fieldList.size(); cellNum++) {
if (!"item_content".equals(fieldList.get(cellNum))) { String s = fieldList.get(cellNum);
if (!"item_content".equals(s) && !"translation".equals(s)) {
sheetItems.addMergedRegion(new CellRangeAddress(startRow, allRow, cellNum, cellNum)); sheetItems.addMergedRegion(new CellRangeAddress(startRow, allRow, cellNum, cellNum));
} }
} }