コード例 #1
0
  // 上传正文
  @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();
  }
コード例 #2
0
 private void setOfficeRight(Document document, WorkflowInstance instance, WorkflowTask task) {
   StringBuilder editType = new StringBuilder("-1"); // "-1,0,1,1,0,0,1,1";//查看保留痕迹
   if (urgenFlag != null && urgenFlag) {
     editType.append(",0,1,1,0,0,1,1");
     document.setEditType(editType.toString());
     document.setPrintSetting(true);
     document.setDownloadSetting(true);
   } else if (viewFlag != null && viewFlag) {
     editType.append(",1,0,0,0,0,1,1");
     document.setEditType(editType.toString());
     document.setPrintSetting(false);
     document.setDownloadSetting(false);
   } else {
     // 是否保户文档
     if (TaskState.WAIT_TRANSACT.getIndex().equals(task.getActive())
         && workflowRightsManager.officialTextEditRight(task)) {
       editType.append(",0");
     } else {
       editType.append(",1");
     }
     // 是否显示痕迹
     if (workflowRightsManager.officialTextViewTrace(task)) {
       editType.append(",1");
     } else {
       editType.append(",0");
     }
     // 是否保留痕迹
     if (workflowRightsManager.officialTextRetainTrace(task)) {
       editType.append(",1");
     } else {
       editType.append(",0");
     }
     editType.append(",0,0,1,1");
     document.setEditType(editType.toString());
     boolean downloadSetting = workflowRightsManager.officialTextDownloadRight(task);
     boolean printSetting = workflowRightsManager.officialTextPrintRight(task);
     document.setPrintSetting(printSetting);
     document.setDownloadSetting(downloadSetting);
   }
 }
コード例 #3
0
 // 新建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";
     }
   }
 }