package com.zcc.activiti03;
import org.activiti.engine.*;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.assertj.core.internal.bytebuddy.asm.Advice;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 流程变量的测试
*/
public class VariablesTest {
/*public static void main(String[] args) {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
//得到RepositoryService
RepositoryService repositoryService = processEngine.getRepositoryService();
//流程部署
Deployment deploy = repositoryService.createDeployment()
.addClasspathResource("diagram/my4.bpmn").name("请假流程-流程变量").deploy();
System.out.println(deploy.getId());
System.out.println(deploy.getName());
}*/
//流程实例启动,设置流程变量的值
/*public static void main(String[] args) {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
//得到RepositoryService
RuntimeService runtimeService = processEngine.getRuntimeService();
String key="myProcess4";
Map<String,Object> variables=new HashMap<>();
Leave leave=new Leave();
leave.setNum(1);
variables.put("leave",leave);
//启动流程实例
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(key, variables);
System.out.println(processInstance.getName());
System.out.println(processInstance.getId());
System.out.println(processInstance.getProcessVariables());
}*/
public static void main(String[] args) {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
TaskService taskService = processEngine.getTaskService();
//查询当前用户是否有任务
Task task = taskService.createTaskQuery().processDefinitionKey("myProcess4").taskAssignee("wangwu").singleResult();
if (task!=null){
taskService.complete(task.getId());
System.out.println("任务完成");
}
}
}