feat(approval): 会签进度("已会签 N/M") — approval-context 多实例计数

- ApprovalContextDto(flowable + gateway)加 cosign/cosignTotal/cosignCompleted
- FlowController.approvalContext: fillCosign 沿执行树向上找带 nrOfInstances 的
  多实例根执行,读 nrOfInstances/nrOfCompletedInstances 回填
- gateway ApprovalController.approvalMeta 透传 cosign 字段
- 单测 FlowControllerTest 会签进度回填(22 绿);live(8089)实证 cosign:true 0/2

注:gateway 端 cosign 展示当前被 platform-report 引入的上古 xerces-eip3.jar(2004)
击穿 WfTemplate XML 解析所阻(AbstractMethodError on DocumentBuilderFactory.setFeature,
影响全部 approve/reject 按钮解析,非本改动引入,需在 report 模块侧隔离/排除该 xerces)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-26 08:19:09 +08:00
parent 4f9e4abfc2
commit 5c4894d40a
5 changed files with 76 additions and 0 deletions

View File

@@ -443,6 +443,40 @@ class FlowControllerTest {
.andExpect(jsonPath("$.processInstanceId").value("pi-1"));
}
@Test
void 会签任务approvalContext回填会签进度() throws Exception {
// 会签(多实例)任务:approval-context 沿执行树向上找带 nrOfInstances 的多实例根执行,回填进度
when(taskService.createTaskQuery()).thenReturn(taskQuery);
when(taskQuery.taskId("mi-1")).thenReturn(taskQuery);
Task t = org.mockito.Mockito.mock(Task.class);
when(t.getProcessInstanceId()).thenReturn("pi-mi");
when(t.getExecutionId()).thenReturn("exec-leaf");
when(taskQuery.singleResult()).thenReturn(t);
// fillCosign:叶执行无 nrOfInstances → 向上到根执行命中
when(runtimeService.getVariablesLocal("exec-leaf")).thenReturn(java.util.Map.of());
when(runtimeService.getVariablesLocal("exec-root"))
.thenReturn(java.util.Map.of("nrOfInstances", 3, "nrOfCompletedInstances", 1));
var execQuery = org.mockito.Mockito.mock(org.flowable.engine.runtime.ExecutionQuery.class);
when(runtimeService.createExecutionQuery()).thenReturn(execQuery);
when(execQuery.executionId("exec-leaf")).thenReturn(execQuery);
org.flowable.engine.runtime.Execution leaf = org.mockito.Mockito.mock(org.flowable.engine.runtime.Execution.class);
when(leaf.getParentId()).thenReturn("exec-root");
when(execQuery.singleResult()).thenReturn(leaf);
// 业务实例查不到(聚焦会签字段),走 PI null 分支
when(runtimeService.createProcessInstanceQuery()).thenReturn(processInstanceQuery);
when(processInstanceQuery.processInstanceId("pi-mi")).thenReturn(processInstanceQuery);
when(processInstanceQuery.singleResult()).thenReturn(null);
when(historyService.createHistoricProcessInstanceQuery()).thenReturn(historicProcessInstanceQuery);
when(historicProcessInstanceQuery.processInstanceId("pi-mi")).thenReturn(historicProcessInstanceQuery);
when(historicProcessInstanceQuery.singleResult()).thenReturn(null);
mvc.perform(get("/api/flow/tasks/mi-1/approval-context"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.cosign").value(true))
.andExpect(jsonPath("$.cosignTotal").value(3))
.andExpect(jsonPath("$.cosignCompleted").value(1));
}
@Test
void 协办超过上限返回400() throws Exception {
StringBuilder ids = new StringBuilder("[");