// 加载要审核的工单 public String preAudit() throws Exception { if (issue.getId() == 0) throw new OceanRuntimeException("标识不合法"); issue = issueService.getById(issue.getId()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); nowDateTime = sdf.format(new Date()); return "audit"; }
@Override // 默认销售负责人负责的工单列表 public String execute() throws Exception { List<Issue> dbIssues = new ArrayList<Issue>(); HttpSession session = request.getSession(); // 获取当前登录用户 User sessionUser = (User) session.getAttribute(LicenseWorkFlowConstants.SESSION_USER); // 获取流程定义列表 List<ProcessDefinition> pdList = issueService.getRepositoryService().createProcessDefinitionQuery().list(); // 获取流程实例列表 List<ProcessInstance> piList = issueService.getExecutionService().createProcessInstanceQuery().list(); // 获取该用户组内的任务 List<Task> taskList = issueService.getTaskService().findGroupTasks(sessionUser.getName()); // 查询库中所有的工单 dbIssues = issueService.getAllIssues(); // 获取流程寮例历史记录列表 List<HistoryProcessInstance> hplist = issueService.getHistoryService().createHistoryProcessInstanceQuery().list(); String processDefinitionId = ""; // 流程定义标识 if (pdList != null && pdList.size() > 0) { processDefinitionId = ((ProcessDefinition) (pdList.get(0))).getId(); } // 遍历系统中的工单 for (Issue issue : dbIssues) { // 设置工单的流程节点 String activeName = issueService.getActiveName(issue.getProcessInstanceId()); IssueVO issueVO = new IssueVO(); issueVO.setWorkFlowNodeName(activeName); // 遍历当前登录用户的task列表 for (Task task : taskList) { // 获取执行 Execution execution = issueService.getExecutionService().findExecutionById(task.getExecutionId()); ExecutionImpl execImpl = (ExecutionImpl) execution; // 获取执行的流程实例 ProcessInstance processInstance = execImpl.getProcessInstance(); if (issue.getProcessInstanceId().equals(processInstance.getId())) { // 显示审核链接 issueVO.setShowAudit(true); // 当前工单要审核的task issueVO.setIssueTask(task); break; } else { issueVO.setShowAudit(false); } } LicenseWorkFlowConstants.issuePOTOVOCopier.copy(issue, issueVO, null); issues.add(issueVO); } return "index"; }
// 审核 public String audit() throws Exception { TaskService taskService = issueService.getTaskService(); HttpSession session = request.getSession(); User sessionUser = (User) session.getAttribute(LicenseWorkFlowConstants.SESSION_USER); User user = userService.getById(sessionUser.getId()); Audit audit = new Audit(); // 审批意见 String groupName = ""; if (user.getGroups() != null && user.getGroups().size() > 0) { List<Group> groupList = new ArrayList<Group>(); groupList.addAll(user.getGroups()); groupName = groupList.get(0).getCnName(); } // 设置审核的部门名称 audit.setAuditDept(groupName); audit.setAuditNotion(auditNotion); // 审批意见 audit.setAuditTime(new Date()); // 审批时间 audit.setAuditUser(user); // 审批用户 String outcome = ""; // 边 if ("1".equals(result)) { outcome = "同意"; audit.setAuditResult("同意"); } else { outcome = "否决"; audit.setAuditResult("不同意"); } /** all the variables visible in the given task */ Set<String> set = taskService.getVariableNames(taskId); /** retrieves a map of variables */ Map<String, Object> variables = taskService.getVariables(taskId, set); if (issue.getId() == 0) throw new OceanRuntimeException("标识不合法"); // 获取工单 issue = issueService.getById(issue.getId()); variables.put("createUser", "admin"); // 执行任务 taskService.completeTask(taskId, outcome, variables); // 修改工单的审核信息 audit.setIssue(issue); Set<Audit> audits = issue.getAudits(); audits.add(audit); issue.setAudits(audits); issueService.saveOrUpdate(issue); // 更新到库中 return "indexAction"; }