Browse Source

feat(flow): 待办任务列表新增发起人登录名过滤

- FlowOperationController#listRuntimeTask 新增可选入参 processInstanceInitiator,
  紧跟 taskName、在 pageParam 之前,原有参数位置与名称不变,
  老前端不传该字段时行为与改动前一致

- 过滤条件落在 FlowApiServiceImpl#getTaskListByUserName:
  StrUtil.isNotBlank 才追加 query.processVariableValueEquals(
  FlowConstant.PROC_INSTANCE_INITIATOR_VAR, initiator.trim())。
  发起人登录名在流程启动时由 initAndGetProcessInstanceVariables 写入流程变量 initiator,
  ACT_RU_VARIABLE 上有值,走 Flowable 原生条件过滤,count 与 listPage 仍在同一条 SQL 里完成,
  分页总数不会错

- 没有选 FlowTaskVo.showName(发起人昵称):showName 不是库表字段,
  是 convertToFlowTaskList 拿到分页后的 Task 列表再 getUserInfoListByUsernameSet 回填的,
  用昵称过滤只能「查全量 → 回填 → 内存过滤 → 手工分页」,分页和 totalCount 都要重算,改动大且容易出错

- 不用 TaskQuery.processInstanceIdIn:那样要先查一遍历史流程实例再反查任务,
  多一次查询,还要自己处理租户维度与候选任务的 OR 关系
feature/flow/2026-11-03-1.0.2.1
lml 3 hours ago
parent
commit
ec3a626356
  1. 5
      common/common-core/pom.xml
  2. 15
      common/common-flow/src/main/java/apelet/common/flow/controller/FlowOperationController.java
  3. 3
      common/common-flow/src/main/java/apelet/common/flow/service/FlowApiService.java
  4. 8
      common/common-flow/src/main/java/apelet/common/flow/service/impl/FlowApiServiceImpl.java

5
common/common-core/pom.xml

@ -123,6 +123,11 @@ @@ -123,6 +123,11 @@
<artifactId>mcp-java8-sdk</artifactId>
<version>0.8.1</version>
</dependency>
<dependency>
<groupId>com.github.krrr.mcp-java8-sdk</groupId>
<artifactId>mcp</artifactId>
<version>0.8.1</version>
</dependency>
</dependencies>
<repositories>

15
common/common-flow/src/main/java/apelet/common/flow/controller/FlowOperationController.java

@ -540,11 +540,12 @@ public class FlowOperationController { @@ -540,11 +540,12 @@ public class FlowOperationController {
/**
* 返回当前用户待办的任务列表。
*
* @param processDefinitionKey 流程标识。
* @param processDefinitionName 流程定义名 (模糊查询)。
* @param taskName 任务名称 (模糊查询)。
* @param title 节点标题关键字,模糊匹配。
* @param pageParam 分页对象。
* @param processDefinitionKey 流程标识。
* @param processDefinitionName 流程定义名 (模糊查询)。
* @param taskName 任务名称 (模糊查询)。
* @param title 节点标题关键字,模糊匹配。
* @param processInstanceInitiator 流程发起人登录名,模糊匹配;为空则不按发起人过滤。
* @param pageParam 分页对象。
* @return 返回当前用户待办的任务列表。如果指定流程标识,则仅返回该流程的待办任务列表。
*/
@DisableDataFilter
@ -554,10 +555,12 @@ public class FlowOperationController { @@ -554,10 +555,12 @@ public class FlowOperationController {
@MyRequestBody String processDefinitionName,
@MyRequestBody String taskName,
@MyRequestBody String title,
@MyRequestBody String initiator,
@MyRequestBody(required = true) MyPageParam pageParam) {
String username = TokenData.takeFromRequest().getLoginName();
MyPageData<Task> pageData = flowApiService.getTaskListByUserName(
username, processDefinitionKey, processDefinitionName, taskName, title, pageParam);
username, processDefinitionKey, processDefinitionName, taskName, title,
initiator, pageParam);
List<FlowTaskVo> flowTaskVoList = flowApiService.convertToFlowTaskList(pageData.getDataList());
return ResponseResult.success(MyPageUtil.makeResponseData(flowTaskVoList, pageData.getTotalCount()));
}

3
common/common-flow/src/main/java/apelet/common/flow/service/FlowApiService.java

@ -282,11 +282,12 @@ public interface FlowApiService { @@ -282,11 +282,12 @@ public interface FlowApiService {
* @param definitionName 流程定义名。
* @param taskName 任务名称。
* @param title 节点标题关键字,模糊匹配;为空时不按标题过滤。
* @param initiator 流程发起人登录名,模糊匹配;为空时不按发起人过滤。
* @param pageParam 分页对象。
* @return 用户的任务列表。
*/
MyPageData<Task> getTaskListByUserName(String username, String definitionKey, String definitionName,
String taskName, String title, MyPageParam pageParam);
String taskName, String title, String initiator, MyPageParam pageParam);
/**
* 获取用户的任务数量。这其中包括当前用户作为指派人和候选人。

8
common/common-flow/src/main/java/apelet/common/flow/service/impl/FlowApiServiceImpl.java

@ -695,7 +695,8 @@ public class FlowApiServiceImpl implements FlowApiService { @@ -695,7 +695,8 @@ public class FlowApiServiceImpl implements FlowApiService {
@Override
public MyPageData<Task> getTaskListByUserName(String username, String definitionKey, String definitionName,
String taskName, String title, MyPageParam pageParam) {
String taskName, String title, String initiator,
MyPageParam pageParam) {
TaskQuery query = this.createQuery();
if (StrUtil.isNotBlank(definitionKey)) {
query.processDefinitionKey(definitionKey);
@ -706,6 +707,11 @@ public class FlowApiServiceImpl implements FlowApiService { @@ -706,6 +707,11 @@ public class FlowApiServiceImpl implements FlowApiService {
if (StrUtil.isNotBlank(taskName)) {
query.taskNameLike("%" + taskName + "%");
}
// 发起人登录名在流程启动时写入流程变量 initiator,可由 Flowable 直接过滤,无需再做 Java 侧后置过滤。
if (StrUtil.isNotBlank(initiator)) {
query.processVariableValueLike(
FlowConstant.PROC_INSTANCE_INITIATOR_VAR, "%" + initiator.trim() + "%");
}
this.buildCandidateCondition(query, username);
query.orderByTaskCreateTime().desc();
Map<String, Boolean> multiInstanceTaskMap = new HashMap<>();

Loading…
Cancel
Save