| | |
| | | package com.consum.base; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.io.InputStream; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | |
| | | import com.iplatform.base.util.UserUtils; |
| | | import com.iplatform.core.BeanContextAware; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.file.FileInfo; |
| | | |
| | | public abstract class BaseController extends PlatformAdapterController { |
| | | |
| | |
| | | return this.getFinSysTenantUserCache().get(String.valueOf(userInfo.getId())); |
| | | } |
| | | |
| | | protected void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) throws IOException { |
| | | OutputStream out = response.getOutputStream(); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("content-Type", "application/vnd.ms-excel"); |
| | | response.setHeader("Content-Disposition", |
| | | "attachment;filename=" + URLEncoder.encode(fileName + ".xls", "UTF-8")); |
| | | protected String downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) throws Exception { |
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| | | workbook.write(byteArrayOutputStream); |
| | | response.setHeader("Content-Length", String.valueOf(byteArrayOutputStream.size())); |
| | | out.write(byteArrayOutputStream.toByteArray()); |
| | | workbook.close(); |
| | | out.close(); |
| | | |
| | | InputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); |
| | | FileInfo fileInfo = this.uploadFileToLocal(byteArrayInputStream, fileName + ".xls", "-1", |
| | | byteArrayOutputStream.size(), 0, "-1"); |
| | | String fileUrl = fileInfo.getUrl(); |
| | | |
| | | return "/file/" + fileUrl; |
| | | } |
| | | |
| | | } |