// 加载要审核的工单 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"; }
// 审核 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"; }