// 新建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"; } } }