feat(pigx-flow-api): 新增流程状态事件注册与校验功能

- 在FlowStatusEventPublisher中添加流程ID注册和校验方法,使用Redis Set存储已注册的flowId
- 更新FlowStatusEventAutoConfiguration,在启动时自动注册所有本地flowId到Redis
- 重构ProcessServiceImpl中的validateFlowId方法,改为通过Redis查询flowId注册状态
- 优化BpmOaLeaveServiceImpl中的流程参数设置逻辑,使用Dict构建root用户信息
This commit is contained in:
PIGCLOUD committed 2026-03-08 15:02:49 +08:00
1 parent 618f3ff1d5
commit 84041ed7ce
4 files changed
+42 -24

No files matched your search

@@ -40,7 +40,9 @@ public class FlowStatusEventAutoConfiguration {
@ConditionalOnMissingBean
@ConditionalOnBean(IProcessInstanceStatusEventService.class)
public FlowStatusEventListener flowStatusEventListener(List<IProcessInstanceStatusEventService> eventServices,
StringRedisTemplate redisTemplate) {
StringRedisTemplate redisTemplate, FlowStatusEventPublisher publisher) {
// 启动时注册所有本地 flowId 到 Redis
eventServices.forEach(service -> publisher.registerFlowId(service.getFlowId()));
return new FlowStatusEventListener(eventServices, redisTemplate);
}
@@ -1,6 +1,7 @@
package com.pig4cloud.pigx.flow.event;
import cn.hutool.json.JSONUtil;
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.flow.dto.ProcessInstanceParamDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -21,6 +22,8 @@ public class FlowStatusEventPublisher {
public static final String CHANNEL = "pigx:flow:status";
public static final String REGISTERED_FLOW_IDS_KEY = CacheConstants.GLOBALLY + "flow:registered-flow-ids";
private final StringRedisTemplate redisTemplate;
/**
@@ -34,4 +37,22 @@ public class FlowStatusEventPublisher {
paramDto.getProcessInstanceId());
}
/**
* 注册 flowId 到 Redis Set
* @param flowId 流程定义Key
*/
public void registerFlowId(String flowId) {
redisTemplate.opsForSet().add(REGISTERED_FLOW_IDS_KEY, flowId);
log.debug("注册 flowId: {}", flowId);
}
/**
* 校验 flowId 是否已注册
* @param flowId 流程定义Key
* @return true 表示已注册
*/
public boolean isFlowIdRegistered(String flowId) {
return Boolean.TRUE.equals(redisTemplate.opsForSet().isMember(REGISTERED_FLOW_IDS_KEY, flowId));
}
}