| 
 | 
 | 
 package com.sunyo.wlpt.cgonms.provide.excle;
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
 import com.sunyo.wlpt.cgonms.provide.domain.ResultExitData;
 | 
| 
 | 
 | 
 import com.sunyo.wlpt.cgonms.provide.response.ResultJson;
 | 
| 
 | 
 | 
 import lombok.extern.slf4j.Slf4j;
 | 
| 
 | 
 | 
 import org.apache.poi.hssf.usermodel.*;
 | 
| 
 | 
 | 
 import org.springframework.beans.factory.annotation.Value;
 | 
| 
...
 | 
...
 | 
@@ -32,15 +33,18 @@ public class ExitExcel { | 
| 
 | 
 | 
     @Value("${path.dir}")
 | 
| 
 | 
 | 
     private String dir;
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     final SimpleDateFormat sdfShort = new SimpleDateFormat("yyyy-MM-dd");
 | 
| 
 | 
 | 
     final SimpleDateFormat sdfLong  = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     @PostMapping("/excel")
 | 
| 
 | 
 | 
     public void getExit(@RequestBody List<ResultExitData> exitInfoList, HttpServletResponse httpServletResponse) {
 | 
| 
 | 
 | 
         exportExcel(exitInfoList, httpServletResponse);
 | 
| 
 | 
 | 
     public ResultJson getExit(@RequestBody List<ResultExitData> exitInfoList, HttpServletResponse httpServletResponse) {
 | 
| 
 | 
 | 
         ResultJson result = new ResultJson();
 | 
| 
 | 
 | 
         String title = exportExcel(exitInfoList, httpServletResponse);
 | 
| 
 | 
 | 
         result.setMsg(title);
 | 
| 
 | 
 | 
         result.setCode("200");
 | 
| 
 | 
 | 
         return result;
 | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     private void exportExcel(List<ResultExitData> exitInfoList, HttpServletResponse response) {
 | 
| 
 | 
 | 
     private String exportExcel(List<ResultExitData> exitInfoList, HttpServletResponse response) {
 | 
| 
 | 
 | 
         // 设置文件名
 | 
| 
 | 
 | 
         String title = "";
 | 
| 
 | 
 | 
         try {
 | 
| 
 | 
 | 
             // 创建工作簿
 | 
| 
 | 
 | 
             HSSFWorkbook workbook = new HSSFWorkbook();
 | 
| 
...
 | 
...
 | 
@@ -156,9 +160,10 @@ public class ExitExcel { | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
             String file_name = UUID.randomUUID().toString().replaceAll("-", "");
 | 
| 
 | 
 | 
             // 设置文件名
 | 
| 
 | 
 | 
             String title = file_name + ".xls";
 | 
| 
 | 
 | 
             title = file_name + ".xls";
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
             String filePath = disc + ":" + File.separator + dir + File.separator + title;
 | 
| 
 | 
 | 
 //            String filePath = disc + ":" + File.separator + dir + File.separator + title;
 | 
| 
 | 
 | 
             String filePath = "excel/" + title;
 | 
| 
 | 
 | 
             /**
 | 
| 
 | 
 | 
              * 创建文件夹
 | 
| 
 | 
 | 
              */
 | 
| 
...
 | 
...
 | 
@@ -181,6 +186,7 @@ public class ExitExcel { | 
| 
 | 
 | 
         } catch (Exception e) {
 | 
| 
 | 
 | 
             e.printStackTrace();
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
         return title;
 | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     /**
 | 
...
 | 
...
 | 
 |