Browse Source

直接返回下载地址

tags/v1.1.0
qiujinyang 2 years ago
parent
commit
00f2868e86
7 changed files with 16 additions and 10 deletions
  1. +3
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/ReportController.java
  2. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/IReportService.java
  3. +8
    -3
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java
  4. +1
    -1
      tuoheng-admin/src/main/resources/application-airport.yml
  5. +1
    -1
      tuoheng-admin/src/main/resources/application-dev.yml
  6. +1
    -1
      tuoheng-admin/src/main/resources/application-prod.yml
  7. +1
    -1
      tuoheng-admin/src/main/resources/application-test.yml

+ 3
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/ReportController.java View File

@@ -10,6 +10,7 @@ import com.tuoheng.common.common.OperationEnum;
import com.tuoheng.common.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.spring.web.json.Json;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -68,8 +69,8 @@ public class ReportController {
* @return
*/
@GetMapping(value = "{reportId}/word")
public void exportReportWord(@PathVariable("reportId") Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception{
reportService.exportReportWord(reportId, request, response);
public JsonResult<String> exportReportWord(@PathVariable("reportId") Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception{
return JsonResult.success(reportService.exportReportWord(reportId, request, response));
}

}

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/IReportService.java View File

@@ -51,5 +51,5 @@ public interface IReportService extends IBaseService<Report> {
* @param reportId 报告ID
* @return
*/
void exportReportWord(Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception;
String exportReportWord(Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception;
}

+ 8
- 3
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java View File

@@ -222,7 +222,7 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
}

@Override
public void exportReportWord(Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception {
public String exportReportWord(Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception {

ReportInfoVO reportInfoVO = detail(reportId);
//创建word
@@ -502,8 +502,11 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
wordUtils.closeDocument();
log.info("问题清单写入完成");


return "/lc/doc/"+fileName;

//清空缓存
response.reset();
/*response.reset();
// 定义浏览器响应表头,并定义下载名
String urlFileName = URLEncoder.encode("汤山林场无人机巡检报告【"+ reportInfoVO.getReportNo() + "】.doc", "UTF-8");
//String urlFileName =new String(("汤山林场无人机巡检报告【"+ reportInfoVO.getReportNo() + "】.doc").getBytes(), StandardCharsets.UTF_8);
@@ -529,7 +532,9 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
}
inputStream.close();
out.close();
out.flush();
out.flush();*/


System.out.println("结束。。。。。。");
}catch (Exception e){
log.info("异常信息:{}",e.getMessage());

+ 1
- 1
tuoheng-admin/src/main/resources/application-airport.yml View File

@@ -157,7 +157,7 @@ file:
#静态资源对外暴露的访问路径
staticAccessPath: /**
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_lc/uploads/
uploadFolder: /data/java/tuoheng_lc/tuoheng_lc_web/dist/lc/

# Shiro
shiro:

+ 1
- 1
tuoheng-admin/src/main/resources/application-dev.yml View File

@@ -156,7 +156,7 @@ file:
#静态资源对外暴露的访问路径
staticAccessPath: /**
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_lc/uploads/
uploadFolder: /data/java/tuoheng_lc/tuoheng_lc_web/dist/lc/

# Shiro
shiro:

+ 1
- 1
tuoheng-admin/src/main/resources/application-prod.yml View File

@@ -156,7 +156,7 @@ file:
#静态资源对外暴露的访问路径
staticAccessPath: /**
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_lc/uploads/
uploadFolder: /data/java/tuoheng_lc/tuoheng_lc_web/dist/lc/

# Shiro
shiro:

+ 1
- 1
tuoheng-admin/src/main/resources/application-test.yml View File

@@ -156,7 +156,7 @@ file:
#静态资源对外暴露的访问路径
staticAccessPath: /**
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_lc/uploads/
uploadFolder: /data/java/tuoheng_lc/tuoheng_lc_web/dist/lc/

# Shiro
shiro:

Loading…
Cancel
Save