bpm:code review 指定审批人

This commit is contained in:
YunaiV 2023-11-19 18:28:00 +08:00
parent 6fd8d0095c
commit 7f75f0abfc
7 changed files with 22 additions and 9 deletions

View File

@ -36,4 +36,5 @@ public class FlowableContextHolder {
public static void setAssignee(Map<String, List<Long>> assignee) { public static void setAssignee(Map<String, List<Long>> assignee) {
ASSIGNEE.set(assignee); ASSIGNEE.set(assignee);
} }
} }

View File

@ -32,9 +32,14 @@ public class BpmProcessInstanceCreateReqDTO {
@NotEmpty(message = "业务的唯一标识") @NotEmpty(message = "业务的唯一标识")
private String businessKey; private String businessKey;
// TODO @haiassignees 复数
/** /**
* 提前指派的审批人 * 提前指派的审批人
* 例如 { taskKey1 :[1,2] }则表示 taskKey1 这个任务提前设定了 userId 1,2 的用户进行审批 *
* keytaskKey 任务编码
* value审批人的数组
* 例如 { taskKey1 :[1, 2] }则表示 taskKey1 这个任务提前设定了 userId 1,2 的用户进行审批
*/ */
private Map<String, List<Long>> assignee; private Map<String, List<Long>> assignee;
} }

View File

@ -18,7 +18,8 @@ public class BpmProcessInstanceCreateReqVO {
@Schema(description = "变量实例") @Schema(description = "变量实例")
private Map<String, Object> variables; private Map<String, Object> variables;
@Schema(description = "提前指派的审批人", requiredMode = Schema.RequiredMode.REQUIRED, example = "{taskKey1:[1,2]}") // TODO @haiassignees 复数
@Schema(description = "提前指派的审批人", requiredMode = Schema.RequiredMode.REQUIRED, example = "{taskKey1: [1, 2]}")
private Map<String, List<Long>> assignee; private Map<String, List<Long>> assignee;
} }

View File

@ -88,9 +88,11 @@ public class BpmProcessInstanceExtDO extends BaseDO {
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = JacksonTypeHandler.class)
private Map<String, Object> formVariables; private Map<String, Object> formVariables;
// TODO @haiassignees 复数
/** /**
* 提前设定好的审批人 * 提前设定好的审批人
*/ */
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = JacksonTypeHandler.class, exist = false) // TODO 芋艿临时 exist = false避免 db 报错
private Map<String, List<Long>> assignee; private Map<String, List<Long>> assignee;
} }

View File

@ -239,12 +239,14 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
@Override @Override
@DataPermission(enable = false) // 忽略数据权限不然分配会存在问题 @DataPermission(enable = false) // 忽略数据权限不然分配会存在问题
public Set<Long> calculateTaskCandidateUsers(DelegateExecution execution) { public Set<Long> calculateTaskCandidateUsers(DelegateExecution execution) {
//1. 先从提前选好的审批人中获取 // 1. 先从提前选好的审批人中获取
List<Long> assignee = processInstanceService.getAssigneeByProcessInstanceIdAndTaskDefinitionKey(execution.getProcessInstanceId(), execution.getCurrentActivityId()); List<Long> assignee = processInstanceService.getAssigneeByProcessInstanceIdAndTaskDefinitionKey(
if(CollUtil.isNotEmpty(assignee)){ execution.getProcessInstanceId(), execution.getCurrentActivityId());
if (CollUtil.isNotEmpty(assignee)) {
// TODO @hainew HashSet 即可
return convertSet(assignee, Function.identity()); return convertSet(assignee, Function.identity());
} }
//2. 通过分配规则计算审批人 // 2. 通过分配规则计算审批人
BpmTaskAssignRuleDO rule = getTaskRule(execution); BpmTaskAssignRuleDO rule = getTaskRule(execution);
return calculateTaskCandidateUsers(execution, rule); return calculateTaskCandidateUsers(execution, rule);
} }

View File

@ -145,12 +145,14 @@ public interface BpmProcessInstanceService {
*/ */
void updateProcessInstanceExtReject(String id, String reason); void updateProcessInstanceExtReject(String id, String reason);
// TODO @hai改成 getProcessInstanceAssigneesByTaskDefinitionKey(String id, String taskDefinitionKey)
/** /**
* 去流程实例扩展表取出指定流程任务提前指定的审批人 * 获取流程实例取出指定流程任务提前指定的审批人
* *
* @param processInstanceId 流程实例的编号 * @param processInstanceId 流程实例的编号
* @param taskDefinitionKey 流程任务定义的 key * @param taskDefinitionKey 流程任务定义的 key
* @return 审批人集合 * @return 审批人集合
*/ */
List<Long> getAssigneeByProcessInstanceIdAndTaskDefinitionKey(String processInstanceId, String taskDefinitionKey); List<Long> getAssigneeByProcessInstanceIdAndTaskDefinitionKey(String processInstanceId, String taskDefinitionKey);
} }