jinlin
2023-11-24 c041523ff100a6a43ebc4411125a3e566e19f193
zt/core/src/main/java/com/zt/modules/oss/cloud/LocalStorageService.java
@@ -8,12 +8,10 @@
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;
@@ -29,7 +27,6 @@
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.Date;
/**
 * 本地上传
@@ -98,8 +95,6 @@
    }
    public void content(SysOss oss, HttpServletResponse response) throws Exception {
        Date beginDate = new Date();
        Date lastDate = beginDate;
        if (oss == null) {
            throw new IOException("文件不存在!");
        }
@@ -118,15 +113,7 @@
            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();
            // 创建缓冲区
@@ -138,9 +125,6 @@
            is.close();
            out.flush();
            out.close();
            nowDate = new Date();
            System.out.println("输出时间:" + CommonUtils.getDatePoor(nowDate, lastDate));
            System.out.println("总时间:" + CommonUtils.getDatePoor(nowDate, beginDate));
        }
    }
@@ -166,7 +150,8 @@
                        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);