md
This commit is contained in:
parent
1a84f5a610
commit
e35023b240
@ -11,6 +11,7 @@
|
||||
|
||||
package com.xdadan.erp.web.emis;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -18,10 +19,13 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xdadan.erp.common.annotation.filter.jackson.JacksonFilter;
|
||||
import com.xdadan.erp.emis.domain.EmisWaybill;
|
||||
import com.xdadan.erp.emis.utils.GZipUtils;
|
||||
import com.xdadan.erp.emis.utils.WaybillHelper;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.compress.archivers.zip.ZipUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@ -115,13 +119,20 @@ public class EmisCommissionDtlController extends BaseController
|
||||
}
|
||||
|
||||
List<Map> list = emisCommissionDtlService.selectCommissionDtlMapList(emisCommissionDtl);
|
||||
|
||||
|
||||
|
||||
return getDataTable(list);
|
||||
if(emisCommissionDtl.getParams().containsKey("blExport")){
|
||||
List<String> exportList= new ArrayList<>();
|
||||
String encStr = GZipUtils.zipToBase64Str(JSON.toJSONString(list));
|
||||
if(encStr!=null) {
|
||||
exportList.add(encStr);
|
||||
}
|
||||
return getDataTable(exportList);
|
||||
}else {
|
||||
return getDataTable(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 按批次查询明细
|
||||
* @param emisCommissionDtl
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
package com.xdadan.erp.emis.utils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class GZipUtils {
|
||||
|
||||
public static String zipToBase64Str(String input){
|
||||
try {
|
||||
return Base64.getEncoder().encodeToString(compress(input));
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String unzipByBase64(String base64InputStr) {
|
||||
try {
|
||||
return decompress(Base64.getDecoder().decode(base64InputStr.getBytes()));
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 压缩文本
|
||||
private static byte[] compress(String text) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (GZIPOutputStream gzos = new GZIPOutputStream(baos)) {
|
||||
gzos.write(text.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
// 解压缩文本
|
||||
private static String decompress(byte[] compressed) throws IOException {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(compressed);
|
||||
try (GZIPInputStream gzis = new GZIPInputStream(bais);
|
||||
java.io.InputStreamReader isr = new java.io.InputStreamReader(gzis, StandardCharsets.UTF_8);
|
||||
java.io.BufferedReader br = new java.io.BufferedReader(isr)) {
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str="你好压缩";
|
||||
String zipEncStr=zipToBase64Str(str);
|
||||
System.out.println(zipEncStr);
|
||||
String decStr = unzipByBase64(zipEncStr);
|
||||
System.out.println(decStr);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user