|
|
@@ -1,6 +1,7 @@
|
|
|
package com.dk.common.util;
|
|
|
|
|
|
import com.dk.common.infrastructure.config.ConfigStatic;
|
|
|
+import com.dk.common.infrastructure.util.AuthUtils;
|
|
|
import io.swagger.models.auth.In;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFFont;
|
|
|
import org.apache.poi.ss.usermodel.BorderStyle;
|
|
|
@@ -9,15 +10,14 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author : 周兴
|
|
|
@@ -26,6 +26,9 @@ import java.util.Set;
|
|
|
*/
|
|
|
public class ExcelPoiUtils {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AuthUtils authUtils;
|
|
|
+
|
|
|
/**
|
|
|
* 将 List<Map<String,Object>> 类型的数据导出为 Excel
|
|
|
*/
|
|
|
@@ -120,13 +123,16 @@ public class ExcelPoiUtils {
|
|
|
// ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
// wb.write(os);
|
|
|
// bytes = os.toByteArray();
|
|
|
- // 判断路径是否存在
|
|
|
- File dir = new File(ConfigStatic.getExcelFolder());
|
|
|
- if(!dir.exists() && !dir.isDirectory()){
|
|
|
- dir.mkdir();
|
|
|
+ // 判断路径是否存在 类型 + 年月+ 日期
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ String dirPath = ConfigStatic.getExcelFolder() + "/" + title + "/" + "/" + currentDate.getYear()
|
|
|
+ + "-" + currentDate.getMonthValue() + "/" + currentDate.getDayOfMonth();
|
|
|
+ File dir = new File(dirPath);
|
|
|
+ if (!dir.exists() && !dir.isDirectory()) {
|
|
|
+ dir.mkdirs();
|
|
|
}
|
|
|
//保存文件到服务器 ,由于不需要保存到本地,所以注释这段了
|
|
|
- String path = ConfigStatic.getExcelFolder() + filename;
|
|
|
+ String path = dirPath + "/" + filename;
|
|
|
OutputStream out = null;
|
|
|
try {
|
|
|
File file = new File(path);
|