|
@@ -1,5 +1,7 @@
|
|
|
package com.fdkankan.sale.util;
|
|
|
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.sale.common.FilePath;
|
|
|
import com.fdkankan.sale.entity.Customer;
|
|
|
import com.fdkankan.sale.entity.PriceList;
|
|
|
import com.fdkankan.sale.service.IPriceListService;
|
|
@@ -12,6 +14,7 @@ import com.alibaba.excel.write.metadata.fill.FillConfig;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
@@ -20,6 +23,8 @@ import java.util.*;
|
|
|
|
|
|
@Component
|
|
|
public class MyExcelUtil {
|
|
|
+ @Autowired
|
|
|
+ FYunFileServiceInterface fYunFileServiceInterface;
|
|
|
|
|
|
//根据模板导出excel
|
|
|
public void listFill(HttpServletResponse response,String excelName,Object obj,Object obj2,Integer type) {
|
|
@@ -35,16 +40,13 @@ public class MyExcelUtil {
|
|
|
// 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
|
|
|
// 填充list 的时候还要注意 模板中{.} 多了个点 表示list
|
|
|
//获取文件路径
|
|
|
- ClassPathResource resource= new ClassPathResource("file/excel/orderList.xlsx");
|
|
|
- if(type == 1 ){
|
|
|
- resource= new ClassPathResource("file/excel/repairWork.xlsx");
|
|
|
- }
|
|
|
- String templateFileName = null;
|
|
|
- try {
|
|
|
- templateFileName = resource.getFile().getPath();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ String ossPath = String.format(FilePath.oss_file_path,FilePath.common,fileName);
|
|
|
+ String localPath = FilePath.file_path + ossPath;
|
|
|
+ File file = new File(localPath);
|
|
|
+ if(!file.exists()){
|
|
|
+ fYunFileServiceInterface.downloadFile(ossPath,localPath );
|
|
|
}
|
|
|
+ String templateFileName = file.getPath();
|
|
|
|
|
|
ExcelWriter excelWriter = null;
|
|
|
try {
|