|
@@ -1,6 +1,8 @@
|
|
package org.springblade.flow.datalog.controller;
|
|
package org.springblade.flow.datalog.controller;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
@@ -20,6 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.IORuntimeException;
|
|
import cn.hutool.core.io.IORuntimeException;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -34,8 +37,8 @@ import io.swagger.annotations.ApiOperation;
|
|
@Api(tags = "AA表单数据导入记录接口", value = "DataExportTasDataImportLogkLog")
|
|
@Api(tags = "AA表单数据导入记录接口", value = "DataExportTasDataImportLogkLog")
|
|
public class DataImportLogController {
|
|
public class DataImportLogController {
|
|
|
|
|
|
- @Value("${blade.file.formDir}")
|
|
|
|
- private String formDir;
|
|
|
|
|
|
+ @Value("${blade.file.uploadPath}")
|
|
|
|
+ private String uploadDir;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private DataImportLogService importLogService;
|
|
private DataImportLogService importLogService;
|
|
@@ -56,14 +59,15 @@ public class DataImportLogController {
|
|
@ApiOperation(value = "下载当时导入的Excel文件")
|
|
@ApiOperation(value = "下载当时导入的Excel文件")
|
|
public void download(Long id, HttpServletResponse response) throws IORuntimeException, IOException {
|
|
public void download(Long id, HttpServletResponse response) throws IORuntimeException, IOException {
|
|
DataImportLog dataLog = importLogService.getById(id);
|
|
DataImportLog dataLog = importLogService.getById(id);
|
|
-// File file = new File(formDir + dataLog.getFileName());
|
|
|
|
-// if (file != null && file.exists() && file.isFile()) {
|
|
|
|
-// response.setContentType("application/vnd.ms-excel");
|
|
|
|
-// response.setCharacterEncoding("utf-8");
|
|
|
|
-// String fileName = URLEncoder.encode(dataLog.getName(), "UTF-8");
|
|
|
|
-// response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
|
-// response.getOutputStream().write(FileUtil.readBytes(file));
|
|
|
|
-// response.getOutputStream().flush();
|
|
|
|
-// }
|
|
|
|
|
|
+ String filePath = uploadDir + dataLog.getFilePath().replace("uploads/", "");
|
|
|
|
+ File file = new File(filePath);
|
|
|
|
+ if (file != null && file.exists() && file.isFile()) {
|
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
|
+ String fileName = URLEncoder.encode(dataLog.getName(), "UTF-8");
|
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
|
+ response.getOutputStream().write(FileUtil.readBytes(file));
|
|
|
|
+ response.getOutputStream().flush();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|