From 473081421a88bc7e07fafb3fc9b0c9345fbae0e7 Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Tue, 27 Jun 2023 13:24:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=96=E7=AB=A0=E6=96=87=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java | 6 +++--- .../pmapi/todocenter/manage/TodoCenterManage.java | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java index fcdae3e..d98be0e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java @@ -6,7 +6,6 @@ import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.util.StrPool; import com.ningdatech.pmapi.irs.config.IrsSealPlatformProperties; import com.ningdatech.pmapi.todocenter.model.dto.SignReqDTO; -import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; import org.apache.commons.lang3.tuple.Pair; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -81,7 +80,8 @@ public class IRSAPIRequest { // 获取盖好章的PDF文件内容Base64字符串 String signFileB64 = object.getString("signFileB64"); if (Objects.nonNull(signFileB64)){ - return signFileB64.getBytes(); + Base64.getDecoder().decode(signFileB64); + return Base64.getDecoder().decode(signFileB64); }else { return null; } @@ -245,7 +245,7 @@ public class IRSAPIRequest { //刷新此输出流并强制写出所有缓冲的输出字节 bout.flush(); byte[] bytes = baos.toByteArray(); - return Base64.encode(bytes); + return String.valueOf(Base64.getEncoder().encode(bytes)); //return encoder.encodeBuffer(bytes); } catch (IOException e) { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index 69ec8c0..ab6f75c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.todocenter.manage; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; @@ -495,9 +496,17 @@ public class TodoCenterManage { signReq.setSignType(signType); // 调用盖章接口,获取盖章后返回的pdf文件字符数组 byte[] signPdf = IRSAPIRequest.createSignPdf(signReq); - + ByteArrayInputStream inputStream = null; + if (Objects.nonNull(signPdf)) { + inputStream = new ByteArrayInputStream(signPdf); + } // 转换成MultipartFile - MultipartFile multipartFile = new MockMultipartFile("file", originalFileName, "application/pdf", signPdf); + MultipartFile multipartFile; + try { + multipartFile = new MockMultipartFile("file", originalFileName, "application/pdf", inputStream); + } catch (IOException e) { + throw new BizException("生成盖章pdf文件失败!"); + } // 上传OSS FileResultVO resultVo = fileService.upload(multipartFile, "default"); // 将返回的文件ID更新到项目库中对应的项目下