代码
public Object addDo(@Param("..")Wf_oa_leave wfOaLeave, HttpServletRequest req) {
try {
Wf_oa_leave wf_oa_leave= wfOaLeaveService.insert(wfOaLeave);
Subject subject = SecurityUtils.getSubject();
Sys_user user = (Sys_user) subject.getPrincipal();
identityService.setAuthenticatedUserId(user.getLoginname());
Map<String, Object> variables = Maps.newHashMap();
// 启动流程
String businessKey = wf_oa_leave.getId().toString();
variables.put("type", "leave");
variables.put("busId", businessKey);
variables.put("title", wf_oa_leave.getName());//设置标题;
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("leave", businessKey, variables);//
// 更新流程实例ID
wf_oa_leave.setProcessInstanceId(processInstance.getId());
wfOaLeaveService.updateIgnoreNull(wf_oa_leave);
return Result.success("system.success");
} catch (Exception e) {
e.printStackTrace();
return Result.error("system.error");
}
}
报错
org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Unknown property used in expression: #{customTaskListener}
at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:742)
at org.activiti.engine.impl.persistence.entity.TaskEntity.setAssignee(TaskEntity.java:559)
at org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.handleAssignments(UserTaskActivityBehavior.java:241)
at org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.execute(UserTaskActivityBehavior.java:208)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:650)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:643)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:650)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:643)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:650)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:643)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
然后 看到 初始化的时候有加这个
private void initActiviti(NutConfig config) {
log.info("Activiti Init Start...");
ProcessEngineConfigurationImpl processEngineConfiguration = config.getIoc().get(null, "processEngineSpec");
// 使用系统角色及用户替换工作流的用户及用户组
List<SessionFactory> list = new ArrayList<>();
CustomGroupEntityManagerFactory customGroupManagerFactory = new CustomGroupEntityManagerFactory();
customGroupManagerFactory.setGroupEntityManager(new CustomGroupEntityManager());
CustomUserEntityManagerFactory customUserEntityManagerFactory = new CustomUserEntityManagerFactory();
customUserEntityManagerFactory.setUserEntityManager(new CustomUserEntityManager());
list.add(customGroupManagerFactory);
list.add(customUserEntityManagerFactory);
processEngineConfiguration.setCustomSessionFactories(list);
//添加任务监听
Map<Object, Object> beans = new HashMap<>();
ProxyTaskListener proxyTaskListener = new ProxyTaskListener();
List<TaskListener> taskListeners = new ArrayList<>();
TaskCategoryTaskListener t1 = new TaskCategoryTaskListener();
taskListeners.add(t1);
proxyTaskListener.setTaskListeners(taskListeners);
beans.put("customTaskListener", proxyTaskListener);//这里。。。
processEngineConfiguration.setBeans(beans);
List<BpmnParseHandler> customDefaultBpmnParseHandlers = new ArrayList<>();
ProxyUserTaskBpmnParseHandler bpmnParseHandler = new ProxyUserTaskBpmnParseHandler();
bpmnParseHandler.setUseDefaultUserTaskParser(true);
bpmnParseHandler.setTaskListenerId("customTaskListener");
customDefaultBpmnParseHandlers.add(bpmnParseHandler);
processEngineConfiguration.setCustomDefaultBpmnParseHandlers(customDefaultBpmnParseHandlers);
processEngineConfiguration.setBpmnParser(new CustomBpmnParser());
//UUID
processEngineConfiguration.setIdGenerator(new StrongUuidGenerator());
ProcessEngine processEngine = config.getIoc().get(ProcessEngine.class);
log.info("Activiti Init End::" + processEngine.getName());
}