/** * 环节跳转功能 * * @return * @throws Exception */ public String goback() throws Exception { String msg = "任务跳转成功"; try { CompleteTaskTipType result = null; workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId); result = taskService.taskJump(workflowInstance, backto, transactors, null, false); switch (result) { case OK: msg = "OK"; break; case RETURN_URL: msg = "RETURN_URL"; break; case SINGLE_TRANSACTOR_CHOICE: User temp; for (String tran : result.getCanChoiceTransactor()) { temp = userManager.getUserByLoginName(tran); if (temp != null) canChoiceTransacators = canChoiceTransacators + tran + "," + temp.getName() + ";"; } msg = "SINGLE_TRANSACTOR_CHOICE"; break; case MESSAGE: msg = result.getContent(); } } catch (Exception e) { PropUtils.getExceptionInfo(e); msg = "环节跳转失败"; } ApiFactory.getBussinessLogService().log("流程监控", "执行环节跳转", ContextUtils.getSystemId("wf")); renderText(msg + "=" + canChoiceTransacators); return null; }
/** 流程监控 减少办理人 */ public String delTransactor() throws Exception { WorkflowInstance instance = null; if (instanceId != null) instance = workflowInstanceManager.getWorkflowInstance(instanceId); else instance = workflowInstanceManager.getWorkflowInstance(workflowId); workflowId = instance.getProcessInstanceId(); boolean isForkTask = taskService.isForkTask(workflowId); if (!isForkTask) { // 表示是分支汇聚任务时不让减少办理人 List<String[]> currentTransactors = taskService.getActivityTaskTransactors(workflowId); List<String> currentPrincipals = taskService.getActivityTaskPrincipals(workflowId); if (currentTransactors != null) { if (currentTransactors.size() == 1) { Object[] transactors = currentTransactors.get(0); transactor = (transactors[1]).toString(); } transactorNum = currentTransactors.size(); } if (currentPrincipals != null) { if (transactorNum == 0 && currentPrincipals.size() == 1) { String loginName = currentPrincipals.get(0); User user = acsUtils.getUserByLoginName(loginName); if (user != null) { transactor = user.getName(); } } transactorNum = transactorNum + currentPrincipals.size(); } } // 判断当前环节是否是子流程 hasActivitySubProcess = taskService.getActivetySubProcess(instance.getProcessInstanceId()); return "delTransactor"; }
/** 指定办理人 */ @Action(value = "taskassign") public String assignTransactor() throws Exception { String to = INPUT; if (task.getId() == null) { this.addErrorMessage("非法的任务"); } else { WorkflowInstance instance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId()); CompleteTaskTipType result = taskService.isNeedAssigningTransactor(instance, task); if (result == null) { result = taskService.isSubProcessNeedChoiceTransactor(task, instance); } switch (result) { case OK: this.addSuccessMessage(result.getContent()); to = input(); break; case MESSAGE: this.addErrorMessage(result.getContent()); to = INPUT; break; case RETURN_URL: candidates = taskService.getNextTasksCandidates(task); this.addErrorMessage("请选择办理人"); to = "assign"; break; case TACHE_CHOICE_URL: addActionMessage("请选择环节"); canChoiceTaches = result.getCanChoiceTaches(); to = choiceTache(); case SINGLE_TRANSACTOR_CHOICE: User temp; for (String tran : result.getCanChoiceTransactor()) { temp = userManager.getUserByLoginName(tran); if (temp != null) canChoiceTransactor.put(tran, temp.getName()); } moreTransactor = CompleteTaskTipType.SINGLE_TRANSACTOR_CHOICE.getContent().equals("true"); to = "singleTransactorChoice"; } } ApiFactory.getBussinessLogService().log("工作流管理", "指定办理人", ContextUtils.getSystemId("wf")); return to; }
/* * 创建spring security使用的用户 * userinfo:loginName~~companyCode */ private com.norteksoft.acs.entity.security.User createUserdetail( User user, Company company, List<GrantedAuthority> authsList, Department subCompany, String userinfo) { com.norteksoft.acs.entity.security.User userdetail = new com.norteksoft.acs.entity.security.User( user.getId(), userinfo, user.getPassword(), user.getEmail(), user.getEnabled(), !user.getAccountExpired(), true, !user.getAccountLocked(), authsList.toArray(new GrantedAuthority[authsList.size()]), company.getId(), company.getCode(), company.getName(), user.getSecretGrade()); userdetail.setLoginName(user.getLoginName()); userdetail.setHonorificTitle(user.getHonorificName()); userdetail.setTrueName(user.getName()); userdetail.setRoleCodes(user.getRoleCodes()); String theme = indexManager.getThemeByUser(user.getId(), company.getId()); if (StringUtils.isEmpty(theme)) theme = getDefaultTheme(); userdetail.setTheme(theme); String language = userCurrentLanguageManager.getUserLanguageByUserId(user.getId(), company.getId()); if (StringUtils.isEmpty(language)) language = getDefaultLanguage(); userdetail.setCurrentLanguage(language); userdetail.setSubCompanyId(user.getSubCompanyId()); userdetail.setDepartmentId(user.getMainDepartmentId()); if (subCompany != null) { userdetail.setSubCompanyCode(subCompany.getCode()); userdetail.setSubCompanyName(subCompany.getName()); userdetail.setSubCompanyShortTitle(subCompany.getShortTitle()); } return userdetail; }
/** 用户节点 */ public String getUserNodes(Long deptId) throws Exception { StringBuilder nodes = new StringBuilder(); Department dept = departmentManager.getDepartment(deptId); for (Department d : dept.getChildren()) { nodes.append(getDdeptNodes(d)).append(","); } for (DepartmentUser du : dept.getDepartmentUsers()) { if (du.isDeleted()) continue; com.norteksoft.acs.entity.organization.User user = du.getUser(); if (user.isDeleted()) continue; nodes .append( JsTreeUtils.generateJsTreeNodeDefault( "USER," + user.getId() + "," + user.getLoginName(), "", user.getName(), "")) .append(","); } JsTreeUtils.removeLastComma(nodes); return nodes.toString(); }
/** 保存任务 */ @Override public String save() throws Exception { log.debug("*** save 办理任务方法开始"); log.debug( new StringBuilder("*** Received parameter:[") .append("task:") .append(task) .append("]") .toString()); ApiFactory.getBussinessLogService().log("工作流管理", "保存任务", ContextUtils.getSystemId("wf")); // 如果为分发环节,指定被分发人 if (TaskProcessingMode.TYPE_DISTRIBUTE.toString().equals(task.getProcessingMode().toString())) { return "distribute"; } // 如果为交办环节,指定被交办人 if (task.getActive() == 0 && TaskProcessingMode.TYPE_ASSIGN.toString().equals(task.getProcessingMode().toString())) { moreTransactor = true; workflowInstanceManager.saveData(task, null); return "assignTree"; } // 如果已经办理但没有指定办理人 if (task.getActive() == 1 && task.getProcessingMode() != TaskProcessingMode.TYPE_ASSIGN) { return assignTransactor(); } String to = ""; try { CompleteTaskTipType result = taskService.completeWorkflowTaskAndSaveData( task, transact, TaskSetting.getTaskSettingInstance() .setTransitionName(transitionName) .setAssignmentTransactors(newTransactor)); switch (result) { case OK: this.addSuccessMessage(result.getContent()); to = input(); break; case MESSAGE: this.addErrorMessage(result.getContent()); to = INPUT; break; case RETURN_URL: to = assignTransactor(); break; case TACHE_CHOICE_URL: addActionMessage("请选择环节"); canChoiceTaches = result.getCanChoiceTaches(); to = choiceTache(); break; case SINGLE_TRANSACTOR_CHOICE: User temp; for (String tran : result.getCanChoiceTransactor()) { temp = userManager.getUserByLoginName(tran); if (temp != null) canChoiceTransactor.put(tran, temp.getName()); } moreTransactor = CompleteTaskTipType.SINGLE_TRANSACTOR_CHOICE.getContent().equals("true"); to = "singleTransactorChoice"; } } catch (TransactorAssignmentException e) { nullAssignmentException = "下一环节没有办理人,请指定!"; return "assignmentTree"; } catch (DecisionException de) { transitionNames = de.getTransitionNames(); messageTip = de.getMessage(); messageTip = getText(messageTip); return input(); } return to; }