(一) 开始一个请假流程
//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.