修改 根据bid获取文件

This commit is contained in:
付庆吉
2021-08-23 10:19:24 +08:00
parent 04650e714e
commit 537311a1f4

View File

@ -2,9 +2,11 @@ package com.chinaunicom.mall.ebtp.extend.signature.service.impl;
import cn.hutool.core.io.FileUtil;
import com.aspose.words.FontSettings;
import com.aspose.words.License;
import com.aspose.words.SaveFormat;
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.api.AttachmentClient;
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentDetail;
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity;
import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
import com.chinaunicom.mall.ebtp.extend.export.service.templateFile.TemplateFileService;
@ -26,10 +28,7 @@ import sun.misc.BASE64Decoder;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Slf4j
@Service
@ -63,9 +62,10 @@ public class ExpertSignatureServiceImpl implements ExpertSignatureService {
//获取专家签名文件
InputStream expertSign = getExpertSign(signature, path);
//获取bid的word文件
AttachmentEntity entity = attachmentClient.findByObjectId(signature.getBid()).orElse(new AttachmentEntity());
AttachmentDetail attachmentDetail = attachmentClient.findByBusinessId(Collections.singletonList(signature.getBid())).orElse(new AttachmentDetail());
AttachmentEntity entity = attachmentDetail.get(signature.getBid()).stream().findAny().orElseThrow(() -> new RuntimeException("文档查询失败"));
byte[] bytes = attachmentClient.downloadFileByObjectId(signature.getBid()).orElse(new byte[0]);
byte[] bytes = attachmentClient.downloadFileByObjectId(signature.getBid()).orElseThrow(() -> new RuntimeException("文档下载失败"));
InputStream word = new ByteArrayInputStream(bytes);
//合并word 转为pdf
@ -116,7 +116,7 @@ public class ExpertSignatureServiceImpl implements ExpertSignatureService {
File f = new File(path + "merged.pdf");
FileOutputStream fos = new FileOutputStream(f);
FontSettings.getDefaultInstance().setDefaultFontName("MS YaHei");
try {
com.aspose.words.Document doc = new com.aspose.words.Document(path + "merged.docx");
doc.save(fos, SaveFormat.PDF);