ActivityBehavior activityBehavior = activity.getActivityBehavior();
// 匹配用户任务
if (activityBehavior instanceof UserTaskActivityBehavior) {
UserTaskActivityBehavior userTaskActivityBehavior = (UserTaskActivityBehavior) activityBehavior;
TaskDefinition taskDefinition = userTaskActivityBehavior.getTaskDefinition();
Set<Expression> candidateUserIdExpressions = taskDefinition.getCandidateUserIdExpressions();
Set<Expression> candidateGroupIdExpressions = taskDefinition.getCandidateGroupIdExpressions();
if (!candidateGroupIdExpressions.isEmpty() || !candidateUserIdExpressions.isEmpty()) {
// 查询历史任务中最新的一条同名记录
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery()
.taskDefinitionKey(task.getTaskDefinitionKey()).executionId(executionId).orderByHistoricTaskInstanceEndTime().desc().list();