// 上传正文
  @Override
  public String input() throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    MultiPartRequestWrapper wrapper = (MultiPartRequestWrapper) request;
    File filePath = wrapper.getFiles("Filedata")[0];
    String fileName = request.getParameter("Filename");
    BufferedInputStream bis = new BufferedInputStream(new FileInputStream(filePath));
    Document document = new Document();

    document.setFileSize(bis.available());
    document.setFileName(fileName);
    document.setCreatedTime(new Date());
    if (request.getParameter("taskId") != null) {
      long taskId = Long.valueOf(request.getParameter("taskId"));
      WorkflowTask task = ApiFactory.getTaskService().getTask(taskId);
      document.setTaskMode(task.getProcessingMode());
      document.setTaskName(task.getName());
      document.setWorkflowId(task.getProcessInstanceId());
      document.setCompanyId(task.getCompanyId());
      document.setCreator(task.getTransactor());
      document.setCreatorName(task.getTransactorName());
    }
    String fileType = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
    if (!("pdf").equals(fileType)) {
      fileType = "." + fileType;
    }
    document.setFileType(fileType);
    officeManager.saveDocument(document);
    DocumentFile file = new DocumentFile();
    byte[] content = null;
    try {
      content = new byte[bis.available()];
      bis.read(content);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      bis.close();
    }
    file.setFileBody(content);
    file.setDocumentId(document.getId());
    file.setCompanyId(document.getCompanyId());
    officeManager.saveDocumentFile(file);
    return "DOCUMENTID:" + document.getId();
  }
 // 新建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";
     }
   }
 }