feat(condition): CONDITION 判断方式二选一——EXPRESSION 内置 Aviator 表达式(沙箱)+ SERVICE 原口径;JudgeBody 补 submitterId
- ExpressionEvaluator:Aviator 5.4.3 沙箱(FEATURE_SET 只留 If、ALLOWED_CLASS_SET 空=禁类访问/反射)、编译缓存、 顶层变量缺失抛错挂起(Aviator 缺失变量按 nil 且 nil 视作最小值,<= 兜底出口会静默放行——宁挂起不误放行) - ConditionRouteService.decide 分流:EXPRESSION 按出边顺序取首个 true(逐边结果摘要落 raw_response), 全 false/异常挂起沿用 SERVICE 纪律(route_log outlet=NULL + EXPRESSION 常量 + 告警 + 管理端重跑) - DefValidator 发布期分层校验:EXPRESSION 出口缺条件/语法错/违禁表达式硬拦;表单变量放行(运行时核对); 内置变量疑似拼错 warn;judgeMode 非法值拦 - /admin/router/eval 调试端点(同一求值核心,不落库不走流程) - 单测 22 新增 + 全量 170 绿;E2E 18/18(发布/分支选路/挂起留痕/重跑/调试)见 local-debug/four-topics-a-e2e.py
This commit is contained in:
@@ -49,6 +49,7 @@ public class FlowAdminController {
|
||||
private final FlwInstanceRepository instanceRepository;
|
||||
private final FlowDiagramService diagramService;
|
||||
private final com.yunhai.flowcenter.service.DiagramImageService imageService;
|
||||
private final com.fasterxml.jackson.databind.ObjectMapper objectMapper;
|
||||
|
||||
// ==================== 流程定义 ====================
|
||||
|
||||
@@ -288,6 +289,47 @@ public class FlowAdminController {
|
||||
routerAdminService.reroute(adminGuard.requireAdmin(user, null), id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表达式调试求值(2026-10-10 四议题):body {expression, variablesJson},与运行时同一求值核心
|
||||
* (ExpressionEvaluator);不落库、不走流程,发布前/挂起排查用。内置变量需在 variablesJson 里
|
||||
* 自行提供样例值(线上是引擎注入的办件上下文)。
|
||||
*/
|
||||
@PostMapping("/router/eval")
|
||||
public Map<String, Object> routerEval(BoaUser user, @RequestBody Map<String, Object> body) {
|
||||
adminGuard.requireAdmin(user, null);
|
||||
String expression = body.get("expression") == null ? "" : String.valueOf(body.get("expression")).trim();
|
||||
String variablesJson = body.get("variablesJson") == null ? "" : String.valueOf(body.get("variablesJson")).trim();
|
||||
Map<String, Object> result = new java.util.HashMap<>();
|
||||
if (expression.isEmpty()) {
|
||||
result.put("result", false);
|
||||
result.put("error", "表达式为空");
|
||||
return result;
|
||||
}
|
||||
Map<String, Object> env;
|
||||
if (variablesJson.isEmpty()) {
|
||||
env = new java.util.HashMap<>();
|
||||
} else {
|
||||
try {
|
||||
env = objectMapper.readValue(variablesJson,
|
||||
new com.fasterxml.jackson.core.type.TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
} catch (Exception e) {
|
||||
result.put("result", false);
|
||||
result.put("error", "样例变量不是合法 JSON 对象:" + e.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Object value = com.yunhai.flowcenter.engine.ExpressionEvaluator.evaluate(expression, env);
|
||||
result.put("result", Boolean.TRUE.equals(value));
|
||||
result.put("value", String.valueOf(value));
|
||||
} catch (Exception e) {
|
||||
result.put("result", false);
|
||||
result.put("error", String.valueOf(e.getMessage() != null ? e.getMessage() : e.toString()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ==================== 办件查询 ====================
|
||||
|
||||
@GetMapping("/instance/page")
|
||||
|
||||
Reference in New Issue
Block a user