Search in sources :

Example 1 with RelicStatus

use of org.daijie.api.enums.RelicStatus 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 2 with RelicStatus

use of org.daijie.api.enums.RelicStatus 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 3 with RelicStatus

use of org.daijie.api.enums.RelicStatus in project daijie-example by daijiejay.

the class RelicService method submit.

@Override
public ModelResult<Boolean> submit(String processInstanceId, String assignee, String auditor) {
    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>();
    RelicStatus relicStatus = RelicStatus.valueOf(task.getTaskDefinitionKey());
    if (relicStatus.nextProcess(Process.THROUGH) != null) {
        variables.put(relicStatus.nextProcess(Process.THROUGH).getAssignee(), auditor);
    }
    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 4 with RelicStatus

use of org.daijie.api.enums.RelicStatus in project daijie-example by daijiejay.

the class RelicService method pay.

@Override
public ModelResult<Boolean> pay(String processInstanceId, String assignee, Integer pay, String auditor) {
    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>();
    variables.put("pay", pay);
    variables.put("repeat", "1");
    RelicStatus relicStatus = RelicStatus.valueOf(task.getTaskDefinitionKey());
    if (relicStatus.nextProcess(Process.THROUGH) != null) {
        variables.put(relicStatus.nextProcess(Process.THROUGH).getAssignee(), auditor);
    }
    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)

Aggregations

HashMap (java.util.HashMap)4 Task (org.activiti.engine.task.Task)4 RelicStatus (org.daijie.api.enums.RelicStatus)4