activiti 使用业务ID查看历史批准信息

    // 查看历史的批注信息
    public String viewHisComment(){
        //获取清单ID
        Long id = workflowBean.getId();
        //1:使用请假单ID,查询请假单对象,将对象放置到栈顶,支持表单回显
        LeaveBill leaveBill = leaveBillService.findLeaveBillById(id);
        ValueContext.putValueStack(leaveBill);
        //2:使用请假单ID,查询历史的批注信息
        List<Comment> commentList = workflowService.findCommentByLeaveBillId(id);
        ValueContext.putValueContext("commentList", commentList);
        return "viewHisComment";
    }
    /**使用请假单ID,查询历史批注信息*/
    @Override
    public List<Comment> findCommentByLeaveBillId(Long id) {
        //使用请假单ID,查询请假单对象
        LeaveBill leaveBill = leaveBillDao.findLeaveBillById(id);
        //获取对象的名称
        String objectName = leaveBill.getClass().getSimpleName();
        //组织流程表中的字段中的值
        String objId = objectName+"."+id;
        
        /**1:使用历史的流程实例查询,返回历史的流程实例对象,获取流程实例ID*/
//        HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery()//对应历史的流程实例表
//                        .processInstanceBusinessKey(objId)//使用BusinessKey字段查询
//                        .singleResult();
//        //流程实例ID
//        String processInstanceId = hpi.getId();
        /**2:使用历史的流程变量查询,返回历史的流程变量的对象,获取流程实例ID*/
        HistoricVariableInstance hvi = historyService.createHistoricVariableInstanceQuery()//对应历史的流程变量表
                        .variableValueEquals("objId", objId)//使用流程变量的名称和流程变量的值查询
                        .singleResult();
        //流程实例ID
        String processInstanceId = hvi.getProcessInstanceId();
        List<Comment> list = taskService.getProcessInstanceComments(processInstanceId);
        return list;
    }

 

posted @ 2016-11-14 17:08  SKYisLimit  阅读(972)  评论(0)    收藏  举报