|
|
@@ -1689,12 +1689,30 @@ public class CustomFunction {
|
|
|
List<String> result = new ArrayList<>();
|
|
|
param = param.trim().replaceAll("(?i:c)", "");
|
|
|
List<String> list = Arrays.asList(param.split("[^.\\d]"));
|
|
|
- List<Integer> index = list.stream().map(Integer::parseInt).collect(Collectors.toList());
|
|
|
+ List<Integer> index = list.stream().map(Integer::parseInt).sorted().collect(Collectors.toList());
|
|
|
Integer type = RandomNumberHolder.getRandomTemplateType();
|
|
|
if(type==null||type==1){
|
|
|
for (Integer i : index) {
|
|
|
- if (i < nodes.size()) {
|
|
|
- result.add(nodes.get(i));
|
|
|
+ boolean isExist = false;
|
|
|
+ //获取当前节点的名称
|
|
|
+ String title = nodes.get(i);
|
|
|
+ //当前节点的名称是否已经在父级节点中包含了
|
|
|
+ if(org.apache.commons.lang.StringUtils.isNotEmpty(title)){
|
|
|
+ for (int j = 0; j < i; j++) {
|
|
|
+ String parentTitle = nodes.get(j);
|
|
|
+ //如果父级节点名称中保存当前节点名称 就跳过当前节点
|
|
|
+ if(org.apache.commons.lang.StringUtils.isNotEmpty(parentTitle) && org.apache.commons.lang.StringUtils.isNotEmpty(title) && parentTitle.contains(title)){
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(isExist){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //保留之间的添加逻辑 在之前对数据做去重过滤
|
|
|
+ if (i < nodes.size()) {
|
|
|
+ result.add(nodes.get(i));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return String.join("", result);
|
|
|
@@ -1707,19 +1725,23 @@ public class CustomFunction {
|
|
|
(existing, replacement) -> replacement // 如果键重复,保留后者
|
|
|
));
|
|
|
for (Integer i : index) {
|
|
|
- if(i==0){
|
|
|
- if(map.containsKey(1)){
|
|
|
- result.add(map.get(1));
|
|
|
- }
|
|
|
- }
|
|
|
- else if(i==1){
|
|
|
- if(map.containsKey(18)){
|
|
|
- result.add(map.get(18));
|
|
|
+ boolean isExist = false;
|
|
|
+ //获取当前节点的名称
|
|
|
+ String title = map.get(i == 0 ? 1 : i == 18 ? 1 : i);
|
|
|
+ //当前节点的名称是否已经在父级节点中包含了
|
|
|
+ if(org.apache.commons.lang.StringUtils.isNotEmpty(title)){
|
|
|
+ for (int j = 0; j < i; j++) {
|
|
|
+ String parentTitle = map.get(j == 0 ? 1 : j == 18 ? 1 : j);
|
|
|
+ //如果父级节点名称中保存当前节点名称 就跳过当前节点
|
|
|
+ if(org.apache.commons.lang.StringUtils.isNotEmpty(parentTitle) && org.apache.commons.lang.StringUtils.isNotEmpty(title) && parentTitle.contains(title)){
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- }else {
|
|
|
- if(map.containsKey(i)){
|
|
|
- result.add(map.get(i));
|
|
|
+ if(isExist){
|
|
|
+ continue;
|
|
|
}
|
|
|
+ result.add(title);
|
|
|
}
|
|
|
}
|
|
|
return String.join("", result);
|