Ver código fonte

gzip压缩工具类修改

tags/24080901
WendyYang 8 meses atrás
pai
commit
0470d5d7aa
3 arquivos alterados com 8 adições e 11 exclusões
  1. +4
    -5
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/GzipUtil.java
  2. +2
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/irs/sign/IRSAPIRequest.java
  3. +2
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java

+ 4
- 5
hz-pm-api/src/main/java/com/hz/pm/api/common/util/GzipUtil.java Ver arquivo

@@ -1,9 +1,9 @@
package com.hz.pm.api.common.util;

import cn.hutool.core.codec.Base64Decoder;
import cn.hutool.core.codec.Base64Encoder;
import cn.hutool.core.util.StrUtil;
import com.ningdatech.basic.exception.BizException;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -35,7 +35,7 @@ public class GzipUtil {
gzip.write(content.getBytes());
gzip.finish();
byte[] bytes = bos.toByteArray();
return new BASE64Encoder().encode(bytes);
return Base64Encoder.encode(bytes);
} catch (IOException e) {
throw new BizException(e);
}
@@ -48,8 +48,7 @@ public class GzipUtil {
if (StrUtil.isBlank(content)) {
return content;
}
BASE64Decoder decoder = new BASE64Decoder();
try (ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(content));
try (ByteArrayInputStream bis = new ByteArrayInputStream(Base64Decoder.decode(content));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
GZIPInputStream gis = new GZIPInputStream(bis)) {
byte[] buffer = new byte[1024 * 16];


+ 2
- 3
hz-pm-api/src/main/java/com/hz/pm/api/irs/sign/IRSAPIRequest.java Ver arquivo

@@ -1,5 +1,6 @@
package com.hz.pm.api.irs.sign;

import cn.hutool.core.codec.Base64Decoder;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@@ -18,7 +19,6 @@ import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import sun.misc.BASE64Decoder;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
@@ -242,8 +242,7 @@ public class IRSAPIRequest {
* @param base64Content 文件的存储路径(含文件名)
*/
public static void base64StringToPdf(String base64Content, String filePath) throws IOException {
BASE64Decoder decoder = new BASE64Decoder();
byte[] bytes = decoder.decodeBuffer(base64Content);
byte[] bytes = Base64Decoder.decode(base64Content);
File file = new File(filePath);
FileUtil.mkParentDirs(file);
try (ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bytes);


+ 2
- 3
hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java Ver arquivo

@@ -3,6 +3,7 @@ package com.hz.pm.api.todocenter.manage;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.codec.Base64Decoder;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -102,7 +103,6 @@ import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Decoder;

import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
@@ -487,10 +487,9 @@ public class TodoCenterManage {
String signPdf = IRSAPIRequest.createSignPdf(signReq);
ByteArrayInputStream inputStream = null;
if (Objects.nonNull(signPdf)) {
BASE64Decoder decoder = new BASE64Decoder();
try {
//转码
byte[] b = decoder.decodeBuffer(signPdf);
byte[] b = Base64Decoder.decode(signPdf);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {//调整异常数据
b[i] += 256;


Carregando…
Cancelar
Salvar