Merge branch 'feature/RDMP-3845' into test
# Conflicts: # workflow-engine-core/src/main/java/cn/axzo/workflow/core/listener/AbstractBpmnEventListener.java
This commit is contained in:
commit
2bd392b424
@ -1,14 +1,16 @@
|
||||
package cn.axzo.workflow.core.listener;
|
||||
|
||||
import cn.axzo.workflow.common.constant.BpmnConstants;
|
||||
import cn.axzo.workflow.core.common.context.OperationContext;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC;
|
||||
|
||||
/**
|
||||
@ -48,30 +50,29 @@ public abstract class AbstractBpmnEventListener<T extends OperationContext> impl
|
||||
return processDefinitionId.split(":")[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除一些业务不需要关心的变量
|
||||
*
|
||||
* @param originVariables
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> removeBpmnConstantsVariables(Map<String, Object> originVariables) {
|
||||
// 定义多个正则表达式规则
|
||||
List<String> regexPatterns = Arrays.asList(
|
||||
"^" + BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO, // 以 "" 开头
|
||||
"^" + BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT,
|
||||
"^" + BpmnConstants.TASK_COMPLETE_OPERATION_TYPE,
|
||||
"^" + BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_LIST_INFO,
|
||||
"_old$", // 以 "_old" 结尾
|
||||
"deprecated|obsolete" // 包含 "deprecated" 或 "obsolete"
|
||||
if (originVariables == null) return new HashMap<>();
|
||||
|
||||
// 定义需要移除的前缀列表
|
||||
List<String> prefixesToRemove = Arrays.asList(
|
||||
BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO,
|
||||
BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT,
|
||||
BpmnConstants.TASK_COMPLETE_OPERATION_TYPE,
|
||||
BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_LIST_INFO
|
||||
);
|
||||
|
||||
// 预编译正则表达式,提升性能
|
||||
List<Pattern> patterns = regexPatterns.stream()
|
||||
.map(Pattern::compile)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 使用 Stream API 和正则进行过滤
|
||||
Map<String, Object> filteredMap = originVariables.entrySet().stream()
|
||||
.filter(entry -> patterns.stream()
|
||||
.noneMatch(pattern -> pattern.matcher(entry.getKey()).find()))
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
Map.Entry::getValue
|
||||
));
|
||||
return filteredMap;
|
||||
return originVariables.entrySet().stream()
|
||||
.filter(entry -> entry.getKey() != null)
|
||||
// 核心修改:检查 key 是否以任一前缀开头
|
||||
.filter(entry -> prefixesToRemove.stream()
|
||||
.noneMatch(prefix -> entry.getKey().startsWith(prefix)))
|
||||
.collect(HashMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), HashMap::putAll);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user