gpt4 book ai didi

java - Activiti候选小组作业实现

转载 作者:行者123 更新时间:2023-12-02 03:33:40 26 4
gpt4 key购买 nike

我正在尝试按照以下场景将任务分配给 Activiti 中的候选组:用户关闭自己的任务,任务必须前进到候选组。

在 Activiti 属性中,此任务没有受让人/候选人组。我正在用 java 代码将候选组添加到此任务中:

public void assignTaskToCandidateGroup(Long entityId) {
ProcessInstance processInstance = super.findProcessInstance(entity);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
if (task != null) {
taskService.complete(task.getId());
}

// Get next task after previos closed and add Candidate group
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.addCandidateGroup(task.getId(), "candidateGroup");
}

public List<Task> getTaskForCandidateGroup() {
return taskService.createTaskQuery().taskCandidateGroup("candidateGroup").list();
}

public void claimTaskCandidate(String taskId, User user) {
Task task = super.findTaskById(taskId);
List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("candidateGroup").list();

if (!tasks.contains(task))
throw new UnsupportedOperationException(String.format("Task with id [%s] is not intended for [%s]",
task.getId(), "candidateGroup"));

// ... check services and exception handing omitted

taskService.claim(task.getId(), user.getUsername());
}

调用 getTaskForCandidateGroup(): 时出现以下异常

"org.springframework.http.converter.HttpMessageNotWritableException",

"message": "Could not write content: lazy loading outside command context (through reference chain: java.util.ArrayList[0]->org.activiti.engine.impl.persistence.entity.TaskEntity[\"variableInstances\"]); 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.TaskEntity[\"variableInstances\"])", "path": "/teuis-api/workflow-bps06/getTasksDirectorDeputyGroup"

有人可以建议另一种解决方案来实现此任务吗?

最佳答案

问题已经解决了。

我尝试调用该服务并直接返回 List,但这是错误的原因。

@RequestMapping(value = "/getTaskForCandidateGroup")
public List<Task> getTaskForCandidateGroup() {
return getTaskForCandidateGroup();
}

新方法:

@RequestMapping(value = "/getTaskForCandidateGroup")
public List<Map<String, Object>> getTaskForCandidateGroup() {
List<Tasks> taskList = getTaskForCandidateGroup();

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;

关于java - Activiti候选小组作业实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37720297/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com