Commit 51f29838 authored by liufan's avatar liufan

修改:移装变更导出的文件的格式,返回文件流

parent b6c35c6c
...@@ -9,6 +9,13 @@ import io.swagger.annotations.ApiOperation; ...@@ -9,6 +9,13 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.Map; import java.util.Map;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -148,8 +155,25 @@ public class JgChangeRegistrationTransferController extends BaseController { ...@@ -148,8 +155,25 @@ public class JgChangeRegistrationTransferController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/export") @GetMapping(value = "/export")
@ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证") @ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证")
public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr){ public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr) throws IOException {
jgChangeRegistrationTransferService.exportUseRegistrationCertificate(sequenceNbr); File file = jgChangeRegistrationTransferService.exportUseRegistrationCertificate(sequenceNbr);
if(ValidationUtil.isEmpty(file)){
throw new BadRequest("使用登记证导出失败,请稍后重试!");
}
FileInputStream in = new FileInputStream(file);
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("使用登记证", "UTF-8") + ".pdf");
response.setHeader("content-Type", "application/msword");
response.setCharacterEncoding("utf-8");
OutputStream out = new BufferedOutputStream(response.getOutputStream());
int b = 0;
byte[] buffer = new byte[2048];
while ((b = in.read(buffer)) != -1) {
out.write(buffer, 0, b);
}
in.close();
out.flush();
out.close();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment