Search in sources :

Example 96 with Task

use of org.activiti.engine.task.Task in project daijie-example by daijiejay.

the class BaseService method getProcessById.

@Override
public ModelResult<PageResult<Map<String, Object>>> getProcessById(Integer id) {
    List<Map<String, Object>> rows = new ArrayList<>();
    PageResult<Map<String, Object>> datas = new PageResult<>();
    TaskQuery query = taskService.createTaskQuery().processInstanceId(id.toString());
    List<Task> tasks = query.list();
    tasks.forEach(task -> {
        Map<String, Object> row = new HashMap<>();
        row.put("taskId", task.getId());
        row.put("taskName", task.getName());
        row.put("assignee", task.getAssignee());
        row.put("category", task.getCategory());
        row.put("createTime", task.getCreateTime());
        row.put("delegationState", task.getDelegationState());
        row.put("description", task.getDescription());
        row.put("dueDate", task.getDueDate());
        row.put("executionId", task.getExecutionId());
        row.put("formKey", task.getFormKey());
        row.put("owner", task.getOwner());
        row.put("parentTaskId", task.getParentTaskId());
        row.put("priority", task.getPriority());
        row.put("processDefinitionId", task.getProcessDefinitionId());
        row.put("processInstanceId", task.getProcessInstanceId());
        row.put("taskDefinitionKey", task.getTaskDefinitionKey());
        rows.add(row);
    });
    datas.setTotal(query.count());
    datas.setRows(rows);
    return Result.build(datas);
}
Also used : Task(org.activiti.engine.task.Task) HashMap(java.util.HashMap) TaskQuery(org.activiti.engine.task.TaskQuery) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) PageResult(org.daijie.core.result.PageResult)

Example 97 with Task

use of org.activiti.engine.task.Task in project daijie-example by daijiejay.

the class BaseService method getProcessByOperator.

@Override
public ModelResult<PageResult<Map<String, Object>>> getProcessByOperator(String assignee) {
    List<Map<String, Object>> rows = new ArrayList<>();
    PageResult<Map<String, Object>> datas = new PageResult<>();
    TaskQuery query = taskService.createTaskQuery().taskAssignee(assignee);
    List<Task> tasks = query.list();
    tasks.forEach(task -> {
        Map<String, Object> taskVariables = taskService.getVariables(task.getId());
        Map<String, Object> row = new HashMap<>();
        row.put("taskId", task.getId());
        row.put("taskName", task.getName());
        row.put("assignee", task.getAssignee());
        row.put("category", task.getCategory());
        row.put("createTime", task.getCreateTime());
        row.put("delegationState", task.getDelegationState());
        row.put("description", task.getDescription());
        row.put("dueDate", task.getDueDate());
        row.put("executionId", task.getExecutionId());
        row.put("formKey", task.getFormKey());
        row.put("owner", task.getOwner());
        row.put("parentTaskId", task.getParentTaskId());
        row.put("priority", task.getPriority());
        row.put("processDefinitionId", task.getProcessDefinitionId());
        row.put("processInstanceId", task.getProcessInstanceId());
        row.put("taskDefinitionKey", task.getTaskDefinitionKey());
        row.put("checkUserId", taskVariables.get("checkUserId"));
        rows.add(row);
    });
    datas.setTotal(query.count());
    datas.setRows(rows);
    return Result.build(datas);
}
Also used : Task(org.activiti.engine.task.Task) HashMap(java.util.HashMap) TaskQuery(org.activiti.engine.task.TaskQuery) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) PageResult(org.daijie.core.result.PageResult)

Example 98 with Task

use of org.activiti.engine.task.Task in project daijie-example by daijiejay.

the class RelicService method review.

