use of com.plumdo.flow.rest.task.TaskCompleteResponse in project plumdo-work by wengwh.
the class RestResponseFactory method createTaskCompleteResponse.
public TaskCompleteResponse createTaskCompleteResponse(Task taskInstance, List<IdentityLink> identityLinks) {
TaskCompleteResponse result = new TaskCompleteResponse();
createTaskResponse(result, taskInstance);
result.setCandidate(createTaskIdentityResponseList(identityLinks));
return result;
}
use of com.plumdo.flow.rest.task.TaskCompleteResponse in project plumdo-work by wengwh.
the class TaskCompleteResource method completeTask.
@RequestMapping(value = "/task/{taskId}/complete", method = RequestMethod.PUT, name = "任务完成")
@ResponseStatus(value = HttpStatus.OK)
@Transactional(propagation = Propagation.REQUIRED)
public List<TaskCompleteResponse> completeTask(@PathVariable("taskId") String taskId, @RequestBody(required = false) TaskCompleteRequest taskCompleteRequest) {
List<TaskCompleteResponse> responses = new ArrayList<TaskCompleteResponse>();
Task task = getTaskFromRequest(taskId);
if (task.getAssignee() == null) {
taskService.setAssignee(taskId, Authentication.getAuthenticatedUserId());
}
// 设置任务的完成人变量
// taskExtService.saveTaskAssigneeVar(taskId);
Map<String, Object> completeVariables = new HashMap<String, Object>();
// 设置流程变量
if (taskCompleteRequest != null && taskCompleteRequest.getVariables() != null) {
for (RestVariable variable : taskCompleteRequest.getVariables()) {
if (variable.getName() == null) {
throw new FlowableIllegalArgumentException("Variable name is required.");
}
completeVariables.put(variable.getName(), restResponseFactory.getVariableValue(variable));
}
}
// 设置多实例变量
if (taskCompleteRequest != null && taskCompleteRequest.getMultiKeys() != null) {
for (MultiKey multiKey : taskCompleteRequest.getMultiKeys()) {
if (multiKey.getName() == null) {
throw new FlowableIllegalArgumentException("multiKey name is required.");
}
completeVariables.put(multiKey.getName(), multiKey.getValue());
}
}
// 判断是否是协办完成还是正常流转
if (task.getDelegationState() != null && task.getDelegationState().equals(DelegationState.PENDING)) {
// taskExtService.setStartTime(taskId);
if (completeVariables.isEmpty()) {
taskService.resolveTask(taskId);
} else {
taskService.resolveTask(taskId, completeVariables);
}
} else {
if (completeVariables.isEmpty()) {
taskService.complete(taskId);
} else {
taskService.complete(taskId, completeVariables);
}
}
return responses;
}
Aggregations