|
@@ -73,6 +73,7 @@ import org.springblade.resource.vo.NewBladeFile;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
+import org.springframework.http.ContentDisposition;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
@@ -94,6 +95,7 @@ import java.io.*;
|
|
|
import java.net.URL;
|
|
|
import java.net.URLConnection;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.StandardCopyOption;
|
|
@@ -2034,6 +2036,48 @@ public class ExcelTabController extends BladeController {
|
|
|
return pdfUrl;
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/downBussPdf")
|
|
|
+ @ApiOperationSupport(order = 32)
|
|
|
+ @ApiOperation(value = "下载pdf数据")
|
|
|
+ @ApiImplicitParam(name = "id", value = "fileId")
|
|
|
+ public void downBussPdf(String id,HttpServletResponse response) throws Exception {
|
|
|
+ if (id == null || id.trim().isEmpty()) {
|
|
|
+ throw new ServiceException("暂无PDF数据");
|
|
|
+ }
|
|
|
+ //获取节点下的所有表单,和附件,如果表单全是隐藏的,并且没有附件,则提示暂无数据
|
|
|
+ String sql = "select name,pdf_url,e_visa_pdf_url,node_pdf_url from u_information_query where id = " + id;
|
|
|
+ List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
|
|
|
+ if (maps.isEmpty()) {
|
|
|
+ throw new ServiceException("暂无PDF数据");
|
|
|
+ } else {
|
|
|
+ Map<String, Object> stringObjectMap = maps.get(0);
|
|
|
+ String pdfUrl = stringObjectMap.get("pdf_url") == null ? "" : stringObjectMap.get("pdf_url") + "";
|
|
|
+ String fileName = stringObjectMap.get("name") == null ? "找不到文件题名" : stringObjectMap.get("name") + "";
|
|
|
+ if (Func.isNotEmpty(stringObjectMap.get("node_pdf_url"))) {
|
|
|
+ pdfUrl = stringObjectMap.get("node_pdf_url") == null ? "" : stringObjectMap.get("node_pdf_url") + "";
|
|
|
+ } else if (Func.isNotEmpty(stringObjectMap.get("e_visa_pdf_url"))) {
|
|
|
+ //优先使用电签的pdf
|
|
|
+ pdfUrl = stringObjectMap.get("e_visa_pdf_url") == null ? "" : stringObjectMap.get("e_visa_pdf_url") + "";
|
|
|
+ }
|
|
|
+ if (pdfUrl.isEmpty()) {
|
|
|
+ throw new ServiceException("暂无PDF数据");
|
|
|
+ }
|
|
|
+// fileName = URLEncoder.encode(fileName, Charsets.UTF_8.name());
|
|
|
+ InputStream redio = CommonUtil.getOSSInputStream(pdfUrl);
|
|
|
+ byte[] buffer = IoUtil.readToByteArray(redio);
|
|
|
+ OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
|
|
|
+ response.setContentType("application/pdf");
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ fileName = fileName.replaceAll("/", "_");
|
|
|
+ String encode = URLEncoder.encode(fileName, "UTF-8");
|
|
|
+ encode = encode.replaceAll( "%2B", "+");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + encode + ".pdf");
|
|
|
+ toClient.write(buffer);
|
|
|
+ toClient.flush();
|
|
|
+ toClient.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 用户端删除复制信息表
|