修改 根据bid获取文件

This commit is contained in:
付庆吉
2021-08-23 13:43:50 +08:00
parent 88f319f9c5
commit a37fb36daa

View File

@ -8,6 +8,7 @@ import com.aspose.words.SaveFormat;
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.api.AttachmentClient; 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.AttachmentDetail;
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity;
import com.chinaunicom.mall.ebtp.common.util.JsonUtils;
import com.chinaunicom.mall.ebtp.common.util.PropertyUtils; import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
import com.chinaunicom.mall.ebtp.extend.export.service.templateFile.TemplateFileService; import com.chinaunicom.mall.ebtp.extend.export.service.templateFile.TemplateFileService;
import com.chinaunicom.mall.ebtp.extend.signature.entity.ExpertSignature; import com.chinaunicom.mall.ebtp.extend.signature.entity.ExpertSignature;
@ -63,9 +64,11 @@ public class ExpertSignatureServiceImpl implements ExpertSignatureService {
InputStream expertSign = getExpertSign(signature, path); InputStream expertSign = getExpertSign(signature, path);
//获取bid的word文件 //获取bid的word文件
AttachmentDetail attachmentDetail = attachmentClient.findByBusinessId(Collections.singletonList(signature.getBid())).orElse(new AttachmentDetail()); AttachmentDetail attachmentDetail = attachmentClient.findByBusinessId(Collections.singletonList(signature.getBid())).orElse(new AttachmentDetail());
AttachmentEntity entity = attachmentDetail.get(signature.getBid()).stream().findAny().orElseThrow(() -> new RuntimeException("文档查询失败")); AttachmentEntity entity = attachmentDetail.get(signature.getBid()).stream().findAny()
.orElseGet(() -> attachmentClient.findByObjectId(signature.getBid()).orElseThrow(() -> new RuntimeException("文档查询失败")));
byte[] bytes = attachmentClient.downloadFileByObjectId(signature.getBid()).orElseThrow(() -> new RuntimeException("文档下载失败")); log.info("----------AttachmentEntity --------: " + JsonUtils.objectToJson(entity));
byte[] bytes = attachmentClient.downloadFileByObjectId(entity.getId()).orElseThrow(() -> new RuntimeException("文档下载失败"));
log.info("----------AttachmentEntity --------: " + bytes.length);
InputStream word = new ByteArrayInputStream(bytes); InputStream word = new ByteArrayInputStream(bytes);
//合并word 转为pdf //合并word 转为pdf
@ -138,22 +141,6 @@ public class ExpertSignatureServiceImpl implements ExpertSignatureService {
private boolean getLicense() { private boolean getLicense() {
boolean result = false; boolean result = false;
InputStream is = ExpertSignatureServiceImpl.class.getClassLoader().getResourceAsStream("/license/aspose-license.xml"); InputStream is = ExpertSignatureServiceImpl.class.getClassLoader().getResourceAsStream("/license/aspose-license.xml");
// String licenseStr =
// "<License>\n" +
// " <Data>\n" +
// " <Products>\n" +
// " <Product>Aspose.Total for Java</Product>\n" +
// " <Product>Aspose.Words for Java</Product>\n" +
// " </Products>\n" +
// " <EditionType>Enterprise</EditionType>\n" +
// " <SubscriptionExpiry>20991231</SubscriptionExpiry>\n" +
// " <LicenseExpiry>20991231</LicenseExpiry>\n" +
// " <SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber>\n" +
// " </Data>\n" +
// " <Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature>\n" +
// "</License>";
// InputStream is = null;
// is = new ByteArrayInputStream(licenseStr.getBytes(StandardCharsets.UTF_8));
License license = new License(); License license = new License();
try { try {
license.setLicense(is); license.setLicense(is);