Search in sources :

Example 1 with PageResult

use of org.daijie.core.result.PageResult 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 2 with PageResult

use of org.daijie.core.result.PageResult 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 3 with PageResult

use of org.daijie.core.result.PageResult in project daijie-example by daijiejay.

the class BaseService method getProcesses.

@Override
public ModelResult<PageResult<Map<String, Object>>> getProcesses() {
    List<Map<String, Object>> rows = new ArrayList<>();
    PageResult<Map<String, Object>> datas = new PageResult<>();
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
    List<ProcessInstance> processInstances = query.list();
    processInstances.forEach(processInstance -> {
        List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).unfinished().list();
        if (!historicActivityInstances.isEmpty()) {
            historicActivityInstances.forEach(historicActivityInstance -> {
                Map<String, Object> row = new HashMap<>();
                row.put("processInstanceId", processInstance.getId());
                Task task = taskService.createTaskQuery().taskId(historicActivityInstance.getTaskId()).singleResult();
                row.put("activityName", historicActivityInstance.getActivityName());
                row.put("taskId", historicActivityInstance.getTaskId());
                row.put("createTime", task.getCreateTime());
                row.put("assignee", task.getAssignee());
                rows.add(row);
            });
        } else {
            Map<String, Object> row = new HashMap<>();
            row.put("processInstanceId", processInstance.getId());
            row.put("activityName", "流程结束");
            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) ArrayList(java.util.ArrayList) PageResult(org.daijie.core.result.PageResult) ProcessInstanceQuery(org.activiti.engine.runtime.ProcessInstanceQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HashMap(java.util.HashMap) Map(java.util.Map) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance)

Aggregations

ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Task (org.activiti.engine.task.Task)3 PageResult (org.daijie.core.result.PageResult)3 TaskQuery (org.activiti.engine.task.TaskQuery)2 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 ProcessInstanceQuery (org.activiti.engine.runtime.ProcessInstanceQuery)1