|
|
@ -53,6 +53,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.text.ParseException; |
|
|
@ -141,16 +142,28 @@ public class LoanBePadsincereApplyRest implements LoanBePadsincereApplyFeign { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void downloadExcel() { |
|
|
|
List<LoanBePadsincereExportVo> list = new ArrayList<>(); |
|
|
|
//定义导出的excel名字
|
|
|
|
String excelName = "逾期垫款导入模板"; |
|
|
|
String fileNameURL = ""; |
|
|
|
try { |
|
|
|
fileNameURL = URLEncoder.encode(excelName, "UTF-8"); |
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("static/当月资方逾期模板.xls"); |
|
|
|
//获取要下载的模板名称
|
|
|
|
String fileName = "当月资方逾期模板.xls"; |
|
|
|
response.setHeader("content-type", "application/octet-stream"); |
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
// 下载文件能正常显示中文
|
|
|
|
fileName = URLEncoder.encode(fileName, "UTF-8"); |
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
|
|
|
response.setHeader("fileName", fileName); |
|
|
|
response.setHeader("Access-Control-Expose-Headers", "filename"); |
|
|
|
OutputStream out = response.getOutputStream(); |
|
|
|
byte[] b = new byte[2048]; |
|
|
|
int len; |
|
|
|
while ((len = resourceAsStream.read(b)) != -1) { |
|
|
|
out.write(b, 0, len); |
|
|
|
} |
|
|
|
out.close(); |
|
|
|
resourceAsStream.close(); |
|
|
|
} catch (Exception ex) { |
|
|
|
ex.printStackTrace(); |
|
|
|
} |
|
|
|
ExportExcelUtils.export(fileNameURL, list, LoanBePadsincereExportVo.class, response); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|