/** 流程监控 减少办理人 */ 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"; }
/** * 环节跳转功能 * * @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; }
/* * 获取用户权限 */ private List<GrantedAuthority> getAuthorityByUser(User user) { log.debug("*** getAuthorityByUser 开始"); List<GrantedAuthority> authsList = null; Set<Role> userRoles = standardRoleManager.getAllRolesByUser(user.getId(), user.getCompanyId()); StringBuilder roles = new StringBuilder(","); for (Role role : userRoles) { roles.append(role.getCode()).append(","); } user.setRoleCodes(roles.toString()); Set<Function> functions = standardRoleManager.getFunctionsByRoles(userRoles); if (isTenant) { // 如果用户属于租户,则只授权用户角色所具有的并且该用户所在的该租户已经购买的功能 // 查询该用户所属租户购买的所有功能 // 如果该角色的权限包含在购买的功能内,则授权该功能 // FIXME 需要判断是否是租户时的权限分配 authsList = getAuthorityFromFunctions(functions); } else { // 否则授权角色所具有的全部功能 authsList = getAuthorityFromFunctions(functions); } log.debug("*** getAuthorityByUser 结束"); authsList = DynamicAuthority.getLogAuthority(authsList, roles); return authsList; }
public void emailReminder(WorkflowTask task) { User user = userManager.getUserByLoginName(task.getTransactor()); String msg = new StringBuilder("任务:") .append(task.getTitle()) .append("已经生成") .append(((System.currentTimeMillis() - task.getCreatedTime().getTime()) / MILLI_SECOND)) .append("天了。请尽快办理!") .toString(); AsyncMailUtils.sendMail(user.getEmail(), "催办超期提醒", msg); }
public void emailInform(WorkflowTask task) { if (StringUtils.isNotEmpty(task.getReminderNoticeUser())) { Set<String> informUserEmails = new HashSet<String>(); User temp; for (String userLoginName : task.getReminderNoticeUser().split(",")) { temp = userManager.getUserByLoginName(userLoginName); if (temp != null) informUserEmails.add(temp.getEmail()); } String msg = new StringBuilder("任务:") .append(task.getTitle()) .append("的办理人") .append(task.getTransactorName()) .append("被催办次数已经超过设置上限,请您核实情况。") .toString(); AsyncMailUtils.sendMail(informUserEmails, "催办超期提醒", msg); } }
/** 指定办理人 */ @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; }
public UserDetails loadUserByUsername(String loginName) throws UsernameNotFoundException, DataAccessException { log.debug("*** Received parameter: loginName:" + loginName); if (loginName.contains( "%")) { // 表示是swing“办公助手”中访问v1/tickets过来的,有%表示用户登录名或分支编码有中文,已进行编码URLEncoder.encode(username, // "utf-8"),需要解码 try { loginName = URLDecoder.decode(loginName, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } // loginName的格式为loginName~~companyCode User user = userManager.getUserByLoginNameAndBranchCode(loginName); // try { // Map<String, String> licence = License.getLicense(); // String dateString = licence.get("end_time"); // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); // Date settingDate = df.parse(dateString); // Date date = userManager.getUserTs(user.getCompanyId()); // if(date != null && settingDate.before(date)){ // log.error("licence invalidation"); // throw new UsernameNotFoundException("licence invalidation"); // } // } catch (Exception e) { // log.error("licence invalidation"); // throw new UsernameNotFoundException("licence invalidation"); // } if (isTenant) { isCompanyValidDate(user); } Company company = companyManager.getCompany(user.getCompanyId()); Department subCompany = null; if (user.getSubCompanyId() != null) { subCompany = departmentManager.getDepartmentById(user.getSubCompanyId()); } List<GrantedAuthority> authsList = getAuthorityByUser(user); log.debug("*** loadUserByUsername 结束"); return createUserdetail(user, company, authsList, subCompany, loginName); }
/** 用户节点 */ 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(); }
public void rtxReminder(WorkflowTask task) { String msg = new StringBuilder("(") .append(new SimpleDateFormat("yyyy-MM-dd").format(new Date(System.currentTimeMillis()))) .append(")任务:") .append(task.getTitle()) .append("已经生成") .append(((System.currentTimeMillis() - task.getCreatedTime().getTime()) / MILLI_SECOND)) .append("天了。请尽快办理!") .toString(); String url = SystemUrls.getSystemUrl(StringUtils.substring(task.getUrl(), 0, task.getUrl().indexOf('/'))) + StringUtils.substring(task.getUrl(), task.getUrl().indexOf('/')); if (url.contains("?")) { url = url + task.getId(); } else { url = url + "?taskId=" + task.getId(); } User user = userManager.getUserByLoginName(task.getTransactor()); rtx.RtxMsgSender.sendNotify(task.getTransactor(), "任务办理提醒", "1", msg, url, user.getCompanyId()); }
/** 保存任务 */ @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; }
/* * 创建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; }