springboot-activiti-获取活动任务列表

u4dcyp6a  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(495)

我想使用以下方法获取活动任务列表:

return processEngine.getTaskService().createTaskQuery().active().list();

但我有个错误:

10:05:37.238 [http-nio-1061-exec-18] ERROR e.e.e.o.k.f.c.s.ControllerAdvice - Could not write JSON: lazy loading outside command context; nested exception is com.fasterxml.jackson.databind.JsonMappingException: lazy loading outside command context (through reference chain: java.util.ArrayList[0]->org.activiti.engine.impl.persistence.entity.TaskEntityImpl["variableInstances"])
3j86kqsm

3j86kqsm1#

您尝试调用服务并直接返回列表,而不是使用 List<Map<String, Object>> . 请看下面的代码片段,它可以帮助您,

public List<Map<String, Object>> getTaskList() {
List<Tasks> taskList = gprocessEngine.getTaskService().createTaskQuery().active().list();

    List<Map<String, Object>> customTaskList = new ArrayList<>();
        for (Task task : taskList) {
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("taskId", task.getId());
            map.put("taskDefinitionKey", task.getTaskDefinitionKey());
            map.put("taskName", task.getName());

            customTaskList.add(map);
        }
        return customTaskList;

相关问题