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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations