Browse Source

REPORT-79909 设计器启动失败,有模板名称叫WorkBook88888888888888.cpt导致

release/11.0
Destiny.Lin 2 years ago
parent
commit
e42c9bd885
  1. 14
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java

14
designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java

@ -5,6 +5,7 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.stable.StringUtils;
import javax.swing.tree.DefaultMutableTreeNode;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -27,19 +28,19 @@ public class JTemplateNameHelper {
DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot();
String[] str = new String[gen.getChildCount()];
List<Integer> reportNum = new ArrayList<>();
List<BigInteger> reportNum = new ArrayList<>();
for (int j = 0; j < gen.getChildCount(); j++) {
str[j] = gen.getChildAt(j).toString();
//返回文件名中的index(算法中没有再匹配文件后缀了,因为DefaultMutableTreeNode中已经匹配过了)
Integer index = getFileNameIndex(prefix, str[j]);
BigInteger index = getFileNameIndex(prefix, str[j]);
if (index != null) {
reportNum.add(index);
}
}
Collections.sort(reportNum);
int idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1) + 1 : 1;
BigInteger idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1).add(BigInteger.valueOf(1)) : BigInteger.valueOf(1);
idx = idx + currentIndex;
idx = idx.add(BigInteger.valueOf(currentIndex));
currentIndex++;
return prefix + idx;
}
@ -52,7 +53,7 @@ public class JTemplateNameHelper {
* @Author Henry.Wang
* @Date 2021/4/9 11:13
**/
private static Integer getFileNameIndex(String prefix, String fileName) {
private static BigInteger getFileNameIndex(String prefix, String fileName) {
if (fileName.length() <= prefix.length()) {
return null;
}
@ -78,9 +79,10 @@ public class JTemplateNameHelper {
}
}
String s = new String(chars).substring(0, i - prefix.length());
BigInteger integer = new BigInteger(s,10);
if (StringUtils.isBlank(s)) {
return null;
}
return Integer.valueOf(s);
return integer;
}
}

Loading…
Cancel
Save