/**
* @Des: 获取我的待办任务
* @Author: liut
* @Date: 2020/11/23 17:52
*/
@GetMapping("/getTasks")
public AjaxResponse getTasks() {
try {
if (GlobalConfig.Test) {
securityUtil.logInAs("bajie");
}
List<HashMap<String, Object>> listMap = new ArrayList<>();
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 100));
List<Task> list = tasks.getContent();
for (Task tk : list) {
ProcessInstance processInstance = processRuntime.processInstance(tk.getProcessInstanceId());
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("id", tk.getId());
hashMap.put("name", tk.getName());
hashMap.put("status", tk.getStatus());
hashMap.put("createdDate", tk.getCreatedDate());
if (tk.getAssignee() == null) {
hashMap.put("assignee", "待拾取任务");
} else {
hashMap.put("assignee", tk.getAssignee());
}
hashMap.put("instanceName", processInstance.getName());
listMap.add(hashMap);
}
return AjaxResponse.AjaxData(GlobalConfig.ResponseCode.SUCCESS.getCode(),
GlobalConfig.ResponseCode.SUCCESS.getDes(), listMap);
} catch (Exception e) {
return AjaxResponse.AjaxData(GlobalConfig.ResponseCode.ERROR.getCode(),
"获取我的待办任务失败", e.getMessage());
}
}
/**
* @Des: 完成待办任务
* @Author: liut
* @Date: 2020/11/24 10:26
*/
@GetMapping("/completeTask")
public AjaxResponse completeTask(@RequestParam("taskID") String taskID) {
try {
if (GlobalConfig.Test) {
securityUtil.logInAs("bajie");
}
Task task = taskRuntime.task(taskID);
if (task.getAssignee() == null) {
Task claim = taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
}
Task complete = taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId()).build());
return AjaxResponse.AjaxData(GlobalConfig.ResponseCode.SUCCESS.getCode(),
GlobalConfig.ResponseCode.SUCCESS.getDes(), null);
} catch (Exception e) {
return AjaxResponse.AjaxData(GlobalConfig.ResponseCode.ERROR.getCode(),
"办理任务失败", e.getMessage());
}
}
activity7 获取待办任务列表、完成待办任务
最新推荐文章于 2024-01-11 07:00:00 发布