|
@@ -1,6 +1,8 @@
|
|
|
package com.idea.buildManage.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.io.IoUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
|
@@ -31,8 +33,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.beans.Transient;
|
|
|
-import java.io.IOException;
|
|
|
+import java.io.*;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.nio.file.Files;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -417,7 +420,24 @@ public class ParkInfoService implements BaseService<ParkInfo, ParkInfoExample> {
|
|
|
return number;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 下载楼盘导出模版
|
|
|
+ * @param response
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public void downLoadTemplate(HttpServletResponse response) throws IOException {
|
|
|
|
|
|
+ File file = new File("/home/project/settleDown/tem/楼盘导入模版.xlsx");
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String date = sdf.format(new Date());
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = URLEncoder.encode("楼盘导入模版" + date, "UTF-8");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+ OutputStream out = response.getOutputStream();
|
|
|
+ IoUtil.copy(FileUtil.getInputStream(file), out);
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -431,7 +451,6 @@ public class ParkInfoService implements BaseService<ParkInfo, ParkInfoExample> {
|
|
|
String fileName = URLEncoder.encode("失败记录" + date, "UTF-8");
|
|
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
|
|
|
-// String templateFileName = "C:\\Users\\35838\\Desktop\\楼盘导出模版.xlsx";
|
|
|
String templateFileName = "/home/project/settleDown/tem/楼盘导出模版.xlsx";
|
|
|
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
|
|
|
.registerWriteHandler(new WriteHandlerStrategy())
|
|
@@ -449,4 +468,8 @@ public class ParkInfoService implements BaseService<ParkInfo, ParkInfoExample> {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|