|
|
@@ -1,11 +1,11 @@
|
|
|
package com.doc.common.utils;
|
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.boot.system.ApplicationHome;
|
|
|
import sun.misc.BASE64Decoder;
|
|
|
import sun.misc.BASE64Encoder;
|
|
|
|
|
|
-import java.io.ByteArrayInputStream;
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.IOException;
|
|
|
+import java.io.*;
|
|
|
import java.util.zip.GZIPInputStream;
|
|
|
import java.util.zip.GZIPOutputStream;
|
|
|
|
|
|
@@ -15,6 +15,7 @@ import java.util.zip.GZIPOutputStream;
|
|
|
* @author wukai
|
|
|
* @date 2024/1/2 16:04
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
public class Tools {
|
|
|
/**
|
|
|
* 使用gzip压缩字符串
|
|
|
@@ -66,4 +67,45 @@ public class Tools {
|
|
|
}
|
|
|
return decompressed;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成激活码
|
|
|
+ *
|
|
|
+ * @param content 文件内容
|
|
|
+ * @param fileName 文件名称
|
|
|
+ * @param tips 提示语
|
|
|
+ */
|
|
|
+
|
|
|
+ public static void generateRegFile(String content, String fileName, String tips) {
|
|
|
+ ApplicationHome home = new ApplicationHome(Tools.class);
|
|
|
+ String path = home.getSource().getParent() + File.separator + fileName;
|
|
|
+ File codeFile = new File(path);
|
|
|
+ try (FileWriter fw = new FileWriter(codeFile)) {
|
|
|
+ fw.write(content);
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ }
|
|
|
+
|
|
|
+ log.error("============{}=================", tips);
|
|
|
+ log.error("===========================================");
|
|
|
+ log.error("===========================================");
|
|
|
+ log.error("===========================================");
|
|
|
+ log.error("===========================================");
|
|
|
+ log.error("========请将文件件||{}||提供给供应商===========", path);
|
|
|
+ log.error("===========================================");
|
|
|
+ log.error("===========================================");
|
|
|
+ log.error("===========================================");
|
|
|
+ log.error("===========================================");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断PDF是否为空
|
|
|
+ *
|
|
|
+ * @param content pdf内容
|
|
|
+ * @return 成功失败
|
|
|
+ */
|
|
|
+ public static boolean contentEmpty(String content) {
|
|
|
+ //无效的PDF解析数据
|
|
|
+ String invalidPdfContent = "学兔兔 www.bzfxw.com";
|
|
|
+ return content.contains(invalidPdfContent) || StringUtils.isEmpty(content);
|
|
|
+ }
|
|
|
}
|