Commit b07bc3d787fc73e4099a806eb3dd2905b869d52b

Authored by YunaiV
1 parent 2a97a49a

fix:【bpm 工作流】已办任务的审批状态过滤不正确

yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskPageReqVO.java
... ... @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 4 import cn.iocoder.yudao.framework.common.util.date.DateUtils;
  5 +import cn.iocoder.yudao.framework.common.validation.InEnum;
  6 +import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
5 7 import io.swagger.v3.oas.annotations.media.Schema;
6 8 import lombok.Data;
7 9 import org.springframework.format.annotation.DateTimeFormat;
... ... @@ -21,6 +23,10 @@ public class BpmTaskPageReqVO extends PageParam {
21 23 @Schema(description = "流程定义的标识", example = "2048")
22 24 private String processDefinitionKey; // 精准匹配
23 25  
  26 + @Schema(description = "审批状态", example = "1")
  27 + @InEnum(BpmTaskStatusEnum.class)
  28 + private Integer status; // 仅【已办】使用
  29 +
24 30 @Schema(description = "创建时间")
25 31 @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
26 32 private LocalDateTime[] createTime;
... ...
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskStatusEnum.java
... ... @@ -2,10 +2,13 @@ package cn.iocoder.yudao.module.bpm.enums.task;
2 2  
3 3 import cn.hutool.core.util.ArrayUtil;
4 4 import cn.hutool.core.util.ObjUtil;
  5 +import cn.iocoder.yudao.framework.common.core.ArrayValuable;
5 6 import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
6 7 import lombok.AllArgsConstructor;
7 8 import lombok.Getter;
8 9  
  10 +import java.util.Arrays;
  11 +
9 12 /**
10 13 * 流程任务 Task 的状态枚举
11 14 *
... ... @@ -13,7 +16,7 @@ import lombok.Getter;
13 16 */
14 17 @Getter
15 18 @AllArgsConstructor
16   -public enum BpmTaskStatusEnum {
  19 +public enum BpmTaskStatusEnum implements ArrayValuable<Integer> {
17 20  
18 21 SKIP(-2, "跳过"),
19 22 NOT_START(-1, "未开始"),
... ... @@ -36,6 +39,8 @@ public enum BpmTaskStatusEnum {
36 39 */
37 40 WAIT(0, "待审批");
38 41  
  42 + public static final Integer[] ARRAYS = Arrays.stream(values()).map(BpmTaskStatusEnum::getStatus).toArray(Integer[]::new);
  43 +
39 44 /**
40 45 * 状态
41 46 * <p>
... ... @@ -47,6 +52,11 @@ public enum BpmTaskStatusEnum {
47 52 */
48 53 private final String name;
49 54  
  55 + @Override
  56 + public Integer[] array() {
  57 + return ARRAYS;
  58 + }
  59 +
50 60 public static boolean isRejectStatus(Integer status) {
51 61 return REJECT.getStatus().equals(status);
52 62 }
... ...
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
... ... @@ -70,7 +70,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
70 70 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
71 71 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
72 72 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID;
73   -import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.*;
  73 +//import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.*;
74 74 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.*;
75 75  
76 76 /**
... ... @@ -231,6 +231,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
231 231 if (StrUtil.isNotBlank(pageVO.getName())) {
232 232 taskQuery.taskNameLike("%" + pageVO.getName() + "%");
233 233 }
  234 + if (pageVO.getStatus() != null) {
  235 + taskQuery.taskVariableValueEquals(BpmnVariableConstants.TASK_VARIABLE_STATUS, pageVO.getStatus());
  236 + }
234 237 // if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
235 238 // taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
236 239 // taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
... ... @@ -603,7 +606,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
603 606 runtimeService.setVariables(task.getProcessInstanceId(), variables);
604 607  
605 608 // 5. 移除辅助预测的流程变量,这些变量在回退操作中设置
606   - String simulateVariableName = StrUtil.concat(false, PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, task.getTaskDefinitionKey());
  609 + // todo @jason:可以直接 + 拼接哈
  610 + String simulateVariableName = StrUtil.concat(false,
  611 + BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, task.getTaskDefinitionKey());
607 612 runtimeService.removeVariable(task.getProcessInstanceId(), simulateVariableName);
608 613  
609 614 // 6. 调用 BPM complete 去完成任务
... ... @@ -936,7 +941,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
936 941 // TODO @jason:【驳回预测相关】是不是搞成一个变量,里面是 set 更简洁一点呀?
937 942 Set<String> taskDefinitionKeyList = getNeedSimulateTaskDefinitionKeys(bpmnModel, currentTask, targetElement);
938 943 Map<String, Object> needSimulateVariables = convertMap(taskDefinitionKeyList,
939   - taskId -> StrUtil.concat(false, PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, taskId), item -> Boolean.TRUE);
  944 + taskId -> StrUtil.concat(false, BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, taskId), item -> Boolean.TRUE);
940 945  
941 946 // 4. 执行驳回
942 947 // 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因:
... ... @@ -948,7 +953,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
948 953 .processVariables(needSimulateVariables)
949 954 // 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
950 955 .localVariable(reqVO.getTargetTaskDefinitionKey(),
951   - String.format(PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()), Boolean.TRUE)
  956 + String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()),
  957 + Boolean.TRUE)
952 958 .changeState();
953 959 }
954 960  
... ... @@ -1492,9 +1498,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
1492 1498 FlowElement userTaskElement = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey());
1493 1499 // 判断是否为退回或者驳回:如果是退回或者驳回不走这个策略(使用 local variable)
1494 1500 Boolean returnTaskFlag = runtimeService.getVariableLocal(task.getExecutionId(),
1495   - String.format(PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, task.getTaskDefinitionKey()), Boolean.class);
  1501 + String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, task.getTaskDefinitionKey()), Boolean.class);
1496 1502 Boolean skipStartUserNodeFlag = Convert.toBool(runtimeService.getVariable(processInstance.getProcessInstanceId(),
1497   - PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class));
  1503 + BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class));
1498 1504 if (userTaskElement.getId().equals(START_USER_NODE_ID)
1499 1505 && (skipStartUserNodeFlag == null // 目的:一般是“主流程”,发起人节点,自动通过审核
1500 1506 || BooleanUtil.isTrue(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核
... ...