Kaynağa Gözat

驳回,结束流程

master
燕鹏 4 yıl önce
ebeveyn
işleme
eb9ceaddb7
  1. 38
      src/main/java/com/example/demo/controller/ACBackController.java

38
src/main/java/com/example/demo/controller/ACBackController.java

@ -6,6 +6,7 @@ import io.swagger.annotations.ApiOperation;
import org.activiti.api.process.runtime.ProcessRuntime;
import org.activiti.api.task.runtime.TaskRuntime;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.EndEvent;
import org.activiti.bpmn.model.FlowNode;
import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.engine.*;
@ -169,4 +170,41 @@ public class ACBackController {
e.printStackTrace();
}
}
@ApiOperation(value = "驳回任务")
@GetMapping("stop")
public void stop(String taskId) {
try {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
String processDefinitionId = task.getProcessDefinitionId();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
// 得到结束节点的信息
FlowNode stopFlowNode = bpmnModel.getMainProcess().findFlowElementsOfType(EndEvent.class).get(0);
// 取得当前节点的信息
// Execution execution = runtimeService.createExecutionQuery().executionId(task.getExecutionId()).singleResult();
// String curActivityId = execution.getActivityId();
FlowNode curFlowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey());
//记录当前节点的原活动方向
List<SequenceFlow> outgoingFlows = new ArrayList<>();
outgoingFlows.addAll(curFlowNode.getOutgoingFlows());
//清理活动方向
curFlowNode.getOutgoingFlows().clear();
//建立新方向
List<SequenceFlow> newSequenceFlowList = new ArrayList<>();
SequenceFlow newSequenceFlow = new SequenceFlow();
newSequenceFlow.setId("newSequenceFlowId");
newSequenceFlow.setSourceFlowElement(curFlowNode);
newSequenceFlow.setTargetFlowElement(stopFlowNode);
newSequenceFlowList.add(newSequenceFlow);
curFlowNode.setOutgoingFlows(newSequenceFlowList);
// 完成任务
taskService.complete(taskId);
//恢复原方向
curFlowNode.setOutgoingFlows(outgoingFlows);
System.out.println("驳回停止成功");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Yükleniyor…
İptal
Kaydet