修改 根据bid获取文件
This commit is contained in:
@ -2,9 +2,11 @@ package com.chinaunicom.mall.ebtp.extend.signature.service.impl;
|
|||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import com.aspose.words.FontSettings;
|
||||||
import com.aspose.words.License;
|
import com.aspose.words.License;
|
||||||
import com.aspose.words.SaveFormat;
|
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.AttachmentEntity;
|
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity;
|
||||||
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;
|
||||||
@ -26,10 +28,7 @@ import sun.misc.BASE64Decoder;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@ -63,9 +62,10 @@ public class ExpertSignatureServiceImpl implements ExpertSignatureService {
|
|||||||
//获取专家签名文件
|
//获取专家签名文件
|
||||||
InputStream expertSign = getExpertSign(signature, path);
|
InputStream expertSign = getExpertSign(signature, path);
|
||||||
//获取bid的word文件
|
//获取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);
|
InputStream word = new ByteArrayInputStream(bytes);
|
||||||
|
|
||||||
//合并word 转为pdf
|
//合并word 转为pdf
|
||||||
@ -116,7 +116,7 @@ public class ExpertSignatureServiceImpl implements ExpertSignatureService {
|
|||||||
|
|
||||||
File f = new File(path + "merged.pdf");
|
File f = new File(path + "merged.pdf");
|
||||||
FileOutputStream fos = new FileOutputStream(f);
|
FileOutputStream fos = new FileOutputStream(f);
|
||||||
|
FontSettings.getDefaultInstance().setDefaultFontName("MS YaHei");
|
||||||
try {
|
try {
|
||||||
com.aspose.words.Document doc = new com.aspose.words.Document(path + "merged.docx");
|
com.aspose.words.Document doc = new com.aspose.words.Document(path + "merged.docx");
|
||||||
doc.save(fos, SaveFormat.PDF);
|
doc.save(fos, SaveFormat.PDF);
|
||||||
|
Reference in New Issue
Block a user