(一) 开始一个请假流程 //user是请假人的actorId ExecutionService es=JbpmServiceFactory.getInstance().openExecutionService(user); HashMap vs=new HashMap(); //一些参数 vs.put(Constants.REQUEST_STATUS,String.valueOf(0)); vs.put(Constants.REQUEST_RETURN_INFO,"No info!"); vs.put(Constants.USER_NAME,EncodeTransfer.toISO(user)); vs.put(Constants.REQUEST_DAYS,String.valueOf(rea.getDays())); try { //开启请假流程 es.startProcessInstance(Constants.WORK_NAME, vs); log.info("["+user+"]"+"申请假期开始!请假"+rea.getDays()+"天!"); return am.findForward("main"); } catch (ExecutionException ex) { ex.printStackTrace(); log.error("请假进程无法开始!"); return am.findForward("error"); }finally{ es.close(); } (二)当前执行任务 对于部门经理或者老板,找到要处理的请假。 String actorId = (String) req.getSession().getAttribute(Constants.USER); if(actorId.equals("wang")){ actorId="boss"; }else if(actorId.equals("bigli")){ actorId="chief"; } // get the execution service ExecutionService executionService = JbpmServiceFactory.getInstance(). openExecutionService(actorId);
// get the tasklist from jbpm for user List tasks = new ArrayList(); // add the jbpm tasks tasks.addAll(executionService.getTaskList(actorId)); // put the tasklist into the form mf.setTasks(tasks); // get the tasklist from jbpm for user List definitions = new ArrayList(); // add the jbpm definitions definitions.addAll(executionService.getLatestDefinitions()); // put the tasklist into the form mf.setRequests(definitions); // close the execution service executionService.close(); req.getSession().setAttribute("mainForm",mf); log.debug("任务: " + tasks); log.debug("当前可以执行的请求: " + definitions); (三)处理请假 String actorId = (String) reqrest.getSession().getAttribute(Constants. USER); Long tokenId=new Long(req.getParameter("tokenId")); // get the execution service ExecutionService executionService = JbpmServiceFactory.getInstance(). openExecutionService(actorId); Map hm=executionService.getVariables(tokenId);//变量 String act=req.getParameter("action");//进行转换的transition executionService.endOfState(tokenId,hm,act); executionService.close(); 
|