|  |  | 
 |  |  |  | 
 |  |  | package com.zt.modules.oss.cloud; | 
 |  |  |  | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.core.toolkit.IdWorker; | 
 |  |  | import com.spire.xls.Workbook; | 
 |  |  | import com.zt.common.exception.ErrorCode; | 
 |  |  | import com.zt.common.exception.RenException; | 
 |  |  | import com.zt.common.utils.CommonUtils; | 
 |  |  | import com.zt.core.oss.encry.IOssEncryptService; | 
 |  |  | import com.zt.modules.oss.enums.CloudChannel; | 
 |  |  | import com.zt.modules.oss.model.QdSysOss; | 
 |  |  | 
 |  |  | import javax.servlet.http.HttpServletResponse; | 
 |  |  | import java.io.*; | 
 |  |  | import java.net.URLEncoder; | 
 |  |  | import java.util.Date; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 本地上传 | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void content(SysOss oss, HttpServletResponse response) throws Exception { | 
 |  |  |         Date beginDate = new Date(); | 
 |  |  |         Date lastDate = beginDate; | 
 |  |  |         if (oss == null) { | 
 |  |  |             throw new IOException("文件不存在!"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |             System.out.println(File.separator); | 
 |  |  |             System.out.println(oss.getPath()); | 
 |  |  |             // 创建文件输入流 | 
 |  |  |             Date nowDate = new Date(); | 
 |  |  |             System.out.println("准备时间:" + CommonUtils.getDatePoor(nowDate, lastDate)); | 
 |  |  |             lastDate = nowDate; | 
 |  |  |  | 
 |  |  |             InputStream is = ossEncryptService.decrypt(file); | 
 |  |  |  | 
 |  |  |             nowDate = new Date(); | 
 |  |  |             System.out.println("解密时间:" + CommonUtils.getDatePoor(nowDate, lastDate)); | 
 |  |  |             lastDate = nowDate; | 
 |  |  |             // 响应输出流 | 
 |  |  |             ServletOutputStream out = response.getOutputStream(); | 
 |  |  |             // 创建缓冲区 | 
 |  |  | 
 |  |  |             is.close(); | 
 |  |  |             out.flush(); | 
 |  |  |             out.close(); | 
 |  |  |             nowDate = new Date(); | 
 |  |  |             System.out.println("输出时间:" + CommonUtils.getDatePoor(nowDate, lastDate)); | 
 |  |  |             System.out.println("总时间:" + CommonUtils.getDatePoor(nowDate, beginDate)); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |                         workbook.saveToStream(outputStream, com.spire.xls.FileFormat.Version2013); // 指定文件格式 | 
 |  |  |                         documentBytes = outputStream.toByteArray(); | 
 |  |  |                         headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); | 
 |  |  |                     }  else if (filename.endsWith(".docx") || filename.endsWith(".xlsx")) { | 
 |  |  |                     } | 
 |  |  |                     if (filename.endsWith(".doc") || filename.endsWith(".docx") ||  filename.endsWith(".xlsx")) { | 
 |  |  |                         documentBytes = FileCopyUtils.copyToByteArray(in); | 
 |  |  |                         headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); | 
 |  |  |                         headers.setContentDispositionFormData("attachment", filename); | 
 |  |  | 
 |  |  |             is.close(); | 
 |  |  |             out.flush(); | 
 |  |  |             out.close(); | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } |