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