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"; }
/* * 根据条件选定办理人 * @param conditions * @param creator * @param _wf_transactor * @return */ public static Set<String> processCondition( Map<TaskTransactorCondition, String> conditions, OpenExecution execution, Map<String, String> param) { Long companyId = ContextUtils.getCompanyId(); if (companyId == null) { Object compIdStr = execution.getVariable(CommonStrings.COMPANY_ID); if (compIdStr != null) { companyId = Long.parseLong(compIdStr.toString()); } } String userCondition = conditions.get(TaskTransactorCondition.USER_CONDITION); if (userCondition == null) { throw new RuntimeException("办理人设置中,解析条件时,设置的条件不能为null"); } // 根据条件获取办理人 Set<String> candidates = new HashSet<String>(); if ("${documentCreator}".equals(userCondition)) { // 文档创建人 candidates.add(param.get(DOCUMENT_CREATOR)); } else if ("${previousTransactorAssignment}".equals(userCondition)) { // 上一环节办理人指定 candidates.add(CommonStrings.TRANSACTOR_ASSIGNMENT); } else if (userCondition.startsWith("${field[")) { // 文档字段中指定//${field[name_zn[name_en]]} int start = userCondition.lastIndexOf("["); int end = userCondition.indexOf("]"); String fieldName = userCondition.substring(start + 1, end); // 根据流程实例ID获取流程表单中指定字段的值 WorkflowInstanceManager manager = (WorkflowInstanceManager) ContextUtils.getBean("workflowInstanceManager"); String fieldValues = manager.getFieldValueInForm(param.get(PROCESS_INSTANCEID), fieldName); if (fieldValues == null) { throw new RuntimeException("办理人设置中,文档字段中指定时,该字段的值不能为null"); } for (String fieldValue : fieldValues.split(",")) { fieldValue = fieldValue.trim(); if (StringUtils.isNotEmpty(fieldValue)) { if ("ALLCOMPANYID".equals(fieldValue)) { // 所有人员(不包含无部门人员) List<String> loginNames = ApiFactory.getAcsService().getLoginNamesByCompany(companyId); candidates.addAll(loginNames); } else if ("ALLWORKGROUP".equals(fieldValue)) { // 所有工作组中的人员 List<String> loginNames = ApiFactory.getAcsService().getLoginNamesByWorkgroup(companyId); candidates.addAll(loginNames); } else { candidates.add(fieldValue); } } } } else { if (execution == null) { throw new RuntimeException("办理人设置中,解析条件时,execution不能为null"); } FormViewManager formManager = (FormViewManager) ContextUtils.getBean("formViewManager"); WorkflowInstanceManager workflowInstanceManager = (WorkflowInstanceManager) ContextUtils.getBean("workflowInstanceManager"); WorkflowInstance wi = workflowInstanceManager.getWorkflowInstance(param.get(PROCESS_INSTANCEID), companyId); if (wi == null) { throw new RuntimeException("办理人设置中,解析条件时,流程实例不能为null"); } FormView form = formManager.getFormView(wi.getFormId()); UserParseCalculator upc = new UserParseCalculator(); upc.setDataId(wi.getDataId()); upc.setFormView(form); upc.setDocumentCreator(param.get(DOCUMENT_CREATOR)); upc.setPreviousTransactor(param.get(PREVIOUS_TRANSACTOR)); upc.setCurrentTransactor(param.get(CURRENT_TRANSACTOR)); upc.setProcessAdmin(param.get(PROCESS_ADMIN)); candidates.addAll( processAdditionalCondition( conditions, upc.getUsers(userCondition, wi.getSystemId(), wi.getCompanyId()), param.get(DOCUMENT_CREATOR), execution)); } return candidates; }