1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/**
* 根据业务ID完成当前用户的任务
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void completeTaskByBusId(WfTaskBo info) {
Map<String, Object> variables = info.getVariables();
Task task = taskService.createTaskQuery()
.processInstanceBusinessKey(String.valueOf(info.getBusinessKey()))
.singleResult();
if (Objects.isNull(task)) {
throw new ServiceException("任务不存在");
}
// 获取 bpmn 模型
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
if (DelegationState.PENDING.equals(task.getDelegationState())) {
if (StringUtils.isNotEmpty(info.getComment())) {
taskService.addComment(task.getId(), task.getProcessInstanceId(), FlowComment.DELEGATE.getType(), info.getComment());
}
taskService.resolveTask(task.getId());
} else {
if (StringUtils.isNotEmpty(info.getComment())) {
// 添加审批意见
taskService.addComment(task.getId(), task.getProcessInstanceId(), FlowComment.NORMAL.getType(), info.getComment());
}
taskService.setAssignee(task.getId(), TaskUtils.getUserId());
if (ObjectUtil.isNotEmpty(variables)) {
// 获取模型信息
String localScopeValue = ModelUtils.getUserTaskAttributeValue(bpmnModel, task.getTaskDefinitionKey(), ProcessConstants.PROCESS_FORM_LOCAL_SCOPE);
boolean localScope = Convert.toBool(localScopeValue, false);
taskService.complete(task.getId(), variables, localScope);
} else {
taskService.complete(task.getId());
}
}
}
|