【代码评审】BPM:触发器 HTTP 异步
This commit is contained in:
parent
35f0d689f1
commit
3c0b9262d7
|
@ -9,7 +9,6 @@ import jakarta.validation.constraints.NotEmpty;
|
|||
*/
|
||||
public interface BpmProcessTaskApi {
|
||||
|
||||
|
||||
/**
|
||||
* 触发流程任务的执行
|
||||
*
|
||||
|
@ -18,4 +17,5 @@ public interface BpmProcessTaskApi {
|
|||
*/
|
||||
void triggerTask(@NotEmpty(message = "流程实例的编号不能为空") String processInstanceId,
|
||||
@NotEmpty(message = "任务 Key 不能为空") String taskDefineKey);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public enum BpmTriggerTypeEnum implements ArrayValuable<Integer> {
|
|||
HTTP_REQUEST(1, "发起 HTTP 请求"),
|
||||
FORM_UPDATE(2, "更新流程表单数据"),
|
||||
FORM_DELETE(3, "删除流程表单数据"),
|
||||
HTTP_REQUEST_ASYNC(4, "发起异步 HTTP 请求");
|
||||
HTTP_REQUEST_ASYNC(4, "发起异步 HTTP 请求"); // TODO @jason:发起 HTTP 回调
|
||||
|
||||
/**
|
||||
* 触发器执行动作类型
|
||||
|
|
|
@ -24,4 +24,5 @@ public class BpmProcessInstanceApiImpl implements BpmProcessInstanceApi {
|
|||
public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO reqDTO) {
|
||||
return processInstanceService.createProcessInstance(userId, reqDTO);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,4 +21,5 @@ public class BpmProcessTaskApiImpl implements BpmProcessTaskApi {
|
|||
public void triggerTask(String processInstanceId, String taskDefineKey) {
|
||||
bpmTaskService.triggerTask(processInstanceId, taskDefineKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -394,6 +394,7 @@ public class BpmSimpleModelNodeVO {
|
|||
*/
|
||||
@Schema(description = "回调任务 Key", example = "xxx", hidden = true)
|
||||
private String callbackTaskDefineKey;
|
||||
|
||||
}
|
||||
|
||||
@Schema(description = "流程表单触发器设置", example = "{}")
|
||||
|
|
|
@ -743,14 +743,15 @@ public class SimpleModelUtils {
|
|||
// 异步 HTTP 请求。需要附加一个 ReceiveTask、发起请求后、等待回调执行
|
||||
if (HTTP_REQUEST_ASYNC.getType().equals(node.getTriggerSetting().getType())) {
|
||||
Assert.notNull(node.getTriggerSetting().getHttpRequestSetting(), "触发器 HTTP 请求设置不能为空");
|
||||
String attachNodeId = "Activity_" + IdUtil.fastUUID();
|
||||
ReceiveTask receiveTask = new ReceiveTask();
|
||||
receiveTask.setId(attachNodeId);
|
||||
receiveTask.setId("Activity_" + IdUtil.fastUUID());
|
||||
receiveTask.setName("异步 HTTP 请求");
|
||||
node.setAttachNodeId(attachNodeId);
|
||||
node.getTriggerSetting().getHttpRequestSetting().setCallbackTaskDefineKey(attachNodeId); // 设置 callbackTaskDefineKey
|
||||
node.setAttachNodeId(receiveTask.getId());
|
||||
flowElements.add(receiveTask);
|
||||
// 重要:设置 callbackTaskDefineKey,用于 HTTP 回调
|
||||
node.getTriggerSetting().getHttpRequestSetting().setCallbackTaskDefineKey(receiveTask.getId());
|
||||
}
|
||||
|
||||
// 触发器使用 ServiceTask 来实现
|
||||
ServiceTask serviceTask = new ServiceTask();
|
||||
serviceTask.setId(node.getId());
|
||||
|
|
|
@ -1340,8 +1340,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||
.activityId(taskDefineKey)
|
||||
.singleResult();
|
||||
if (execution == null) {
|
||||
log.error("[triggerReceiveTask][processInstanceId({}) activityId({}) 没有找到执行活动]",
|
||||
processInstanceId, taskDefineKey);
|
||||
log.error("[triggerTask][processInstanceId({}) activityId({}) 没有找到执行活动]", processInstanceId, taskDefineKey);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.flowable.engine.runtime.ProcessInstance;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
// TODO @jason:BpmHttpCallbackTrigger
|
||||
/**
|
||||
* BPM 发送异步 HTTP 请求触发器
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue