Commit 3c0b9262d7498891d8934d1c347219661936f597
1 parent
35f0d689
【代码评审】BPM:触发器 HTTP 异步
Showing
8 changed files
with
12 additions
and
8 deletions
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessTaskApi.java
| @@ -9,7 +9,6 @@ import jakarta.validation.constraints.NotEmpty; | @@ -9,7 +9,6 @@ import jakarta.validation.constraints.NotEmpty; | ||
| 9 | */ | 9 | */ |
| 10 | public interface BpmProcessTaskApi { | 10 | public interface BpmProcessTaskApi { |
| 11 | 11 | ||
| 12 | - | ||
| 13 | /** | 12 | /** |
| 14 | * 触发流程任务的执行 | 13 | * 触发流程任务的执行 |
| 15 | * | 14 | * |
| @@ -18,4 +17,5 @@ public interface BpmProcessTaskApi { | @@ -18,4 +17,5 @@ public interface BpmProcessTaskApi { | ||
| 18 | */ | 17 | */ |
| 19 | void triggerTask(@NotEmpty(message = "流程实例的编号不能为空") String processInstanceId, | 18 | void triggerTask(@NotEmpty(message = "流程实例的编号不能为空") String processInstanceId, |
| 20 | @NotEmpty(message = "任务 Key 不能为空") String taskDefineKey); | 19 | @NotEmpty(message = "任务 Key 不能为空") String taskDefineKey); |
| 20 | + | ||
| 21 | } | 21 | } |
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTriggerTypeEnum.java
| @@ -19,7 +19,7 @@ public enum BpmTriggerTypeEnum implements ArrayValuable<Integer> { | @@ -19,7 +19,7 @@ public enum BpmTriggerTypeEnum implements ArrayValuable<Integer> { | ||
| 19 | HTTP_REQUEST(1, "发起 HTTP 请求"), | 19 | HTTP_REQUEST(1, "发起 HTTP 请求"), |
| 20 | FORM_UPDATE(2, "更新流程表单数据"), | 20 | FORM_UPDATE(2, "更新流程表单数据"), |
| 21 | FORM_DELETE(3, "删除流程表单数据"), | 21 | FORM_DELETE(3, "删除流程表单数据"), |
| 22 | - HTTP_REQUEST_ASYNC(4, "发起异步 HTTP 请求"); | 22 | + HTTP_REQUEST_ASYNC(4, "发起异步 HTTP 请求"); // TODO @jason:发起 HTTP 回调 |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | * 触发器执行动作类型 | 25 | * 触发器执行动作类型 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java
| @@ -24,4 +24,5 @@ public class BpmProcessInstanceApiImpl implements BpmProcessInstanceApi { | @@ -24,4 +24,5 @@ public class BpmProcessInstanceApiImpl implements BpmProcessInstanceApi { | ||
| 24 | public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO reqDTO) { | 24 | public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO reqDTO) { |
| 25 | return processInstanceService.createProcessInstance(userId, reqDTO); | 25 | return processInstanceService.createProcessInstance(userId, reqDTO); |
| 26 | } | 26 | } |
| 27 | + | ||
| 27 | } | 28 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessTaskApiImpl.java
| @@ -21,4 +21,5 @@ public class BpmProcessTaskApiImpl implements BpmProcessTaskApi { | @@ -21,4 +21,5 @@ public class BpmProcessTaskApiImpl implements BpmProcessTaskApi { | ||
| 21 | public void triggerTask(String processInstanceId, String taskDefineKey) { | 21 | public void triggerTask(String processInstanceId, String taskDefineKey) { |
| 22 | bpmTaskService.triggerTask(processInstanceId, taskDefineKey); | 22 | bpmTaskService.triggerTask(processInstanceId, taskDefineKey); |
| 23 | } | 23 | } |
| 24 | + | ||
| 24 | } | 25 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
| @@ -394,6 +394,7 @@ public class BpmSimpleModelNodeVO { | @@ -394,6 +394,7 @@ public class BpmSimpleModelNodeVO { | ||
| 394 | */ | 394 | */ |
| 395 | @Schema(description = "回调任务 Key", example = "xxx", hidden = true) | 395 | @Schema(description = "回调任务 Key", example = "xxx", hidden = true) |
| 396 | private String callbackTaskDefineKey; | 396 | private String callbackTaskDefineKey; |
| 397 | + | ||
| 397 | } | 398 | } |
| 398 | 399 | ||
| 399 | @Schema(description = "流程表单触发器设置", example = "{}") | 400 | @Schema(description = "流程表单触发器设置", example = "{}") |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
| @@ -743,14 +743,15 @@ public class SimpleModelUtils { | @@ -743,14 +743,15 @@ public class SimpleModelUtils { | ||
| 743 | // 异步 HTTP 请求。需要附加一个 ReceiveTask、发起请求后、等待回调执行 | 743 | // 异步 HTTP 请求。需要附加一个 ReceiveTask、发起请求后、等待回调执行 |
| 744 | if (HTTP_REQUEST_ASYNC.getType().equals(node.getTriggerSetting().getType())) { | 744 | if (HTTP_REQUEST_ASYNC.getType().equals(node.getTriggerSetting().getType())) { |
| 745 | Assert.notNull(node.getTriggerSetting().getHttpRequestSetting(), "触发器 HTTP 请求设置不能为空"); | 745 | Assert.notNull(node.getTriggerSetting().getHttpRequestSetting(), "触发器 HTTP 请求设置不能为空"); |
| 746 | - String attachNodeId = "Activity_" + IdUtil.fastUUID(); | ||
| 747 | ReceiveTask receiveTask = new ReceiveTask(); | 746 | ReceiveTask receiveTask = new ReceiveTask(); |
| 748 | - receiveTask.setId(attachNodeId); | 747 | + receiveTask.setId("Activity_" + IdUtil.fastUUID()); |
| 749 | receiveTask.setName("异步 HTTP 请求"); | 748 | receiveTask.setName("异步 HTTP 请求"); |
| 750 | - node.setAttachNodeId(attachNodeId); | ||
| 751 | - node.getTriggerSetting().getHttpRequestSetting().setCallbackTaskDefineKey(attachNodeId); // 设置 callbackTaskDefineKey | 749 | + node.setAttachNodeId(receiveTask.getId()); |
| 752 | flowElements.add(receiveTask); | 750 | flowElements.add(receiveTask); |
| 751 | + // 重要:设置 callbackTaskDefineKey,用于 HTTP 回调 | ||
| 752 | + node.getTriggerSetting().getHttpRequestSetting().setCallbackTaskDefineKey(receiveTask.getId()); | ||
| 753 | } | 753 | } |
| 754 | + | ||
| 754 | // 触发器使用 ServiceTask 来实现 | 755 | // 触发器使用 ServiceTask 来实现 |
| 755 | ServiceTask serviceTask = new ServiceTask(); | 756 | ServiceTask serviceTask = new ServiceTask(); |
| 756 | serviceTask.setId(node.getId()); | 757 | serviceTask.setId(node.getId()); |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| @@ -1340,8 +1340,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -1340,8 +1340,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 1340 | .activityId(taskDefineKey) | 1340 | .activityId(taskDefineKey) |
| 1341 | .singleResult(); | 1341 | .singleResult(); |
| 1342 | if (execution == null) { | 1342 | if (execution == null) { |
| 1343 | - log.error("[triggerReceiveTask][processInstanceId({}) activityId({}) 没有找到执行活动]", | ||
| 1344 | - processInstanceId, taskDefineKey); | 1343 | + log.error("[triggerTask][processInstanceId({}) activityId({}) 没有找到执行活动]", processInstanceId, taskDefineKey); |
| 1345 | return; | 1344 | return; |
| 1346 | } | 1345 | } |
| 1347 | 1346 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/trigger/http/BpmAsyncHttpRequestTrigger.java
| @@ -10,6 +10,7 @@ import org.flowable.engine.runtime.ProcessInstance; | @@ -10,6 +10,7 @@ import org.flowable.engine.runtime.ProcessInstance; | ||
| 10 | import org.springframework.stereotype.Component; | 10 | import org.springframework.stereotype.Component; |
| 11 | import org.springframework.util.MultiValueMap; | 11 | import org.springframework.util.MultiValueMap; |
| 12 | 12 | ||
| 13 | +// TODO @jason:BpmHttpCallbackTrigger | ||
| 13 | /** | 14 | /** |
| 14 | * BPM 发送异步 HTTP 请求触发器 | 15 | * BPM 发送异步 HTTP 请求触发器 |
| 15 | * | 16 | * |