fix:修正本地应用节点净室策略问题

This commit is contained in:
2026-01-24 10:18:55 +08:00
parent 4d985594d5
commit 70fc5ae4cb
3 changed files with 39 additions and 9 deletions

View File

@@ -33,9 +33,17 @@ public class UserTaskDirectoryPreparationListener implements ExecutionListener {
String nodeId = execution.getCurrentActivityId();
String processDefinitionId = execution.getProcessDefinitionId();
// 【新增逻辑】处理本地应用注册节点的 ID 映射
// 如果监听器运行在 Register 节点(例如 "Task_1_register"),我们需要还原为原始 ID ("Task_1")
String originalNodeId = FlowNodeIdUtils.parseOriginalNodeId(nodeId);
if (!nodeId.equals(originalNodeId)) {
log.info("检测到辅助节点ID 还原: {} -> {}", nodeId, originalNodeId);
nodeId = originalNodeId;
}
//创建本地文件夹用于后续节点计算直接从本地读取不需要再从minio中获取数据
JSONObject params =processNodeParamService.getParam(processDefinitionId,nodeId,runId);
log.info("userTaskDirectoryPreparationListener, 启动流程 runId:{},nodeId:{},实例id: {},参数 params:{}", runId,nodeId,execution.getProcessInstanceId(),params);
JSONObject params = processNodeParamService.getParam(processDefinitionId, nodeId, runId);
log.info("userTaskDirectoryPreparationListener, 启动流程 runId:{},nodeId:{},实例id: {},参数 params:{}", runId, nodeId, execution.getProcessInstanceId(), params);
Long currentNodeOutputDirId = params.getLong("outputDirId");
if(ObjectUtils.isEmpty(currentNodeOutputDirId)){
throw new RuntimeException("当前节点未配置输出文件夹");
@@ -49,4 +57,4 @@ public class UserTaskDirectoryPreparationListener implements ExecutionListener {
String objectKey = fileBaseInfoResp.getData().getObjectKey();
FlowNodeIdUtils.prepareLocalDir(objectKey);
}
}
}

View File

@@ -553,6 +553,11 @@ public class Dto2BpmnConverter {
disableAsyncRetry(registerTask);
registerTask.setImplementation("${localAppRegisterDelegate}");
registerTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
// 【新增逻辑】为 Register 节点添加目录准备监听器
// 这样在进入组合节点的第一步时,就会执行文件夹清空/准备
addDirectoryPreparationListener(registerTask);
process.addFlowElement(registerTask);
// 2. Wait Node (ReceiveTask)
@@ -601,6 +606,23 @@ public class Dto2BpmnConverter {
process.addFlowElement(userTask);
}
/**
* 为节点添加目录准备监听器
* @param flowElement 需要添加监听器的节点
*/
private void addDirectoryPreparationListener(FlowElement flowElement) {
FlowableListener dirPrepareListener = new FlowableListener();
dirPrepareListener.setEvent("start");
dirPrepareListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
dirPrepareListener.setImplementation("${userTaskDirectoryPreparationListener}");
if (flowElement instanceof UserTask) {
((UserTask) flowElement).getExecutionListeners().add(dirPrepareListener);
} else if (flowElement instanceof ServiceTask) {
((ServiceTask) flowElement).getExecutionListeners().add(dirPrepareListener);
}
}
// 抽取通用的 UserTask 扩展属性设置
private void addUserTaskExtensions(UserTask userTask, FlowElementDTO nodeDto) throws JsonProcessingException {
@@ -620,12 +642,11 @@ public class Dto2BpmnConverter {
// 设置用户任务的属性,使其可以被任何人处理
// 不设置 assignee 或 candidateUsers这样任何人都可以处理任务
// 可选:绑定 TaskListener在任务完成时触发逻辑
FlowableListener dirPrepareListener = new FlowableListener();
dirPrepareListener.setEvent("start");
dirPrepareListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
dirPrepareListener.setImplementation("${userTaskDirectoryPreparationListener}");
userTask.getExecutionListeners().add(dirPrepareListener);
// 【修改逻辑】仅当不是本地应用节点时,才在 UserTask 上添加目录准备监听器
// 因为本地应用节点已经前移到 Register 节点处理了
if (!FlowNodeIdUtils.isLocalAppNode(nodeDto)) {
addDirectoryPreparationListener(userTask);
}
}
private void createServiceTask(Process process, FlowElementDTO nodeDto, Map<String, String> asyncTaskMap) throws JsonProcessingException {