@Override
public ModelResult<Boolean> review(String processInstanceId, String assignee, Boolean vote, String customerService) {
    Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).taskAssignee(assignee).singleResult();
    if (task == null) {
        return Result.build("没有需要处理的订单!", ApiResult.ERROR);
    }
    Map<String, Object> variables = new HashMap<String, Object>();
    Object obj = runtimeService.getVariable(task.getExecutionId(), "reviewVotes");
    Integer votes = obj == null ? 0 : (Integer) obj;
    if (vote) {
        variables.put("reviewVotes", votes + 1);
    }
    runtimeService.setVariables(task.getExecutionId(), variables);
    variables.put(assignee, vote);
    Integer nrOfCompletedInstances = (Integer) runtimeService.getVariable(task.getExecutionId(), "nrOfCompletedInstances");
    if (nrOfCompletedInstances >= 2) {
        RelicStatus relicStatus = RelicStatus.valueOf(task.getTaskDefinitionKey());
        if (relicStatus.nextProcess(Process.THROUGH) != null) {
            variables.put(relicStatus.nextProcess(Process.THROUGH).getAssignee(), customerService);
        }
    }
    taskService.complete(task.getId(), variables);
    return Result.build(true);
}
Also used : Task(org.activiti.engine.task.Task) HashMap(java.util.HashMap) RelicStatus(org.daijie.api.enums.RelicStatus)

Example 99 with Task

use of org.activiti.engine.task.Task in project daijie-example by daijiejay.

the class RelicService method lastTrail.

@Override
public ModelResult<Boolean> lastTrail(String processInstanceId, String assignee, Boolean vote, String operator) {
    Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).taskAssignee(assignee).singleResult();
    if (task == null) {
        return Result.build("没有需要处理的订单!", ApiResult.ERROR);
    }
    Map<String, Object> variables = new HashMap<String, Object>();
    Object obj = runtimeService.getVariable(task.getExecutionId(), "lastTrailVotes");
    Integer votes = obj == null ? 0 : (Integer) obj;
    if (vote) {
        variables.put("lastTrailVotes", votes + 1);
    }
    runtimeService.setVariables(task.getExecutionId(), variables);
    variables.put(assignee, vote);
    RelicStatus relicStatus = RelicStatus.valueOf(task.getTaskDefinitionKey());
    if (relicStatus.nextProcess(Process.THROUGH) != null) {
        variables.put(relicStatus.nextProcess(Process.THROUGH).getAssignee(), operator);
    }
    taskService.complete(task.getId(), variables);
    return Result.build(true);
}
Also used : Task(org.activiti.engine.task.Task) HashMap(java.util.HashMap) RelicStatus(org.daijie.api.enums.RelicStatus)

Example 100 with Task

use of org.activiti.engine.task.Task in project daijie-example by daijiejay.

the class RelicService method record.

@Override
public ModelResult<Boolean> record(String processInstanceId, String assignee) {
    Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).taskAssignee(assignee).singleResult();
    if (task == null) {
        return Result.build("没有需要处理的订单!", ApiResult.ERROR);
    }
    taskService.complete(task.getId());
    return Result.build(true);
}
Also used : Task(org.activiti.engine.task.Task)

Aggregations

Task (org.activiti.engine.task.Task)955 Deployment (org.activiti.engine.test.Deployment)548 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)502 HashMap (java.util.HashMap)197 Test (org.junit.Test)123 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)109 ArrayList (java.util.ArrayList)74 Date (java.util.Date)65 Execution (org.activiti.engine.runtime.Execution)59 DelegateTask (org.activiti.engine.delegate.DelegateTask)54 TaskQuery (org.activiti.engine.task.TaskQuery)54 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)51 Job (org.activiti.engine.runtime.Job)49 Calendar (java.util.Calendar)44 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)44 RequestContext (org.alfresco.rest.api.tests.client.RequestContext)44 JsonNode (com.fasterxml.jackson.databind.JsonNode)41 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)41 JSONObject (org.json.simple.JSONObject)40 TasksClient (org.alfresco.rest.workflow.api.tests.WorkflowApiClient.TasksClient)38