目录
private List<Task> queryMyTasks(){
String username = SecurityUtils.getUsername();
String roles = String.join(",", tokenService.getLoginUser().getRoles());
//待办
List<String> assignedTaskIds = taskService.createTaskQuery()
.taskAssignee(username)
// .taskCandidateOrAssigned(username)
.list().stream().map(TaskInfo::getId).collect(Collectors.toList());
//待签收
List<String> waitClaimTaskIdsByCandidateUser = actRuIdentityLinkMapper.queryTaskIdsByCandidateUser(username);
List<String> waitClaimTaskIdsByCandidateGroup = actRuIdentityLinkMapper.queryTaskIdsByCandidateGroup(roles);
//待签收任务合并去重
waitClaimTaskIdsByCandidateUser.removeAll(waitClaimTaskIdsByCandidateGroup);
waitClaimTaskIdsByCandidateUser.addAll(waitClaimTaskIdsByCandidateGroup);
//待办、待签收合并去重
assignedTaskIds.removeAll(waitClaimTaskIdsByCandidateUser);
assignedTaskIds.addAll(waitClaimTaskIdsByCandidateUser);
return assignedTaskIds.stream().map(taskId -> taskService.createTaskQuery().taskId(taskId).singleResult()).collect(Collectors.toList());
}
注:查询待办任务时并没有使当前用户进行任务拾取,而是等他办理审批时确定拾取人是当前用户
如果是申请用户调整申请,则允许修改实体类+审批(对于申请用户并没有审批的功能,只是判断他是否继续申请还是取消申请)。如果是继续申请,则点击同意并修改实体类;取消申请则没必要对实体类进行修改了
public AjaxResult formDataSave(@PathVariable("taskID") String taskID,
@RequestBody List<ActWorkflowFormDataDTO> formData ) throws ParseException {
return toAjax(actTaskService.formDataSave(taskID, formData));
}
public int formDataSave(String taskID, List<ActWorkflowFormDataDTO> awfs) throws ParseException {
// Task task = taskRuntime.task(taskID);
Task task = taskService.createTaskQuery().taskId(taskID).singleResult();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
Boolean hasVariables = false;//没有任何参数
HashMap<String, Object> variables = new HashMap<String, Object>();
//前端传来的字符串,拆分成每个控件
List<ActWorkflowFormData> acwfds = new ArrayList<>();
for (ActWorkflowFormDataDTO awf : awfs) {
ActWorkflowFormData actWorkflowFormData = new ActWorkflowFormData(processInstance.getBusinessKey(),awf, task);
acwfds.add(actWorkflowFormData);
//构建参数集合
if(!"f".equals(awf.getControlIsParam())) {
variables.put(awf.getControlId(), awf.getControlValue());
hasVariables = true;
}
}
if (task.getAssignee() == null) {
// taskService.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
//拾取任务
taskService.claim(task.getId(),SecurityUtils.getUsername());
}
if (hasVariables) {
//带参数完成任务
/* taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskID)
.withVariables(variables)
.build());*/
taskService.complete(taskID,variables);
} else {
/* taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskID)
.build());*/
taskService.complete(taskID);
}
//
//写入数据库 这张表是自己设计的,在查看历史任务是会用到
return actWorkflowFormDataService.insertActWorkflowFormDatas(acwfds);
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章