Revert "add 文档拆分导出 增加表格译文"

This reverts commit ca028ee43b.
This commit is contained in:
lijiarao
2024-08-01 17:38:19 +08:00
parent 61327952c7
commit cb1de1bfcd
3 changed files with 11 additions and 70 deletions
@@ -18,6 +18,4 @@ public class FileSpiltValTableExportDto {
private List<List<SarFileSplitItemsTableEO>> tableEOList; private List<List<SarFileSplitItemsTableEO>> tableEOList;
private String tableHtCon; private String tableHtCon;
private String tableHtConTranslation;
} }
@@ -13,5 +13,4 @@ public class FileSplitValImgExportDto {
private String imgName; private String imgName;
private String imgPath; private String imgPath;
private String imgPathTranslation;
} }
@@ -3876,7 +3876,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
tableExportDto.setTableName("tableSheet" + tableName); tableExportDto.setTableName("tableSheet" + tableName);
// tableExportDto.setTableEOList(tableList); // tableExportDto.setTableEOList(tableList);
tableExportDto.setTableHtCon(itemsValEO.getItemContent()); tableExportDto.setTableHtCon(itemsValEO.getItemContent());
tableExportDto.setTableHtConTranslation(itemsValEO.getTranslation());
allTableList.add(tableExportDto); allTableList.add(tableExportDto);
tableIndex++; tableIndex++;
page.setTableIndex(tableIndex); page.setTableIndex(tableIndex);
@@ -3885,7 +3884,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
splitContext(valContent); splitContext(valContent);
String imgContent = itemsValEO.getItemContent(); String imgContent = itemsValEO.getItemContent();
String imgTranslation = itemsValEO.getTranslation();
String imgUUIndex = "img" + String.valueOf(imgIndex); String imgUUIndex = "img" + String.valueOf(imgIndex);
if (MyStringUtils.isNotEmpty(imgContent)){ if (MyStringUtils.isNotEmpty(imgContent)){
lastOne.setValContent(imgUUIndex+".png"); lastOne.setValContent(imgUUIndex+".png");
@@ -3893,10 +3891,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto(); FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto();
fileSplitValImgExportDto.setImgName(imgUUIndex+".png"); fileSplitValImgExportDto.setImgName(imgUUIndex+".png");
String url = imgContent.substring(imgContent.lastIndexOf("=") + 1); String url = imgContent.substring(imgContent.lastIndexOf("=") + 1);
String urlTranslation = imgTranslation.substring(imgTranslation.lastIndexOf("=") + 1);
fileSplitValImgExportDto.setImgPath(url); fileSplitValImgExportDto.setImgPath(url);
fileSplitValImgExportDto.setImgPathTranslation(urlTranslation);
allImgList.add(fileSplitValImgExportDto); allImgList.add(fileSplitValImgExportDto);
imgIndex++; imgIndex++;
@@ -4117,15 +4113,12 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
HSSFRow row1 = sheetItems.createRow(allRow); HSSFRow row1 = sheetItems.createRow(allRow);
// 开始向单元格添加数据 // 开始向单元格添加数据
for(int cellNum = 0; cellNum < fieldList.size(); cellNum++){ for(int cellNum = 0; cellNum < fieldList.size(); cellNum++){
String fieldName = fieldList.get(cellNum); if (!"item_content".equals(fieldList.get(cellNum)) &&
FileSplitValExportDto fileSplitValExportDto = valList.get(valRow); !"interpretation_articles".equals(fieldList.get(cellNum)) &&
if (!"item_content".equals(fieldName) && ObjectUtils.isNotEmpty(exportDto.get(fieldList.get(cellNum)))) {
!"interpretation_articles".equals(fieldName) &&
!"translation".equals(fieldName) &&
ObjectUtils.isNotEmpty(exportDto.get(fieldName))) {
// 处理文件 // 处理文件
if(fileList.contains(fieldName)) { if(fileList.contains(fieldList.get(cellNum))) {
String connectId = (String) exportDto.get(fieldName); String connectId = (String) exportDto.get(fieldList.get(cellNum));
List<OSSFile> ossFileList = ossFileService.getFileInfosByConnectId(connectId); List<OSSFile> ossFileList = ossFileService.getFileInfosByConnectId(connectId);
List<String> fileNameList = new ArrayList<>(); List<String> fileNameList = new ArrayList<>();
if (ossFileList != null && !ossFileList.isEmpty()) { if (ossFileList != null && !ossFileList.isEmpty()) {
@@ -4150,16 +4143,15 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
allRelevFileList.addAll(ossFileList); allRelevFileList.addAll(ossFileList);
} }
} else { } else {
row1.createCell(cellNum).setCellValue(exportDto.get(fieldName).toString()); row1.createCell(cellNum).setCellValue(exportDto.get(fieldList.get(cellNum)).toString());
row1.getCell(cellNum).setCellStyle(cellStyle); row1.getCell(cellNum).setCellStyle(cellStyle);
} }
} } else if ("item_content".equals(fieldList.get(cellNum))) {
else if ("item_content".equals(fieldName)) {
// 条款内容特殊处理 // 条款内容特殊处理
HSSFCell cell2 = row1.createCell(cellNum); HSSFCell cell2 = row1.createCell(cellNum);
row1.getCell(cellNum).setCellStyle(cellStyle); row1.getCell(cellNum).setCellStyle(cellStyle);
String content = fileSplitValExportDto.getValContent(); String content = valList.get(valRow).getValContent();
if (StringUtils.isNotEmpty(content)) { if (StringUtils.isNotEmpty(content)) {
content = content.replaceAll("null",""); content = content.replaceAll("null","");
if (content.lastIndexOf("\n") > -1) { if (content.lastIndexOf("\n") > -1) {
@@ -4167,7 +4159,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
} }
} }
if("TABLE".equals(fileSplitValExportDto.getValType())){ if("TABLE".equals(valList.get(valRow).getValType())){
/* 连接跳转*/ /* 连接跳转*/
CreationHelper createHelper = workbook.getCreationHelper(); CreationHelper createHelper = workbook.getCreationHelper();
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.DOCUMENT); Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.DOCUMENT);
@@ -4175,7 +4167,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
hyperlink1.setAddress(tableName); hyperlink1.setAddress(tableName);
cell2.setHyperlink(hyperlink1);// 链接 cell2.setHyperlink(hyperlink1);// 链接
row1.getCell(cellNum).setCellStyle(cellStyleLink); row1.getCell(cellNum).setCellStyle(cellStyleLink);
} else if ("IMG".equals(fileSplitValExportDto.getValType())) { } else if ("IMG".equals(valList.get(valRow).getValType())) {
/* 连接跳转*/ /* 连接跳转*/
CreationHelper createHelper = workbook.getCreationHelper(); CreationHelper createHelper = workbook.getCreationHelper();
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE); Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
@@ -4185,41 +4177,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
row1.getCell(cellNum).setCellStyle(cellStyleLink); row1.getCell(cellNum).setCellStyle(cellStyleLink);
} }
cell2.setCellValue(content); // IllegalArgumentException异常,excel单元格最大字符长度有限制 cell2.setCellValue(content); // IllegalArgumentException异常,excel单元格最大字符长度有限制
} } else if ("interpretation_articles".equals(fieldList.get(cellNum))) {
else if ("translation".equals(fieldName)) {
// 条款内容特殊处理
HSSFCell cell2 = row1.createCell(cellNum);
row1.getCell(cellNum).setCellStyle(cellStyle);
String content = exportDto.get(fieldName).toString();
if (StringUtils.isNotEmpty(content)) {
content = content.replaceAll("null","");
if (content.lastIndexOf("\n") > -1) {
content = content.substring(0,content.lastIndexOf("\n"));
}
}
if("TABLE".equals(fileSplitValExportDto.getValType())){
/* 连接跳转*/
content = fileSplitValExportDto.getValContent()+"translation";
CreationHelper createHelper = workbook.getCreationHelper();
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.DOCUMENT);
String tableName = "#\'"+ content + "\'!A1";
hyperlink1.setAddress(tableName);
cell2.setHyperlink(hyperlink1);// 链接
row1.getCell(cellNum).setCellStyle(cellStyleLink);
} else if ("IMG".equals(fileSplitValExportDto.getValType())) {
/* 连接跳转*/
content = fileSplitValExportDto.getValContent()+"translation";
CreationHelper createHelper = workbook.getCreationHelper();
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
String imgName = content;
hyperlink1.setAddress(imgName);
cell2.setHyperlink(hyperlink1);// 链接
row1.getCell(cellNum).setCellStyle(cellStyleLink);
}
cell2.setCellValue(content); // IllegalArgumentException异常,excel单元格最大字符长度有限制
}
else if ("interpretation_articles".equals(fieldName)) {
// 条文解读特殊处理 // 条文解读特殊处理
HSSFCell cell2 = row1.createCell(cellNum); HSSFCell cell2 = row1.createCell(cellNum);
row1.getCell(cellNum).setCellStyle(cellStyle); row1.getCell(cellNum).setCellStyle(cellStyle);
@@ -4303,8 +4261,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// HSSFSheet sheetTable = workbook.createSheet(tableExportDto.getTableName()); // HSSFSheet sheetTable = workbook.createSheet(tableExportDto.getTableName());
String tableName = tableExportDto.getTableName(); String tableName = tableExportDto.getTableName();
String tableHtml = tableExportDto.getTableHtCon(); String tableHtml = tableExportDto.getTableHtCon();
String tableHtmlTranslation = tableExportDto.getTableHtConTranslation();
if (StringUtils.isNotEmpty(tableHtml) && tableHtml.indexOf("<tbody>") < 0) { if (StringUtils.isNotEmpty(tableHtml) && tableHtml.indexOf("<tbody>") < 0) {
if (tableHtml.indexOf("<thead>") < 0) { if (tableHtml.indexOf("<thead>") < 0) {
tableHtml = tableHtml.replaceFirst("<tr>","<tbody><tr>"); tableHtml = tableHtml.replaceFirst("<tr>","<tbody><tr>");
@@ -4317,18 +4273,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String cnt = "\n"; String cnt = "\n";
tableHtml = tableHtml.replaceAll("<[\\s]*?br[^>]*?>|<[\\s]*?\\/[\\s]*?br[\\s]*?>", cnt); tableHtml = tableHtml.replaceAll("<[\\s]*?br[^>]*?>|<[\\s]*?\\/[\\s]*?br[\\s]*?>", cnt);
workbook = ConvertHtml2Excel.table2Excel(tableHtml,workbook,tableName); workbook = ConvertHtml2Excel.table2Excel(tableHtml,workbook,tableName);
if (StringUtils.isNotEmpty(tableHtmlTranslation) && tableHtmlTranslation.indexOf("<tbody>") < 0) {
if (tableHtmlTranslation.indexOf("<thead>") < 0) {
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("<tr>","<tbody><tr>");
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("</table>","</tbody></table>");
} else {
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("</thead>","</thead><tbody>");
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("</table>","</tbody></table>");
}
}
tableHtmlTranslation = tableHtmlTranslation.replaceAll("<[\\s]*?br[^>]*?>|<[\\s]*?\\/[\\s]*?br[\\s]*?>", cnt);
workbook = ConvertHtml2Excel.table2Excel(tableHtmlTranslation,workbook,tableName+"translation");
// for (int r=0;r<rowtableList.size();r++) { // for (int r=0;r<rowtableList.size();r++) {
// List<SarFileSplitItemsTableEO> colTableList = rowtableList.get(r); // List<SarFileSplitItemsTableEO> colTableList = rowtableList.get(r);
// HSSFRow tRow = sheetTable.createRow(colTableList.get(0).getRowNum()-1); // HSSFRow tRow = sheetTable.createRow(colTableList.get(0).getRowNum()-1);