Selaa lähdekoodia

信创审核列表 预览文件优化

tags/24080901
PoffyZhang 4 kuukautta sitten
vanhempi
commit
0a5b231660
3 muutettua tiedostoa jossa 8 lisäystä ja 5 poistoa
  1. +2
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java
  2. +4
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXchxFileHelper.java
  3. +2
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java

+ 2
- 1
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java Näytä tiedosto

@@ -23,6 +23,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.List;

/**
@@ -153,7 +154,7 @@ public class PurchaseController {

@GetMapping("/exportXcfhFile/{code}")
@ApiOperation("直接导出信创文件")
public void exportXcfhFile(@PathVariable String code,HttpServletResponse response) {
public void exportXcfhFile(@PathVariable String code,HttpServletResponse response) throws UnsupportedEncodingException {
purchaseManage.exportXcfhFile(code,response);
}



+ 4
- 3
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXchxFileHelper.java Näytä tiedosto

@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.file.Files;

/**
@@ -67,15 +68,15 @@ public class MhXchxFileHelper {
return JSONUtil.toJsonStr(retFileInfo);
}

public void exportReport(String reportFile, HttpServletResponse response){
public void exportReport(String reportFile, HttpServletResponse response) throws UnsupportedEncodingException {
if (StrUtils.isBlank(reportFile)) {
throw BizException.wrap("信创报告文件不能为空");
}

File file = mhFileClient.downloadToTmpFile(reportFile);
// 设置响应的内容类型和头信息
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=\"" + file.getName() + "\"");
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment;filename=\"" + URLEncoder.encode(file.getName(),"utf-8") + "\"");

// 使用ServletOutputStream写文件内容
try (InputStream in = Files.newInputStream(file.toPath());


+ 2
- 1
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java Näytä tiedosto

@@ -80,6 +80,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
@@ -755,7 +756,7 @@ public class PurchaseManage {
return mhXchxFileHelper.getXchxFile(code, null);
}

public void exportXcfhFile(String code,HttpServletResponse response) {
public void exportXcfhFile(String code,HttpServletResponse response) throws UnsupportedEncodingException {
mhXchxFileHelper.exportReport(code, response);
}
}

Loading…
Peruuta
Tallenna