<c:choose>
<c:when test="${flag.status eq '新建'}">
<a>提交</a>
</c:when>
<c:otherwise>
审核中...
</c:otherwise>
</c:choose>
提交公文---》显示流程下的路由 用于用户提交公文交给谁审批----》提交公文(提交申请)
- /**
- *显示流程下的路由 用于用户提交公文交给谁审批
- **/
- //显示流程下的路由
- public List<String> findNextStepTransition(long processInstanceId) {
- JbpmContext context = getContext();
- List<String> transitions = new ArrayList<String>();
- ProcessInstance pe = context.getProcessInstance(processInstanceId);
- List<Transition> nextSteps = pe.getRootToken().getNode().getLeavingTransitions();
- for(Transition transition : nextSteps) {
- transitions.add(transition.getName());
- }
- return transitions;
- }
- //提交公文(提交申请)
- //提交公文
- //uname 得到当前用户的工作列表
- //dom_id 取得Doc对象 得到流程实例ID 得到流程实例
- //transitionName 路由名称
- public void applyDoc(String uname,Document doc,String transitionName) {
- String status = getStatus(uname, doc.getProcessInstanceId(), transitionName);
- doc.setStatus(status);
- update(doc);
- }
- //辅助方法 提交公文后得到对应的公文状态
- private String getStatus(String uname,long processInstanceId,String transitionName) {
- JbpmContext context = getContext();
- String status = null;
- //得到流程实例
- ProcessInstance pi = context.getProcessInstance(processInstanceId);
- //得到当前的节点
- String currentNodeName = pi.getRootToken().getNode().getName();
- //得到起始节点
- String startNodeName = pi.getProcessDefinition().getStartState().getName();
- if(currentNodeName.equals(startNodeName)) {
- //是开始节点 通过signal()来触发流程向下一步流动
- pi.getRootToken().signal(transitionName);
- } else {
- //首先找出当前用户的当前任务
- List<TaskInstance> tasks = context.getTaskMgmtSession().findTaskInstances(uname);
- for(TaskInstance task : tasks) {
- if(task.getProcessInstance().getId()==processInstanceId) {
- task.end(transitionName);
- break;
- }
- }
- }
- //将公文当前所处的节点作为状态信息返回
- status = pi.getRootToken().getNode().getName();
- //判断当前的状态是否结束
- if(pi.hasEnded()) {
- status = Document.STATUS_END;
- }
- return status;
- }
转载于:https://blog.51cto.com/12772226/878548