Search in sources :

Example 6 with ProcessInstance

use of org.flowable.engine.runtime.ProcessInstance in project plumdo-work by wengwh.

the class ProcessInstanceVariableResource method deleteExecutionVariable.

@DeleteMapping(value = "/process-instances/{processInstanceId}/variables/{variableName}", name = "删除流程实例变量")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteExecutionVariable(@PathVariable String processInstanceId, @PathVariable("variableName") String variableName) {
    ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
    runtimeService.removeVariable(processInstance.getId(), variableName);
}
Also used : ProcessInstance(org.flowable.engine.runtime.ProcessInstance) HistoricProcessInstance(org.flowable.engine.history.HistoricProcessInstance) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 7 with ProcessInstance

use of org.flowable.engine.runtime.ProcessInstance in project plumdo-work by wengwh.

the class ProcessInstanceSuspendResource method suspendProcessInstance.

@PutMapping(value = "/process-instances/{processInstanceId}/suspend", name = "流程实例挂起")
@ResponseStatus(value = HttpStatus.OK)
public void suspendProcessInstance(@PathVariable String processInstanceId) {
    ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
    if (processInstance.isSuspended()) {
        exceptionFactory.throwConflict(ErrorConstant.INSTANCE_ALREADY_SUSPEND, processInstance.getId());
    }
    runtimeService.suspendProcessInstanceById(processInstance.getId());
}
Also used : ProcessInstance(org.flowable.engine.runtime.ProcessInstance) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 8 with ProcessInstance

use of org.flowable.engine.runtime.ProcessInstance in project plumdo-work by wengwh.

the class ProcessInstanceActivateResource method activateProcessInstance.

@PutMapping(value = "/process-instances/{processInstanceId}/activate", name = "流程实例激活")
@ResponseStatus(value = HttpStatus.OK)
public void activateProcessInstance(@PathVariable String processInstanceId) {
    ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
    if (!processInstance.isSuspended()) {
        exceptionFactory.throwConflict(ErrorConstant.INSTANCE_ALREADY_ACTIVE, processInstance.getId());
    }
    runtimeService.activateProcessInstanceById(processInstance.getId());
}
Also used : ProcessInstance(org.flowable.engine.runtime.ProcessInstance) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 9 with ProcessInstance

use of org.flowable.engine.runtime.ProcessInstance in project Resource by lovelifeming.

the class FlowableService method startAndComplete.

/**
 * 创建流程并完成第一个任务
 *
 * @param processKey  流程定义key(流程图ID)
 * @param businessKey 业务key
 * @param map         变量键值对
 */
public void startAndComplete(String processKey, String businessKey, HashMap<String, Object> map) {
    ProcessInstance instance = startProcessInstanceByKey(processKey, businessKey, map);
    Task task = processEngine.getTaskService().createTaskQuery().processInstanceId(instance.getId()).singleResult();
    taskService.complete(task.getId(), map);
}
Also used : Task(org.flowable.task.api.Task) ProcessInstance(org.flowable.engine.runtime.ProcessInstance) HistoricProcessInstance(org.flowable.engine.history.HistoricProcessInstance)

Example 10 with ProcessInstance

use of org.flowable.engine.runtime.ProcessInstance in project Resource by lovelifeming.

the class ApproveProcessController method success.

@ApiOperation("执行同意流程")
@PostMapping("success")
public ResultSet success(@RequestBody @Valid SuccessVO successVO, BindingResult results) {
    if (results.hasErrors())
        return ResultSet.fail(results.getFieldError().getDefaultMessage());
    Task task = service.getOneTaskByTaskId(successVO.getTaskId());
    if (task == null) {
        return ResultSet.fail("任务不存在");
    }
    HashMap<String, Object> map = new HashMap<>();
    map.put("handler", successVO.getUserId());
    map.put("userId", successVO.getNextUserId());
    map.put("approve", "yes");
    map.put("due", "no");
    if ("财务总监".equals(task.getName())) {
        Object level = service.getProcessVariable(task.getProcessInstanceId(), "level");
        map.put("level", level);
    } else if ("会计审计".equals(task.getName())) {
        Object verify = service.getProcessVariable(task.getProcessInstanceId(), "verify");
        map.put("verify", verify);
    }
    ProcessInstance instance = service.getProcessByProcessId(task.getProcessInstanceId());
    service.complete(successVO.getTaskId(), map);
    log.info("success成功执行流程,userId={},nextUserId={},processId={},taskId={},businessKey={}", successVO.getUserId(), successVO.getNextUserId(), instance.getId(), successVO.getTaskId(), instance.getBusinessKey());
    Task task1 = service.getOneTaskByProcessId(task.getProcessInstanceId());
    if (task1 == null) {
        return ResultSet.success("流程已完结");
    }
    ProcessInfo info = new ProcessInfo(task1.getId(), task1.getProcessInstanceId(), instance.getBusinessKey());
    return ResultSet.success(info);
}
Also used : Task(org.flowable.task.api.Task) HashMap(java.util.HashMap) ProcessInstance(org.flowable.engine.runtime.ProcessInstance) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ProcessInstance (org.flowable.engine.runtime.ProcessInstance)20 Task (org.flowable.task.api.Task)12 ApiOperation (io.swagger.annotations.ApiOperation)8 HashMap (java.util.HashMap)8 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)7 HistoricProcessInstance (org.flowable.engine.history.HistoricProcessInstance)5 FlowableConflictException (com.plumdo.flow.exception.FlowableConflictException)2 ProcessEngineConfiguration (org.flowable.engine.ProcessEngineConfiguration)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 PutMapping (org.springframework.web.bind.annotation.PutMapping)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 RestVariable (com.plumdo.flow.rest.variable.RestVariable)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Scanner (java.util.Scanner)1 User (org.apache.syncope.core.persistence.api.entity.user.User)1 PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)1 WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)1