fix 条款拆分导入时<>转为&lt;&gt;时特殊处理上下角标情况

This commit is contained in:
lijiarao
2024-10-12 09:41:57 +08:00
parent fa69c6b0b5
commit 6429834ed6
2 changed files with 26 additions and 7 deletions
@@ -3543,18 +3543,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if (getValList != null && !getValList.isEmpty()) {
for (SarFileSplitItemsValEO valEO : getValList) {
String type = valEO.getType();
String itemContent = valEO.getItemContent().replace("<", "&lt;").replace(">", "&gt;")
.replace("&lt;sub&gt;", "<sub>").replace("&lt;/sub&gt;", "</sub>")
.replace("&lt;sup&gt;", "<sup>").replace("&lt;/sup&gt;", "</sup>");
String translation = valEO.getTranslation().replace("<", "&lt;").replace(">", "&gt;")
.replace("&lt;sub&gt;", "<sub>").replace("&lt;/sub&gt;", "</sub>")
.replace("&lt;sup&gt;", "<sup>").replace("&lt;/sup&gt;", "</sup>");
String itemContent = valEO.getItemContent();
String translation = valEO.getTranslation();
// 当前段内容
String valContent = "";
String valContentTranslation = "";
if ("TEXT".equals(type)) {
itemContent = itemContent.replace("<", "&lt;").replace(">", "&gt;")
.replace("&lt;sub&gt;", "<sub>").replace("&lt;/sub&gt;", "</sub>")
.replace("&lt;sup&gt;", "<sup>").replace("&lt;/sup&gt;", "</sup>");
valContent += "<p>" + itemContent + "</p>";
if (StringUtils.isNotBlank(translation)){
translation = translation.replace("<", "&lt;").replace(">", "&gt;")
.replace("&lt;sub&gt;", "<sub>").replace("&lt;/sub&gt;", "</sub>")
.replace("&lt;sup&gt;", "<sup>").replace("&lt;/sup&gt;", "</sup>");
valContentTranslation += "<p>" + translation + "</p>";
}
} else if ("IMG".equals(type)) {
@@ -3563,9 +3565,26 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
valContentTranslation += "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\""+ translation +"\">";
}
} else if ("TABLE".equals(type)) {
itemContent = itemContent.replace("<", "&lt;").replace(">", "&gt;")
.replace("&lt;sub&gt;", "<sub>").replace("&lt;/sub&gt;", "</sub>")
.replace("&lt;sup&gt;", "<sup>").replace("&lt;/sup&gt;", "</sup>")
.replace("&lt;table border=\"1\" style=\"border-collapse:collapse;width:100%;\"&gt;", "<table border=\"1\" style=\"border-collapse:collapse;width:100%;\">")
.replace("&lt;/table&gt;", "</table>")
.replace("&lt;tr&gt;", "<tr>").replace("&lt;/tr&gt;", "</tr>")
.replace("&lt;td &gt;", "<td>").replace("&lt;/td&gt;", "</td>")
;
valEO.setItemContent(itemContent.replaceAll("\n","<br/>"));
valContent += itemContent;
if (StringUtils.isNotBlank(translation)){
translation = translation.replace("<", "&lt;").replace(">", "&gt;")
.replace("&lt;sub&gt;", "<sub>").replace("&lt;/sub&gt;", "</sub>")
.replace("&lt;sup&gt;", "<sup>").replace("&lt;/sup&gt;", "</sup>")
.replace("&lt;table border=\"1\" style=\"border-collapse:collapse;width:100%;\"&gt;", "<table border=\"1\" style=\"border-collapse:collapse;width:100%;\">")
.replace("&lt;/table&gt;", "</table>")
.replace("&lt;tr&gt;", "<tr>").replace("&lt;/tr&gt;", "</tr>")
.replace("&lt;td &gt;", "<td>").replace("&lt;/td&gt;", "</td>")
;
valEO.setTranslation(translation.replaceAll("\n","<br/>"));
valContentTranslation += translation;
}
@@ -107,7 +107,7 @@ public class POIReadExcelToHtml {
}
if (null == row) {
sb.append("<tr><td > </td></tr>");
sb.append("<tr><td> </td></tr>");
continue;
}else if(row.getZeroHeight()){
continue;