From 537311a1f4ee989b5aa852ed56918a9d997dff1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=BA=86=E5=90=89?= <51312040@qq.com> Date: Mon, 23 Aug 2021 10:19:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=A0=B9=E6=8D=AEbid?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ExpertSignatureServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java index 8d44059..28b858f 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java @@ -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);