✨ #5595 【需求】协同管理工作流支持流程节点执行回调

This commit is contained in:
冷冷 committed 2024-08-21 22:26:13 +08:00
1 parent 7aa4a255c9
commit 947789a6f9
3 files changed
+50 -1

No files matched your search

@@ -5,6 +5,8 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import com.pig4cloud.pigx.flow.engine.service.NodeTaskCompleteNotifyService;
import com.pig4cloud.pigx.flow.task.api.feign.RemoteFlowTaskService;
import com.pig4cloud.pigx.flow.task.dto.*;
import com.pig4cloud.pigx.flow.task.utils.NodeUtil;
@@ -117,7 +119,6 @@ public class FlowProcessEventListener implements FlowableEventListener {
processNodeRecordParamDto.setNodeName(activityName);
remoteFlowTaskService.endNodeEvent(processNodeRecordParamDto);
}
if (event.getType().toString().equals(FlowableEngineEventType.VARIABLE_UPDATED.toString())) {
@@ -190,6 +191,8 @@ public class FlowProcessEventListener implements FlowableEventListener {
remoteFlowTaskService.taskEndEvent(processNodeRecordAssignUserParamDto);
SpringUtil.getBean(NodeTaskCompleteNotifyService.class).sendNotify(SecurityUtils.getToken(),processNodeRecordAssignUserParamDto);
}
if (event.getType().toString().equals(FlowableEngineEventType.TASK_ASSIGNED.toString())) {
// 任务被指派了人员
@@ -0,0 +1,44 @@
package com.pig4cloud.pigx.flow.engine.service;
import cn.hutool.core.lang.Validator;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.pig4cloud.pigx.common.core.util.RetOps;
import com.pig4cloud.pigx.common.security.util.NonWebTokenContextHolder;
import com.pig4cloud.pigx.flow.task.api.feign.RemoteFlowTaskService;
import com.pig4cloud.pigx.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
/**
* 节点任务完成通知处理
*
* @author lengleng
* @date 2024/7/9
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class NodeTaskCompleteNotifyService {
private final RemoteFlowTaskService remoteFlowTaskService;
@Async
public void sendNotify(String token, ProcessNodeRecordAssignUserParamDto taskCompleteParamDto) {
NonWebTokenContextHolder.setToken(token);
RetOps.of(remoteFlowTaskService.queryNodeOriData(taskCompleteParamDto.getFlowId(), taskCompleteParamDto.getNodeId()))
.getData()
.ifPresent(node -> {
if (Validator.isUrl(node.getEventConfig())) {
HttpResponse response = HttpRequest.post(node.getEventConfig())
.body(JSONUtil.toJsonStr(taskCompleteParamDto))
.timeout(10000)
.execute();
log.debug("节点任务完成通知处理完成:{},数据:{}", response.getStatus(), taskCompleteParamDto);
}
});
}
}
@@ -29,6 +29,8 @@ public class Node {
@JsonProperty("childNode")
private Node children;
private String eventConfig;
private Integer assignedType;
private Boolean multiple;