@Override
  @Transactional
  public int doWorkFlow(Integer workFlowId, UserVO userVO, ApproveLog approveLog) throws Exception {
    WorkFlow workFlow = workFlowDao.findWorkFlowById(workFlowId);
    List<FlowNode> flowNodes = flowNodeDao.findFlowNodeByModelId(workFlow.getModelId());
    // 得到当前节点
    FlowNode nowFlowNode = findWorkFlowById(flowNodes, workFlow.getWorkflowNode());
    // 判断有无权限
    if (!userVO.getJobsIds().contains(nowFlowNode.getJobsId())) {
      System.err.println("没有该权限");
      return -1;
    }
    // 拒绝
    if (approveLog.getStatus() == FlowConst.AGREE_FALSE) {
      // 标记工作流为开始状态
      FlowNode firstFlowNode = flowNodes.get(FlowConst.node_type_start);
      workFlow.setJobsId(firstFlowNode.getJobsId());
      workFlow.setStatus(FlowConst.START);
      workFlow.setWorkflowNode(firstFlowNode.getId());

    } else if (approveLog.getStatus() == FlowConst.AGREE_TRUE) {
      // 寻找下一个节点
      FlowNode nextFlowNode = findWorkFlowBySort(flowNodes, nowFlowNode.getNextSort());
      changeworkFlow(nextFlowNode, workFlow, flowNodes);
    }
    int n = workFlowDao.updateWorkFlow(workFlow);
    approveLog.setUserCode(userVO.getUserCode());
    approveLog.setUserName(userVO.getUserName());
    approveLog.setFlowNode(nowFlowNode.getId());
    approveLog.setWorkFlowId(workFlowId);
    approveLogDao.insertApproveLog(approveLog);
    return n;
  }
 @Override
 public void insertWorkFlow(WorkFlow workFlow, UserVO userVO) throws Exception {
   if (userVO.getJobsIds() == null) {
     FlowNode firstNode = flowNodeDao.findFirstFlowNodeById(workFlow.getModelId());
     workFlow.setJobsId(firstNode.getJobsId());
     workFlow.setWorkflowNode(firstNode.getId());
     workFlow.setStatus(0);
   } else {
     List<FlowNode> flowNodes = flowNodeDao.findFlowNodeByModelId(workFlow.getModelId());
     // 得到当前节点
     FlowNode nowFlowNode = findWorkFlowById(flowNodes, workFlow.getWorkflowNode());
     FlowNode nextFlowNode = findWorkFlowBySort(flowNodes, nowFlowNode.getNextSort());
     changeworkFlow(nextFlowNode, workFlow, flowNodes);
   }
   workFlowDao.insertWorkFlow(workFlow);
 }
 @Override
 public int findUserWorkFlowVOCountByUserCode(String userCode) throws Exception {
   return workFlowDao.findUserWorkFlowVOCountByUserCode(userCode);
 }
 @Override
 public List<WorkFlowVO> findUserWorkFlowVOByUserCode(String userCode) throws Exception {
   return workFlowDao.findUserWorkFlowVOByUserCode(userCode);
 }
 @Override
 public WorkFlow findWorkFlowById(Integer id) throws Exception {
   return workFlowDao.findWorkFlowById(id);
 }