公告结构化

This commit is contained in:
zhangqinbin
2023-12-11 17:35:21 +08:00
parent 81f7cd9727
commit ae8f85ec49
2 changed files with 22 additions and 10 deletions

View File

@ -210,20 +210,28 @@ public class WpsController {
Optional<AttachmentDetail> optional = attachmentClient.findByBusinessId(businessIdList); Optional<AttachmentDetail> optional = attachmentClient.findByBusinessId(businessIdList);
String fileLength = "10";
String fileName = fileId;
byte buf[] = new byte[0];
if(optional!=null&&optional.get()!=null){
AttachmentDetail detail = optional.get(); AttachmentDetail detail = optional.get();
List<AttachmentEntity> entityList = detail.get(fileId); List<AttachmentEntity> entityList = detail.get(fileId);
Optional<byte[]> optional1 = attachmentClient.downloadFileByObjectId(entityList.get(0).getId()); Optional<byte[]> optional1 = attachmentClient.downloadFileByObjectId(entityList.get(0).getId());
fileLength = String.valueOf(optional1.get().length);
fileName = entityList.get(0).getFilename();
buf = optional1.get();
}
try{ try{
// 设置响应的头信息,告诉浏览器文件的大小和下载方式 // 设置响应的头信息,告诉浏览器文件的大小和下载方式
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Length", String.valueOf(optional1.get().length)); response.setHeader("Content-Length", fileLength);
response.setHeader("Content-Disposition", "attachment; filename=".concat(new String(entityList.get(0).getFilename().getBytes(StandardCharsets.UTF_8), "ISO8859-1"))); response.setHeader("Content-Disposition", "attachment; filename=".concat(new String(fileName.getBytes(StandardCharsets.UTF_8), "ISO8859-1")));
InputStream word = new ByteArrayInputStream(optional1.get()); InputStream word = new ByteArrayInputStream(buf);
// 创建输入输出流 // 创建输入输出流
BufferedInputStream inStream = new BufferedInputStream(word); BufferedInputStream inStream = new BufferedInputStream(word);
BufferedOutputStream outStream = new BufferedOutputStream(response.getOutputStream()); BufferedOutputStream outStream = new BufferedOutputStream(response.getOutputStream());

View File

@ -630,6 +630,8 @@ public class WpsServiceImpl implements WpsService {
Optional<AttachmentDetail> optional = attachmentClient.findByBusinessId(businessIdList); Optional<AttachmentDetail> optional = attachmentClient.findByBusinessId(businessIdList);
if(optional!=null&&optional.get()!=null) {
AttachmentDetail detail = optional.get(); AttachmentDetail detail = optional.get();
List<AttachmentEntity> entityList = detail.get(id); List<AttachmentEntity> entityList = detail.get(id);
@ -637,6 +639,8 @@ public class WpsServiceImpl implements WpsService {
Optional<byte[]> optional1 = attachmentClient.downloadFileByObjectId(entityList.get(0).getId()); Optional<byte[]> optional1 = attachmentClient.downloadFileByObjectId(entityList.get(0).getId());
return optional1.get(); return optional1.get();
} }
return new byte[0];
}
@Override @Override
public Map<String,String> saveKSFile(KingSoftFileSaveVo vo){ public Map<String,String> saveKSFile(KingSoftFileSaveVo vo){