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