http://blog.csdn.net/zwk626542417/article/details/46602419
@RequestMapping(value = "deleteProcessDefinitionByKey")
@ResponseBody
public ResultBean deleteProcessDefinitionByKey(String myPrivateKey, String processDefinitionKey){
ResultBean br = new ResultBean(); if(myPrivateKey.equals("libra@yuanchuagnyun")){
// 先使用流程定义的key查询流程定义,查询出所有的版本
List<ProcessDefinition> list = processEngine.getRepositoryService()
.createProcessDefinitionQuery()
.processDefinitionKey(processDefinitionKey)// 使用流程定义的key查询
.list(); // 遍历,获取每个流程定义的部署ID
if (list != null && list.size() > 0) {
for (ProcessDefinition pd : list) {
// 获取部署ID
String deploymentId = pd.getDeploymentId();
// /*
// * 不带级联的删除, 只能删除没有启动的流程,如果流程启动,就会抛出异常
// */
// processEngine.getRepositoryService().deleteDeployment(deploymentId); /**
* 级联删除 不管流程是否启动,都可以删除
*/
processEngine.getRepositoryService().deleteDeployment(deploymentId, true);
}
} br.setStatus(1);
br.setData("删除成功");
}else{
br.setStatus(0);
br.setData("密钥不对");
} return br;
}