@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 WorkFlow findWorkFlowById(Integer id) throws Exception { return workFlowDao.findWorkFlowById(id); }