Spring Boot 流程引擎服务:流程定义/实例/任务、审批人解析、 回调分发、oapi 接口及单元测试。 保留远程 .gitea/workflows/build.yml 与 docker/Dockerfile, 新增 .gitignore 排除 target/ 构建产物。
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package com.yunhai.flowcenter.engine;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 引擎关键状态变迁事件(概览 §5.2 v1.1 增补):事务内发布,AFTER_COMMIT 后由
|
||||
* CallbackDispatcher(回调给业务方)与 UserMsgNotifier(通知人)消费——引擎本身不知道
|
||||
* 也不依赖任何业务方的存在。携带 instanceId 而非实体快照:监听方在提交后按需重读(含最新 version)。
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class FlowEvent {
|
||||
|
||||
public enum Type {
|
||||
/** 代发起/重提成功(instance=10) */
|
||||
SUBMITTED("flow.submitted"),
|
||||
/** 任一审批任务创建(并行会签每个任务各发一条,data 带 n/m 汇总) */
|
||||
TASK_CREATED("flow.task.created"),
|
||||
/** 任一任务被办理(同意/拒绝各发一条,进度同步用) */
|
||||
TASK_HANDLED("flow.task.handled"),
|
||||
/** END 激活,instance=20 */
|
||||
COMPLETED("flow.completed"),
|
||||
/** END_REJECTED,instance=30 */
|
||||
REJECTED("flow.rejected"),
|
||||
/** 提交人撤回,instance=40 */
|
||||
WITHDRAWN("flow.withdrawn"),
|
||||
/** 催办(仅 UserMsg 通道,非回调事件枚举) */
|
||||
URGE("flow.urge");
|
||||
|
||||
private final String code;
|
||||
|
||||
Type(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static Type ofCode(String code) {
|
||||
for (Type t : values()) {
|
||||
if (t.code.equals(code)) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private final Type type;
|
||||
private final Long instanceId;
|
||||
/** 任务事件带 taskId(SUBMITTED 等办件级事件为 null) */
|
||||
private final Long taskId;
|
||||
/** 事件明细(result/opinion/rejectNode/task.created 的 n/m 等),可为空 */
|
||||
private final Map<String, Object> data;
|
||||
|
||||
public static FlowEvent of(Type type, Long instanceId) {
|
||||
return new FlowEvent(type, instanceId, null, new HashMap<>());
|
||||
}
|
||||
|
||||
public static FlowEvent of(Type type, Long instanceId, Long taskId, Map<String, Object> data) {
|
||||
return new FlowEvent(type, instanceId, taskId, data == null ? new HashMap<>() : data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user