F2-7: 审批办理 UI 后端——trace/delegate 端点增补

- flowable-service:新增 GET /api/flow/process/{id}/trace(历史任务节点+
  审批意见+结果,biz 库不可达时用户名 1s 超时降级),TraceNodeDto;
  biz 数据源加 connectionTimeout/socketTimeout 快速失败
- platform-flow-gateway:FlowableClient 增加 trace/delegate 方法;
  TodoController 增加 /api/flow/process/{id}/trace 和 /api/task/{id}/delegate
  网关透传端点;GatewayRequests.DelegateRequest;TraceNodeDto 镜像
- 单测:TraceAndDelegateTest 3 个(MockRestServiceServer),全套 34/34 通过
- application-dev.yml:eip4.flow.read-timeout-ms=60000 适配慢查询

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 23:09:11 +08:00
parent b0657a7765
commit 6dbb205e94
9 changed files with 279 additions and 2 deletions

View File

@@ -104,6 +104,26 @@ public class FlowableClient {
return post("发起", "/api/flow/process/start", startRequest, ProcessInstanceDto.class);
}
/**
* 查流程轨迹(历史任务节点列表,含办理人姓名/意见/结果)。
* 对应 flowable-service {@code GET /api/flow/process/{processInstanceId}/trace}。
*/
public List<TraceNodeDto> trace(String processInstanceId) {
return execute("轨迹", () -> restClient.get()
.uri("/api/flow/process/{id}/trace", processInstanceId)
.retrieve()
.body(new ParameterizedTypeReference<List<TraceNodeDto>>() {}));
}
/**
* 委托(delegate)任务给指定用户。
* 对应 flowable-service {@code POST /api/flow/tasks/{taskId}/delegate}。
*/
public void delegate(String taskId, String delegateUserId) {
post("委托", "/api/flow/tasks/" + taskId + "/delegate",
Map.of("delegateUserId", delegateUserId), Void.class);
}
/**
* 查流程实例(供办理后判定是否结束以回写业务状态)。
* 实例不存在(404)返回 null;运行中 {@code ended=false},已结束 {@code ended=true}。

View File

@@ -0,0 +1,16 @@
package com.eip4.platform.flowgateway.client;
/**
* 流程轨迹节点 DTO(镜像 flowable-service TraceNodeDto 出参,经网关透传给前端)。
*/
public class TraceNodeDto {
public String taskId;
public String taskName;
public String assignee;
public String assigneeName;
public String comment;
public String result;
public Long startTime;
public Long endTime;
public boolean current;
}

View File

@@ -30,4 +30,9 @@ public final class GatewayRequests {
public String businessKey;
public Map<String, Object> variables;
}
/** 委托(delegate)请求。 */
public static class DelegateRequest {
public String delegateUserId;
}
}

View File

@@ -18,6 +18,7 @@ import com.eip4.platform.flowgateway.aggregate.TodoAggregator;
import com.eip4.platform.flowgateway.aggregate.TodoItem;
import com.eip4.platform.flowgateway.client.FlowableClient;
import com.eip4.platform.flowgateway.client.ProcessInstanceDto;
import com.eip4.platform.flowgateway.client.TraceNodeDto;
import com.eip4.platform.flowgateway.writeback.StatusWriteback;
import io.swagger.v3.oas.annotations.Operation;
@@ -107,6 +108,27 @@ public class TodoController {
return ResponseEntity.ok(flowableClient.start(body));
}
@Operation(summary = "流程轨迹", description = "返回流程实例的历史任务节点(含当前活动节点),按开始时间升序;包含办理人姓名/审批意见/办理结果")
@GetMapping("/api/flow/process/{processInstanceId}/trace")
public ResponseEntity<List<TraceNodeDto>> trace(@PathVariable String processInstanceId) {
List<TraceNodeDto> nodes = flowableClient.trace(processInstanceId);
return ResponseEntity.ok(nodes);
}
@Operation(summary = "委托任务", description = "将任务委托给指定用户(delegateUserId),assignee 变受托人,owner 记原办理人")
@PostMapping("/api/task/{id}/delegate")
public ResponseEntity<Map<String, Object>> delegate(@PathVariable String id,
@RequestBody GatewayRequests.DelegateRequest req) {
if (req == null || req.delegateUserId == null || req.delegateUserId.isBlank()) {
return ResponseEntity.badRequest().build();
}
flowableClient.delegate(id, req.delegateUserId);
Map<String, Object> resp = new HashMap<>();
resp.put("delegated", true);
resp.put("delegateUserId", req.delegateUserId);
return ResponseEntity.ok(resp);
}
/** 实例不存在(已被清理)按"已结束"处理(complete 后无运行实例即流程终结)。 */
private boolean isProcessEnded(String processInstanceId) {
ProcessInstanceDto pi = flowableClient.processInstance(processInstanceId);