Merge branch 'feature/REQ-5965' into dev

This commit is contained in:
wangli 2025-11-21 13:34:43 +08:00
commit 0ceacfb3bd

View File

@ -7,10 +7,9 @@ import org.slf4j.MDC;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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; import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC;
@ -52,29 +51,21 @@ public abstract class AbstractBpmnEventListener<T extends OperationContext> impl
} }
public static Map<String, Object> removeBpmnConstantsVariables(Map<String, Object> originVariables) { public static Map<String, Object> removeBpmnConstantsVariables(Map<String, Object> originVariables) {
// 定义多个正则表达式规则 if (originVariables == null) return new HashMap<>();
List<String> regexPatterns = Arrays.asList(
"^" + BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO, // "" 开头 // 定义需要移除的前缀列表
"^" + BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT, List<String> prefixesToRemove = Arrays.asList(
"^" + BpmnConstants.TASK_COMPLETE_OPERATION_TYPE, BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO,
"^" + BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_LIST_INFO, BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT,
"_old$", // "_old" 结尾 BpmnConstants.TASK_COMPLETE_OPERATION_TYPE,
"deprecated|obsolete" // 包含 "deprecated" "obsolete" BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_LIST_INFO
); );
// 预编译正则表达式提升性能 return originVariables.entrySet().stream()
List<Pattern> patterns = regexPatterns.stream() .filter(entry -> entry.getKey() != null)
.map(Pattern::compile) // 核心修改检查 key 是否以任一前缀开头
.collect(Collectors.toList()); .filter(entry -> prefixesToRemove.stream()
.noneMatch(prefix -> entry.getKey().startsWith(prefix)))
// 使用 Stream API 和正则进行过滤 .collect(HashMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), HashMap::putAll);
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;
} }
} }