|
@@ -4,7 +4,9 @@ import cn.cslg.report.common.core.base.Constants;
|
|
import cn.cslg.report.common.utils.DateUtils;
|
|
import cn.cslg.report.common.utils.DateUtils;
|
|
import cn.cslg.report.common.utils.FileUtils;
|
|
import cn.cslg.report.common.utils.FileUtils;
|
|
|
|
|
|
|
|
+import cn.cslg.report.service.OutInterfaceService;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -25,11 +27,27 @@ import java.net.URLEncoder;
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
public class DownloadController {
|
|
public class DownloadController {
|
|
private final FileUtils fileUtils;
|
|
private final FileUtils fileUtils;
|
|
|
|
+ private final OutInterfaceService outInterfaceService;
|
|
|
|
|
|
@GetMapping("downloadFile")
|
|
@GetMapping("downloadFile")
|
|
@Operation(summary = "下载文件")
|
|
@Operation(summary = "下载文件")
|
|
- public ResponseEntity<FileSystemResource> downloadSystemFile2(String url) throws IOException {
|
|
|
|
|
|
+ public ResponseEntity<FileSystemResource> downloadSystemFile2(String url, String taskId) throws IOException {
|
|
File file = new File(fileUtils.getSystemPath() + url);
|
|
File file = new File(fileUtils.getSystemPath() + url);
|
|
|
|
+ if (!file.exists()) {
|
|
|
|
+ if (taskId != null) {
|
|
|
|
+ //根据任务id,调用分析系统查询任务接口,获得任务对象
|
|
|
|
+ //String json = outInterfaceService.getTask(taskId);
|
|
|
|
+ //JSONObject jsonObject = JSONObject.parseObject(json);
|
|
|
|
+ //TaskFromPASVO task = JSONObject.parseObject(jsonObject.get("data").toString(), TaskFromPASVO.class);
|
|
|
|
+ //判断若该任务是与报告关联,则调用分析系统的下载接口(目前是为了下载Excel)
|
|
|
|
+ //if (task.getReportId() != null) {
|
|
|
|
+ String json2 = outInterfaceService.getDownLoadFile(url);
|
|
|
|
+ JSONObject jsonObject2 = JSONObject.parseObject(json2);
|
|
|
|
+ String path = jsonObject2.get("data").toString();
|
|
|
|
+ file = new File(path);
|
|
|
|
+ //}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
HttpHeaders headers = new HttpHeaders();
|
|
HttpHeaders headers = new HttpHeaders();
|
|
String fileName = DateUtils.getNowTimeFormat(DateUtils.YYYYMMDDHHMMSS) + "." + FileUtil.extName(file.getName());
|
|
String fileName = DateUtils.getNowTimeFormat(DateUtils.YYYYMMDDHHMMSS) + "." + FileUtil.extName(file.getName());
|
|
headers.add("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
|
headers.add("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|