thank you for your bosses to reassure
0 Answer
thank you for your bosses to reassure
if it helps Thank you also please take
Another problem is that my process is not necessarily completed, it may be unfinished to reach the current user, and then the current user to someone else
This answer quotes ChatGPT
To query the number of tasks transferred from Activiti, you can do the following:
First gets the ID of the current user, which can be done with the following code:
String userId = "current_user_id";
Then create a task query object using the createTaskQuery() method in TaskService, which can be implemented using the following code:
TaskService taskService = processEngine.getTaskService();
TaskQuery taskQuery = taskService.createTaskQuery();
Then set the search conditions. Set the task leader to the current user, set the status to Completed, and set the original task leader not to the current user. This can be implemented using the following code:
List tasks = taskQuery.taskAssignee(userId)
.taskCompleted()
.taskVariableValueNotEquals("originalAssignee", userId)
.list();
the above code USES taskVariableValueNotEquals() method to eliminate the current user is responsible for the task of original, because you are looking for has been passed on to other tasks.
Finally, the tasks.size() method can be used to get the number of qualified tasks, which is the number of tasks transferred out. This can be implemented using the following code:
int transferredTasks = tasks.size();
This way, you can use Activiti's API to query the number of tasks transferred. Please note that the above code only works with Activiti 7 and later. If you are using an older version of Activiti, you may need to use a different API.
String assignee = "转交人的用户名";
TaskService taskService = processEngine.getTaskService();
List tasks = taskService.createTaskQuery().taskAssignee(assignee).list();
int transferredCount = 0;
for (Task task : tasks) {
DelegationState state = task.getDelegationState();
if (state != null && state.equals(DelegationState.PENDING)) {
transferredCount++;
}
}
System.out.println("转交出去的任务个数: " + transferredCount);
This code firstly looks up all the tasks assigned by the user via the taskAssignee method, then iterates through the task list and obtains the delegate status of the task via the getDelegationState method. If the delegate status is PENDING, it indicates that the task is transferred. Count the number of tasks transferred.
thank you, just send it with the front of the current user name
这家伙很懒,什么都没留下...