日期:2014-05-17 浏览次数:20682 次
String isSubmit=request.getParameter("isSubmit"); if(null!=isSubmit&"true".equals(isSubmit)){ String title=request.getParameter("title"); String money_count=request.getParameter("money_count"); String remark=request.getParameter("remark"); String issueperson=request.getSession().getAttribute("loginuser").toString(); JbpmContext jbpmContext=JbpmConfiguration.getInstance().createJbpmContext(); try{ //设置当前的登录用户为issueperson jbpmContext.setActorId(issueperson); ProcessDefinition pd=jbpmContext.getGraphSession().findLatestProcessDefinition("payment"); //每次都新建一个实例 ProcessInstance pi=new ProcessInstance(); pi=pd.createProcessInstance(); out.println("<script> alert("+pi.getId()+")</script>"); ContextInstance ci=pi.getContextInstance(); ci.setVariable("issueperson",issueperson); //创建任务开始节点的TaskInstance TaskInstance ti=pi.getTaskMgmtInstance().createStartTaskInstance(); //向任务实例当中写入相关变量 ti.setVariable("title",title); ti.setVariable("money_count",money_count); ti.setVariable("remark",remark); //结束任务实例,流程的Token就进入部门经理审批节点 ti.end(); }finally{ jbpmContext.close(); } out.println("<h1>报销申请提交成功</h1>"); return; }
<form action="wirte.jsp" method="post"> 报销主题:<input type="text" name="title"/><br/> 报销金额:<input type="text" name="money_count" /><br> 报销说明:<input type="text" name="remark"/><br/> <input type="hidden" name="isSubmit" value="true"/> <input type="submit" value="提交报销"/> </form>
public class ManagerAssignment implements AssignmentHandler,Constants { @Override public void assign(Assignable assignable, ExecutionContext executionContext) throws SqlOperationException { //从当前流程实例上下文当中取出当前报销人 String issueperson=executionContext.getContextInstance().getVariable(this.ISSUE_PERSON).toString(); if(issueperson.equals("user1")){ //当报销人为user1时,部门经理为manager1 assignable.setActorId("manager1"); }else{ //当报销人为其他人时,部门经理为manager2 assignable.setActorId("manager2"); } } }