activiti分组用户工作流和审核流
1 特定申请的用户:
指定申请人:----#{userId} 启动申请时传递—可以传userId
Map<String,Object> map = new HashMap<String,Object>();
map.put("userId",userId);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process","1", map);//流程图id,
2 特定审核的用户—组:
指定申请人:----#{approval}
List<Task> list = taskService.createTaskQuery().processDefinitionKey("process").taskCandidateGroup(apploval).list();
具体代码实现
@GetMapping("/start")
public Object start(String userId) throws Exception {
Map<String,Object> map = new HashMap<String,Object>();
map.put("userId",userId);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process","1", map);//流程图id,业务表id
return "666";
}
@GetMapping("/submit")
public Object submit(String userId) throws Exception {
List<Task> list = taskService.createTaskQuery().processDefinitionKey("process").taskCandidateOrAssigned(userId).list();
for (Task task : list) {
TaskFormData taskFormData = formService.getTaskFormData(task.getId());
List<FormProperty> formProperties = taskFormData.getFormProperties();
Map<String, Object> variables = new HashMap();
for (FormProperty formProperty : formProperties) {
String line = null;
if (StringFormType.class.isInstance(formProperty.getType())) {
variables.put(formProperty.getId(), "y");
} else if (DateFormType.class.isInstance(formProperty.getType())) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormat.parse("2018-01-01");
variables.put(formProperty.getId(), date);
} else {
}
}
taskService.complete(task.getId(), variables);
}
return null;
}
@GetMapping("/approval")
public Object approval(String apploval) throws Exception {
List<Task> list = taskService.createTaskQuery().processDefinitionKey("process").taskCandidateGroup(apploval).list();
for (Task task : list) {
TaskFormData taskFormData = formService.getTaskFormData(task.getId());
List<FormProperty> formProperties = taskFormData.getFormProperties();
Map<String, Object> variables = new HashMap();
for (FormProperty formProperty : formProperties) {
String line = null;
if (StringFormType.class.isInstance(formProperty.getType())) {
variables.put(formProperty.getId(), "y");
} else if (DateFormType.class.isInstance(formProperty.getType())) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormat.parse("2018-01-01");
variables.put(formProperty.getId(), date);
} else {
}
}
taskService.complete(task.getId(), variables);
}
return null;
}