/** * 意见 * * @return * @throws Exception */ public String opinion() throws Exception { // workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId); // authority(workflowInstance.getProcessDefinitionId(),task.getName()); // if(view){ // opinions = // workflowInstanceManager.getOpinionsByInstanceId(workflowInstance.getProcessInstanceId(),companyId); // } if (taskId == null) { view = true; } else { task = taskService.getWorkflowTask(taskId); if (task.getActive() == 2) { edit = false; } } workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId); opinions = workflowInstanceManager.getOpinions(taskId, task.getCompanyId()); if (workflowRightsManager.mustOpinionRight(BeanUtil.turnToModelTask(task)) && (opinions == null || opinions.size() <= 0)) { must = true; } else { must = false; } companyId = ContextUtils.getCompanyId(); ApiFactory.getBussinessLogService().log("流程汇编", "意见列表", ContextUtils.getSystemId("wf")); return "opinion"; }
/** * 保存工作组添加用户 * * @return * @throws Exception */ @Action("work-group-workgroupAddUser") public String workgroupAddUser() throws Exception { if (StringUtils.isNotEmpty(ids)) { userIds = new ArrayList<Long>(); User user = userManager.getUserById(ContextUtils.getUserId()); if ("ALLCOMPANYID".equals(ids)) { // 全公司 userIds.add(0l); } else { if (roleManager.hasSystemAdminRole(user)) { for (String str : ids.split(",")) { userIds.add(Long.valueOf(str)); } } else if (roleManager.hasBranchAdminRole(user)) { userIds = ApiFactory.getAcsService().getTreeUserIds(ids); } } String addUsers = workGroupManager.workgroupAddUser(workGroupId, userIds, 0); if (StringUtils.isNotEmpty(addUsers)) ApiFactory.getBussinessLogService() .log("工作组管理", "工作组添加人员:" + addUsers, ContextUtils.getSystemId("acs")); } this.renderText("ok"); return null; }
/** 解析用户和工作组的关系 */ public static boolean parseWorkGroup(String atomicExpress, String loginName) { if (StringUtils.contains(atomicExpress, TextOperator.NET.getCode())) { String workGroupName = StringUtils.substringBetween(atomicExpress, "'", "'").trim(); return !userInWorkGroup(ContextUtils.getCompanyId(), loginName, workGroupName); } else if (StringUtils.contains(atomicExpress, TextOperator.ET.getCode())) { String workGroupName = StringUtils.substringBetween(atomicExpress, "'", "'").trim(); return userInWorkGroup(ContextUtils.getCompanyId(), loginName, workGroupName); } return false; }
/** 保存审批结果 */ public String saveOpinion() throws Exception { workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId); Opinion opi = new Opinion(); opi.setTransactor(ContextUtils.getUserName()); opi.setCreatedTime(new Date()); opi.setOpinion(opinion); opi.setWorkflowId(workflowInstance.getProcessInstanceId()); opi.setCompanyId(ContextUtils.getCompanyId()); opi.setTaskId(taskId); workflowInstanceManager.saveOpinion(opi); ApiFactory.getBussinessLogService().log("流程汇编", "保存意见", ContextUtils.getSystemId("wf")); return opinion(); }
@Override public String save() throws Exception { workGroupManager.saveWorkGroup(workGroup); addActionMessage("保存工作组成功"); ApiFactory.getBussinessLogService().log("工作组管理", "保存工作组信息", ContextUtils.getSystemId("acs")); return RELOAD; }
/** * 批量环节跳转/选择环节 * * @return * @throws Exception */ @Action("task-volumeBackView") public String volumeBackView() throws Exception { String[] str = instanceIds.split(","); workflowIds = ""; for (String s : str) { workflowInstance = workflowInstanceManager.getWorkflowInstance(Long.valueOf(s)); if (workflowInstance != null) wfdId = workflowInstance.getWorkflowDefinitionId(); workflowId = workflowInstance.getProcessInstanceId(); boolean isForkTask = taskService.isForkTask(workflowId); if (!isForkTask) { // 当前任务是分支汇聚任务时不让跳转 List<String> temp = taskService.getTaskNames(workflowId); if (temp != null && temp.size() > 0) { if (StringUtils.isNotEmpty(workflowIds)) { workflowIds += ","; } canBackTo = temp; workflowIds += workflowId; } } else { break; } } if (canBackTo == null) { canBackTo = new ArrayList<String>(); } ApiFactory.getBussinessLogService().log("流程监控", "批量环节跳转选择环节页面", ContextUtils.getSystemId("wf")); return SUCCESS; }
public String getTrustorSubCompanyName() { User user = ApiFactory.getAcsService().getUserById(trustorId); if (user != null) { return user.getSubCompanyName(); } return ContextUtils.getCompanyName(); }
/** * 环节跳转功能 * * @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; }
/** * 流程监控/保存增加的办理人 * * @return * @throws Exception */ public String addTransactorSave() throws Exception { taskService.addTransactor(workflowId, transactors); ApiFactory.getBussinessLogService().log("流程监控", "增加办理人", ContextUtils.getSystemId("wf")); this.addSuccessMessage("办理人已增加"); return addTransactor(); }
/** 提交表单 */ public String submit() throws Exception { log.debug("*** submit 方法开始"); log.debug( new StringBuilder("*** Received parameter:[") .append("taskId:") .append(taskId) .append("]") .toString()); task = taskService.getWorkflowTask(taskId); String to = ""; CompleteTaskTipType result = workflowInstanceManager.submitForm(task); 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: canChoiceTaches = result.getCanChoiceTaches(); to = choiceTache(); break; } ApiFactory.getBussinessLogService().log("工作流管理", "提交表单", ContextUtils.getSystemId("wf")); return to; }
public String saveChoice() throws Exception { CompleteTaskTipType completeTaskTipType = taskService.completeTacheChoice(taskId, transitionName); this.addSuccessMessage(completeTaskTipType.getContent()); ApiFactory.getBussinessLogService().log("工作流管理", "完成选择环节", ContextUtils.getSystemId("wf")); return input(); }
private String preView(String operate) { log.debug("*** preView 方法开始"); log.debug( new StringBuilder("*** Received parameter:[") .append("task:") .append(task) .append("]") .toString()); workflowInstance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId()); workflowId = task.getProcessInstanceId(); StringBuilder builder = new StringBuilder(); builder .append("<input type=\"hidden\" name=\"dataId\" value=\"") .append(workflowInstance.getDataId()) .append("\"/>"); FormView form = formViewManager.getFormView(workflowInstance.getFormId()); formHtml = workflowInstanceManager.setValueForHtml(workflowInstance.getDataId(), form, form.getHtml()); formHtml = builder.toString() + formHtml; if (SAVE.equals(operate)) { formHtml = workflowInstanceManager.getFormHtml( workflowInstance, formHtml, workflowInstance.getDataId(), true, false); fieldPermission = ApiFactory.getFormService().getFieldPermission(task.getId()); } else { formHtml = workflowInstanceManager.getFormHtml( workflowInstance, formHtml, workflowInstance.getDataId(), false, false); fieldPermission = workflowRightsManager.getFieldPermission(false); } ApiFactory.getBussinessLogService().log("工作流管理", "查看已完成任务", ContextUtils.getSystemId("wf")); log.debug("*** preView 方法结束"); return "view"; }
/** * 批量环节跳转功能 * * @return * @throws Exception */ @Action("task-volumeBack") public String volumeBack() throws Exception { String msg = "任务跳转成功"; try { CompleteTaskTipType result = null; String[] wfids = workflowIds.split(","); result = taskService.taskJumps(wfids, backto, transactors, "volumeBack"); switch (result) { case OK: msg = "OK"; break; case RETURN_URL: msg = "RETURN_URL"; break; case MESSAGE: msg = result.getContent(); } } catch (Exception e) { PropUtils.getExceptionInfo(e); msg = "环节跳转失败"; } ApiFactory.getBussinessLogService().log("流程监控", "执行批量环节跳转", ContextUtils.getSystemId("wf")); renderText(msg); return null; }
public String delTransactorTree() throws Exception { StringBuilder tempTree = new StringBuilder(); StringBuilder tree = new StringBuilder(); tree.append("["); tree.append("{\"attr\":{") .append(JsTreeUtil1.treeAttrBefore) .append("company_company-company") .append(JsTreeUtil1.treeAttrMiddle) .append("company") .append(JsTreeUtil1.treeAttrAfter) .append("},\"state\":\"open\",\"data\":\"" + ContextUtils.getCompanyName() + "\""); // List<String[]> currentTransactors=taskService.getActivityTaskTransactors(workflowId); // List<String> currentPrincipals=taskService.getActivityTaskPrincipals(workflowId); taskList = taskService.getActivityTasks(workflowId, ContextUtils.getCompanyId()); int transactNum = taskList.size(); if (transactNum > 1) { tempTree.append(",\"children\":"); tempTree.append("["); for (WorkflowTask t : taskList) { if (StringUtils.isEmpty(t.getTrustorName())) { tempTree .append( JsTreeUtil1.generateJsTreeNodeNew( "user_" + t.getTransactorName() + "-" + t.getTransactor(), "", t.getTransactorName(), "user")) .append(","); } else { tempTree .append( JsTreeUtil1.generateJsTreeNodeNew( "user_" + t.getTransactorName() + "-" + t.getTransactor(), "", t.getTransactorName() + "(受托于" + t.getTrustorName() + ")", "user")) .append(","); } } tree.append(delComma(tempTree.toString())); tree.append("]"); } tree.append("}"); tree.append("]"); renderText(tree.toString()); return null; }
/** * 字段保存 * * @param tableColumn */ @Transactional(readOnly = false) public void saveColumn(TableColumn tableColumn, boolean canChange) { tableColumn.setCompanyId(ContextUtils.getCompanyId()); tableColumnDao.save(tableColumn); // if(!canChange && !tableColumn.getDataTable().getExistedTable()){ // jdbcDao.addTableColumn(tableColumn.getDataTable().getTableName(), tableColumn); // } }
/** * 工作组去除用户(小写字母g) * * @return * @throws Exception */ @Action("work-group-removeWorkgroupToUsers") public String removeWorkgroupToUsers() throws Exception { String removeUsers = workGroupManager.workgroupAddUser(workGroupId, userIds, 1); if (StringUtils.isNotEmpty(removeUsers)) ApiFactory.getBussinessLogService() .log("工作组管理", "工作组移除人员:" + removeUsers, ContextUtils.getSystemId("acs")); return getUserByWorkGroup(); }
public String choiceTachePop() throws Exception { if (canChoiceTaches == null) { workflowInstance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId()); canChoiceTaches = taskService.isNeedChoiceTache(task, workflowInstance).getCanChoiceTaches(); } ApiFactory.getBussinessLogService().log("工作流管理", "弹出选择环节页面", ContextUtils.getSystemId("wf")); return "choiceUrlPop"; }
public String assignTransactorPop() throws Exception { if (task.getId() == null) { this.addErrorMessage("非法的任务"); } else { candidates = taskService.getNextTasksCandidates(task); this.addErrorMessage("请选择办理人"); } ApiFactory.getBussinessLogService().log("工作流管理", "弹出指定办理人", ContextUtils.getSystemId("wf")); return "assignPop"; }
// 新建word/excel @Action("office-createOffice") public String createOffice() throws Exception { WorkflowInstance instance = null; WorkflowTask task = null; if (id == null) { task = ApiFactory.getTaskService().getTask(taskId); instance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId()); document.setTaskName(task.getName()); document.setTaskMode(task.getProcessingMode()); document.setWorkflowId(instance.getProcessInstanceId()); document.setCreator(ContextUtils.getLoginName()); document.setCreatorName(ContextUtils.getUserName()); document.setCompanyId(ContextUtils.getCompanyId()); document.setEditType("-1,0,0,0,0,0,1,1"); // 允许编辑,不显示和保留痕迹,允许批注 document.setPrintSetting(true); document.setDownloadSetting(true); if (document.getFileType().equalsIgnoreCase("pdf")) { return "office-pdf"; } else { String template = DefinitionXmlParse.getOfficialTextTemplate( instance.getProcessDefinitionId(), task.getName()); if (StringUtils.isNotEmpty(template)) document.setTemplateId(Long.valueOf(StringUtils.substringBetween(template, "[", "]"))); setOfficeRight(document, instance, task); return "office-view"; } } else { if (taskId == null) { instance = workflowInstanceManager.getWorkflowInstance(document.getWorkflowId()); task = ApiFactory.getTaskService().getTask(instance.getFirstTaskId()); } else { task = ApiFactory.getTaskService().getTask(taskId); instance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId()); } setOfficeRight(document, instance, task); if (document.getFileType().equalsIgnoreCase("pdf")) { return "office-pdf"; } else { return "office-view"; } } }
/** * 批量保存字段 * * @param dataTable */ @Transactional(readOnly = false) public void saveTableColumns(DataTable dataTable) { List<Object> list = JsonParser.getFormTableDatas(TableColumn.class); for (Object obj : list) { TableColumn column = (TableColumn) obj; column.setCompanyId(ContextUtils.getCompanyId()); column.setDataTableId(dataTable.getId()); tableColumnDao.save(column); } }
/** * 流程监控/保存更改的办理人 * * @return * @throws Exception */ public String changeTransactorSave() throws Exception { taskService.changeTransactor(taskId, transactor); task = taskService.getWorkflowTask(taskId); workflowId = task.getProcessInstanceId(); workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId); // 更改办理人业务补偿 taskService.changeTransactorSet(workflowInstance, transactor, task.getId()); ApiFactory.getBussinessLogService().log("流程监控", "更改办理人", ContextUtils.getSystemId("wf")); this.addSuccessMessage("办理人已更改"); return changeTransactor(); }
/** * 完成交办 * * @return * @throws Exception */ public String assignTo() throws Exception { task = taskService.getWorkflowTask(taskId); newTransactor = transactors.toString().replace(" ", "").replace("[", "").replace("]", ""); taskService.completeWorkflowTask( task, TaskProcessingResult.ASSIGN, TaskSetting.getTaskSettingInstance().setAssignmentTransactors(newTransactor)); ApiFactory.getBussinessLogService().log("工作流管理", "完成交办任务", ContextUtils.getSystemId("wf")); this.addSuccessMessage("任务交办成功"); return input(); }
/** * 完成分发 * * @return * @throws Exception */ public String distribute() throws Exception { CompleteTaskTipType completeTaskTipType = taskService.completeDistributeTask(taskId, transactors); if (CompleteTaskTipType.RETURN_URL == completeTaskTipType) { return assignTransactor(); } else { this.addSuccessMessage(completeTaskTipType.getContent()); task = taskService.getWorkflowTask(taskId); ApiFactory.getBussinessLogService().log("工作流管理", "完成分发任务", ContextUtils.getSystemId("wf")); return input(); } }
/** 流程监控 更改办理人 */ public String changeTransactor() throws Exception { if (instanceId != null) workflowInstance = workflowInstanceManager.getWorkflowInstance(instanceId); else workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId); taskList = taskService.getActivityTasks( workflowInstance.getProcessInstanceId(), ContextUtils.getCompanyId()); // 判断当前环节是否是子流程 hasActivitySubProcess = taskService.getActivetySubProcess(workflowInstance.getProcessInstanceId()); return "changeTransactor"; }
/** * 环节跳转/选择环节 * * @return * @throws Exception */ public String backView() throws Exception { workflowInstance = workflowInstanceManager.getWorkflowInstance(instanceId); if (workflowInstance != null) wfdId = workflowInstance.getWorkflowDefinitionId(); workflowId = workflowInstance.getProcessInstanceId(); boolean isForkTask = taskService.isForkTask(workflowId); if (!isForkTask) { // 当前任务是分支汇聚任务时不让跳转 canBackTo = taskService.getTaskNames(workflowId); } else { canBackTo = new ArrayList<String>(); } ApiFactory.getBussinessLogService().log("流程监控", "环节跳转选择环节页面", ContextUtils.getSystemId("wf")); return "goback"; }
/** 保存新建工作组信息 */ @Action("work-group-saveWorkGroup") public String saveWorkGroup() throws Exception { boolean logSign = true; // 该字段只是为了标识日志信息:true表示新建工作组、false表示修改工作组 if (id == null) { Company company = companyManager.getCompany(companyId); workGroup.setCompany(company); workGroupManager.saveWorkGroup(workGroup); } else { workGroupManager.saveWorkGroup(workGroup); logSign = false; } if (logSign) { ApiFactory.getBussinessLogService() .log("工作组管理", "新建工作组:" + workGroup.getName(), ContextUtils.getSystemId("acs")); } else { ApiFactory.getBussinessLogService() .log("工作组管理", "修改工作组:" + workGroup.getName(), ContextUtils.getSystemId("acs")); } addSuccessMessage("保存成功"); return null; }
// 移交任务 @Action("transfer-task-tree") public String transferTaskTree() throws Exception { List<ZTreeNode> treeNodes = new ArrayList<ZTreeNode>(); String name = getText("workflow.doing") + "(" + taskService.getTransferTaskNum(ContextUtils.getUserId(), false) + ")"; ZTreeNode root = new ZTreeNode("TRANSFER_ING", "0", name, "false", "false", "", "", "folder", ""); treeNodes.add(root); name = getText("workflow.complete") + "(" + taskService.getTransferTaskNum(ContextUtils.getUserId(), true) + ")"; root = new ZTreeNode("TRANSFER_END", "0", name, "false", "false", "", "", "folder", ""); treeNodes.add(root); renderText(JsonParser.object2Json(treeNodes)); return null; }
/** * 判断用户是不是在部门里,如果在返回ture;否则,返回false。 * * @param companyId * @param loginName * @param departmentName * @return 用户在部门里,返回ture;否则,返回false。 */ public static boolean userInDepartment(Long companyId, String loginName, String departmentName) { if (ContextUtils.getCompanyId() == null) { ThreadParameters parameters = new ThreadParameters(companyId); ParameterUtils.setParameters(parameters); } List<Department> departments = ApiFactory.getAcsService().getDepartments(loginName); for (Department department : departments) { if (department.getName().equals(departmentName)) { return true; } } return false; }
/** * 判断用户是不是拥有某权限,如果有返回ture;否则,返回false。 * * @param companyId * @param loginName * @param departmentName * @return 用户拥有某权限,返回ture;否则,返回false。 */ public static boolean userHaveRole(Long companyId, String loginName, String roleName) { // 获得子系统的id集合 BusinessSystemManager businessSystemManager = (BusinessSystemManager) ContextUtils.getBean("businessSystemManager"); List<Long> subSystemIds = businessSystemManager.getSystemIdsByParentCode(ContextUtils.getSystemCode()); if (ContextUtils.getCompanyId() == null) { ThreadParameters parameters = new ThreadParameters(companyId); ParameterUtils.setParameters(parameters); } Set<Role> roles = ApiFactory.getAcsService().getRolesByUser(loginName); for (Role role : roles) { if (role.getName().equals(roleName)) { boolean result = validateRole(role, subSystemIds); if (result) { return result; } else { continue; } } } return false; }
/** 处理任务 */ @Override public String input() throws Exception { log.debug("*** input 处理任务方法开始"); log.debug( new StringBuilder("*** Received parameter:[") .append("task:") .append(task) .append("]") .toString()); taskService.updateTaskIsRead(task); workflowId = task.getProcessInstanceId(); workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId); opinions = workflowInstanceManager.getOpinions(taskId, task.getCompanyId()); if (workflowRightsManager.mustOpinionRight(BeanUtil.turnToModelTask(task)) && (opinions == null || opinions.size() <= 0)) { must = true; } StringBuilder builder = new StringBuilder(); builder .append("<input type=\"hidden\" name=\"dataId\" value=\"") .append(workflowInstance.getDataId()) .append("\"/>"); formHtml = workflowInstanceManager.getHtml( workflowInstance.getProcessDefinitionId(), workflowInstance.getFormId(), workflowInstance.getDataId(), task.getName()); formHtml = builder.toString() + formHtml; if (TaskState.COMPLETED.getIndex().equals(task.getActive()) || TaskState.CANCELLED.getIndex().equals(task.getActive())) { // 列表控件控制 formHtml = workflowInstanceManager.getFormHtml( workflowInstance, formHtml, workflowInstance.getDataId(), false, false); fieldPermission = workflowRightsManager.getFieldPermission(false); } else if (TaskState.WAIT_CHOICE_TACHE.getIndex().equals(task.getActive())) { canChoiceTaches = taskService.isNeedChoiceTache(task, workflowInstance).getCanChoiceTaches(); return choiceTache(); } else { // 列表控件控制 formHtml = workflowInstanceManager.getFormHtml( workflowInstance, formHtml, workflowInstance.getDataId(), true, false); fieldPermission = ApiFactory.getFormService().getFieldPermission(task.getId()); } ApiFactory.getBussinessLogService().log("工作流管理", "任务办理页面", ContextUtils.getSystemId("wf")); log.debug("*** input 处理任务方法结束"); return INPUT; }