解决-法规月报-导出中英文内容勾选不一致bug

This commit is contained in:
yjq
2022-12-01 16:30:46 +08:00
parent fcc1817aa0
commit 90fec909c5
@@ -1195,16 +1195,18 @@ public class WordUtil {
setBlank(text, run, sb, itemText);
}
if("Scope".equals(fieldName)){
// M,N,Enterprise,Vehicle,System/Parts,New Car Model,Models In Production
// M,N,Enterprise,Vehicle,System/Part ,New Type ,New Vehicle
String itemText = "M,N,Enterprise,Vehicle,System/Parts,New Car Model,Models In Production";
setBlank(text, run, sb, itemText);
}
if("状态".equals(fieldName)){
String itemText = "草稿,公示稿,发布稿";
setBlank(text, run, sb, itemText);
}
if("Status".equals(fieldName)){
String itemText = "Draft,Public Notice,Release";
// Draft,Public Notice,Release
String itemText = "Draft,Publicity,Final";
setBlank(text, run, sb, itemText);
}
if("用法".equals(fieldName)){
@@ -1224,7 +1226,7 @@ public class WordUtil {
}
private static void setBlank(String text, XWPFRun run, StringBuilder sb, String itemText) {
//用法的三个复选框 在后端get到的英文和导出的word对应不上,也就是和itemText中的内容对应不上
//用法的三个复选框 在后端get到的英文和导出的word对应不上,也就是和itemText中给定的内容对应不上
if(text.equals("constraint")){
text = "Mandatory";
}
@@ -1235,12 +1237,28 @@ public class WordUtil {
text = "Mandatory if fitted";
}
if(text.equals("Public Notice")){
text = "Publicity";
}
if(text.equals("Release")){
text = "Final";
}
for (String value : itemText.split(",")) {
String blank = getBlank(value);
if(text.equals(value)){
//contains()方法 当选中的是Mandatory if fitted时,Mandatory也包含在其中结果会是true,也会被选中
if(text.equals("Mandatory if fitted") && value.equals("Mandatory if fitted")){
sb.append(""+value+blank);
break;
}
if(text.contains(value)){
//将错误的英文转为正确的
String value1 = scopeConvert(value);
sb.append(""+value1+blank);
}else{
sb.append(""+value+blank);
String value1 = scopeConvert(value);
sb.append(""+value1+blank);
}
}
String[] split = sb.toString().split("\r\n");
@@ -1252,6 +1270,23 @@ public class WordUtil {
}
}
private static String scopeConvert(String text){
if(text.equals("System/Parts")){
text = "System/Part ";
return text;
}
if(text.equals("New Car Model")){
text = "New Type ";
return text;
}
if(text.equals("Models In Production")){
text = "New Vehicle ";
return text;
}
return text;
}
public static String getBlank(String value){
String blank = "";
switch (value) {